C******************** START FILE CONLBL.FOR ; GROUP CONCTR ******************
C=============================================================
C  CONLBL     D. MC CUNE  23-MAY-1980
C
C  LABEL A CONTOUR PLOT.
C   (1) MARK CONTOURS THEMSELVES (PRESUMED ALREADY DRAWN)
C       WITH PASSED CHARACTER CODE
C   (2) GENERATE KEY RELATING CONTOUR CHARACTER CODES TO
C       NUMERIC VALUE OF CONTOUR
C   (3) LABEL X, Y, AXIS AND UNITS, FUNCTION CONTOUR-PLOTTED,
C       AND THE RUN #
C
C  ARGUMENTS:
C   X(NX)     X-AXIS INDEP. VARIABLE ARRAY
C   Z(NZ1,NY) FUNCTION BEING PLOTTED
C   Y(NY)     Y-AXIS INDEP. VARIABLE ARRAY
C   NX,NZ1,NY ARRAY DIMENSIONS
C   XLAB      CHAR LABEL FOR X-AXIS VARIABLE
C   ZLAB      CHAR LABEL FOR FUNCTION
C   YLAB      CHAR LABEL FOR Y-AXIS VARIABLE
C   XUN       CHAR UNITS FOR X
C   ZUN       CHAR UNITS FOR FUNCTION
C   YUN       CHAR UNITS FOR Y
C   RLAB      CHAR LABEL FOR RUN
C   IINT      FUNCTION INTEGRATION CODE: 0  - NOT INTEGRATED
C            				 1  - VOL. INTEGRATED
C    					 2  - FLUX INTEGRATED
C					 3  - AREA INTEGRATED
C   ISMOO    ISMOO=1 MEANS DATA HAS BEEN SMOOTHED
C   ZCNTR     LOCATION (FUNCTION UNITS) OF CONTOURS
C   ACNTR     1-CHAR IDENTIFICATION CODE, UNIQUE FOR EACH CONTOUR
C   NC        # OF CONTOURS
C  NPAGE-- PAGE # WITH WHICH TO LABEL GRAPH (FIRST INCREMENT)
C=========
C
      SUBROUTINE CONLBL(X,Z,Y,NX,NZ1,NY,XLAB,ZLAB,YLAB,
     >              XUN,ZUN,YUN,RLAB,IINT,ISMOO,ZCNTR,ACNTR,NC,NPAGE)
C
C  LOCAL DECLARATIONS
      PARAMETER (NSUP0=8)
      PARAMETER (NCY0=1)
C   PASSED ARGS:
      DIMENSION X(NX),Z(NZ1,NY),Y(NY),ZCNTR(NC)
      CHARACTER*(*) XLAB,ZLAB,YLAB,XUN,YUN,ZUN,RLAB
      CHARACTER*1 ACNTR(NC)
C  LOCAL
C
      DIMENSION YFIX(NSUP0)
      INTEGER INDY(NSUP0)
      CHARACTER*10 ZBL10,ZSMLAB
      CHARACTER*12 ZENCOD
      CHARACTER*75 MNLAB,MNLAB2
c
c
      DIMENSION IOFFL(5)
C
      DATA ZSMLAB/' SMOOTHED '/
      DATA ZBL10/'          '/
C
C  INCLUDE INTEGRATION LABELS
C
      INCLUDE 'INTLAB'
C     
C  START OF EXECUTABLE CODE
C
C  (1)  MARK CONTOURS
C     ALG:  SEVERAL LINES OF CONST. Y ARE CHOSEN;
C          THE INTERSECTION OF Z WITH CONTOURS ALONG THESE
C          LINES ARE CALCULATED; EVERY NCY'TH SUCH INTERSECTION
C          IS MARKED WITH THE LETTER CODE FOR THE CONTOUR
C          INTERSECTED
C
      IF(NY.LE.1) RETURN
      IF(NY.LT.(NSUP0+2)) GO TO 5
      J0=2
      JL=NY-1
      JN=NY-2
      GO TO 10
 5    CONTINUE
      J0=1
      JL=NY
      JN=NY
 10   CONTINUE
C  NSUP= # OF LINES OF CONST. Y
C  NCY=  1+ # OF CONTOURS TO SKIP BETWEEN MARKED CONTOURS
      NSUP=MIN0(NSUP0,JN)
      NCY=MIN0(NCY0,NSUP)
C
      DELY=Y(JL)-Y(J0)
      YFIX(1)=Y(J0)
      YINTVL=DELY/(NSUP-1)
      DO 20 I=2,NSUP
        IM1=I-1
        YFIX(I)=YFIX(IM1)+YINTVL
 20   CONTINUE
C  FIND INDICES TO SET OF LINES OF CONST Y
      CALL LMVRTI(Y(J0),Y(JL),J0,JL,YFIX,INDY,NSUP)
C
C  MARK EVERY NCY'TH CONTOUR ALONG EACH LINE OF CONST. Y
C
      ISKIP0=1
      DO 50 IROW=1,NSUP
        ISKIP0=ISKIP0-1
        IF(ISKIP0.LT.0) ISKIP0=NCY-1
        X0=X(1)
        Z0=Z(1,INDY(IROW))
        ISKIP=ISKIP0
C
C  START OF LOOP FOR A SINGLE LINE
 40     CONTINUE
          IF(X0.GE.X(NX)) GO TO 50
C  FIND NEXT CONTOUR INTERCEPT
          CALL FNEXC(X,Z(1,INDY(IROW)),NX,ZCNTR,NC,X0,Z0,IRET)
          IF(IRET.EQ.0) GO TO 40
          ISKIP=ISKIP-1
          IF(ISKIP.GE.0) GO TO 40
          ISKIP=NCY-1
          CALL PUTCHR(X0,Y(INDY(IROW)),ACNTR(IRET))
        GO TO 40
 50   CONTINUE
C
C  (2)   GENERATE KEY TO EQUATE CONTOUR CHARACTER SYMBOLS
C        TO NUMERIC VALUES
C
C  DRAW KEY FRAME
      IX1=750
      IX2=1000
      IY1=125
      IY2=700
      IYL=IY2
      IXL=IX1+20
      IDY=28
C
      CALL DPLOFR(IX1,IX2,IY1,IY2,0)
C
      IYL=IYL-IDY
      CALL GRFLBL(IXL,IYL,'CONTOURS:',16,0,0)
C
      IYL=IYL-IDY
      CALL GRFLBL(IXL,IYL,ZUN,16,0,0)
C
      DO 70 IJ=1,NC
        WRITE(ZENCOD,7003) ZCNTR(IJ)
 7003 FORMAT(1PE11.4,1X)
        IYL=IYL-IDY
        CALL GRFLBL(IXL,IYL,ACNTR(IJ)//' = '//ZENCOD,16,0,0)
 70   CONTINUE
C
C  (3)  LABEL X,Y AXES
C
      CALL GRFLBL(800,70,XUN,0,-1,0)
C
      CALL GRFLBL(30,680,YUN,0,-1,1)
C
      IJINT=1
      IF(IINT.GT.0) IJINT=2
      JINT=max(1,(IINT+5))
C
      MNLAB=trim(ZLINT(JINT))//' '//trim(ZLAB)//' VS '//
     >   trim(XLAB)//' & '//trim(YLAB)
      CALL GRFLBL(50,18,MNLAB,0,0,0)
C
C  INCREMENT AND LABEL PAGE #
      NPAGE=NPAGE+1
      ilrlab=min(38,len_trim(rlab))
      IF(ISMOO.NE.1) WRITE(MNLAB2,8007) RLAB(1:ILRLAB),ZBL10,NPAGE
      IF(ISMOO.EQ.1) WRITE(MNLAB2,8007) RLAB(1:ILRLAB),ZSMLAB,NPAGE
 8007 FORMAT(A,1X,A,1X,'page ',I4,1X)
      CALL GRFLBL(150,727,MNLAB2,0,0,0)
C
      RETURN
      END
C******************** END FILE CONLBL.FOR ; GROUP CONCTR ******************
