C******************** START FILE GMMSEL.FOR ; GROUP GMMSEL *************
C----------------------------------------------------------------
C  GMMSEL
C   BASED ON G3MSEL
C
C  GENERATE PLOT OF MULTIPLE CONTOURS (R,Y), INDEXED BY Z
C
      SUBROUTINE GMMSEL(R,Y,ND1,NC,Z,NZ,
     >     RUN,YUN,ZLAB,ZUN,MNLAB,KYLAB,FZLAB)
C
C  R(ND1,NZ)
C  Y(ND1,NZ)  SEQUENCES OF ORDERED PAIRS (R,Y) TO BE PLOTTED
C             R MAPPED ALONG HORIZONTAL AXIS, Y ALONG VERTICAL AXIS
C             ND1= 1ST DIMENSION OF R,Y ARRAYS
C
C  NC         NUMBER OF PTS IN EACH CONTOUR (.LE. ND1)
C             (R(1,J),Y(2,J)), (R(2,J),Y(2,J)), ..., (R(NC,J),Y(NC,J))
C
C  Z(NZ)      CONTOUR INDEXING  JTH CONTOUR IS ASSOCIATED WITH Z(J)
C
C  RUN        10 CHAR LABEL PHYSICAL UNITS OF R
C  YUN        10 CHAR LABEL PHYSICAL UNITS OF Y
C
C  ZLAB       10 CHAR LABEL FOR Z
C  ZUN        10 CHAR LABEL UNITS OF Z
C
C  MNLAB      3 60 CHAR "MAIN" LABELS FOR MULTIPLOT
C    MNLAB(1),MNLAB(2) APPEAR ABOVE PLOT  MNLAB(3) APPEARS BELOW
C
C  ** CALLER SUPPLIES ALL OF THE ABOVE **
C
C  KYLAB      5 17 CHAR "KEY" LABELS FOR MULTIPLOT
C
C  ** KYLAB(3) THRU KYLAB(5) MAY BE SET BY CALLER.  THESE LABELS APPEAR
C  AT THE BOTTOM OF THE KEY BOX IN THE PLOT
C
C  FZLAB      15 12-character FIXED PT. (Z) LABELS FOR MULTIPLOT
C
C  KEY LABELS 1 AND 2, AND
C  ALL FIXED Z LABELS SET UP HERE.
C
C  SEE SUBROUTINES GRFMM1 AND MULCDR
C
      REAL R(ND1,NZ),Y(ND1,NZ),Z(NZ)
C
      CHARACTER*(*) RUN,YUN,ZLAB,ZUN,FZLAB(15)
C
      INTEGER ISELF(15)
      REAL ZSELF(15)
      INTEGER NCA(1)
C
      CHARACTER*(*) MNLAB(3)
      CHARACTER*(*) KYLAB(5)
C
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCHAR
      LOGICAL LXOUT
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
C  EXECUTABLE CODE
C
      LUNTRM=LNOUT(0)
 10   CONTINUE
C
      KYLAB(1)=ZLAB
      KYLAB(2)=ZUN
C
      ZZ1=Z(1)
      ZZ2=Z(NZ)
C
 50   CONTINUE
      CALL NEUPAG
 51   IF(LXOUT(0)) WRITE(LUNTRM,1002) MNLAB(1),NZ,ZLAB,ZZ1,ZZ2,ZUN
 1002 FORMAT(/' PLOTTING:'/1X,A/
     >  1X,I4,' CONTOURS AVAILABLE AT FIXED VALUES OF ',A,' FROM'/
     >  1X,1PE11.4,' TO ',1PE11.4,1X,A,' NO INTERPOLATIONS.'//
     >  ' OPTIONS--'/
     >  '  A:  SPECIFY ALL CONTOURS'/
     >  '  B:  SPECIFY STARTING CONTOUR, SPACING INTERVAL AND NUMBER'/
     >  '  C:  SPECIFY STARTING CONTOUR INDEX, NUMBER AND INCREMENT'/
     >  '  Q:  QUIT'/)
C
      CALL UREAD('GMMSEL:  ENTER CONTOUR OPCODE (A/B/C/X/Q):$')
      IANS=IXUOPC('ABCQ$')
      CALL UCHKOP(IANS,0,1,100,-1,*51)
      GO TO (100,200,300,500) IANS
C
C  ALL CONTOURS SPECIFIED
C
 100  CONTINUE
      NSEL=0
 101  CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,1003) ZLAB,ZUN
 1003 FORMAT(' SPECIFY ',A,' VALUES IN ',A)
      IF(LXOUT(0)) WRITE(LUNTRM,1004)
 1004 FORMAT(
     >  ' ENTER LIST OF VALUES, TERMINATE WITH AN "X"'/
     >  ' NEAREST AVAILABLE CONTOUR WILL BE TAKEN'/)
 105  CALL UREAD('$')
      IF(LCHAR('X')) GO TO 190
      if(lchar('Q')) goto 50
      ZVAL=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 101
C
      CALL G3INX1(ZVAL,1,Z,NZ,Z,NZ,ISELF,ZSELF,15,NSEL)
      GO TO 105
C
 190  CONTINUE
      IF(NSEL.EQ.0) GO TO 50
      GO TO 1000
C-----
 200  CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,1003) ZLAB,ZUN
      CALL UREAD('GMMSEL:  ENTER START VALUE:$')
      if(lchar('Q')) goto 50
      ZV1=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 200
 210  CONTINUE
      CALL UREAD('GMMSEL:  ENTER INTERVAL:$')
      IF(LCHAR('Q')) GO TO 50
      ZVI=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 210
 220  CONTINUE
      CALL UREAD('GMMSEL:  ENTER NUMBER OF CONTOURS (INTEGER):$')
      IF(LCHAR('Q')) GO TO 50
      INSEL=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 220
      INSEL=MAX0(1,MIN0(15,INSEL))
C
      ZV=ZV1-ZVI
      NSEL=0
      DO 230 I=1,INSEL
        ZV=ZV+ZVI
        CALL G3INX1(ZV,1,Z,NZ,Z,NZ,ISELF,ZSELF,15,NSEL)
 230  CONTINUE
      GO TO 1000
C-----
 300  CONTINUE
      CALL UREAD('GMMSEL:  ENTER START INDEX:$')
      IF(LCHAR('Q')) GO TO 50
      ISTART=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 50
C
 310  CONTINUE
      CALL UREAD('GMMSEL:  ENTER NO. OF CONTOURS TO PLOT (MAX 15):$')
      IF(LCHAR('Q')) GO TO 50
      INSEL=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 310
      INSEL=MAX0(1,MIN0(15,INSEL))
C
 320  CONTINUE
      CALL UREAD(
     >  'GMMSEL:  ENTER INTERVAL (E.G. 2 FOR ALTERNATE CONTOURS):$')
      IF(LCHAR('Q')) GO TO 50
      INTVL=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 320
      INTVL=MAX0(1,INTVL)
C
      IND=ISTART-INTVL
      NSEL=0
      DO 350 I=1,INSEL
        IND=IND+INTVL
        ZV=Z(MAX0(1,MIN0(NZ,IND)))
        CALL G3INX1(ZV,1,Z,NZ,Z,NZ,ISELF,ZSELF,15,NSEL)
 350  CONTINUE
      GO TO 1000
C
 500  CONTINUE
      RETURN
C
 1000 CONTINUE
      DO 1010 I=1,NSEL
        IF(ZSELF(I).LE.0.0) WRITE(FZLAB(I),2001) ZSELF(I)
        IF(ZSELF(I).GT.0.0) WRITE(FZLAB(I),2002) ZSELF(I)
 1010 CONTINUE
C
 2001 FORMAT(1PE11.4)
 2002 FORMAT(1PE11.5)
C
      NCA = NC  ! formally an array is needed for arg. 4:
      CALL GRFMM1(R,Y,ND1,NCA,1,Z,NZ,ISELF,NSEL,
     >     RUN,YUN,MNLAB,KYLAB,FZLAB)
C
      GO TO 50
      END
C******************** END FILE GMMSEL.FOR ; GROUP GMMSEL ***************
