subroutine rmsdiv(rms, du, dv, dw)
! actually, this is NOT the rms divergence of velocity, its like an
! l_1 norm or something.
use types,only:rprec
use param,only:ld,nx,ny,nz
implicit none
integer::jx,jy,jz
real(kind=rprec),dimension(ld,ny,nz)::du,dv,dw
real(kind=rprec)::rms
rms=0._rprec
do jz=1,nz-1
do jy=1,ny
do jx=1,nx
   rms=rms+abs(du(jx,jy,jz)+dv(jx,jy,jz)+dw(jx,jy,jz))
end do
end do
end do
rms=rms/(nx*ny*(nz-1))
end subroutine rmsdiv
