C-------------------------------------------------------------
C  GSCXDF - 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 X AXIS, UPCOMING PLOT
C  THIS MAY INCLUDE ASKING THE USER FOR INFORMATION
C
      SUBROUTINE GSCXDF(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  MOD DMC - PASSED ARG OVERRIDE OPTION
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
        JOPTX=NOPTX
        JOPTY=NOPTY
C
        IF((JOPTX.EQ.2).OR.(JOPTY.EQ.2)) CALL NEUPAG
C
      ELSE
        JOPTX=IOPT
      ENDIF
C
 10   CONTINUE
C  DO X AXIS
      GO TO (20,30,40,50,60) JOPTX
C
 20   CONTINUE
      XMIN=GMINX
      XMAX=GMAXX
      IF((IXXMAP(IAXCUR).EQ.1).AND.(GMINXP.GT.0.0)) THEN
        XMIN=GMINXP
        XMAX=AMAX1(XMAX,1.1*XMIN)
      ENDIF
C
      GO TO 90
C
 30   CONTINUE
      IF(lxout(0)) WRITE(LUNTRM,3001) GMINX,GMAXX,GMINY,GMAXY
 3001 FORMAT(//'  DATA:'/
     >  '  MINIMUM X:  ',1PE10.3,' MAXIMUM X:  ',1PE10.3/
     >  '  MINIMUM Y:  ',1PE10.3,' MAXIMUM Y:  ',1PE10.3/
     >  '  ENTER "X" TO USE THE ABOVE LIMITS IN THE PLOT SCALE')
      CALL UREAD(' GSCSET >> ENTER XMIN FOR GRAPH:$')
      IF(.NOT.LCHAR('X')) XMIN=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 30
C
 35   CONTINUE
      CALL UREAD(' GSCSET >> ENTER XMAX FOR GRAPH:$')
      IF(.NOT.LCHAR('X')) XMAX=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 35
      GO TO 90
C
 40   CONTINUE
      XMIN=XMIN00
      XMAX=XMAX00
      GO TO 90
C
 50   CONTINUE
      XMAX=GMAXX
      XMIN=XMAX*XRAT00
C
      GO TO 90
C
 60   CONTINUE
      XMIN=GMINX
      XMAX=XMIN*XRAT00
      GO TO 90
C
 90   CONTINUE
      IF(XMAX.LT.XMIN) THEN
        ZTMP=XMAX
        XMAX=XMIN
        XMIN=ZTMP
      ELSE IF(XMAX.EQ.XMIN) THEN
C  XMAX=XMIN
        ZDELX=ABS(.01*XMIN)
        ZXA=XMIN
        IF(ZDELX.EQ.0.0) ZDELX=0.1
        XMIN=ZXA-ZDELX
        XMAX=ZXA+ZDELX
      ENDIF
C
      RETURN
      END
