ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
	subroutine plt5(mxlen,maxit,rcscrv,nmax,rcnt)
c plot all regional curves in a stacked plot.

	integer mxlen,maxit,rcnt
	real*4 rcscrv(mxlen,2,maxit)
c	local
	integer i,p,j,k,nrows,ncols,nplts
	integer red,blue,green
	real*4 miny, maxy, minx, maxx
	real*4 x(5000),y1(5000),y2(5000)
	character string*16,dev*3
	logical ok,bg
c
       dev='Mac1';ok=.true.
       red=255;green=255;blue=255
       bg=.false.
c
10	if(ok)call plsdev(dev)
c
c set background color
c
      if(.not.bg)then
        call plscol0(0,255,255,255)              !change default color map black>white 
        call plscol0(15,0,0,0)                   !change default color map white>black
        call plscolbg(red,green,blue)            !change background color if other than white is desired
      elseif(bg)then
        call plscol0(15,255,255,255)              !change default color map white>black
        call plscol0(0,0,0,0)                   !change default color map black>white
        call plscolbg(red,green,blue)            !change background color if other than white is desired
      endif  
c	
	miny=9999.;maxy=-9999.
	minx=0.;maxx=float(nmax)
	do k=1,rcnt
	  do j=1,2
	    do p=1,mxlen
	      if(rcscrv(p,j,k).gt.maxy)maxy=rcscrv(p,j,k)
	      if(rcscrv(p,j,k).lt.miny.and.rcscrv(p,j,k).ne.0.0)miny=rcscrv(p,j,k)
	    enddo
	  enddo
	enddo
c
	if(rcnt.le.8)then
	   nrows=2;ncols=4
	elseif(rcnt.gt.8.and.rcnt.le.10)then
	   nrows=2;ncols=5
	elseif(rcnt.gt.10.and.rcnt.le.15)then
	   nrows=3;ncols=5
	elseif(rnct.gt.15.and.rcnt.le.20)then
	   nrows=4;ncols=5
	else
	   write(*,'(/1x,''Too many Regional curves to plot. Try '')')
	   write(*,'(1x,''plotting them outside this program.'')')
	   write(*,'(1x,''Hit RETURN to Continue'')')
	   pause
	   return
	endif
c	
	string='Iteration #     '
	nplts=nrows*ncols
c
c initialize plplot
	call plinit()
	call plssub(nrows,ncols)
	do i=1,rcnt
	    	  do p=1,nmax
	    	       y1(p)=rcscrv(p,1,i)
	              y2(p)=rcscrv(p,2,i)
	              if(i.eq.1)x(p)=real(p)
	         enddo
	         call plcol(15)   !color box and lables
	         call plenv(minx,maxx,miny,maxy,0,2)
	         if(i.eq.1)then
	             call pllab('Biological Year','Y','Initial RC and Fit')
	         else
	            write(string(14:16),'(i3)')i-1
	            call pllab('Biological Year','Y',string)
	         endif
	         call plcol(9)
	         call plwid(1)	     
	         call plline(nmax,x,y1)
	         call plcol(1)   !color box and lables
	         call plwid(2)	     
	         call plline(nmax,x,y2)
	         call plwid(1)	
	enddo
	if(rcnt.lt.nplts)then
	    do i=1,(nplts-rcnt)
	       call pladv()
	    enddo
	endif
c
20	call plend()	    	    
c	
       ans='C '
	dev='Mac1'
       write(*,'(/1x,''|************* plot options menu ***************|'')')
       write(*,'(1x,''|-----------------------------------------------|'')')
       write(*,'(1x,''|       [s]ave   <[c]ontinue>   [r]eplot        |'')') 
       write(*,'(1x,''|_______________________________________________|'')')
       write(*,'(/1x,'' enter option number > '',$)')
       read(*,'(a1)')ans
       if((ans.eq.'S').or.(ans.eq.'s'))then
         dev='psc';ok=.false.;filename='fig11.ps'
	  call plsdev(dev)
         call plsfnam(filename)
         goto 10
       elseif((ans.eq.'R').or.(ans.eq.'r'))then
         ok=.true.
         goto 10
       elseif((ans.eq.'C').or.(ans.eq.'c').or.(ans.eq.' ').or.
     *                             (ans.eq.'Y').or.(ans.eq.'y'))then
         return
	endif
c
	return
	end
