c=======================================================================


      subroutine zlayer(nz,z,nzz,zz,lz) 4
c   
c purpose: given an array of "special" altitudes, zz(k), ZLAYER will
c          find the index array lz(k) such that z(nz-lz(k)+1) is the
c          largest element of z less than or equal to abs(zz(i)+.001)
c          (note reversal of array order).  if zz(k) < 0 then lz(k) 
c          will also be tagged negative. Other routines use this info
c          to indicate altitude ranges.  
c
c          Note that setting zz(i) to a negative integer makes
c          abs(zz(i)+.001) slightly less than the integer.  Thus
c          zz=[1,-3,0,0,0] will select altitude layers at 1 and 2 km
c          only, which is appropriate since choosing the 2km layer
c          affects conditions throughout the computational layer
c          between 2 and 3 km.
c
c          REMEMBER: z, t, p, wh, wo all use bottom up numbering while
c                    everthing else uses top-down numbering 
c

c input:
c   nz     number of atmospheric layers
c
c   z      array of layer altitudes (monotonically increasing)
c
c   nzz    number of "special" altitude layers
c
c   zz     array of "special" altitudes. zz<-1.e20 signals the end of list
c
c
c output:
c lz       index array
c
c example: nz = 9 
c                   9    8   7   6    5   4   3   2   1
c          z  = [   0,   1,  3,  5,   7,  9, 10, 12, 15 ]
c          zz = [   0,   2, -3,  3,  -8]
c          lz = [   9,   8,   8,   7, 5]
c
      dimension z(*),zz(*),lz(*)
c

      do 30 kk=1,nzz
        isgn=1
        if(zz(kk).lt.0.) isgn=-1
        do 10 j=nz,1,-1
          if( 10     continue
        isgn=0
 20     continue
        lz(kk)=isgn*(nz-j+1)
 30   continue
      
      return
      end