C******************** START FILE GRF3.FOR ; GROUP GRF3SG ******************
C============================================================
C
C  MOD DMC FEB 1986 - MAINTENANCE
C   *REMOVE ENCODE STATEMENTS
C   *IMPROVE 2D GRAPHICS LABELING
C   *REPLACE OBSOLETE "AGX" LABELING OF 3D ISOMETRIC PLOT
C   *GENERAL CLEANUP
C
C   *NOTE CLEANUP *NOT DONE* ON AG PLOT - WILL CHECK FOR CONSOLIDATION
C   OF INTERFACE W/ RPLOT VSN!
C
C-------------------------------
C  DMC JUNE 1988
C   THIS ROUTINE MADE A SHELL FOR THE NEW, STREAMLINED GRF3F1
C
C   NOTE SOME OF THE OLD ARGUMENTS TO GRF3 NO LONGER HAVE ANY EFFECT,
C   BUT ARE RETAINED FOR HISTORICAL REASONS ***
C     IDIR
C     NSHOT2(1..NS2)
C
C   IT IS SUGGESTED THAT NEW CODE USE THE GRF3F1 ROUTINE DIRECTLY
C
C-------------------------------
C
C  GRF3 "SG" VERSION
C  THIS VERSION USES THE NEW SG PACKAGE FOR 3D ISOMETRIC AND
C  ALL OTHER PLOTS, INSTEAD OF OLD AG/ EZIS KLUGE.
C  ALSO A NEW ARGUMENT IS ADDED:  IDEV = 4 CHARACTER DEVICE
C  CODE (I.E. PDX, PLT, TFTR ...)
C   THIS ROUTINE IS ORIENTED TOWARDS PLOTTING DIAGNOSTIC DATA FROM
C  TOKAMAK DEVICES BUT IDEV COULD BE "RUN " AND NSHOT COULD BE A
C  "RUN NUMBER" (MAX 5 DIGITS) ... BUT SEE ALSO ARGUMENT ISF
C
      SUBROUTINE GRF3(X,Z,Y,Z2,NX,NY,NZ1,
     >                  XLAB,YLAB,ZLAB,
     >                  XUN,YUN,ZUN,
     >                  ZTITLE,ITITLE,
     >                  IDIR,ISF,
     >                  IDEV,NSHOT,IAVTYP,NSHOT2,NS2,ISMTYP)
C
C  INTERACTIVE ROUTINE TO CONTROL PRODUCTION OF TWO AND
C  THREE DIMENSIONAL GRAPHS OF DATA FUNCTION OF TWO
C  INDEPENDANT VARIABLES.
C    3-D GRAPHS:  LABELING AND TITLEING CONTROLLED BY PASSED
C                 VARIABLES
C                 USER MAY SPECIFY SUBSET OF X-Y DOMAIN, AND
C                 # OF LINES OF CONSTANT X AND Y TO DRAW
C                 BY INTERACTIVE I/O.
C    2-D GRAPHS:  LABELING AND TITLEING CONTROLLED BY PASSED
C                 VARIABLES;
C                 USER HAS CONTROL OF HORIZONTAL AND VERTICAL
C                 SCALE BY INTERACTIVE I/O.
C                 USER SPECIFIES X CONSTANT WHILE Y VARIES OR
C                 VICE VERSA, BY INTERACTIVE I/O.
C
C  INPUT VARIABLES:
C    X       1ST INDEPENDANT VARIABLE VALUES, IN ASCENDING ORDER
C            CORRESPONDS TO FIRST DIMENSION OF Z ARRAY
C    Z       2-D ARRAY OF DEPENDANT VARIABLE VALUES
C    Y       2ND INDEPENDANT VARIABLE VALUES, IN ASCENDING ORDER
C            CORRESNPONDS TO SECOND DIMENSION OF Z ARRAY.
C    Z(I,J) = Z AT (X(I),Y(J))
C
C    NX      # OF X VALUES
C    NY      # OF Y VALUES
C    NZ1     FIRST DIMENSION OF Z
C
C    XLAB    NAME OF FIRST INDEP. VARIABLE (E.G. 'RADIUS    ')
C            10 CHARACTERS ASCII.
C    YLAB    NAME OF SECOND INDP. VARIABLE (E.G. 'TIME      ')
C            10 CHARACTERS ASCII
C    ZLAB    NAME OF DEPENDANT VARIABLE
C            (E.G. 'ELECTRON TEMPERATURE')
C            20 CHARACTERS ASCII
C    XUN     UNITS OF FIRST INDEP. VARIABLE (E.G. 'CM       $')
C            9 CHARACTERS ASCII TERMINATED BY '$' REQUIRED BY
C            FS ROUTINES.
C    YUN     UNITS OF SECOND INDEP. VARIABLE (E.G. 'SECONDS  $')
C    ZUN     UNITS OF DEPENDANT VARIABLE (E.G. 'EV       $')
C
C    ZTITLE  30 CHARACTER TITLE TO GO ON TOP OF 3-D GRAPH
C    ITITLE  WRITE ZTITLE IFF ITITLE=1
C
C    IDIR    =0==>X-AXIS ALONG BOTTOM OF SCREEN, Y-AXIS GOING
C                 'INTO' SCREEN FOR 3-D PLOTS.
C            =1==>INTERCHANGE X AND Y AXES.
C
C    ISF  CODE INDENTIFYING INTEGER IDENTIFIERS:
C   ISF=0 OR 1, THEN NSHOT/NSHOT2 ARE 5 DIGIT INTEGER "SHOT NUMBERS"
C   ISF=2, THEN NSHOT/NSHOT2 ARE 4 DIGIT "RUN NUMBERS"
C    IF ISF=0 OR 1 THEN A LABEL IS BUILT UTILIZING THE 4 CHAR
C     DEVICE CODE (E.G. "PDX "); IF ISF =2 THE LABEL BUILT IS
C     OF FORM "RUN ####"
C (NEW 17 MAR 1982):
C    IDEV 4 CHARACTER TOKAMAK DEVICE CODE/ ID CODE FOR PLOT
C    E.G. "PLT ", "PDX ", ...
C    NSHOT   5 DIGIT SINGLE SHOT NUMBER FOR DISPLAY ON 2-D
C            GRAPHS AND ON 3-D GRAPHS IF IAVTYP.EQ.0
C    IAVTYP  =0==> DATA IS DERIVED FROM A SINGLE SHOT
C            =1==> DATA IS AVERAGED FROM SEVERAL SHOTS
C
C    NSHOT2  LIST OF 5 DIGIT SHOT NUMBERS GOING INTO DATA AVG
C            IF IAVTYP.EQ.1
C    NS2     # OF SHOT NUMBERS IN NSHOT2
C
C    ISMTYP  =0==> DATA IS 'RAW' (NOT SMOOTHED)
C            =1==> DATA IS SMOOTHED.
C
C    Z2      WORKSPACE OF DIMENSION NY AT LEAST.
C---------------------------
C
C  EXTERNAL REFERENCES:
C   3-D GRAFICS:  FSISU3  (LOAD @PLTFSB[66,600],@PLTSUB[66,600]
C                                  @PLTUSR[66,600])
C   2-D GRAFICS:  GRFAH0    (LOAD GRFAH0.FOR[GOLD.TRANSP],
C                            DPLOT1.FOR)
C
C----------------------------
C
C  AUTHOR:  D. MC CUNE    15-MAY-79
C
C
C----------------------------
C   DECLARATIONS:
C
C
      DIMENSION X(NX),Y(NY),Z2(NY),Z(NZ1,NY),NSHOT2(NS2),ZL(20)
      CHARACTER*10 ZLAB(2),YLAB,XLAB,XUN,YUN,ZUN
      CHARACTER*(*) ZTITLE(3)
      CHARACTER*4 IDEV
C--------------------------------------------------------------
C  DMC - MAINTENANCE - FEB 1986 - NEW LABELING BUFFERS
C
      CHARACTER*45 ZTITL
      CHARACTER*15 ZSHOT
C
C--------------------------------------------------------------
C DMC FEB 1986 - FIX LABELS
C
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCHAR
      LOGICAL LYES
      LOGICAL LYESC
      LOGICAL LXOUT
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
C ====================
C  START OF EXECUTABLE CODE
C
      LUNTRM=LNOUT(0)
C
      IF(ITITLE.EQ.1) THEN
        ZTITL=ZTITLE(1)//ZTITLE(2)//ZTITLE(3)
      ELSE
        ZTITL='                              '
      ENDIF
C
      zshot=' '
      IF((ISF.LE.1).AND.(NSHOT.NE.0)) THEN
         if(nshot.le.999999) then
            WRITE(ZSHOT,8005) IDEV,NSHOT
         else
            write(zshot,80051) idev,nshot
         endif
      ELSE IF(ISF.EQ.2) THEN
         WRITE(ZSHOT,80041) NSHOT
      ENDIF
C
 8005 FORMAT(A4,1x,I6)
80051 format(a4,1x,i10)
80041 FORMAT('RUN # ',I4)
C
      IPROC=0
      IPROC=IPROC+IAVTYP+2*ISMTYP
C
      CALL GRF3F1(X,Z,Y,Z2,NX,NY,NZ1,
     >    XLAB,ZLAB(1)//ZLAB(2),YLAB,XUN,ZUN,YUN,ZTITL,ZSHOT,IPROC)
C
      RETURN
      END
