C  THE SCALE ROUTINE MUST BE CALLED PRIOR TO ANY PLOTTING
C  OPERATIONS (LINE CHAR  ETC.).  FOR COMPLETE
C  DESCRIPTION OF ARGUMENTS SEE USER DOCUMENTATION.
C
      SUBROUTINE SCALE(DXP,DYP,XP,YP,NOPTS,IER)
      DIMENSION DXP(2),DYP(2),XP(1),YP(1)
C
$INCLUDE:'pxz99.cmn'
C
C
      INTEGER PXZ00,PXZ09
C
c      DATA SCLED,ESCLD/7.15633E13,-4.43887E-10/
      DATA SCLED/7.15633E13/
C
C  CHECK NOPTS..
      IF (NOPTS.GT.0.AND.NOPTS.LE.4) GO TO 10
      CALL PXZ02(1)
      GO TO 60
C
C  CHECK IF SCALED
   10 IF (FSCAL.EQ.SCLED) GO TO 30
C
C--------------------------------------------------
C
C  THE FOLLOWING CODE WOULD BE REQUIRED FOR SYSTEMS
C  WITH SUB-ANSI FORTRAN-IV COMPILERS WHICH DO NOT
C  SUPPORT NAMED COMMON AND MULTIPLE BLOCK DATA
C  MODULES...
C
C     IF (FSCAL.EQ.ESCLD) GO TO 1
C
C  VERY FIRST SCALING, SO CALL INITIALIZER ROUTINE.
C     CALL PXZ97
C
C  NOW INITIALIZED
C     FSCAL=ESCLD
C   1 CONTINUE
C
C  NOTE..  ENDPT MUST USE ESCLD UPON TERMINATION.
C
C--------------------------------------------------
C
C  CALL PLOTTER INITIALIZATION
      IF (PXZ00(1).EQ.0) GO TO 20
      CALL PXZ02(2)
      GO TO 60
C
C  CLEAR X PAPER SIZE AS TAG AND SET SCALING SIZE
   20 XRSPP=0
      XMAX=XRASX
      YMAX=YRASX
C***********************************************************************
      XRASPI=1.0/XRASP
      YRASPI=1.0/YRASP
C***********************************************************************
      GO TO 40
C
C  SET FOR RESCALING
   30 XMAX=XRSPP
      YMAX=YRSPP
C
C  SET SCALING
   40 IF (PXZ09(DXP,XP,IXLOG,XRASP,XMAX,RXMIN,RXMAX,
     1 XSCLE,XOFFS,XPP,NOPTS,FMTL2).NE.0.OR.
     2 PXZ09(DYP,YP,IYLOG,YRASP,YMAX,RYMIN,RYMAX,
     3 YSCLE,YOFFS,YPP,NOPTS,FMTL2).NE.0) GO TO 60
C
C  SET PAPER SIZE, IF NOT PREVIOUSLY SCALED.
      IF (XRSPP.NE.0) GO TO 50
      XRSPP=XPP
      YRSPP=YPP
      I=PXZ00(2)
C
C  DONE SCALING, CALL POST SCALE ROUTINE
   50 IER=0
      FSCAL=SCLED
      RETURN
C
C  ERROR
   60 IER=1
      RETURN
C
      END


