C******************** START FILE CONRDF.FOR ; GROUP CONCTR *************
C=============================================================
C  SUBROUTINE CONRDF
C    D. MC CUNE  22 MAY 1980
C
C  REDEFINE CONTROLS FOR CONTOUR PLOT
C
      SUBROUTINE CONRDF(X,Z,Y,NX,NZ1,NY,ITYPX,ITYPY,
     >         XLAB,XUN,YLAB,YUN,ZUN,NLZMMX,
     >     XMIN,XMAX,CMIN,CMAX,YMIN,YMAX,NCTRY,ILOGC,
     >     ZCNTR1,ZWRK,NCMAX0)
C
      CHARACTER*(*) XLAB,YLAB,XUN,YUN,ZUN
      DIMENSION X(NX),Z(NZ1,NY),Y(NY),ZCNTR1(NCMAX0),ZWRK(NCMAX0)
      LOGICAL NLZMMX
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCHAR
      LOGICAL LYESC
      LOGICAL LXOUT
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
C---------------------------
C
      LUNTRM=LNOUT(0)
 1001 CONTINUE
C
      CALL NEUPAG
      IF(LXOUT(0)) WRITE(LUNTRM,3001) XLAB,XUN,YLAB,YUN,ZUN,
     >   XMIN,XMAX,YMIN,YMAX,CMIN,CMAX
 3001 FORMAT(/'  "XMIN, XMAX" ARE IN ',A,'; UNITS:  ',A/
     >          '  "YMIN, YMAX" ARE IN ',A,'; UNITS:  ',A/
     >  '  "CMIN, CMAX" ARE CONTOUR LIMITS IN FUNCTION UNITS:  ',A/
     > /'  XMIN, XMAX = ',2(1PE11.4,1X)/
     >  '  YMIN, YMAX = ',2(1PE11.4,1X)/
     >  '  CMIN, CMAX = ',2(1PE11.4,1X)/
     > /'  >>> ENTER "X" NOT TO CHANGE THE VALUE OF A VARIABLE'/)
C
 321  CALL UREAD(' SUB:CONRDF >> ENTER NEW XMIN:$')
      IERT=0
      if(lchar('Q')) return
      ZMIN=XMIN
      IF(.NOT.LCHAR('X')) ZMIN=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 321
C
 322  CALL UREAD(' SUB:CONRDF >> ENTER NEW XMAX:$')
      IERT=0
      if(lchar('Q')) goto 1001
      ZMAX=XMAX
      IF(.NOT.LCHAR('X')) ZMAX=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 322
C
      CALL SPREDM(ZMIN,ZMAX,XMIN,XMAX)
C
 323  CALL UREAD(' SUB:CONRDF >> ENTER NEW YMIN:$')
      IERT=0
      if(lchar('Q')) goto 1001
      ZMIN=YMIN
      IF(.NOT.LCHAR('X')) ZMIN=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 323
C
 324  CALL UREAD(' SUB:CONRDF >> ENTER NEW YMAX:$')
      IERT=0
      if(lchar('Q')) goto 1001
      ZMAX=YMAX
      IF(.NOT.LCHAR('X')) ZMAX=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 324
C
      CALL SPREDM(ZMIN,ZMAX,YMIN,YMAX)
C
 325  CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,3003)
 3003 FORMAT(' *ENTER "L" TO ENTER LIST OF CONTOUR VALUES FOR PLOT')
      CALL UREAD(' SUB:CONRDF >> ENTER NEW CMIN:$')
      IERT=0
      IF(LCHAR('L')) GOTO 330
      IF(LCHAR('Q')) GOTO 1001
      ZMIN=CMIN
      IF(LCHAR('X')) GO TO 326
      ZMIN=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 325
      NLZMMX=.FALSE.
C
 326  CALL UREAD(' SUB:CONRDF >> ENTER NEW CMAX:$')
      IERT=0
      IF(LCHAR('L')) GOTO 330
      IF(LCHAR('Q')) GOTO 1001
      ZMAX=CMAX
      IF(LCHAR('X')) GO TO 327
      ZMAX=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 326
      CMAX=ZMAX
      NLZMMX=.FALSE.
C
 327  CONTINUE
      IF(NLZMMX) GO TO 328
      CALL SPREDM(ZMIN,ZMAX,CMIN,CMAX)
      ZDC=CMAX-CMIN
      CMAX=CMAX+.0001*ZDC
      CMIN=CMIN-.0001*ZDC
      GO TO 328
C
C  GET USER LIST OF CONTOUR VALUES
 330  CONTINUE
      CMIN=0.0
      CMAX=0.0
      IRET=0
      CALL INORD(ZCNTR1,ZWRK,NCMAX0,IRET,'CONTOUR TEST VALUES',0)
      IF(IRET.EQ.0) GO TO 325
      NCTRY=IRET
      NLZMMX=.FALSE.
C
 328  CONTINUE
      IF((CMIN.NE.0.0).OR.(CMAX.NE.0.0)) THEN
        CALL UREAD(
     >	  ' SUB:CONRDF >> ENTER "Y" FOR LOG-SPACING OF CONTOURS:$')
        IF(LCHAR('Q')) RETURN
        IF(.NOT.LCHAR('X')) THEN
          ILOGC=1
          IF(LYESC('Y')) ILOGC=2
        ENDIF
      ENDIF
C
      ILMIN=2
      ILMAX=NCMAX0
 320  CONTINUE
      IF((CMIN.NE.0.0).OR.(CMAX.NE.0.0)) THEN
        IF(LXOUT(0)) WRITE(LUNTRM,2021) ILMIN,ILMAX,NCTRY
 2021   FORMAT(/' PROGRAM''S MIN # OF CONTOURS =',I3/
     >		  ' PROGRAM''S MAX # OF CONTOURS =',I3/
     >		  ' CURRENT    MAX # OF CONTOURS =',I3)
        CALL UREAD(
     >	  ' SUB:CONRDF >> ENTER MAX # OF CONTOURS YOU WANT TO SEE:$')
        ICTRY=NCTRY
        IERT=0
        IF(LCHAR('Q')) RETURN
        IF(.NOT.LCHAR('X')) ICTRY=IDCOD(IERT)
        IF(IERT.NE.0) GO TO 320
        IF(ICTRY.LT.ILMIN) GO TO 320
        ICTRY=MIN(ILMAX,ICTRY)
        NCTRY=ICTRY
      ENDIF
C
      IF(.NOT.NLZMMX) GO TO 121
      IFND=0
C
      DO 120 IY=1,NY
        IF((Y(IY).LT.YMIN).OR.(Y(IY).GT.YMAX)) GO TO 120
        DO 119 IX=1,NX
          IF((X(IX).LT.XMIN).OR.(X(IX).GT.XMAX)) GO TO 119
          IFND=IFND+1
          IF(IFND.EQ.1) CMIN=Z(IX,IY)
          IF(IFND.EQ.1) CMAX=Z(IX,IY)
          CMIN=AMIN1(CMIN,Z(IX,IY))
          CMAX=AMAX1(CMAX,Z(IX,IY))
 119    CONTINUE
 120  CONTINUE
C
      CALL SPREDM(CMIN,CMAX,CMIN,CMAX)
C
C  AXES TYPES
 121  CONTINUE
 282  CONTINUE
      CALL NEUPAG
      IF(LXOUT(0)) WRITE(LUNTRM,2025) ITYPX,ITYPY
 2025 FORMAT(/' AXES TYPE CODES: 1-- LINEAR, 2-- LOG'/
     >  ' CURRENT SETTINGS:  X AXIS:  ',I1/
     >  '                    Y AXIS:  ',I1/)
C
 283  CALL UREAD(
     >  ' SUB:CONCTR >> ENTER NEW X AXIS TYPE:$')
      IF(LCHAR('Q')) RETURN
      IF(LCHAR('X')) GO TO 284
      IANS=IDCOD(IERT)
      CALL UCHKOP(IANS,IERT,1,2,1,*282)
      ITYPX=IANS
C
 284  CALL UREAD(
     >  ' SUB:CONCTR >> ENTER NEW Y AXIS TYPE:$')
      IF(LCHAR('Q')) RETURN
      IF(LCHAR('X')) GO TO 289
      IANS=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 284
      IF((IANS.LE.0).OR.(IANS.GT.2)) GO TO 284
      ITYPY=IANS
 289  CONTINUE
C
      RETURN
      	END
C******************** END FILE CONRDF.FOR ; GROUP CONCTR ***************
