C #SCALA   V2A   29-MAY-73
C  LAST UPDATE:
C
      SUBROUTINE  SCALA (A, N, AMIN, AMAX)
      DIMENSION  A(N)
C
C *PURPOSE.
C	TO GET THE BOUNDS OF A REAL ARRAY A(I) AND TURN THEM
C INTO PRETTY NUMBERS OF THE FORM  (1, 2, OR 5)*10**N.  FOR THE
C PURPOSES OF SETTING THE SCALE FOR A PLOT OUTPUT ETC.
C
C *PARAMETERS:
C
C  A   - THE REAL ARRAY OF DIMENSION "N" OR MORE FOR WHICH THE
C	SCALE FACTORS ARE REQUIRED.  THE ARRAY IS NOT CHANGED.
C  N   - THE INTEGER LOGICAL LENGTH OF THE ARRAY "A".
C  AMIN- RETURNS THE LOWER BOUND OF THE SCALED RANGE.
C  AMAX- RETURNS THE UPPER BOUND OF THE SCALED RANGE.
C
C INPUT PARAMETERS:
C	A, N
C OUTPUT PARAMETERS:
C	AMIN, AMAX
C
C *METHOD.
C	THE UPPER AND LOWER BOUNDS OF THE ARRAY ARE FOUND AND
C TURNED INTO PRETTY NUMBERS IN A FAIRLY STRAIGHTFORWARD WAY.
C  IF BOTH BOUNDS HAVE THE SAME SIGN THE ONE OF SMALLER ABSOLUTE
C VALUE IS REPLACED WITH ZERO.  IF THEY HAVE OPPOSITE SIGN
C THE ONE WITH SMALLER ABSOLUTE VALUE IS REPLACED WITH MINUS THE
C OTHER ONE.
C	THUS EITHER ZERO IS IN THE MIDDLE OF THE RANGE OR ELSE
C IT IS ONE OF THE RANGE LIMITS.
C
C *ACCURACY.
C
C *RESTRICTIONS.
C
C *ERROR CONDITIONS.
C
C *NON STANDARD ROUTINES CALLED.
C  BOUNDS - TO GET THE RAW BOUNDS OF THE ARRAY - MRMLIB.
C
C *TYPICAL TIMES.
C
C *ORIGIN.   M.R.MANNING.
C
C *COMMENTS.
C
C #END.
C
C #START.
      CALL BOUNDS(A, N, AMIN, AMAX)
C  THAT GETS ACTUAL LIMITS.
      IF( AMAX*AMIN.GE.0.) GO TO 5
C IF OPPOSITE SIGN MAKE RANGE SYMMETRIC
        AMAX= AMAX1(AMAX, -AMIN)
        AMIN= -AMAX
        GO TO 10
C ELSE (IF SAME SIGN) MAKE ONE WITH SMALLER ABS VALUE = 0.
5       AMAX= AMAX1(AMAX, 0.)
        AMIN= AMIN1(0., AMIN)
C  END-IF
10    ASSIGN 20 TO IRTN
      T= AMIN
      GO TO 100
C  INTERNAL PROCEDURE!
20    AMIN= T
C
      ASSIGN 30 TO IRTN
      T= AMAX
      GO TO 100
C  AND AGAIN
30    AMAX= T
      RETURN
C
C  INTERNAL PROCEDURE TO MAKE NUMBERS PRETTY.
C
100   IF (T.EQ.0.) GO TO IRTN
      EZ= ALOG10(ABS(T) )
      IZ= EZ
      IF (EZ.LT.0.)  IZ= IZ-1
      EZ= 10.**IZ
      IN= T/EZ
      IF (T.GT.0.) IN= IN+1
      IF (IN.GT.2) IN= MAX0(5, IN)
      IF (IN.GT.5) IN= 10
      T= FLOAT(IN)*EZ
      GO TO IRTN
C
C  ENDS PROCEDURE
C
      END

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������