C-------------------------------------------------------------------
C  GSCSM0 - AUTOSCALE EVALUATION FOR MULTIPLOT DATA
C
C   USE GSCSET SUBROUTINE TO EVALUATE AUTOSCALE FOR EACH INDIVIDUAL
C   CONTOUR IN MULTIPLOT DATA; TAKE THE EXTREMA OF SCALES TO BE THE
C   AUTOSCALE FOR THE UPCOMING PLOT
C
      SUBROUTINE GSCSM0(XDATA,YDATA,NDATAX,NDATAY,
     >     IPTRX,IINCX,IPTRY,IINCY,LPTR,NPTR,ZLIM1,ZLIM2,IYONLY)
C
C
      REAL XDATA(NDATAX),YDATA(NDATAY)
C
C   XDATA(NDATAX)  STORAGE FOR "X" DATA IN (X,Y) PAIRS
C   YDATA(NDATAY)  STORAGE FOR "Y" DATA IN (X,Y) PAIRS
C
      INTEGER IPTRX(NPTR),IPTRY(NPTR),LPTR(NPTR)
C
C   LPTR(I)  NUMBER OF (X,Y) PTS IN I'TH CONTOUR
C   IPTRX(I)  ADDRESS IN XDATA OF 1ST X PT, I'TH CONTOUR
C    IINCX    SPACING BTW SUCCESSIVE X PTS
C   IPTRY(I)  ADDRESS IN YDATA OF 1ST Y PT, I'TH CONTOUR
C    IINCY    SPACING BTW SUCCESSIVE Y PTS
C
C   FOR I = 1 TO NPTR
C
C   ZLIM1,ZLIM2 - A PRIORI CONSTRAINTS ON X
C   IYONLY = 1 FOR MODIFICATION OF Y SCALE ONLY (NOT X)
C  ** SEE GSCMMX SUBROUTINE **
C
C  SCALE SETTING COMMON BLOCKS --
C
C    GMINX, GMAXX, GMINY, GMAXX -- OUTPUT COMPUTED AUTOSCALE ***
C
      INCLUDE 'GSCALE_BLK'
C
      DATA ZINFIN/1.E38/
C
C  START OF EXECUTABLE CODE
C
C  COMPUTE AUTOSCALE
C
      ZMINX=ZINFIN
      ZMAXX=-ZINFIN
      ZMINY=ZINFIN
      ZMAXY=-ZINFIN
C
      ZMINXP=0.0
      ZMINYP=0.0
C
      DO 10 I=1,NPTR
        IX=IPTRX(I)
        IY=IPTRY(I)
C
C  COMPUTE AUTOSCALE ( (X,Y) DATA MIN/MAX) FOR THIS ONE CURVE OUT OF
C  THE MULTIPLOT
C
        CALL GSCMMX(XDATA,NDATAX,YDATA,YDATA,0,NDATAY,
     >                IX,IINCX,IY,IINCY,LPTR(I),
     >                ZLIM1,ZLIM2,0)
C
C  TAKE THE MIN/MAX OF THE COMPUTED CURVE AUTOSCALES
C  AS THE MULTIPLOT AUTOSCALE
C
C  USE THE MIN-POSITIVE INFORMATION IF THE TRACE HAD
C  ANY POSITIVE NUMBERS IN IT
C
        IF(GMAXX.GT.0.0) THEN
          IF(ZMINXP.EQ.0.0) THEN
            ZMINXP=GMINXP
          ELSE
            ZMINXP=AMIN1(GMINXP,ZMINXP)
          ENDIF
        ENDIF
C
        IF(GMAXY.GT.0.0) THEN
          IF(ZMINYP.EQ.0.0) THEN
            ZMINYP=GMINYP
          ELSE
            ZMINYP=AMIN1(GMINYP,ZMINYP)
          ENDIF
        ENDIF
C
        ZMINX=AMIN1(ZMINX,GMINX)
        ZMAXX=AMAX1(ZMAXX,GMAXX)
        ZMINY=AMIN1(ZMINY,GMINY)
        ZMAXY=AMAX1(ZMAXY,GMAXY)
C
 10   CONTINUE
C
      GMINX=ZMINX
      GMAXX=ZMAXX
      GMINY=ZMINY
      GMAXY=ZMAXY
C
      GMINXP=ZMINXP
      GMINYP=ZMINYP
C
      RETURN
      END
