C******************** START FILE CONCTS.FOR ; GROUP CONCTR *************
C============================================================
C  CONCTS    D. MC CUNE MAY 21 1980 -- NON-INTERACTIVE MAIN
C
C  CONTROL GENERATION OF CONTOUR PLOT OF 2D GRID
C  FUNCTION
C
C  PROGRAM CONTROLS GENERATION OF A QUICK DEFAULT CONTOUR PLOT
C  AND EXITS -- NO USER I/O
C
C  ARGUMENTS:
C    X(NX)    INDEP. VAR ALONG 1ST DIMENSION OF FUNCTION
C    Z(NZ1,NY)  2D FUNCTION TO BE PLOTTED
C    Y(NY)    INDEP VAR. ALONG 2ND DIMENSION OF FUNCTION
C    XLAB     10 CHAR LABEL FOR X
C    ZLAB(2)  20 CHAR LABEL FOR Z
C    YLAB     10 CHAR LABEL FOR Y
C    XUN      10 CHAR. PHYS. UNITS FOR X TERMINATED WITH "$"
C    ZUN      DITTO FOR Z
C    YUN      DITTO FOR Y
C    RLAB     10 CHAR. RUN LABEL , E.G. "RUN # 1234"
C             (SHOULDNT BE TERMINATED WITH "$")
C    IINT     FCN INTEGRATION CODE:
C             0 -- NOT INTEGRATED
C             1 -- VOL. INTEGRATED
C             2 -- FLUX. INTEGRATED
C             3 -- AREA INTEGRATED
C    ISMOO    IF ISMOO=1, DATA HAS BEEN SMOOTHED
C                (FOR LABELING)
C    NPAGE  INCREMENTS BY ONE TO YIELD PAGE # OF GRAPH TO BE
C           DRAWN; PAGE # IS ADDL LABEL ON GRAPH
C
      SUBROUTINE CONCTS(X,Z,Y,NX,NZ1,NY,XLAB,ZLAB,YLAB,
     >                    XUN,ZUN,YUN,RLAB,IINT,ISMOO,NPAGE,
     >                    ITYPX,ITYPY,ILOGC)
C
C  ITYPX-- =1 FOR LINEAR X AXIS, 2 FOR LOG X AXIS
C  ITYPY-- =1 FOR LINEAR Y AXIS, 2 FOR LOG Y AXIS
C  ILOGC-- =1 FOR LINEAR CONTOUR SPACING, 2 FOR LOG CONTOURS
C  DECLARATIONS
C   PARAMETER:  MAX # OF CONTOURS
C    LIMITED BY CONTOUR LABELING, SPACE IN KEY
      PARAMETER (NCMAX0=18)
C
C  PASSED ARGS
C
      DIMENSION X(NX),Z(NZ1,NY),Y(NY)
      CHARACTER*(*) XLAB,ZLAB,YLAB,RLAB,XUN,YUN,ZUN
C
C   LOCAL
C
C  ARRAY OF CONTOUR VALUES
      DIMENSION ZCNTR1(NCMAX0)
C  CONTOUR ID CHARACTERS
      CHARACTER*1 ACNTR1(NCMAX0)
C
      DATA ACNTR1/'A','B','C','D','E','F','G','H','J','K',
     >              'L','M','N','P','Q','R','S','T'/
C
      CHARACTER*10 FLAB,CLAB
      DATA FLAB/'FUNCTION  '/
      DATA CLAB/'CONTOUR   '/
C  INITIAL DEFAULT FLAG VALUES--
C   SET MIN,MAX CONTOUR LIMITS TO FUNCTION MIN,MAX
C
      LOGICAL NLZMMX,ILZMMX
      DATA NLZMMX/.TRUE./
C   SET  DOMAIN TO ENTIRE DOMAIN OF FUNCTION
      LOGICAL NLXMMX
      DATA NLXMMX/.TRUE./
      LOGICAL NLYMMX
      DATA NLYMMX/.TRUE./
C   SET EQUAL SPACING OF CONTOURS
      LOGICAL NLLOGC
C
      LOGICAL LXOUT
C
C  SET MAX # OF CONTOURS INITIALLY TO PROGRAM LIIMIT
      DATA NCMAX/NCMAX0/
C
C  START OF EXECUTABLE CODE-- PRESENT USER OPTIONS
C
      LUNTRM=LNOUT(0)
      if(luntrm.eq.0) LUNTRM=6
C
C  CHECK FOR MIN. NX, NY
      IF((NX.GT.1).AND.(NY.GT.1)) GO TO 10
        WRITE(LUNTRM,9009) NX,NY
 9009   FORMAT('  NX=',I3,'  NY=',I3/
     >	  '  TOO FEW X OR Y PTS FOR CONTOUR PLOTTING ***')
        CALL UPAUST(1)
        RETURN
 10   CONTINUE
C
C  MAKE PLOT
C
 100  CONTINUE
C  SET DEFAULTS
C  SET CURRENT MAX # OF CONTOURS
      NCTRY=NCMAX
C  SET DOMAIN LIMITS
      IF(NLXMMX) GO TO 140
        XMIN=0.0 !XMIN0
        XMAX=0.0 !XMAX0
        GO TO 150
C  TO MIN,MAX OF X
 140  CONTINUE
        XMIN=X(1)
        XMAX=X(NX)
        CALL SPREDM(XMIN,XMAX,XMIN,XMAX)
 150  CONTINUE
C
      IF(NLYMMX) GO TO 160
        YMIN=0.0 !YMIN0
        YMAX=0.0 !YMAX0
        GO TO 170
C
 160  CONTINUE
        YMIN=Y(1)
        YMAX=Y(NY)
        CALL SPREDM(YMIN,YMAX,YMIN,YMAX)
 170  CONTINUE
C  CONTOUR LIMITS
      IF(NLZMMX) GO TO 110
        CMIN=0.0 !CMIN0
        CMAX=0.0 !CMAX0
        GO TO 130
 110  CONTINUE
C  SET TO MIN,MAX OF FCN
        IFND=0
        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
        CALL SPREDM(CMIN,CMAX,CMIN,CMAX)
C
 130  CONTINUE
C
C
C  DRAW CONTOURS
C
 180  CONTINUE
      CALL CONPLT(X,Z,Y,NX,NZ1,NY,XLAB,ZLAB,YLAB,
     >       XUN,ZUN,YUN,RLAB,IINT,ISMOO,ITYPX,ITYPY,
     >       XMIN,XMAX,CMIN,CMAX,YMIN,YMAX,NCTRY,ILOGC,NLZMMX,
     >       ZCNTR1,ACNTR1,NPAGE)
C
      RETURN
      END
C******************** END FILE CONCTS.FOR ; GROUP CONCTR ***************
