subroutine advecv_2nd(putin, putout)
use modglobal, only:ih, ib, ie, jh, jb, je, kb, ke, kh, dx, dxi, dxiq, dyiq, dzf, dzfi5, dzhi, dyi
use modfields, only:u0, v0, w0, pres0
implicit none
real, dimension(ib - ih:ie + ih, jb - jh:je + jh, kb - kh:ke + kh), intent(in) :: putin !< Input: the v-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, 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) - ( &
( &
(u0(ip, j, k) + u0(ip, jm, k))*(putin(i, j, k) + putin(ip, j, k)) &
- (u0(i, j, k) + u0(i, jm, k)) *(putin(i, j, k) + putin(im, j, k)) & ! d(uv)/dx
)*dxiq &
+ ( &
( v0(i, jp, k) + v0(i, j, k))*(putin(i, j, k) + putin(i, jp, k)) &
- (v0(i, jm, k) + v0(i, j, k))*(putin(i, j, k) + putin(i, jm, k)) & ! d(vv)/dy
)*dyiq &
) &
- ((pres0(i, j, k) - pres0(i, jm, k))*dyi) ! - dp/dy
end do
end do
end do
do j = jb, je
jm = j - 1
jp = j + 1
do i = ib, ie
im = i - 1
ip = i + 1
do k = kb, ke
km = k - 1
kp = k + 1
putout(i, j, k) = putout(i, j, k) - ( &
(w0(i, j, kp) + w0(i, jm, kp)) &
* (putin(i, j, kp)*dzf(k) + putin(i, j, k)*dzf(kp))*dzhi(kp) &
- (w0(i, j, k) + w0(i, jm, k)) &
* (putin(i, j, km)*dzf(k) + putin(i, j, k)*dzf(km))*dzhi(k) &
)*0.5*dzfi5(k)
end do
end do
end do
end subroutine advecv_2nd