forked from KuangLab-Harvard/SAM_SRCv6.11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
advect2_mom_z.f90
93 lines (74 loc) · 1.56 KB
/
advect2_mom_z.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
subroutine advect2_mom_z
! momentum tendency due to the 2nd-order-central vertical advection
use vars
implicit none
real fuz(nx,ny,nz),fvz(nx,ny,nz),fwz(nx,ny,nzm)
integer i, j, k, kc, kb
real dz2, dz25, www, rhoi
dz25=1./(4.*dz)
dz2=dz25*2.
do j=1,ny
do i=1,nx
fuz(i,j,1) = 0.
fvz(i,j,1) = 0.
fuz(i,j,nz) = 0.
fvz(i,j,nz) = 0.
fwz(i,j,1) = 0.
fwz(i,j,nzm) = 0.
end do
end do
uwle(1) = 0.
vwle(1) = 0.
if(RUN3D) then
do k=2,nzm
kb = k-1
rhoi = dz25 * rhow(k)
uwle(k) = 0.
vwle(k) = 0.
do j=1,ny
do i=1,nx
fuz(i,j,k) = rhoi*(w(i,j,k)+w(i-1,j,k))*(u(i,j,k)+u(i,j,kb))
fvz(i,j,k) = rhoi*(w(i,j,k)+w(i,j-1,k))*(v(i,j,k)+v(i,j,kb))
uwle(k) = uwle(k)+fuz(i,j,k)
vwle(k) = vwle(k)+fvz(i,j,k)
end do
end do
end do
else
do k=2,nzm
kb = k-1
rhoi = dz25 * rhow(k)
uwle(k) = 0.
vwle(k) = 0.
do j=1,ny
do i=1,nx
www = rhoi*(w(i,j,k)+w(i-1,j,k))
fuz(i,j,k) = www*(u(i,j,k)+u(i,j,kb))
fvz(i,j,k) = www*(v(i,j,k)+v(i,j,kb))
uwle(k) = uwle(k)+fuz(i,j,k)
vwle(k) = vwle(k)+fvz(i,j,k)
end do
end do
end do
endif
do k=1,nzm
kc = k+1
rhoi = 1./(rho(k)*adz(k))
do j=1,ny
do i=1,nx
dudt(i,j,k,na)=dudt(i,j,k,na)-(fuz(i,j,kc)-fuz(i,j,k))*rhoi
dvdt(i,j,k,na)=dvdt(i,j,k,na)-(fvz(i,j,kc)-fvz(i,j,k))*rhoi
fwz(i,j,k)=dz25*(w(i,j,kc)*rhow(kc)+w(i,j,k)*rhow(k))*(w(i,j,kc)+w(i,j,k))
end do
end do
end do
do k=2,nzm
kb=k-1
rhoi = 1./(rhow(k)*adzw(k))
do j=1,ny
do i=1,nx
dwdt(i,j,k,na)=dwdt(i,j,k,na)-(fwz(i,j,k)-fwz(i,j,kb))*rhoi
end do
end do
end do ! k
end subroutine advect2_mom_z