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

Contents 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.8 - (show annotations) (download)
Fri Feb 29 01:30:59 2008 UTC (16 years, 2 months ago) by mlosch
Branch: MAIN
CVS Tags: checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59o
Changes since 1.7: +3 -1 lines
improve vectorizability by moving a few statements out of the main loop

1 C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_os7mp_adv_x.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_X(
7 I bi,bj,k, calcCFL, deltaTloc,
8 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 LOGICAL calcCFL
27 _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 _RL uLoc,Fac,DelIp,DelI,Phi,Eps,rp1h,rp1h_cfl
39 _RL Qippp,Qipp,Qip,Qi,Qim,Qimm,Qimmm
40 _RL MskIpp,MskIp,MskI,MskIm,MskImm,MskImmm
41 _RL d2,d2p1,d2m1,A,B,C,D
42 _RL dp1h,dm1h,qMD,qUL,qLC,PhiMD,PhiLC,PhiMin,PhiMax
43 _RL DelM,DelP,DelMM,DelPP,DelMMM,DelPPP
44 _RL Del2MM,Del2M,Del2,Del2P,Del2PP
45 _RL Del3MM,Del3M,Del3P,Del3PP
46 _RL Del4M,Del4,Del4P
47 _RL Del5M,Del5P
48 _RL Del6
49
50 Eps = 1. _d -20
51
52 DO j=1-Oly,sNy+Oly
53 uT(1-Olx,j)=0. _d 0
54 uT(2-Olx,j)=0. _d 0
55 uT(3-Olx,j)=0. _d 0
56 uT(4-Olx,j)=0. _d 0
57 uT(sNx+Olx-2,j)=0. _d 0
58 uT(sNx+Olx-1,j)=0. _d 0
59 uT(sNx+Olx,j)=0. _d 0
60 ENDDO
61 DO j=1-Oly,sNy+Oly
62 DO i=1-Olx+4,sNx+Olx-3
63
64 uLoc = uFld(i,j)
65 cfl = uLoc
66 IF ( calcCFL ) cfl = abs(uLoc*deltaTloc*recip_dxC(i,j,bi,bj))
67
68 IF (uTrans(i,j).gt.0.) THEN
69 Qippp = Q(i+2,j)
70 Qipp = Q(i+1,j)
71 Qip = Q(i,j)
72 Qi = Q(i-1,j)
73 Qim = Q(i-2,j)
74 Qimm = Q(i-3,j)
75 Qimmm = Q(i-4,j)
76
77 MskIpp = maskLocW(i+2,j)
78 MskIp = maskLocW(i+1,j)
79 MskI = maskLocW(i,j)
80 MskIm = maskLocW(i-1,j)
81 MskImm = maskLocW(i-2,j)
82 MskImmm = maskLocW(i-3,j)
83 ELSEIF (uTrans(i,j).lt.0.) THEN
84 Qippp = Q(i-3,j)
85 Qipp = Q(i-2,j)
86 Qip = Q(i-1,j)
87 Qi = Q(i,j)
88 Qim = Q(i+1,j)
89 Qimm = Q(i+2,j)
90 Qimmm = Q(i+3,j)
91
92 MskIpp = maskLocW(i-2,j)
93 MskIp = maskLocW(i-1,j)
94 MskI = maskLocW(i,j)
95 MskIm = maskLocW(i+1,j)
96 MskImm = maskLocW(i+2,j)
97 MskImmm = maskLocW(i+3,j)
98 ELSE
99 Qippp = 0. _d 0
100 Qipp = 0. _d 0
101 Qip = 0. _d 0
102 Qi = 0. _d 0
103 Qim = 0. _d 0
104 Qimm = 0. _d 0
105 Qimmm = 0. _d 0
106
107 MskIpp = 0. _d 0
108 MskIp = 0. _d 0
109 MskI = 0. _d 0
110 MskIm = 0. _d 0
111 MskImm = 0. _d 0
112 MskImmm = 0. _d 0
113 ENDIF
114
115 IF (uTrans(i,j).ne.0.) THEN
116 C 2nd order correction [i i-1]
117 Fac = 1.
118 DelP = (Qip-Qi)*MskI
119 Phi = Fac * DelP
120 C 3rd order correction [i i-1 i-2]
121 Fac = Fac * ( cfl + 1. )/3.
122 DelM = (Qi-Qim)*MskIm
123 Del2 = DelP - DelM
124 Phi = Phi - Fac * Del2
125 C 4th order correction [i+1 i i-1 i-2]
126 Fac = Fac * ( cfl - 2. )/4.
127 DelPP = (Qipp-Qip)*MskIp*MskI
128 Del2P = DelPP - DelP
129 Del3P = Del2P - Del2
130 Phi = Phi + Fac * Del3p
131 C 5th order correction [i+1 i i-1 i-2 i-3]
132 Fac = Fac * ( cfl - 3. )/5.
133 DelMM = (Qim-Qimm)*MskImm*MskIm
134 Del2M = DelM - DelMM
135 Del3M = Del2 - Del2M
136 Del4 = Del3P - Del3M
137 Phi = Phi + Fac * Del4
138 C 6th order correction [i+2 i+1 i i-1 i-2 i-3]
139 Fac = Fac * ( cfl + 2. )/6.
140 DelPPP = (Qippp-Qipp)*MskIpp*MskIp*MskI
141 Del2PP = DelPP - DelP
142 Del3PP = Del2PP - Del2P
143 Del4P = Del3PP - Del3P
144 Del5P = Del4P - Del4
145 Phi = Phi + Fac * Del5P
146 C 7th order correction [i+2 i+1 i i-1 i-2 i-3 i-4]
147 Fac = Fac * ( cfl + 2. )/7.
148 DelMMM = (Qimm-Qimmm)*MskImmm*MskImm*MskIm
149 Del2MM = DelMM - DelMMM
150 Del3MM = Del2M - Del2MM
151 Del4M = Del3M - Del3MM
152 Del5M = Del4 - Del4M
153 Del6 = Del5P - Del5M
154 Phi = Phi - Fac * Del6
155
156 DelIp = ( Qip - Qi ) * MskI
157 Phi = sign(1. _d 0,Phi)*sign(1. _d 0,DelIp)
158 & *abs(Phi+Eps)/abs(DelIp+Eps)
159
160 DelI = ( Qi - Qim ) * MskIm
161 rp1h =sign(1. _d 0,DelI)*sign(1. _d 0,DelIp)
162 & *abs(DelI+Eps)/abs(DelIp+Eps)
163 rp1h_cfl = rp1h/(cfl+Eps)
164
165 C TVD limiter
166 ! Phi = max(0. _d 0, min( 2./(1-cfl), Phi, 2.*rp1h_cfl ) )
167
168 C MP limiter
169 d2 = Del2 !( ( Qip + Qim ) - 2.*Qi ) * MskI * MskIm
170 d2p1 = Del2P !( ( Qipp + Qi ) - 2.*Qip ) * MskIp * MskI
171 d2m1 = Del2M !( ( Qi + Qimm ) - 2.*Qim ) * MskIm * MskImm
172 A = 4.*d2 - d2p1
173 B = 4.*d2p1 - d2
174 C = d2
175 D = d2p1
176 dp1h = max(min(A,B,C,D),0. _d 0)+min(max(A,B,C,D),0. _d 0)
177 A = 4.*d2m1 - d2
178 B = 4.*d2 - d2m1
179 C = d2m1
180 D = d2
181 dm1h = max(min(A,B,C,D),0. _d 0)+min(max(A,B,C,D),0. _d 0)
182 !qMD = 0.5*( ( Qi + Qip ) - dp1h )
183 qMD = 0.5*( ( 2.*Qi + DelIp ) - dp1h )
184 qUL = Qi + (1.-cfl)/(cfl+Eps)*DelI
185 qLC = Qi + 0.5*( 1.+dm1h/(DelI+Eps) )*(qUL-Qi)
186 PhiMD = 2./(1.-cfl)*(qMD-Qi+Eps)/(DelIp+Eps)
187 PhiLC = 2.*rp1h_cfl*(qLC-Qi+Eps)/(qUL-Qi+Eps)
188 PhiMin = max(min(0. _d 0,PhiMD),
189 & min(0. _d 0,2.*rp1h_cfl,PhiLC))
190 PhiMax = min(max(2. _d 0/(1.-cfl),PhiMD),
191 & max(0. _d 0,2.*rp1h_cfl,PhiLC))
192 Phi = max(PhiMin,min(Phi,PhiMax))
193
194 Psi = Phi * 0.5 * (1. - cfl)
195 uT(i,j) = uTrans(i,j)*( Qi + Psi*DelIp )
196 ELSE
197 uT(i,j) = 0.
198 ENDIF
199
200 ENDDO
201 ENDDO
202
203 RETURN
204 END

  ViewVC Help
Powered by ViewVC 1.1.22