C******************** START FILE G3MSEL.FOR ; GROUP G3MSEL ******************
C----------------------------------------------------------------
C  G3MSEL
C    CONTROL GENERATION OF MULTIPLOT CONSISTING OF MULTIPLE
C  SLICES OF FUNCTION OF 2 INDEPENDANT VARIABLES.
C    TITLE LABELING SET UP BY CALLER; ONLY THAT LABELING WHICH
C  DEPENDS ON USER CHOICE OF SLICES IS SET UP HERE.
C    CALLING SUBROUTINE - GRF3
C
C  DMC 12/87 -- ADDING A DIGIT OF PRECISION TO THE SLICE LABELS
C    NOW 11 CHARACTERS USED
C    CF FURTHER EXPANSION WILL REQUIRE CHANGE TO DPLOTK ROUTINE
C    AND RE-MAPPING OUT OF KEY BOX RASTER COORDS ...
C
      SUBROUTINE G3MSEL(Z,NZ1,X,NX,Y,NY,ZWK,
     >     XLAB,XUN,YLAB,YUN,ZLAB,ZUN,MNLAB)
C
C  Z(NZ1,NY)  DATA TO BE PLOTTED
C  X(NX)      FIRST DIMENSION INDEPENDANT VAR. OF Z
C  Y(NY)      SECOND DIMENSION INDEPENDANT. VAR. OF Z
C  ZWK(NY)    WORKSPACE FOR MULTIPLOT SUBROUTINE
C
C  XLAB       CHAR LABEL FOR X
C  XUN        CHAR UNITS FOR X
C  YLAB       CHAR LABEL FOR Y
C  YUN        CHAR UNITS FOR Y
C  ZLAB       CHAR LABEL FOR Z
C  ZUN        CHAR UNITS FOR Z
C
C  MNLAB      3 CA. 60 CHAR "MAIN" LABELS FOR MULTIPLOT
C
C  3RD MAIN LABEL, KEY LABELS 1 AND 2, AND
C  ALL SLICE LABELS SET UP HERE.
C
C  SEE SUBROUTINES GRFMF1 AND MULFDR
C
      DIMENSION Z(NZ1,NY),X(NX),Y(NY),ZWK(NY)
C
      CHARACTER*(*) XLAB,XUN,YLAB,YUN,ZLAB,ZUN
      CHARACTER*(*) MNLAB(3)
C
      CHARACTER*12 FNLAB(15)
C
      CHARACTER*20 KYLAB(5)
C
      INTEGER ISELF(15)
C
      REAL ZSELF(15)
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)
C
 10   CONTINUE
C
      CALL NEUPAG
C
      IF(LXOUT(0)) WRITE(LUNTRM,1001) XLAB,YLAB
 1001 FORMAT(/'  DIMENSION #1: ',A,'  DIMENSION #2: ',A/)
C
 11   CONTINUE
      CALL UREAD(
     >  'G3MSEL:  CHOOSE DIMENSION FOR X AXIS (1 OR 2):$')
      IF(LCHAR('Q')) GO TO 500
C
      ISELX=IDCOD(IERT)
      IF((ISELX.LE.0).OR.(ISELX.GT.2)) THEN
        CALL UERMSI(' % CHOOSE DIMENSION 1 OR 2 ONLY',ISELX,0)
        GO TO 11
      ENDIF
C
      IF(ISELX.EQ.1) THEN
        MNLAB(3)=ZLAB//' VS '//XLAB
        KYLAB(1)=YLAB
        KYLAB(2)=YUN
C
        ZX1=X(1)
        ZX2=X(NX)
        INX=NX
C
        ZY1=Y(1)
        ZY2=Y(NY)
        INY=NY
C
      ELSE
        MNLAB(3)=ZLAB//' VS '//YLAB
        KYLAB(1)=XLAB
        KYLAB(2)=XUN
C
        ZX1=Y(1)
        ZX2=Y(NY)
        INX=NY
C
        ZY1=X(1)
        ZY2=X(NX)
        INY=NX
C
      ENDIF
C
      KYLAB(3)=' '
      KYLAB(4)=' '
      KYLAB(5)=' '
C
 50   CONTINUE
      CALL NEUPAG
 51   IF(LXOUT(0)) WRITE(LUNTRM,1002) INY,KYLAB(1),ZY1,ZY2,KYLAB(2)
 1002 FORMAT(/1X,I6,' SLICES OF ',A,' AVAILABLE FROM'/
     >  1X,1PE12.5,' TO ',1PE12.5,1X,A,' NO INTERPOLATIONS.'//
     >  ' OPTIONS--'/
     >  '  A:  SPECIFY ALL SLICES'/
     >  '  B:  SPECIFY STARTING SLICE, SPACING INTERVAL AND NUMBER'/
     >  '  C:  SPECIFY STARTING SLICE INDEX, NUMBER AND INCREMENT'/
     >  '  X:  SWITCH X AXIS'/
     >  '  Q:  QUIT'/)
C
      CALL UREAD('G3MSEL:  ENTER SLICE OPCODE (A/B/C/X/Q):$')
      IANS=IXUOPC('ABCXQ$')
      CALL UCHKOP(IANS,0,1,100,-1,*51)
      GO TO (100,200,300,10,500) IANS
C
C  ALL SLICES SPECIFIED
C
 100  CONTINUE
C
      NSEL=0
 101  CONTINUE
      IF(LXOUT(0)) WRITE(LUNTRM,1003) KYLAB(1),KYLAB(2)
 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 SLICE WILL BE TAKEN'/)
C
 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,ISELX,X,NX,Y,NY,ISELF,ZSELF,15,NSEL)
      GO TO 105
C
 190  CONTINUE
      IF(NSEL.EQ.0) GO TO 50
      GO TO 1000
C-----
 200  CONTINUE
C
      IF(LXOUT(0)) WRITE(LUNTRM,1003) KYLAB(1),KYLAB(2)
      CALL UREAD('G3MSEL:  ENTER START VALUE:$')
      if(lchar('Q')) goto 50
      ZV1=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 200
C
 210  CONTINUE
      CALL UREAD('G3MSEL:  ENTER INTERVAL:$')
      IF(LCHAR('Q')) GO TO 50
      ZVI=FDCOD(IERT)
      IF(IERT.NE.0) GO TO 210
C
 220  CONTINUE
      CALL UREAD('G3MSEL:  ENTER NUMBER OF SLICES (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,ISELX,X,NX,Y,NY,ISELF,ZSELF,15,NSEL)
 230  CONTINUE
      GO TO 1000
C-----
 300  CONTINUE
C
      CALL UREAD('G3MSEL:  ENTER START INDEX:$')
      IF(LCHAR('Q')) GO TO 50
      ISTART=IDCOD(IERT)
      IF(IERT.NE.0) GO TO 50
C
 310  CONTINUE
      CALL UREAD('G3MSEL:  ENTER NUMBER OF SLICES 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(
     >  'G3MSEL:  ENTER INTERVAL (E.G. 2 FOR ALTERNATE SLICES):$')
      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
        IF(ISELX.EQ.1) ZV=Y(MAX0(1,MIN0(NY,IND)))
        IF(ISELX.EQ.2) ZV=X(MAX0(1,MIN0(NX,IND)))
        CALL G3INX1(ZV,ISELX,X,NX,Y,NY,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(FNLAB(I),2001) ZSELF(I)
        IF(ZSELF(I).GT.0.0) WRITE(FNLAB(I),2002) ZSELF(I)
 1010 CONTINUE
C
 2001 FORMAT(1PE11.4)
 2002 FORMAT(1PE11.5)
C
      IF(ISELX.EQ.1) THEN
        CALL GRFMF1(Z,NZ1,X,NX,Y,NY,ZWK,ISELX,ISELF,NSEL,
     >	     ZUN,XUN,MNLAB,KYLAB,FNLAB)
      ELSE
        CALL GRFMF1(Z,NZ1,X,NX,Y,NY,ZWK,ISELX,ISELF,NSEL,
     >	     ZUN,YUN,MNLAB,KYLAB,FNLAB)
      ENDIF
C
      GO TO 50
      END
C******************** END FILE G3MSEL.FOR ; GROUP G3MSEL ******************
