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

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

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


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

  ViewVC Help
Powered by ViewVC 1.1.22