subroutine wallstress(txz,tyz)
! For use with staggered grid LES
! JDA, 23 Jan 96
! zo is nondimensionalized, zo1 not!
use types,only:rprec
use param,only:dz,ld,lh,nx,ny,nz,vonk
use sim_param,only:u,v
use bottombc,only:zo,psi_m
use test_filtermodule
implicit none
integer::jx,jy
real(kind=rprec),dimension(ld,ny,nz),intent(out)::txz,tyz
real(kind=rprec),dimension(nx,ny)::ustar,u_avg,u_aver,denom
real(kind=rprec),dimension(ld,ny)::u1,v1
real(kind=rprec)::const

!TS Remove the following line when obukhov.f is used
psi_m=0._rprec

u1=u(:,:,1)
v1=v(:,:,1)
call test_filter(u1,G_test)
call test_filter(v1,G_test)
denom=log(0.5_rprec*dz/zo)-psi_m
   u_avg=sqrt(u1(1:nx,1:ny)**2+v1(1:nx,1:ny)**2)
ustar=u_avg*vonk/denom

do jy=1,ny
do jx=1,nx
   const=-(ustar(jx,jy)**2) /u_avg(jx,jy)
   txz(jx,jy,1)=const *u1(jx,jy)
   tyz(jx,jy,1)=const *v1(jx,jy)
end do
end do
end subroutine wallstress
