c  PRESLEV:
c
c  Compute an index array for evenly spaced pressure levels.  The array
c  PINDX consists of a whole number which is the index of the mandatory
c  level above the pressure level and a fractional part which is the lin
c  in log(P) interpolation weight from the upper mandatory level.  The
c  index of the PINDX array is related to the pressure through a linear
c  mapping given by:
c
c       index = pressure * RFACT + RDISP
c
c  where the RFACT and RDISP values depend upon the pressure and are cha
c  with (roughly) each factor of 10 change in the pressure to ensure 
c  adequate
c  resolution of the pressure.  The factors and a summary of the
c  relationship between pressure and the PINDX index is given below:
c
c                      Pressure       PINDX
c       Pressure      Resolution      index        RFACT     RDISP
c       --------      ----------      -----        -----     -----
c
c      0.1 - 1            .001        1 - 901      1000.      -99.
c        1 - 10           .01       901 - 1801      100.      801.
c       10 - 50           .1       1801 - 2201       10.     1701.
c       50 - 1050        1.        2201 - 3201        1.     2151.
c
c  There are 900 pressures tabulated between each factor of 10 change in
c  pressure, except for the 10 - 50 mb range, where the range is reduced
c  so that the 50 - 1050 mb range is identical to the original PINDX arr
c
      SUBROUTINE preslev(pmand,nlevoi,pindx)
      REAL pmand(18), pindx(3201)
c
      DO 7002 ip = 1 , 3201
c
c Assign parameters relating pressure to index
c
        IF (ip .LT. 901) THEN
          rfact = 1000.
          irdisp = (-99)
        ELSEIF (ip .LT. 1801) THEN
          rfact = 100.
          irdisp = 801
        ELSEIF (ip .LT. 2201) THEN
          rfact = 10.
          irdisp = 1701
        ELSE
          rfact = 1.
          irdisp = 2151
        ENDIF
c
c Compute pressure corresponding to index
c
        p = real(ip - irdisp) / rfact
c
c find bracketing mandatory levels
c
        lb = 1
 7000   IF ((lb .LE. nlevoi .AND. nint(pmand(lb) * rfact) .LE. ip 
     &        - irdisp)) THEN
          lb = lb + 1
          GOTO 7000
        ENDIF
 7001   CONTINUE
c
        IF (lb .EQ. 1) THEN
          lb = 2
        ENDIF
        IF (lb .EQ. nlevoi + 1) THEN
          lb = nlevoi
        ENDIF
c
        la = lb - 1
c
c Compute interpolation weight for lower level
c
        IF (nint(pmand(la) * rfact) .EQ. ip - irdisp) THEN
          wb = 0.
        ELSE
          wb = alog(p / pmand(la)) / alog(pmand(lb) / pmand(la))
        ENDIF
c
c Assign value of pindx: mandatory level index . interpolation weight
c
        pindx(ip) = la + wb
c
 7002 CONTINUE
c
      RETURN
      END
