C-------------------------------------------------------------
C  GSCYDF - BASED ON DATA X,Y MIN MAX INFORMATION STORED IN COMMON,
C   AND OPTION SWITCH SETTINGS, ALSO IN COMMON,
C  DECIDE ON THE SCALE FOR THE *Y*  AXIS, UPCOMING PLOT
C  THIS MAY INCLUDE ASKING THE USER FOR INFORMATION
C
      SUBROUTINE GSCYDF(IOPT)
C
C  AXIS TYPES COMMON--
C
      INCLUDE 'GAXES_BLK'
C
C  SCALE SETTING COMMON BLOCKS --
C
      INCLUDE 'GSCALE_BLK'
C
C  PLOT1 COMMON
C
      INCLUDE 'PLOT1MMX'
C
C  START OF EXECUTABLE CODE
C
C  DMC - PASSED ARG OVERRIDE OPTION ADDED MAR 1986
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCHAR,lxout
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
      luntrm=lnout(0)

      IF(IOPT.EQ.0) THEN
        JOPTY=NOPTY
      ELSE
        JOPTY=IOPT
      ENDIF
C
 10   CONTINUE
C  DO Y AXIS
      GO TO (20,30,40,50,60) JOPTY
 20   CONTINUE
      YMIN=GMINY
      YMAX=GMAXY
      IF((IXYMAP(IAXCUR).EQ.1).AND.(GMINYP.GT.0.0)) THEN
        YMIN=GMINYP
        YMAX=AMAX1(YMAX,1.1*YMIN)
      ENDIF
C
      GO TO 90
C
 30   CONTINUE
      IF(lxout(0)) WRITE(LUNTRM,3001) GMINY,GMAXY
 3001 FORMAT(//'  DATA:'/
     >  '  MINIMUM Y:  ',1PE10.3,' MAXIMUM Y:  ',1PE10.3/
     >  '  ENTER "X" TO USE THE ABOVE LIMITS IN THE PLOT SCALE')
      CALL UREAD(' GSCSET >> ENTER YMIN FOR GRAPH:$')
      IF(.NOT.LCHAR('X')) YMIN=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 30
C
 35   CONTINUE
      CALL UREAD(' GSCSET >> ENTER YMAX FOR GRAPH:$')
      IF(.NOT.LCHAR('X')) YMAX=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 35
      GO TO 90
C
 40   CONTINUE
      YMIN=YMIN00
      YMAX=YMAX00
      GO TO 90
C
 50   CONTINUE
      YMAX=GMAXY
      YMIN=YMAX*YRAT00
C
      GO TO 90
C
 60   CONTINUE
      YMIN=GMINY
      YMAX=YMIN*YRAT00
      GO TO 90
C
 90   CONTINUE
      IF(YMAX.LT.YMIN) THEN
        ZTMP=YMAX
        YMAX=YMIN
        YMIN=ZTMP
      ELSE IF(YMAX.EQ.YMIN) THEN
C  YMAX=YMIN
        ZDELY=ABS(.01*YMIN)
        ZYA=YMIN
        IF(ZDELY.EQ.0.0) ZDELY=0.1
        YMIN=ZYA-ZDELY
        YMAX=ZYA+ZDELY
      ENDIF
C
      RETURN
      END
