C....*...1.........2.........3.........4.........5.........6.........7.*.......8
C     POLISH   1/24/73
C
C     PURPOSE
C     POLISH THE GIVEN MAXIMUM AND MINIMUM VALUES OF AN ARRAY FOR BETTER
C     APPEARING PLOTS.
C
C     USAGE
C     CALL POLISH(AMAX,AMIN,GRID)
C
C     ARGUMENTS
C     AMAX - ON INPUT THE MAXIMUM.  ON OUTPUT THE POLISHED MAXIMUM.
C            REAL*8
C     AMIN - ON INPUT THE MINIMUM.  ON OUTPUT THE POLISHED MINIMUM.
C            REAL*8
C     GRID - DETERMINES THE CLOSENESS OF POLISHED VALUES TO SUPPLIED
C            VALUES OF AMAX AND AMIN.  A REASONABLE VALUE IS 100.0.
C            REAL*8
C
C
      SUBROUTINE POLISH(AMAX,AMIN,GRID)
      implicit real*8 (a-h,o-z)
      save
      XMAX=AMAX
      XMIN=AMIN
C     POLISH MAX AND MIN
      S=dLOG10((XMAX-XMIN)/GRID)
      IS=S
      A=XMAX*10.d0**(-IS)
      B=XMIN*10.d0**(-IS)
      IXMAX=A
      IXMIN=B
      IF((A.GT.0.d0).AND.(A.GT.dFLOAT(IXMAX)))IXMAX=IXMAX+1
      IF((B.LT.0.d0).AND.(B.LT.dFLOAT(IXMIN)))IXMIN=IXMIN-1
      XMAX=dFLOAT(IXMAX)*10.d0**IS
      XMIN=dFLOAT(IXMIN)*10.d0**IS
      AMAX=XMAX
      AMIN=XMIN
      RETURN
      END
