subroutine diffu (putout)
use modglobal, only : ib,ie,ih,jb,je,jh,kb,ke,kh,kmax,dx2i,dxi,lles,&
dzf,dzfi,dy,dyi,dy2i,dzhi,dzhiq,jmax,numol
use modfields, only : u0,v0,w0
use modsurfdata,only : ustar
use modmpi, only : myid
implicit none
real, intent(inout) :: putout(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)
real :: emmo,emom,emop,empo
real :: fu,dummy
real :: ucu, upcu
integer :: i,j,k,jm,jp,km,kp
if (lles) then
do k=kb,ke
kp=k+1
km=k-1
do j=jb,je
jp=j+1
jm=j-1
do i=ib,ie
emom = ( dzf(km) * ( ekm(i,j,k) + ekm(i-1,j,k) ) + &
dzf(k) * ( ekm(i,j,km) + ekm(i-1,j,km))) * dzhiq(k)
emop = ( dzf(kp) * ( ekm(i,j,k) + ekm(i-1,j,k)) + &
dzf(k) * ( ekm(i,j,kp) + ekm(i-1,j,kp))) * dzhiq(kp)
empo = 0.25 * ((ekm(i,j,k) + ekm(i,jp,k)) + (ekm(i-1,j ,k) + ekm(i-1,jp,k)))
emmo = 0.25 * ((ekm(i,j,k) + ekm(i,jm,k)) + (ekm(i-1,jm,k) + ekm(i-1,j ,k)))
! Discretized diffusion term
putout(i,j,k) = putout(i,j,k) &
+ ( &
ekm(i,j,k) * (u0(i+1,j,k)-u0(i,j,k)) &
- ekm(i-1,j,k)* (u0(i,j,k)-u0(i-1,j,k)) &
) * 2. * dx2i &
+ ( &
empo * ( &
(u0(i,jp,k)-u0(i,j,k)) *dyi &
+ (v0(i,jp,k)-v0(i-1,jp,k))*dxi &
) &
-emmo * ( &
(u0(i,j,k)-u0(i,jm,k)) *dyi &
+ (v0(i,j,k)-v0(i-1,j,k)) *dxi &
) &
) * dyi &
+ ( &
emop * ( &
(u0(i,j,kp)-u0(i,j,k)) *dzhi(kp) &
+ (w0(i,j,kp)-w0(i-1,j,kp))*dxi) &
-emom * ( &
(u0(i,j,k)-u0(i,j,km)) *dzhi(k) &
+ (w0(i,j,k)-w0(i-1,j,k)) *dxi) &
) *dzfi(k)
end do
end do
end do
else ! DNS
do k=kb,ke
kp=k+1
km=k-1
do j=jb,je
jp=j+1
jm=j-1
do i=ib,ie
! Discretized diffusion term
putout(i,j,k) = putout(i,j,k) &
+ ( &
numol * (u0(i+1,j,k)-u0(i,j,k))*dxi &
- numol * (u0(i,j,k)-u0(i-1,j,k))*dxi &
) * 2. * dxi &
+ ( &
numol * ( &
(u0(i,jp,k)-u0(i,j,k)) *dyi &
+ (v0(i,jp,k)-v0(i-1,jp,k))*dxi &
) &
- numol * ( &
(u0(i,j,k)-u0(i,jm,k)) *dyi &
+ (v0(i,j,k)-v0(i-1,j,k)) *dxi &
) &
) * dyi &
+ ( &
numol * ( &
(u0(i,j,kp)-u0(i,j,k)) *dzhi(kp) &
+ (w0(i,j,kp)-w0(i-1,j,kp))*dxi) &
- numol * ( &
(u0(i,j,k)-u0(i,j,km)) *dzhi(k) &
+ (w0(i,j,k)-w0(i-1,j,k)) *dxi &
) &
) *dzfi(k)
end do
end do
end do
end if ! lles
end subroutine diffu