C------------------------------------------------------------
C  GSCREC - RECORD SCALE OF PLOT ABOUT TO BE DRAWN IN GSCALE COMMON
C
C   RECORDED SCALE MAY BE RETRIEVED FOR A FUTURE PLOT
C
      SUBROUTINE GSCREC
C
      INCLUDE 'GSCALE_BLK'
C
      INCLUDE 'PLOT1MMX'
C
      CHARACTER*8 ZSCLNM(4)  ! UREAD PARAMETER NAMES  - PLOT SCALE
      CHARACTER*12 ZSCLVL(4)  ! UREAD PARAMETER VALUES - PLOT SCALE
C
C  STRING PARAMETER NAMES-- SAVE SCALE OF LAST PLOT AS
C  UREAD STRING PARAMETERS ACCESSIBLE TO USER PROCEDURES
C
      DATA ZSCLNM/'/XMINP==','/XMAXP==','/YMINP==','/YMAXP=='/
C
C  CHECK FOR INITIAL CALL
C
      IF(NSCPRV.EQ.0) THEN
        NSCPRV=1
        NCURSC=1
      ELSE
C  CHECK IF THERE IS NO SCALE CHANGE FROM PREV. PLOT
        IF((XMINP(NCURSC).EQ.XMIN).AND.(XMAXP(NCURSC).EQ.XMAX).AND.
     >       (YMINP(NCURSC).EQ.YMIN).AND.(YMAXP(NCURSC).EQ.YMAX)) RETURN
C  CHECK FOR INCREMENT OF NUMBER OF SAVED SCALES
        IF(NSCPRV.LT.MXSPRV) THEN
          NSCPRV=NSCPRV+1
          NCURSC=NCURSC+1
        ELSE
C  IF OUT OF SPACE OVERWRITE OLDEST SAVED SCALE
          NCURSC=NCURSC+1
          IF(NCURSC.GT.MXSPRV) NCURSC=1
        ENDIF
      ENDIF
C
      XMINP(NCURSC)=XMIN
      XMAXP(NCURSC)=XMAX
      YMINP(NCURSC)=YMIN
      YMAXP(NCURSC)=YMAX
C
C  COMPATIBILITY FEATURE...
C  DMC MAR 1984-- WRITE UREAD STRING PARAMETERS RECORDING SCALE
C  OF LATEST PLOT.
C
 6001 FORMAT(1PE12.5)
      WRITE(ZSCLVL(1),6001) XMIN
      WRITE(ZSCLVL(2),6001) XMAX
      WRITE(ZSCLVL(3),6001) YMIN
      WRITE(ZSCLVL(4),6001) YMAX
C
      DO 801 IL=1,4
        CALL URDCMI(ZSCLNM(IL)//ZSCLVL(IL),IER)
 801  CONTINUE
C
      RETURN
      END
