      SUBROUTINE   GPSIMQ
     I                   (AXTYP,MAXLN,GLNTYP,GSYMBL,MAXP,CNTP,YPT,XPT,
     I                    TITL1,YLAB1,XLAB1,CLAB1)
C
C     + + + PURPOSE + + +
C     calls routines to make a plot of the results of QUAL2E with
C     observed data
C
C     + + + DUMMY ARGUMENTS + + +
      INTEGER     AXTYP(2),MAXP,MAXLN,CNTP(MAXLN),GLNTYP(MAXLN),
     1            GSYMBL(MAXLN)
      REAL        YPT(MAXP,MAXLN),XPT(MAXP,MAXLN)
      CHARACTER*1 TITL1(240),YLAB1(80),XLAB1(80),CLAB1(20,MAXLN)
C
C     + + + ARGUMENT DEFINITION + + +
C     AXTYP - type of axis - 1- arith, 2-log, 1-Y,2-X
C     MAXLN - number of lines to plot
C     MAXP  - max number of points in PTS to plot
C     CNTP  - number of points in PTS to for each curve in plot
C     YPT   - array of Y values to plot
C     XPT   - array of X values to plot
C     TITL1 - title of plot
C     YLAB1 - y label for plot
C     XLAB1 - x label for plot
C     CLAB1 - label for each curve
C
C     + + + LOCAL VARIABLES + + +
      INTEGER     I,J,IPOS,IWAIT,RETCOD,GWCH(18),GTICS(4),
     1            GBVALF(4),GCTYP(6),GCOLOR(6),IMET,
     2            GPATRN(6),GTRANF(18),GXTYP,GYTYP(2)
C      INTEGER     I,J,IPOS,IWAIT,RETCOD,GWCH(18),GTICS(4),
C     1            GBVALF(4),GCTYP(5),GCOLOR(5),IMET,
C     2            GPATRN(5),GTRANF(18),GXTYP,GYTYP(2)
      INTEGER     IP1,INDX,NOVAR
C     2            GPATRN(5),GTRANF(2,5),GXTYP,GYTYP(2)
      INTEGER     WSID,ICLOS
      REAL        GVMIN(2),GVMAX(2),PLMN(4),PLMX(4),RDUM,GALEN
      REAL*4      GSIZL,GXPAGE,GYPAGE,GXPHYS,GYPHYS,GXLEN,GYLEN,GALENX
      CHARACTER*1 OLAB1(80),BLNK
C
C     + + + EXTERNALS + + +
      EXTERNAL   GPNCRV,GPDATR,GPCURV,GPVAR,SCALIT,GPSCLE,GPLABL
C      EXTERNAL   GPSIZE,PSETUP,PLTONE,DONPLT,ZIPR,ZIPI,ZIPC
      EXTERNAL   GPSIZE,PSETUP,PLTONE,PDNPLT,ZIPR,ZIPI,ZIPC
C
C     + + + END SPECIFICATIONS + + +
C
      write(99,*) 'AXTYP:(y,x):',AXTYP
      write(99,*) 'MAXLN,MAXP :',MAXLN,MAXP
      write(99,*) 'CNTP       :',CNTP
      write(99,*) 'about to call GPNCRV'
C     how many curves and variables?
      NOVAR=MAXLN*2
      CALL GPNCRV(MAXLN,NOVAR)
      IPOS= 1
      INDX= 1
      DO 10 I= 1,MAXLN
C       save the Y data
        CALL GPDATR (INDX,IPOS,CNTP(I),YPT(1,I),RETCOD)
C       y data transformations
        GTRANF(INDX)= AXTYP(1)
        IPOS= IPOS+ CNTP(I)
        INDX=INDX+1
C       save the X data
        CALL GPDATR (INDX,IPOS,CNTP(I),XPT(1,I),RETCOD)
C       x data transformations
        GTRANF(INDX)= AXTYP(2)
C       save where the data went
        CALL GPWCXY (I,INDX-1,INDX)
        IPOS= IPOS+ CNTP(I)
        INDX= INDX+ 1
 10   CONTINUE
C
C - This is the old 10 loop.
CC
C      DO 10 I= 1,MAXLN
CC       save the Y data
C        write(99,*) 'about to call GPDATR',I,IPOS
CC       IF (I.EQ.1) write(99,*) 'save YPT:',(YPT(J,I),J=1,CNTP(I))
CC        CALL GPDATR (I,1,IPOS,CNTP(I),YPT(1,I),RETCOD)
C        CALL GPDATR (INDX,IPOS,CNTP(I),YPT(1,I),RETCOD)
C        write(99,*) 'RETCOD:',RETCOD
CC       save the X data
C        IPOS= IPOS+ CNTP(I)
C        INDX=INDX+1
C        write(99,*) '2nd call to GPDATR',I,IPOS
CC       IF (I.EQ.1) write(99,*) 'save XPT:',(XPT(J,I),J=1,CNTP(I))
CC        CALL GPDATR (I,2,IPOS,CNTP(I),XPT(1,I),RETCOD)
C        CALL GPDATR (INDX,IPOS,CNTP(I),XPT(1,I),RETCOD)
C        write(99,*) 'RETCOD:',RETCOD
C        IPOS= IPOS+ CNTP(I)
C        CALL GPWCXY (I,INDX-1,INDX)
C        INDX=INDX+1
C 10   CONTINUE
C
C     save curve info
      DO 15 I= 1,MAXLN
C       xy plot
        GCTYP(I) = 6
C       black/white color
        GCOLOR(I)= 1
C       line pattern
        J = 1 + 2*(I-1)
        GPATRN(I)= 0
C       line type
        GLNTYP(I) = I
        IF (I .GT. 2) GLNTYP(I) = 0
        IF (I .GT. 2) GSYMBL(I) = I
C       y axis type
C        GTRANF(1,I)= AXTYP(1)
        GTRANF(I)= AXTYP(1)
C       x axis type
C        GTRANF(2,I)= AXTYP(2)
        IP1=I+1
        GTRANF(IP1)= AXTYP(2)
 15   CONTINUE
CDWD
C      CALL GPCURV (GCTYP,GLNTYP,GSYMBL,GCOLOR,GPATRN,GTRANF,CLAB1)
      CALL GPCURV (GCTYP,GLNTYP,GSYMBL,GCOLOR,GPATRN,CLAB1)
CDWD
C     save data ranges
C      GWCH(1)= 1
C      GWCH(2)= 4
C     set data ranges and scaling
      DO 301 I = 1,MAXLN
        J = 1 + 2*(I-1)
        GWCH(J)= 1
        GWCH(J+1)= 4
 301  CONTINUE
C
      RDUM= 1.0E30
      CALL ZIPR(4,RDUM,GVMIN)
      RDUM= -1.0E30
      CALL ZIPR(4,RDUM,GVMAX)
      DO 30 J= 1,MAXLN
        DO 20 I= 1,CNTP(J)
          IF (YPT(I,J).GT.GVMAX(1)) GVMAX(1)= YPT(I,J)
          IF (YPT(I,J).LT.GVMIN(1)) GVMIN(1)= YPT(I,J)
          IF (XPT(I,J).LT.GVMIN(2)) GVMIN(2)= XPT(I,J)
          IF (XPT(I,J).GT.GVMAX(2)) GVMAX(2)= XPT(I,J)
 20     CONTINUE
 30   CONTINUE
      write(99,*) 'ranges of data:',GVMIN,GVMAX
C     write(*,*) 'about to call GPVAR'
      BLNK= ' '
      CALL ZIPC(80,BLNK,OLAB1)
C      CALL GPVAR (GVMIN,GVMAX,GWCH,OLAB1)
      CALL GPVAR (GVMIN,GVMAX,GWCH,GTRANF,OLAB1)
C     scale data, Y then X
      write(99,*) 'about to call SCALIT for Y'
      CALL SCALIT(AXTYP(1),GVMIN(1),GVMAX(1),
     O            PLMN(1),PLMX(1))
      GTICS(1) = 10
      write(99,*) 'after SCALIT:',PLMN(1),PLMX(1)
      write(99,*) 'about to call SCALIT for X'
      CALL SCALIT(AXTYP(2),GVMIN(2),GVMAX(2),
     O            PLMN(4),PLMX(4))
C     how many tics are used
      GTICS(4) = 10
      RDUM= (PLMX(4)-PLMN(4))/10.
C     lower tics unneeded?
      I= 0
 50   CONTINUE
        IF (PLMN(4)+RDUM.LT.GVMIN(2)) THEN
C         dont need it
          GTICS(4)= GTICS(4)- 1
          PLMN(4) = PLMN(4)+ RDUM
        ELSE
C         keep it
          I= 1
        END IF
      IF (I.EQ.0) GO TO 50
C     upper tics needed
      I= 0
 60   CONTINUE
        IF (PLMX(4)-RDUM.GT.GVMAX(2)) THEN
C         dont need it
          GTICS(4)= GTICS(4)- 1
          PLMX(4) = PLMX(4)- RDUM
        ELSE
C         keep it
          I= 1
        END IF
      IF (I.EQ.0) GO TO 60
C
      IF (XPT(1,1).GT.XPT(CNTP(1),1)) THEN
C       reverse axis
        RDUM= PLMX(4)
        PLMX(4)= PLMN(4)
        PLMN(4)= RDUM
      END IF
      write(99,*) 'after SCALIT:',PLMN(4),PLMX(4)
      CALL ZIPI(4,0,GBVALF)
C     set up axis scaling
      write(99,*) 'about to call GPSCLE'
      CALL GPSCLE(PLMN,PLMX,GTICS,GBVALF)
C     define axes
      write(99,*) 'about to call GPLABL',AXTYP
      GXTYP= AXTYP(2)
      GYTYP(1)= AXTYP(1)
      GYTYP(2)= 0 
      GALEN   = 0.0
      CALL GPLABL (GXTYP,GYTYP,GALEN,YLAB1,XLAB1,OLAB1,TITL1)
      CALL GPLBXB (XLAB1)
C     set up sizes
      write(99,*) 'about to call GPSIZE'
C      CALL GPSIZE(0.08,8.0,8.0,1.5,1.5,5.5,5.5,0.0)
      CALL GPSIZE(0.15,8.0,8.0,2.0,2.0,5.0,5.0,0.0)
C      CALL GPSIZE(0.12,10.0,8.0,2.5,1.5,5.0,5.0,0.0)
C
C     open workstation
      write(99,*) 'about to call PSETUP'
C      CALL PSETUP(RETCOD,IWAIT,IMET)
      CALL PSETUP(RETCOD)
C
      IF (RETCOD.EQ.0) THEN
C       make the plot
        write(99,*) 'about to call PLTONE'
        CALL PLTONE
        write(99,*) 'after call to PLTONE'
      ELSE
C       problem
        write(99,*) 'error on workstation open:',RETCOD
      END IF
C
C     close workstations
      write(99,*) 'about to close workstations PDNPLT',WSID,ICLOS,IWAIT
CLH
C      CALL DONPLT (IWAIT)
      WSID =1
      ICLOS=1
      CALL PDNPLT (WSID,ICLOS,IWAIT)
CLH
      write(99,*) 'done close of workstations'
C
      RETURN
      END
