      SUBROUTINE FINDDEPTHLEVELNUM(dz,kdim,numdeps,zdepth,idepthout)

C     FINDDEPTHLEVELNUM FINDS THE CLOSEST STANDARD DEPTH LEVEL
C     NUMBER BASED ON GIVEN DEPTH

      dimension dz(kdim)

      idepthout=0
      kmore=0
      kless=0
      do 50 k=1,numdeps

       if ( dz(k) .lt. zdepth + 0.01 .and.
     *      dz(k) .gt. zdepth - 0.01 ) then
        idepthout=k
        return
       endif

       if ( dz(k) .lt. zdepth ) kless=k+1
       if ( dz(k) .gt. zdepth .and. kmore .eq. 0 ) 
     *  kmore=k

50    continue

      if ( kless .eq. 0 ) return

      if ( kmore .eq. 0 ) then
       idepthout=numdeps+1
       return
      endif

      zless=zdepth-dz(kless)
      zmore=dz(kmore)-zdepth

      if ( zless .lt. zmore ) then
       idepthout=kless
      else
       idepthout=kmore
      endif

      return
      end
