/      SUBROUTINE XPLOT (IQ,XX,YY,ZZ,NP,IW,IERR)SC_TITLE  XPLOT  Generalized plotting routine designed to interface to the XG systemC_ARGUMENTS*	INTEGER IQ	     ![In] Input control code.1	REAL*4 XX(*)         ![In] X label ASCII string.$	REAL*4 YY(*)         ![In] Y label.$	REAL*4 ZZ(*)         ![In] Z label.J	INTEGER NP           ![IN] Number of longwords needed for working storageF	INTEGER IW(9)        ![In] For IQ=1 and 2, is an input parameter set./	INTEGER IERR         ![Out] Error return code.FC_DESCRIPTION  The program XPLOT.FOR is a generalized plotting routine2C designed to interface to the XG database system.CC_CALLS  B2B  DATIME  MAPINI  MAGINI  MAPROJ  PWRIT1  SET1  MAPGRID(C	  POINTS  FRSTPT  VECTOR  PWRIT  FRAME8C_HISTORY  85Nov06 R.Gurule U.S.G.S, Flagstaff AZ. 86001C_ENDNC-----------------------------------------------------------------------------C	GC  Generalized plotting routine designed to interface to the XX	system.C ;C  Arguments have some change of meaning with different IQ.C&C	IQ is always the input control code.2C	IW(*); for IQ =1 & 2, is an input parameter set GC	     for IQ = 3,4,5 ; scratch working area available to this routine.&C	IERR is always an error return code.C	 0 = Normal successful return	C	 -*=???AC    Other arguments described for each IQ below, or are ignored.CAC***  IQ =1 ***   Define a Graph, Get all user defined parametersC!C Input	XX = X label ASCII stringC	YY = Y labelC	ZZ = Z label1C	IW: The first 9 items are identical to NCAR_1, 6C           program must set items 1-3 (logical units)@C	    this routine sets item 4 (default) and item 5 (execution).C-C	IW(1) = LUN for plot input or control file.C	IW(2) = LUN for prompt%C	IW(4) = Prompt flag: 0 = batch modeC	IW(5) = LUN for log file.&C	IW(10)= LUN Input for XX parameters./C	IW(11) = X label length, number of characters/C	IW(12) = Y label length, number of characters/C	IW(13) = Z label length, number of characters/C	IW( ) = Max number of points in a single callAC	IW( ) = Max number of points in repeated calls to the same pageC<C Output NP = number of longwords needed for working storageCGC*** IQ=2 ***	Initiate a curve, {initiate new page}, {change line type}C6C Input	IW(1) = Flag to get new curve type definition ?C	IW(3) = Number of characters in title for page ( up to 6 willC			be used for curve title)FC	XX(1,2) = minimum,maximum of X to use for plot_auto-scale [not impl]FC	YY(1,2) = minimum,maximum of Y to use for plot_auto-scale [not impl](C	ZZ(1- ) = Title of curve {and of page})C	NP = PAGE FLAG; 1=New page, 0=same pageC	$C*** IQ=3 ***   Plot a set of pointsC	C Input	XX(*) = X data pointsC	YY(*) = Y data pointsC	ZZ(*) = Z data pointsC	NP = number of pointsC;C*** IQ=4 ***	Stop curve (if open) and stop frame (if open)C	C*** IQ=5 ***	End the plot jobC.C----GENERAL PHILOSOPHY BEHIND THESE PROGRAMS.CEC      The philosophy used in these programs was intended to give theJC      user as much flexibility as possible.  Below is a brief summary of !C      the conventions used here.CDC	1) XPLOT is called from a user supplied program.  Generally there	JC          will be at least five calls to xplot, based on the value of IQ.C?C	2) With minimal modification these routines should be easily 5C	   transformed into a generalized plotting package.CCC	3) The routines MAPGRID, AND XGRID do the plotting of grid lines.HC	   the conventions used here is that at least the left and right      JC          longitudes, as well as the minimum and maximum latitudes are toEC	   be plotted.  If the grid extends beyond a 10 degree range either:C	   in x or y, then 10 degree grid lines will be plotted.C@C	4) When using the map projection routines, if a map definitionHC	   parameter is left blank, the map initialization routine will prompt(C	   the user for the missing parameter.C6C			Hugh Kieffer & 	R.L. Gurule'   USGS Flagstaff, AZ.C			1985 Feb 15, June 26NC-----------------------------------------------------------------------------B	PARAMETER (NANN=7)	                       ! number of annotations@	PARAMETER (LENANN=40)		! maximum length of an annotation string%	LOGICAL PFLG,START,POINT,COPEN,FOPEN	BYTE LAB(LENANN,NANN),TPROJ(4)!	REAL*4  PARMAP(8),DATIM(5),RA(8)	INTEGER*4 LTYPE,KON(10)+	INTEGER*2 IT(3),ICL(3),IXL(3),IYL(3),ITEMP	CHARACTER*40 LABEL,DUM )        CHARACTER*12 IFMTX,IFMTY,CPROJ *42 	CHARACTER ANS*1, NT*2, PFILE*16, PROMPT(NANN)*10,	DIMENSION IP(7,NANN),X(4),Y(4),MAJ(7),XY(2)#	DIMENSION ITL(3),LLCODE(2),IGRD(7)=	DATA NX,NY/6,6/, ISIZX,ISIZY/0,0/, IXDEC,IYDEC/0,0/, IXOR/0/<	DATA PROMPT/'X-AXIS','Y-AXIS', 'Z-AXIS','TITLE','DAY_TIME',!     1	'FRAME','ZOFFSET'/,NUMZ/6/5        DATA START/.FALSE./,NXCHAR,NYCHAR,NTITLE/3*6/!        DATA NFRAME/0/,ICHAR/'*'/%        DATA PARMAP/8 * 0.0/,LTYPE/1/+        DATA IFMTX,IFMTY/'(F6.1)','(F6.1)'/         DATA IGRD/5,0,5,0,1,1,5/	DATA IP /	2     & 500,  50,  40,   1,   1,   0,  -1,	! x-axis2     &  10, 500,  40,   1,   1,  90,  -1,	! y-axis2     &  10,  50,  40,   1,   1,   0,  -1,	! z-axis1     &  20, 950,   0,   1,   1,   0,  -1,	! title4     & 700, 950,   0,  20,   1,   0,  -1,	! day_time)     & 850, 50,   40,   1,   1,   0,  -1,:     &  10,   0,   0,   1,   1,   0,  -1/	! z-value offset	INCLUDE 'RAD$INC:GRID.INC'		IERR = 0 	GO TO (100,200,300,400,500) ,IQ"!-----Prompt for any user options. 100    CONTINUE!-------Opt to plot a z offset.
                     IPV = 1	LOG = IW(5)!-------Save all labels.=	CALL B2B (%REF(' '),LAB,-NANN*LENANN)	! blank all annotation	IP(4,1) = 6				! X axis 	CALL B2B (XX, LAB(1,1),IP(4,1))	IP(4,2) = 6				! y axis 	CALL B2B (YY, LAB(1,2),IP(4,2))"	IP(4,3) = 6   			        ! z axis 	CALL B2B (ZZ, LAB(1,3),IP(4,3))6        IP(4,4) = 1				! curve title (defined at IQ=2)	IP(4,5) = 20				! day-time	CALL DATIME (DATIM)	CALL B2B (DATIM,LAB(1,5),20)	IP(4,6) = 8				! frame number	IP(4,7) = 1&	CALL B2B(%REF(' FRAME 0'),LAB(1,6),8);!--- get map projection parameters, and initiate projection*      					       ! Flag for Ncar1 series.*        CALL MAPINI (PARMAP,LLCODE) 	     '	CALL MAGINI (RA,TICLEN,PARMAP)	                                       IF(IOPT.NE.1)THEN          ZSCALE = IP(5,IPV)          ZANG = IP(6,IPV)!          RAD = 180.0 / 3.1415927&          ZXFAC = COS(ZANG/RAD)/ZSCALE          ZYFAC = SIN(ZANG/RAD);        ENDIF                                                      IPEN=0
	START=.TRUE.-	NP=0					!We won't request any core for now."	FOPEN=.FALSE.				!frame open flag@!-------Prompt for the labels. Converting to uppercase as we go.		DO I=1,3		DO K=1,6<	 IF(LAB(K,I).GE.97.AND.LAB(K,I).LE.122)LAB(K,I)=LAB(K,I)-32	ENDDO	ENDDO!	WRITE(LOG,1000) PFILE,DATIM,NVAR3 1000	FORMAT('0 THE INPUT FILE IS ',A14,'  ',5A4,/,2	1      ' THE NUMBER OF VARIABLES PLOTTED =',I1,/) 	RETURNL!---------------------------------------------------------------------------;!	Initiate a curve, new page, and draw the grid, and labelsL!---------------------------------------------------------------------------200	CONTINUE	KON(10)=2         NCUR = NCUR + 1	NPF=NPF+NP9	IF(NP.EQ.1.AND.COPEN) THEN	        !Close curve if open.	  WRITE(LOG,1050)NCUR,NP	  COPEN=.FALSE.	ENDIF*	IF (FOPEN) THEN				!Close any open frame.          NFRAME = NFRAME + 1!	  WRITE(LOG,1420)NFRAME,NCUR,NPF9 1420     FORMAT(' FRAME, # CURVES, #POINTS TOTAL=',3I6/)
	  CALL FRAME	  FOPEN=.FALSE.
	  NPF = 0	  NCUR = 0	ENDIF2220	NTITLE = MIN(IW(3),LENANN)		!Save curve title.	IP(4,4) = NTITLE	CALL B2B (ZZ,LAB(1,4),NTITLE)F      	CALL SET(RA(1),RA(2),RA(3),RA(4),RA(5),RA(6),RA(7),RA(8),LTYPE)>	WRITE(LOG,'(A,40A1)')' CURVE TITLE = ', (LAB(I,4),I=1,NTITLE)>	IF(NP.EQ.1 .OR. .NOT.START) THEN	!IF NP=1 THEN START NEW PAGE	  FOPEN=.TRUE.+          COPEN=.FALSE.				!curve open flag	  WRITE(LOG,1060)NFRAME( 1060 	  FORMAT('   FRAME NUMBER ',I3,/)	  LAB(8,6) = LAB(8,6) + 1K          IF(NPF.NE.0)CALL MAPGRID(LLCODE,PARMAP(1))  !Plot the grid lines.$	  NPF=0					      !Plot the labels	          DO J=1,NANND	    WRITE(DUM,4001)(LAB(K,J),K=1,40)          !Internal read/write. 4001       FORMAT(40A1)            READ(DUM,4002)LABEL 4002       FORMAT(A<IP(4,J)>)<            CALL PWRIT (IP(1,J),IP(2,J),%REF(LABEL),IP(4,J),$     1      IP(5,J),IP(6,J),IP(7,J))          ENDDO	ENDIF	RETURN             C---- Plot a set of points.@                                                                 300	NPTS=NP						IF(NPTS.LT.1) RETURN	COPEN = .TRUE.	NCUR = NCUR + 1%        CALL MAPROJ(NPTS,XX,YY,XX,YY)	XLAST = XX(1)	YLAST = YY(1)	XZL = XX(1)	YZL = YY(1)C---- plot the path.
	ICHAR = 0		INPT = 0O!-----Plot the location of each point.  Add some buffering here for ncar, only 5!     send a maximum of 50 points to curve at a time.	IF(IOPT.EQ.1)THEN/	  IF(NP.NE.0)CALL POINTS (XX,YY,NP,ICHAR,IPEN)		ENDIF   !---- plot the z value.	IF (IOPT.EQ.2) THEN	    CALL FRSTPT (XX(1),YY(1))	    DO I=1,NP!	     XZL = XX(I) + ZXFAC * ZZ(I)!	     YZL = YY(I) + ZYFAC * ZZ(I)	     CALL VECTOR (XZL,YZL)            ENDDO	ELSE IF(IOPT.EQ.3)THEN	    DO I=1,NP	      XOFF = 10	      YOFF = 10(	      ENCODE (NUMZ,'(F6.1)',LABZ) ZZ(I)0	      CALL PWRIT (XZL+XOFF,YY(I)+YOFF,LABZ,NUMZ     &        ,IPV5,IPV6,IPV7)
	    ENDDO	  ENDIF	XLAST = XX(NP)	YLAST = YY(NP)	NPTOT=NPTOT+NP
      RETURN	HC=======================================================================<  400   CONTINUE		! IF USER CALLS WITH IQ=4 THEN END OF PAGE)  	IF(COPEN) THEN		! CLOSE ANY OPEN CURVE	  NPF=NPF+NPTOT	  WRITE(LOG,1050)NCUR,NPTOTC 1050     FORMAT('     CURVE NUMBER ',I3,' HAS ',I5,' DATA POINTS')	  COPEN=.FALSE.	ENDIF)	IF (FOPEN) THEN				!Close any open frame!	  WRITE(LOG,1420)NFRAME,NCUR,NPF
	  CALL FRAME	  FOPEN=.FALSE.
	  NPF = 0	  NCUR = 0	ENDIF	RETURN;  500   CALL FRAME		!IF USER CALLS WITH IQ=5 THEN END XPLOT	RETURN	END