* Thu Jun 11 10:03:23 EDT 1992 /leverrier/h1/ksg/src/test plot2.f
C   Tue Jan 23 14:53:44 EST 1990 /plasma/h1/vgr/src/plt plot2
* Tue Apr 12 08:49:44 EDT 1988 /usr4/rlm/src/test plot2.f
C	GSG JR March 20 1997 changed include addresses to reative addresses
	block data plt
	include "pltcom.h"
c
      COMMON /CLCOMP/XFSET,YFSET,XACUM,YACUM,
     & SKIP,NSKIP,IOPT,XLEN,YLEN,XFAC,YFAC,FAC,NHARD,
     & XPOSIT,YPOSIT,FILE,PLOTR,CFILE, lnopts, lplot, lskip, laser
	integer laser
      LOGICAL SKIP,FILE,PLOTR,CFILE, lnopts, lplot, lskip
c
	data skip /.false./, file /.false./, plotr /.false./
	data cfile /.false./
	data laser /0/
	data xlr / XL/, xrr /XR/, ybr /YB/, ytr /YT/
	data xlv /XLVWS/, xrv /XRVWS/, ybv /YBVWS/, ytv /YTVWS/
	data xla /XLVWS/, xra /XRVWS/, yba /YBVWS/, yta /YTVWS/
	data xld /XLVWS/, xrd /XRVWS/, ybd /YBVWS/, ytd /YTVWS/
        data xbb / XLVWS, XLVWS, XRVWS, XRVWS, XLVWS/
        data ybb / YBVWS, YTVWS, YTVWS, YBVWS, YBVWS/
	data ipltcorx /LINEAR/, ipltcory /LINEAR/
	data linit  /.false./, lnopts /.false./, lplot /.true./
	data lskip /.true./
	end

	subroutine plot2( xx, yy, iip)
	nnn = 1
	call plot2x( xx, yy, iip, nnn)
	return
	end

	subroutine plots
	nnn = 2
	call plot2x( xx, yy, iip, nnn)
	return
	end

	subroutine openplt
	nnn = 2
	call plot2x( xx, yy, iip, nnn)
	return
	end
c
	subroutine plot2x( xx, yy, iip, nnn)
	include "pltcom.h"
	real x, y, xx, yy, xoff, yoff
      COMMON /CLCOMP/XFSET,YFSET,XACUM,YACUM,
     & SKIP,NSKIP,IOPT,XLEN,YLEN,XFAC,YFAC,FAC,NHARD,
     & XPOSIT,YPOSIT,FILE,PLOTR,CFILE, lnopts, lplot, lskip, laser
      LOGICAL SKIP,FILE,PLOTR,CFILE, lnopts, lplot, lskip
	integer laser
	integer ipen, iip, ip
	real xln,ybn
c	character*1 c
c
	integer icount
	integer i2, i5
	data i2 /2/, i5 /5/
	data icount /0/
c
	data  xoff /0.0/, yoff /0.0/
c
	if ( nnn .eq. 2) go to 9999
	icount = icount + 1
 	ip = iip
c    	write (6,6) xx,yy, ip, xoff, yoff
 6	format('0plot2',1p,2e12.3,i4,3x,2e10.2,i4)
c 	if (mod(icount,125) .eq. 0) read (5,*) c
c	if file flag is set write out current call
	if  (file)  call  pout( 1, xx, yy, ip)
	x = xx + xoff
	y = yy + yoff
	ipen = iabs(ip)
	if (ipen    .lt. 10)  go to 90
	if (ipen/10 .ne.  2)  go to 60
	xoff = x
	yoff = y
	go to 90
 60	continue
 90	continue
c
	if (linit)  go to 111
	linit = .true.
	go to 40     
c
9999	continue
C	entry  plots 
c
C	entry  openplt 
	if (linit) return  
c	open core
 40	continue
	if ( lplot) then
		call pltst
	end if
c	if you do not open now you never can
	rx(1) = xln
	ry(1) = ybn
c       if ( .not. lnopts)  call options
	if (linit)  go to 111
	linit = .true.
	return
 111	continue
	rx(2) = x
	ry(2) = y
c
	if ( lplot) then 
		call moveabs2( rx(1), ry(1))
		if (mod(ipen,10) .eq. 2)   then
			call lineabs2( rx(2), ry(2))
		else
			call moveabs2( rx(2), ry(2))
		end if
c     |  	call polylineabs2( rx, ry, 2)
	end if
	if ( laser .eq. 1) then
c	let options page the printer
c	call llout( 1, x, y, iabs( ip))
	else if ( laser .eq. 2) then
c		rx2 = (x - xposit)*12./xlen
c		ry2 = (y - yposit)*8.0/ylen
		rx2 = x
		ry2 = y
c	call llout( 1, rx2, ry2, iabs( ip))
	end if
	rx(1) = rx(2)
	ry(1) = ry(2)
	if (ip .GT. 0) go to 200  
c 150	if ( .not. lnopts)  call options
	if ( .not. lskip) then
		xoff = 0.
		yoff = 0.
		rx(1) = 0.
		ry(1) = 0.
	else
		xoff = xoff + xx
		yoff = yoff + yy
c	write (6,*) 'plot2',xx,yy,ip,xoff,yoff
	end if
 200	continue
	if (iabs(ipen) .ne. 999) return
c	entry endplt
	call	pltend
c
	end
	subroutine pltend
      COMMON /CLCOMP/XFSET,YFSET,XACUM,YACUM,
     & SKIP,NSKIP,IOPT,XLEN,YLEN,XFAC,YFAC,FAC,NHARD,
     & XPOSIT,YPOSIT,FILE,PLOTR,CFILE, lnopts, lplot, lskip, laser
      LOGICAL SKIP,FILE,PLOTR,CFILE, lnopts, lplot, lskip
	integer laser
	if (lplot) call pltendt
	return
	end
