/[MITgcm]/MITgcm/pkg/generic_advdiff/gad_os7mp_adv_r.F
ViewVC logotype

Contents of /MITgcm/pkg/generic_advdiff/gad_os7mp_adv_r.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download)
Mon Jun 16 13:40:25 2008 UTC (15 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y, HEAD
Changes since 1.6: +42 -31 lines
- add "_d 0" for real constant (safer, but has no effect here)
- simplify and avoid division by zero

1 C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_os7mp_adv_r.F,v 1.6 2007/10/05 10:50:47 mlosch Exp $
2 C $Name: $
3
4 #include "GAD_OPTIONS.h"
5
6 SUBROUTINE GAD_OS7MP_ADV_R(
7 I bi,bj,k,deltaTloc,
8 I wTrans, wFld,
9 I Q,
10 O wT,
11 I myThid )
12 C /==========================================================\
13 C | SUBROUTINE GAD_OS7MP_ADV_R |
14 C | o Compute Vertical advective Flux of tracer Q using |
15 C | 7th Order DST Sceheme with monotone preserving limiter |
16 C |==========================================================|
17 IMPLICIT NONE
18
19 C == GLobal variables ==
20 #include "SIZE.h"
21 #include "GRID.h"
22 #include "GAD.h"
23
24 C == Routine arguments ==
25 INTEGER bi,bj,k
26 _RL deltaTloc
27 _RL wTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
28 _RL wFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
29 _RL Q (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
30 _RL wT (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
31 INTEGER myThid
32
33 C == Local variables ==
34 INTEGER i,j,kp3,kp2,kp1,km1,km2,km3,km4
35 _RL cfl,Psi
36 _RL wLoc,Fac,DelIp,DelI,Phi,Eps,rp1h,rp1h_cfl
37 _RL recip_DelIp, recip_DelI
38 _RL Qippp,Qipp,Qip,Qi,Qim,Qimm,Qimmm
39 _RL MskIpp,MskIp,MskI,MskIm,MskImm,MskImmm
40 _RL d2,d2p1,d2m1,A,B,C,D
41 _RL dp1h,dm1h, PhiMD,PhiLC,PhiMin,PhiMax
42 _RL DelM,DelP,DelMM,DelPP,DelMMM,DelPPP
43 _RL Del2MM,Del2M,Del2,Del2P,Del2PP
44 _RL Del3MM,Del3M,Del3P,Del3PP
45 _RL Del4M,Del4,Del4P
46 _RL Del5M,Del5P
47 _RL Del6
48
49 Eps = 1. _d -20
50
51 km4=MAX(1,k-4)
52 km3=MAX(1,k-3)
53 km2=MAX(1,k-2)
54 km1=MAX(1,k-1)
55 kp1=MIN(Nr,k+1)
56 kp2=MIN(Nr,k+2)
57 kp3=MIN(Nr,k+3)
58
59 DO j=1-Oly,sNy+Oly
60 DO i=1-Olx,sNx+Olx
61
62 wLoc = wFld(i,j)
63 cfl = abs(wLoc*deltaTloc*recip_drC(k))
64
65 IF (wTrans(i,j).LT.0. _d 0) THEN
66 Qippp = Q(i,j,kp2)
67 Qipp = Q(i,j,kp1)
68 Qip = Q(i,j,k)
69 Qi = Q(i,j,km1)
70 Qim = Q(i,j,km2)
71 Qimm = Q(i,j,km3)
72 Qimmm = Q(i,j,km4)
73
74 MskIpp = maskC(i,j,kp2,bi,bj) * float(kp2-kp1)
75 MskIp = maskC(i,j,kp1,bi,bj) * float(kp1-k)
76 MskI = maskC(i,j,k,bi,bj) * float(k-km1)
77 MskIm = maskC(i,j,km1,bi,bj) * float(km1-km2)
78 MskImm = maskC(i,j,km2,bi,bj) * float(km2-km3)
79 MskImmm = maskC(i,j,km3,bi,bj) * float(km3-km4)
80 ELSEIF (wTrans(i,j).GT.0. _d 0) THEN
81 Qippp = Q(i,j,km3)
82 Qipp = Q(i,j,km2)
83 Qip = Q(i,j,km1)
84 Qi = Q(i,j,k)
85 Qim = Q(i,j,kp1)
86 Qimm = Q(i,j,kp2)
87 Qimmm = Q(i,j,kp3)
88
89 MskIpp = maskC(i,j,km2,bi,bj) * float(km2-km3)
90 MskIp = maskC(i,j,km1,bi,bj) * float(km1-km2)
91 MskI = maskC(i,j,k,bi,bj) * float(k-km1)
92 MskIm = maskC(i,j,kp1,bi,bj) * float(kp1-k)
93 MskImm = maskC(i,j,kp2,bi,bj) * float(kp2-kp1)
94 MskImmm = maskC(i,j,kp3,bi,bj) * float(kp3-kp2)
95 ELSE
96 Qippp = 0. _d 0
97 Qipp = 0. _d 0
98 Qip = 0. _d 0
99 Qi = 0. _d 0
100 Qim = 0. _d 0
101 Qimm = 0. _d 0
102 Qimmm = 0. _d 0
103
104 MskIpp = 0. _d 0
105 MskIp = 0. _d 0
106 MskI = 0. _d 0
107 MskIm = 0. _d 0
108 MskImm = 0. _d 0
109 MskImmm = 0. _d 0
110 ENDIF
111
112 IF (wTrans(i,j).NE.0. _d 0) THEN
113 C 2nd order correction [i i-1]
114 Fac = 1. _d 0
115 DelP = (Qip-Qi)*MskI
116 Phi = Fac * DelP
117 C 3rd order correction [i i-1 i-2]
118 Fac = Fac * ( cfl + 1. _d 0 )/3. _d 0
119 DelM = (Qi-Qim)*MskIm
120 Del2 = DelP - DelM
121 Phi = Phi - Fac * Del2
122 C 4th order correction [i+1 i i-1 i-2]
123 Fac = Fac * ( cfl - 2. _d 0 )/4. _d 0
124 DelPP = (Qipp-Qip)*MskIp*MskI
125 Del2P = DelPP - DelP
126 Del3P = Del2P - Del2
127 Phi = Phi + Fac * Del3p
128 C 5th order correction [i+1 i i-1 i-2 i-3]
129 Fac = Fac * ( cfl - 3. _d 0 )/5. _d 0
130 DelMM = (Qim-Qimm)*MskImm*MskIm
131 Del2M = DelM - DelMM
132 Del3M = Del2 - Del2M
133 Del4 = Del3P - Del3M
134 Phi = Phi + Fac * Del4
135 C 6th order correction [i+2 i+1 i i-1 i-2 i-3]
136 Fac = Fac * ( cfl + 2. _d 0 )/6. _d 0
137 DelPPP = (Qippp-Qipp)*MskIpp*MskIp*MskI
138 Del2PP = DelPP - DelP
139 Del3PP = Del2PP - Del2P
140 Del4P = Del3PP - Del3P
141 Del5P = Del4P - Del4
142 Phi = Phi + Fac * Del5P
143 C 7th order correction [i+2 i+1 i i-1 i-2 i-3 i-4]
144 Fac = Fac * ( cfl + 2. _d 0 )/7. _d 0
145 DelMMM = (Qimm-Qimmm)*MskImmm*MskImm*MskIm
146 Del2MM = DelMM - DelMMM
147 Del3MM = Del2M - Del2MM
148 Del4M = Del3M - Del3MM
149 Del5M = Del4 - Del4M
150 Del6 = Del5P - Del5M
151 Phi = Phi - Fac * Del6
152
153 DelIp = ( Qip - Qi ) * MskI
154 c Phi = sign(1. _d 0,Phi)*sign(1. _d 0,DelIp)
155 c & *abs(Phi+Eps)/abs(DelIp+Eps)
156 C-- simplify and avoid division by zero
157 recip_DelIp = sign(1. _d 0,DelIp)/max(abs(DelIp),Eps)
158 Phi = Phi*recip_DelIp
159
160 DelI = ( Qi - Qim ) * MskIm
161 c rp1h =sign(1. _d 0,DelI)*sign(1. _d 0,DelIp)
162 c & *abs(DelI+Eps)/abs(DelIp+Eps)
163 C-- simplify and avoid division by zero
164 recip_DelI = sign(1. _d 0,DelI)/max(abs(DelI),Eps)
165 rp1h = DelI*recip_DelIp
166 rp1h_cfl = rp1h/(cfl+Eps)
167
168 C TVD limiter
169 c Phi = max(0. _d 0, min( 2./(1-cfl), Phi, 2.*rp1h_cfl ) )
170
171 C MP limiter
172 d2 = Del2 !( ( Qip + Qim ) - 2.*Qi ) * MskI * MskIm
173 d2p1 = Del2P !( ( Qipp + Qi ) - 2.*Qip ) * MskIp * MskI
174 d2m1 = Del2M !( ( Qi + Qimm ) - 2.*Qim ) * MskIm * MskImm
175 A = 4. _d 0*d2 - d2p1
176 B = 4. _d 0*d2p1 - d2
177 C = d2
178 D = d2p1
179 dp1h = max(min(A,B,C,D),0. _d 0)+min(max(A,B,C,D),0. _d 0)
180 A = 4. _d 0*d2m1 - d2
181 B = 4. _d 0*d2 - d2m1
182 C = d2m1
183 D = d2
184 dm1h = max(min(A,B,C,D),0. _d 0)+min(max(A,B,C,D),0. _d 0)
185 c qMD = 0.5*( ( Qi + Qip ) - dp1h )
186 c qMD = 0.5 _d 0*( ( 2. _d 0*Qi + DelIp ) - dp1h )
187 c qUL = Qi + (1. _d 0-cfl)/(cfl+Eps)*DelI
188 c qLC = Qi + 0.5 _d 0*( 1. _d 0+dm1h/(DelI+Eps) )*(qUL-Qi)
189 c PhiMD = 2. _d 0/(1. _d 0-cfl)*(qMD-Qi+Eps)/(DelIp+Eps)
190 c PhiLC = 2. _d 0*rp1h_cfl*(qLC-Qi+Eps)/(qUL-Qi+Eps)
191 C-- simplify and avoid division by zero
192 PhiMD = 1. _d 0/(1. _d 0-cfl)*(DelIp-dp1h)*recip_DelIp
193 PhiLC = rp1h_cfl*( 1. _d 0+dm1h*recip_DelI )
194 C--
195 PhiMin = max(min(0. _d 0,PhiMD),
196 & min(0. _d 0,2. _d 0*rp1h_cfl,PhiLC))
197 PhiMax = min(max(2. _d 0/(1. _d 0-cfl),PhiMD),
198 & max(0. _d 0,2. _d 0*rp1h_cfl,PhiLC))
199 Phi = max(PhiMin,min(Phi,PhiMax))
200
201 Psi = Phi * 0.5 _d 0 * (1. _d 0 - cfl)
202 wT(i,j) = wTrans(i,j)*( Qi + Psi*DelIp )
203 ELSE
204 wT(i,j) = 0. _d 0
205 ENDIF
206
207 ENDDO
208 ENDDO
209
210 RETURN
211 END

  ViewVC Help
Powered by ViewVC 1.1.22