      subroutine setsponge(sponge)

      implicit none
      include 'dimen.h'

      real sponge(nz),factor
      integer k

! sets relaxation term to vertical momentum equation in top quarter
! of domain, relaxation timescale on top is 50s with a factor of 5 if we
! had Nz=40 for the layers 40...31, Nieuwstadt et al. 1991, turbulent shear 
! flows

      sponge=0._rprec
      factor=9._rprec/real(nz-3*nz/4+1,kind=rprec)
      sponge(nz)=z_i/(50._rprec*u_star)
      do k=nz-1,3*nz/4+1,-1
        sponge(k)=sponge(k+1)/real(5.,kind=rprec)**factor
      end do

      return
      end
