subroutine advecw_2nd(putin, putout)
use modglobal, only:ih, ib, ie, jh, jb, je, kb, ke, kh, dx, dxi, dxiq, dyiq, dzf, dzhi, dzhiq
use modfields, only:u0, v0, w0, pres0
! use modmpi, only : myid
implicit none
real, dimension(ib - ih:ie + ih, jb - jh:je + jh, kb - kh:ke + kh), intent(in) :: putin !< Input: the w-field
real, dimension(ib - ih:ie + ih, jb - jh:je + jh, kb:ke + kh), intent(inout) :: putout !< Output: the tendency
integer :: i, j, k, ip, im, jp, jm, kp, km
do k = kb + 1, ke
km = k - 1
kp = k + 1
do j = jb, je
jm = j - 1
jp = j + 1
do i = ib, ie
im = i - 1
ip = i + 1
putout(i, j, k) = putout(i, j, k) - ( &
( &
(putin(ip, j, k) + putin(i, j, k))*(dzf(km)*u0(ip, j, k) + dzf(k)*u0(ip, j, km)) &
- (putin(i, j, k) + putin(im, j, k))*(dzf(km)*u0(i, j, k) + dzf(k)*u0(i, j, km)) &
)*dxiq*dzhi(k) & ! d(uw)/dx
+ ( &
(putin(i, jp, k) + putin(i, j, k))*(dzf(km)*v0(i, jp, k) + dzf(k)*v0(i, jp, km)) &
- (putin(i, j, k) + putin(i, jm, k))*(dzf(km)*v0(i, j, k) + dzf(k)*v0(i, j, km)) &
)*dyiq*dzhi(k) & ! d(vw)/dy
+ ( &
(putin(i, j, k) + putin(i, j, kp))*(w0(i, j, k) + w0(i, j, kp)) &
- (putin(i, j, k) + putin(i, j, km))*(w0(i, j, k) + w0(i, j, km)) &
)*dzhiq(k) & ! d(ww)/dz
) &
- ((pres0(i, j, k) - pres0(i, j, km))*dzhi(k)) ! - dp/dz
end do
end do
end do
end subroutine advecw_2nd