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

Annotation of /MITgcm/pkg/generic_advdiff/gad_os7mp_adv_x.F

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


Revision 1.9 - (hide 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.8: +43 -32 lines
- add "_d 0" for real constant (safer, but has no effect here)
- simplify and avoid division by zero

1 jmc 1.9 C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_os7mp_adv_x.F,v 1.8 2008/02/29 01:30:59 mlosch Exp $
2 mlosch 1.2 C $Name: $
3 adcroft 1.1
4     #include "GAD_OPTIONS.h"
5    
6     SUBROUTINE GAD_OS7MP_ADV_X(
7 jmc 1.3 I bi,bj,k, calcCFL, deltaTloc,
8 adcroft 1.1 I uTrans, uFld,
9     I maskLocW, Q,
10     O uT,
11     I myThid )
12     C /==========================================================\
13     C | SUBROUTINE GAD_OS7MP_ADV_X |
14     C | o Compute Zonal 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 jmc 1.3 LOGICAL calcCFL
27 adcroft 1.1 _RL deltaTloc
28     _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
29     _RL uFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
30     _RS maskLocW(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
31     _RL Q (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
32     _RL uT (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 adcroft 1.5 _RL uLoc,Fac,DelIp,DelI,Phi,Eps,rp1h,rp1h_cfl
39 jmc 1.9 _RL recip_DelIp, recip_DelI
40 adcroft 1.1 _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 jmc 1.9 _RL dp1h,dm1h, PhiMD,PhiLC,PhiMin,PhiMax
44 adcroft 1.5 _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 adcroft 1.1
51     Eps = 1. _d -20
52    
53     DO j=1-Oly,sNy+Oly
54     uT(1-Olx,j)=0. _d 0
55     uT(2-Olx,j)=0. _d 0
56     uT(3-Olx,j)=0. _d 0
57     uT(4-Olx,j)=0. _d 0
58     uT(sNx+Olx-2,j)=0. _d 0
59     uT(sNx+Olx-1,j)=0. _d 0
60     uT(sNx+Olx,j)=0. _d 0
61 mlosch 1.8 ENDDO
62     DO j=1-Oly,sNy+Oly
63 adcroft 1.1 DO i=1-Olx+4,sNx+Olx-3
64    
65     uLoc = uFld(i,j)
66 jmc 1.3 cfl = uLoc
67     IF ( calcCFL ) cfl = abs(uLoc*deltaTloc*recip_dxC(i,j,bi,bj))
68 adcroft 1.1
69 jmc 1.9 IF (uTrans(i,j).GT.0. _d 0) THEN
70 adcroft 1.1 Qippp = Q(i+2,j)
71     Qipp = Q(i+1,j)
72     Qip = Q(i,j)
73     Qi = Q(i-1,j)
74     Qim = Q(i-2,j)
75     Qimm = Q(i-3,j)
76     Qimmm = Q(i-4,j)
77    
78     MskIpp = maskLocW(i+2,j)
79     MskIp = maskLocW(i+1,j)
80     MskI = maskLocW(i,j)
81     MskIm = maskLocW(i-1,j)
82     MskImm = maskLocW(i-2,j)
83     MskImmm = maskLocW(i-3,j)
84 jmc 1.9 ELSEIF (uTrans(i,j).LT.0. _d 0) THEN
85 adcroft 1.1 Qippp = Q(i-3,j)
86     Qipp = Q(i-2,j)
87     Qip = Q(i-1,j)
88     Qi = Q(i,j)
89     Qim = Q(i+1,j)
90     Qimm = Q(i+2,j)
91     Qimmm = Q(i+3,j)
92    
93     MskIpp = maskLocW(i-2,j)
94     MskIp = maskLocW(i-1,j)
95     MskI = maskLocW(i,j)
96     MskIm = maskLocW(i+1,j)
97     MskImm = maskLocW(i+2,j)
98     MskImmm = maskLocW(i+3,j)
99 mlosch 1.7 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 adcroft 1.1 ENDIF
115    
116 jmc 1.9 IF (uTrans(i,j).NE.0. _d 0) THEN
117 adcroft 1.1 C 2nd order correction [i i-1]
118 jmc 1.9 Fac = 1. _d 0
119 adcroft 1.5 DelP = (Qip-Qi)*MskI
120     Phi = Fac * DelP
121 adcroft 1.1 C 3rd order correction [i i-1 i-2]
122 jmc 1.9 Fac = Fac * ( cfl + 1. _d 0 )/3. _d 0
123 adcroft 1.5 DelM = (Qi-Qim)*MskIm
124     Del2 = DelP - DelM
125     Phi = Phi - Fac * Del2
126 adcroft 1.1 C 4th order correction [i+1 i i-1 i-2]
127 jmc 1.9 Fac = Fac * ( cfl - 2. _d 0 )/4. _d 0
128 adcroft 1.5 DelPP = (Qipp-Qip)*MskIp*MskI
129     Del2P = DelPP - DelP
130     Del3P = Del2P - Del2
131     Phi = Phi + Fac * Del3p
132 adcroft 1.1 C 5th order correction [i+1 i i-1 i-2 i-3]
133 jmc 1.9 Fac = Fac * ( cfl - 3. _d 0 )/5. _d 0
134 adcroft 1.5 DelMM = (Qim-Qimm)*MskImm*MskIm
135     Del2M = DelM - DelMM
136     Del3M = Del2 - Del2M
137     Del4 = Del3P - Del3M
138     Phi = Phi + Fac * Del4
139 adcroft 1.1 C 6th order correction [i+2 i+1 i i-1 i-2 i-3]
140 jmc 1.9 Fac = Fac * ( cfl + 2. _d 0 )/6. _d 0
141 adcroft 1.5 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 adcroft 1.1 C 7th order correction [i+2 i+1 i i-1 i-2 i-3 i-4]
148 jmc 1.9 Fac = Fac * ( cfl + 2. _d 0 )/7. _d 0
149 adcroft 1.5 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 adcroft 1.1
157     DelIp = ( Qip - Qi ) * MskI
158 jmc 1.9 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 adcroft 1.1
164     DelI = ( Qi - Qim ) * MskIm
165 jmc 1.9 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 adcroft 1.4 rp1h_cfl = rp1h/(cfl+Eps)
171 adcroft 1.1
172     C TVD limiter
173 jmc 1.9 c Phi = max(0. _d 0, min( 2./(1-cfl), Phi, 2.*rp1h_cfl ) )
174 adcroft 1.1
175     C MP limiter
176 adcroft 1.5 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 jmc 1.9 A = 4. _d 0*d2 - d2p1
180     B = 4. _d 0*d2p1 - d2
181 adcroft 1.1 C = d2
182 jmc 1.6 D = d2p1
183 mlosch 1.2 dp1h = max(min(A,B,C,D),0. _d 0)+min(max(A,B,C,D),0. _d 0)
184 jmc 1.9 A = 4. _d 0*d2m1 - d2
185     B = 4. _d 0*d2 - d2m1
186 adcroft 1.1 C = d2m1
187 jmc 1.6 D = d2
188 mlosch 1.2 dm1h = max(min(A,B,C,D),0. _d 0)+min(max(A,B,C,D),0. _d 0)
189 jmc 1.9 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 adcroft 1.1 Phi = max(PhiMin,min(Phi,PhiMax))
204    
205 jmc 1.9 Psi = Phi * 0.5 _d 0 * (1. _d 0 - cfl)
206 adcroft 1.1 uT(i,j) = uTrans(i,j)*( Qi + Psi*DelIp )
207     ELSE
208 jmc 1.9 uT(i,j) = 0. _d 0
209 adcroft 1.1 ENDIF
210    
211     ENDDO
212     ENDDO
213    
214     RETURN
215     END

  ViewVC Help
Powered by ViewVC 1.1.22