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

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

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


Revision 1.5 - (show annotations) (download)
Fri May 9 21:43:16 2008 UTC (16 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint59r, 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
Changes since 1.4: +1 -4 lines
change option: GAD_ALLOW_SOM_ADVECT to GAD_ALLOW_TS_SOM_ADV which only
applies to files where Temperature & salinity 2nd Order moments are used

1 C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/gad_som_adv_y.F,v 1.4 2008/02/12 20:32:34 jmc Exp $
2 C $Name: $
3
4 #include "GAD_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: GAD_SOM_ADV_Y
8
9 C !INTERFACE: ==========================================================
10 SUBROUTINE GAD_SOM_ADV_Y(
11 I bi,bj,k, limiter,
12 I overlapOnly, interiorOnly,
13 I N_edge, S_edge, E_edge, W_edge,
14 I deltaTloc, vTrans,
15 U sm_v, sm_o, sm_x, sm_y, sm_z,
16 U sm_xx, sm_yy, sm_zz, sm_xy, sm_xz, sm_yz,
17 O vT,
18 I myThid )
19
20 C !DESCRIPTION:
21 C Calculates the area integrated meridional flux due to advection
22 C of a tracer using
23 C--
24 C Second-Order Moments Advection of tracer in Y-direction
25 C ref: M.J.Prather, 1986, JGR, 91, D6, pp 6671-6681.
26 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
27 C The 3-D grid has dimension (Nx,Ny,Nz) with corresponding
28 C velocity field (U,V,W). Parallel subroutine calculate
29 C advection in the X- and Z- directions.
30 C The moment [Si] are as defined in the text, Sm refers to
31 C the total mass in each grid box
32 C the moments [Fi] are similarly defined and used as temporary
33 C storage for portions of the grid boxes in transit.
34 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
35
36 C !USES: ===============================================================
37 IMPLICIT NONE
38 #include "SIZE.h"
39 #include "GAD.h"
40
41 C !INPUT PARAMETERS: ===================================================
42 C bi,bj :: tile indices
43 C k :: vertical level
44 C limiter :: 0: no limiter ; 1: Prather, 1986 limiter
45 C overlapOnly :: only update the edges of myTile, but not the interior
46 C interiorOnly :: only update the interior of myTile, but not the edges
47 C [N,S,E,W]_edge :: true if N,S,E,W edge of myTile is an Edge of the cube
48 C vTrans :: zonal volume transport
49 C myThid :: my Thread Id. number
50 INTEGER bi,bj,k
51 INTEGER limiter
52 LOGICAL overlapOnly, interiorOnly
53 LOGICAL N_edge, S_edge, E_edge, W_edge
54 _RL deltaTloc
55 _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
56 INTEGER myThid
57
58 C !OUTPUT PARAMETERS: ==================================================
59 C sm_v :: volume of grid cell
60 C sm_o :: tracer content of grid cell (zero order moment)
61 C sm_x,y,z :: 1rst order moment of tracer distribution, in x,y,z direction
62 C sm_xx,yy,zz :: 2nd order moment of tracer distribution, in x,y,z direction
63 C sm_xy,xz,yz :: 2nd order moment of tracer distr., in cross direction xy,xz,yz
64 C vT :: meridional advective flux
65 _RL sm_v (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
66 _RL sm_o (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
67 _RL sm_x (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
68 _RL sm_y (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
69 _RL sm_z (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
70 _RL sm_xx (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
71 _RL sm_yy (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
72 _RL sm_zz (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
73 _RL sm_xy (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
74 _RL sm_xz (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
75 _RL sm_yz (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
76 _RL vT (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
77
78 C !LOCAL VARIABLES: ====================================================
79 C i,j :: loop indices
80 C vLoc :: volume transported (per time step)
81 C [iMin,iMax]Upd :: loop range to update tracer field
82 C [jMin,jMax]Upd :: loop range to update tracer field
83 C nbStrips :: number of strips (if region to update is splitted)
84 _RL two, three
85 PARAMETER( two = 2. _d 0 )
86 PARAMETER( three = 3. _d 0 )
87 INTEGER i,j
88 INTEGER ns, nbStrips
89 INTEGER iMinUpd(2), iMaxUpd(2), jMinUpd(2), jMaxUpd(2)
90 _RL recip_dT
91 _RL slpmax, s1max, s1new, s2new
92 _RL vLoc, alf1, alf1q, alpmn
93 _RL alfp, alpq, alp1, locTp
94 _RL alfn, alnq, aln1, locTn
95 _RL alp (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
96 _RL aln (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
97 _RL fp_v (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
98 _RL fn_v (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
99 _RL fp_o (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
100 _RL fn_o (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
101 _RL fp_x (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
102 _RL fn_x (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
103 _RL fp_y (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
104 _RL fn_y (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
105 _RL fp_z (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
106 _RL fn_z (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
107 _RL fp_xx(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
108 _RL fn_xx(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
109 _RL fp_yy(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
110 _RL fn_yy(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
111 _RL fp_zz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
112 _RL fn_zz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
113 _RL fp_xy(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
114 _RL fn_xy(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
115 _RL fp_xz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
116 _RL fn_xz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
117 _RL fp_yz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
118 _RL fn_yz(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
119 CEOP
120
121 recip_dT = 0.
122 IF ( deltaTloc.GT.0. _d 0 ) recip_dT = 1.0 _d 0 / deltaTloc
123
124 C- Set loop ranges for updating tracer field (splitted in 2 strips)
125 nbStrips = 1
126 iMinUpd(1) = 1-Olx
127 iMaxUpd(1) = sNx+Olx
128 jMinUpd(1) = 1-Oly+1
129 jMaxUpd(1) = sNy+Oly-1
130 IF ( overlapOnly ) THEN
131 C update in overlap-Only
132 IF ( S_edge ) jMinUpd(1) = 1
133 IF ( N_edge ) jMaxUpd(1) = sNy
134 IF ( W_edge ) THEN
135 iMinUpd(1) = 1-Olx
136 iMaxUpd(1) = 0
137 ENDIF
138 IF ( E_edge ) THEN
139 IF ( W_edge ) nbStrips = 2
140 iMinUpd(nbStrips) = sNx+1
141 iMaxUpd(nbStrips) = sNx+Olx
142 ENDIF
143 ELSE
144 C do not only update the overlap
145 IF ( interiorOnly .AND. W_edge ) iMinUpd(1) = 1
146 IF ( interiorOnly .AND. E_edge ) iMaxUpd(1) = sNx
147 ENDIF
148
149 C- Internal exchange for calculations in Y
150 c IF ( overlapOnly ) THEN
151 c CALL GAD_SOM_FILL_CS_CORNER( .FALSE.,
152 c U sm_v, sm_o, sm_x, sm_y, sm_z,
153 c U sm_xx, sm_yy, sm_zz, sm_xy, sm_xz, sm_yz,
154 c I bi, bj, myThid )
155 c ENDIF
156
157 C-- start 1rst loop on strip number "ns"
158 DO ns=1,nbStrips
159
160 IF ( limiter.EQ.1 ) THEN
161 DO j=jMinUpd(1)-1,jMaxUpd(1)+1
162 DO i=iMinUpd(ns),iMaxUpd(ns)
163 C If flux-limiting transport is to be applied, place limits on
164 C appropriate moments before transport.
165 slpmax = 0.
166 IF ( sm_o(i,j).GT.0. ) slpmax = sm_o(i,j)
167 s1max = slpmax*1.5 _d 0
168 s1new = MIN( s1max, MAX(-s1max,sm_y(i,j)) )
169 s2new = MIN( (slpmax+slpmax-ABS(s1new)/three),
170 & MAX(ABS(s1new)-slpmax,sm_yy(i,j)) )
171 sm_xy(i,j) = MIN( slpmax, MAX(-slpmax,sm_xy(i,j)) )
172 sm_yz(i,j) = MIN( slpmax, MAX(-slpmax,sm_yz(i,j)) )
173 sm_y (i,j) = s1new
174 sm_yy(i,j) = s2new
175 ENDDO
176 ENDDO
177 ENDIF
178
179 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
180 C--- part.1 : calculate flux for all moments
181 DO j=jMinUpd(1),jMaxUpd(1)+1
182 DO i=iMinUpd(ns),iMaxUpd(ns)
183 vLoc = vTrans(i,j)*deltaTloc
184 C-- Flux from (j-1) to (j) when V>0 (i.e., take right side of box j-1)
185 fp_v (i,j) = MAX( 0. _d 0, vLoc )
186 alp (i,j) = fp_v(i,j)/sm_v(i,j-1)
187 alpq = alp(i,j)*alp(i,j)
188 alp1 = 1. _d 0 - alp(i,j)
189 C- Create temporary moments/masses for partial boxes in transit
190 C use same indexing as velocity, "p" for positive V
191 fp_o (i,j) = alp(i,j)*( sm_o(i,j-1) + alp1*sm_y(i,j-1)
192 & + alp1*(alp1-alp(i,j))*sm_yy(i,j-1)
193 & )
194 fp_y (i,j) = alpq *( sm_y(i,j-1) + three*alp1*sm_yy(i,j-1) )
195 fp_yy(i,j) = alp(i,j)*alpq*sm_yy(i,j-1)
196 fp_x (i,j) = alp(i,j)*( sm_x(i,j-1) + alp1*sm_xy(i,j-1) )
197 fp_z (i,j) = alp(i,j)*( sm_z(i,j-1) + alp1*sm_yz(i,j-1) )
198
199 fp_xy(i,j) = alpq *sm_xy(i,j-1)
200 fp_yz(i,j) = alpq *sm_yz(i,j-1)
201 fp_xx(i,j) = alp(i,j)*sm_xx(i,j-1)
202 fp_zz(i,j) = alp(i,j)*sm_zz(i,j-1)
203 fp_xz(i,j) = alp(i,j)*sm_xz(i,j-1)
204 C-- Flux from (j) to (j-1) when V<0 (i.e., take left side of box j)
205 fn_v (i,j) = MAX( 0. _d 0, -vLoc )
206 aln (i,j) = fn_v(i,j)/sm_v(i, j )
207 alnq = aln(i,j)*aln(i,j)
208 aln1 = 1. _d 0 - aln(i,j)
209 C- Create temporary moments/masses for partial boxes in transit
210 C use same indexing as velocity, "n" for negative V
211 fn_o (i,j) = aln(i,j)*( sm_o(i, j ) - aln1*sm_y(i, j )
212 & + aln1*(aln1-aln(i,j))*sm_yy(i, j )
213 & )
214 fn_y (i,j) = alnq *( sm_y(i, j ) - three*aln1*sm_yy(i, j ) )
215 fn_yy(i,j) = aln(i,j)*alnq*sm_yy(i, j )
216 fn_x (i,j) = aln(i,j)*( sm_x(i, j ) - aln1*sm_xy(i, j ) )
217 fn_z (i,j) = aln(i,j)*( sm_z(i, j ) - aln1*sm_yz(i, j ) )
218 fn_xy(i,j) = alnq *sm_xy(i, j )
219 fn_yz(i,j) = alnq *sm_yz(i, j )
220 fn_xx(i,j) = aln(i,j)*sm_xx(i, j )
221 fn_zz(i,j) = aln(i,j)*sm_zz(i, j )
222 fn_xz(i,j) = aln(i,j)*sm_xz(i, j )
223 C-- Save zero-order flux:
224 vT(i,j) = ( fp_o(i,j) - fn_o(i,j) )*recip_dT
225 ENDDO
226 ENDDO
227
228 C-- end 1rst loop on strip number "ns"
229 c ENDDO
230
231 C- Internal exchange for next calculations in X
232 c IF ( overlapOnly ) THEN
233 c CALL GAD_SOM_FILL_CS_CORNER( .TRUE.,
234 c U sm_v, sm_o, sm_x, sm_y, sm_z,
235 c U sm_xx, sm_yy, sm_zz, sm_xy, sm_xz, sm_yz,
236 c I bi, bj, myThid )
237 c ENDIF
238
239 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
240 C-- start 2nd loop on strip number "ns"
241 c DO ns=1,nbStrips
242
243 C--- part.2 : re-adjust moments remaining in the box
244 C take off from grid box (j): negative V(j) and positive V(j+1)
245 DO j=jMinUpd(1),jMaxUpd(1)
246 DO i=iMinUpd(ns),iMaxUpd(ns)
247 alf1 = 1. _d 0 - aln(i,j) - alp(i,j+1)
248 alf1q = alf1*alf1
249 alpmn = alp(i,j+1) - aln(i,j)
250 sm_v (i,j) = sm_v (i,j) - fn_v (i,j) - fp_v (i,j+1)
251 sm_o (i,j) = sm_o (i,j) - fn_o (i,j) - fp_o (i,j+1)
252 sm_y (i,j) = alf1q*( sm_y(i,j) - three*alpmn*sm_yy(i,j) )
253 sm_yy(i,j) = alf1*alf1q*sm_yy(i,j)
254 sm_xy(i,j) = alf1q*sm_xy(i,j)
255 sm_yz(i,j) = alf1q*sm_yz(i,j)
256 sm_x (i,j) = sm_x (i,j) - fn_x (i,j) - fp_x (i,j+1)
257 sm_xx(i,j) = sm_xx(i,j) - fn_xx(i,j) - fp_xx(i,j+1)
258 sm_z (i,j) = sm_z (i,j) - fn_z (i,j) - fp_z (i,j+1)
259 sm_zz(i,j) = sm_zz(i,j) - fn_zz(i,j) - fp_zz(i,j+1)
260 sm_xz(i,j) = sm_xz(i,j) - fn_xz(i,j) - fp_xz(i,j+1)
261 ENDDO
262 ENDDO
263
264 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
265 C--- part.3 : Put the temporary moments into appropriate neighboring boxes
266 C add into grid box (j): positive V(j) and negative V(j+1)
267 DO j=jMinUpd(1),jMaxUpd(1)
268 DO i=iMinUpd(ns),iMaxUpd(ns)
269 sm_v (i,j) = sm_v (i,j) + fp_v (i,j) + fn_v (i,j+1)
270 alfp = fp_v(i, j )/sm_v(i,j)
271 alfn = fn_v(i,j+1)/sm_v(i,j)
272 alf1 = 1. _d 0 - alfp - alfn
273 alp1 = 1. _d 0 - alfp
274 aln1 = 1. _d 0 - alfn
275 alpmn = alfp - alfn
276 locTp = alfp*sm_o(i,j) - alp1*fp_o(i,j)
277 locTn = alfn*sm_o(i,j) - aln1*fn_o(i,j+1)
278 sm_yy(i,j) = alf1*alf1*sm_yy(i,j) + alfp*alfp*fp_yy(i,j)
279 & + alfn*alfn*fn_yy(i,j+1)
280 & - 5. _d 0*(-alpmn*alf1*sm_y(i,j) + alfp*alp1*fp_y(i,j)
281 & - alfn*aln1*fn_y(i,j+1)
282 & + two*alfp*alfn*sm_o(i,j) + (alp1-alfp)*locTp
283 & + (aln1-alfn)*locTn
284 & )
285 sm_xy(i,j) = alf1*sm_xy(i,j) + alfp*fp_xy(i,j)
286 & + alfn*fn_xy(i,j+1)
287 & + three*( alpmn*sm_x(i,j) - alp1*fp_x(i,j)
288 & + aln1*fn_x(i,j+1)
289 & )
290 sm_yz(i,j) = alf1*sm_yz(i,j) + alfp*fp_yz(i,j)
291 & + alfn*fn_yz(i,j+1)
292 & + three*( alpmn*sm_z(i,j) - alp1*fp_z(i,j)
293 & + aln1*fn_z(i,j+1)
294 & )
295 sm_y (i,j) = alf1*sm_y(i,j) + alfp*fp_y(i,j) + alfn*fn_y(i,j+1)
296 & + three*( locTp - locTn )
297 sm_o (i,j) = sm_o (i,j) + fp_o (i,j) + fn_o (i,j+1)
298 sm_x (i,j) = sm_x (i,j) + fp_x (i,j) + fn_x (i,j+1)
299 sm_xx(i,j) = sm_xx(i,j) + fp_xx(i,j) + fn_xx(i,j+1)
300 sm_z (i,j) = sm_z (i,j) + fp_z (i,j) + fn_z (i,j+1)
301 sm_zz(i,j) = sm_zz(i,j) + fp_zz(i,j) + fn_zz(i,j+1)
302 sm_xz(i,j) = sm_xz(i,j) + fp_xz(i,j) + fn_xz(i,j+1)
303 ENDDO
304 ENDDO
305
306 C-- end 2nd loop on strip number "ns"
307 ENDDO
308
309 RETURN
310 END

  ViewVC Help
Powered by ViewVC 1.1.22