C******************** START FILE GSCDEF.FOR ; GROUP GSCALE ******************
C-------------------------------------------------------------
C  GSCALE
C
C  INTERACTIVELY CONTROLLED SCALE-SETTING FOR 2-D GRAPHS
C
C   2 ROUTINES:  GSCDEF-- INTERACTIVELY DEFINE RULES FOR
C      SETTING SCALE OF GRAPH FOR ROUTINE "DPLOT1", I.E.
C      XMIN,XMAX,YMIN,YMAX
C
C                GSCSET-- SET SCALE FOR PARTICULAR GRAPH,
C      USING CONTROLS DEFINED IN GSCDEF.
C
C  ALSO INITIALIZATION ROUTINE GSCINI INITIALIZES CONTROLS TO
C  FOLLOWING:  MIN AND MAX OF GRAPH AUTOMATICALLY SET TO
C   MIN AND MAX OF DATA PASSED
C
C-------------------------------
C  GSCDEF   LET USER DEFINE RULES FOR SCALING 2D GRAPHS
C
C   FOR USE IN CONJUNCTION WITH ROUTINES SUCH AS
C   DPLOT1.FOR, GRFAH0.FOR,GRFADH.FOR,GRFHX2.FOR ...
C     UTILIZING STANDARD 2D AG4010 GRAPHICS UTILITIES
C
C   WHICH USE COMMON BLOCK
C    "DPLOT1" CONTAINING XMIN,XMAX,YMIN,YMAX OF GRAPH
C   ABOUT TO BE DRAWN.
C
C
      SUBROUTINE GSCDEF
C
      INCLUDE 'GSCALE_BLK'
C
      INCLUDE 'PLOT1MMX'
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCHAR,lxout
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
C  START OF EXECUTABLE CODE
C
      luntrm=lnout(0)
C
      IF(IGSINI.EQ.0) CALL GSCINI
C  SAVE SETTINGS LOCALLY
        IOPTX=NOPTX
        IOPTY=NOPTY
        ZXMIN0=XMIN00
        ZXMAX0=XMAX00
        ZYMIN0=YMIN00
        ZYMAX0=YMAX00
        ZXRAT0=XRAT00
        ZYRAT0=YRAT00
C
 10   CONTINUE
C
      CALL NEUPAG
      IF(LXOUT(0)) WRITE(LUNTRM,1001)
 1001 FORMAT(//'  SCALING OPTIONS:'/
     >  ' (1)  FULLY AUTOMATIC: SCALE OF GRAPH SET TO INCLUDE'/
     >  '      MINIMUM AND MAXIMUM VALUES OF DATA BEING GRAPHED'/
     >  ' (2)  MANUAL:  MINIMUM AND MAXIMUM VALUES OF DATA ARE'/
     >  '      DISPLAYED; USER ENTERS SCALE FOR GRAPH'/
     >  ' (3)  FIXED:  ALL GRAPHS ARE SET TO SAME SCALE'/
     >  ' (4)  AUTOMATIC:  UPPER SCALE LIMIT SET TO MAXIMUM OF'/
     >  '      DATA;  LOWER LIMIT A FIXED MULTIPLE OF THE'/
     >  '      UPPER LIMIT (I.E. CONTROL # OF DECADES IN LOG PLOT)'/
     >  ' (5)  AUTOMATIC: LOWER SCALE LIMIT SET TO MINIMUM OF'/
     >  '      DATA; UPPER LIMIT A FIXED MULTIPLE OF THE '/
     >  '      LOWER LIMIT'//
     >  ' *** THESE OPTIONS ARE DEFINED INDEPENDANTLY FOR'/
     >  ' *** EACH AXIS'//)
C
 15   CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,1002)
 1002 FORMAT(' *OR* ENTER "R" TO SET DEFAULT SCALE TO EQUAL THE'/
     >         '      SCALE OF A PREVIOUSLY DRAWN GRAPH')
      CALL UREAD(
     >  ' GSCDEF >> ENTER SCALING OPTION # FOR * X-AXIS *:$')
C
C  *NO SCALE DEFAULT CHANGES IF USER QUITS HERE*
      IF(LCHAR('Q')) RETURN
C
      IF(LCHAR('R')) THEN
        CALL GSCRSC(ISET)
        IF(ISET.EQ.0) GO TO 10
C  MAKE CHOSEN SCALE THE DEFAULT SCALE
        NOPTX=3
        XMIN00=XMIN
        XMAX00=XMAX
        NOPTY=3
        YMIN00=YMIN
        YMAX00=YMAX
        RETURN
      ENDIF
C
C  DECODE OLD STANDARD NUMERIC OPCODE
      IOPTX=IDCOD(IERT)
      IF((IOPTX.LT.1).OR.(IOPTX.GT.5).OR.(IERT.NE.0)) THEN
        CALL UERMSG('% ILLEGAL INTEGER OPCODE',' ',1)
        GO TO 10
      ENDIF
C
      GO TO (45,45,25,35,35) IOPTX
C
C  GET FIXED LIMITS
C
 25   CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,1003) XMIN,XMAX
 1003 FORMAT(
     >' %ENTER "X"''S TO RETAIN XMIN=',1PE11.4,' AND/OR XMAX=',1PE11.4)
      CALL GSCGT1('GSCDEF','XMIN',ZXMIN0,XMIN,IRET,' ')
      IF(IRET) 10,26,25
 26   CONTINUE
      CALL GSCGT1('GSCDEF','XMAX',ZXMAX0,XMAX,IRET,' ')
      IF(IRET) 10,45,26
C
C  GET FIXED MULTIPLE FACTOR
C
 35   CONTINUE
      CALL UREAD(' GSCDEF >> ENTER FIXED X-MULTIPLIER (E10.):$')
      IF(LCHAR('Q')) GOTO 10
      ZXRAT0=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 35
C
      GO TO 45
C
C-------
C
 45   CONTINUE
C  NOW, THE Y AXIS
C
      CALL UREAD(
     >  ' GSCDEF >> ENTER SCALING OPTION # FOR * Y-AXIS *:$')
      IF(LCHAR('Q')) GOTO 10
      IOPTY=IDCOD(IERT)
      IF((IOPTY.LE.0).OR.(IOPTY.GT.5).OR.(IERT.NE.0)) THEN
        CALL UERMSG('% ILLEGAL INTEGER OPCODE',' ',2)
        IF(LXOUT(0)) WRITE(LUNTRM,1001)
        GO TO 45
      ENDIF
C
      GO TO (90,90,60,80,80) IOPTY
C
C  ENTER FIXED SCALE FACTORS
C
 60   CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,1004) YMIN,YMAX
 1004 FORMAT(
     >' %ENTER "X"''S TO RETAIN YMIN=',1PE11.4,' AND/OR YMAX=',1PE11.4)
      CALL GSCGT1('GSCDEF','YMIN',ZYMIN0,YMIN,IRET,' ')
      IF(IRET) 10,65,60
 65   CONTINUE
      CALL GSCGT1('GSCDEF','YMAX',ZYMAX0,YMAX,IRET,' ')
      IF(IRET) 10,90,65
C
C  ENTER MULTIPLIER
C
 80   CONTINUE
      CALL UREAD(' GSCDEF >> ENTER FIXED Y-MULTIPLIER (E10.):$')
      IF(LCHAR('Q')) GOTO 10
      ZYRAT0=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 80
C
C  END OF ROUTINE - NORMAL EXIT; ALL SCALE CONTROLS RESET LOCALLY--
C   COPY TO COMMON
C
 90   CONTINUE
C
      NOPTX=IOPTX
      NOPTY=IOPTY
C
      XMIN00=ZXMIN0
      XMAX00=ZXMAX0
      YMIN00=ZYMIN0
      YMAX00=ZYMAX0
      XRAT00=ZXRAT0
      YRAT00=ZYRAT0
C
      RETURN
C
      	END
C******************** END FILE GSCDEF.FOR ; GROUP GSCALE ******************
