3 |
|
|
4 |
#include "GAD_OPTIONS.h" |
#include "GAD_OPTIONS.h" |
5 |
|
|
6 |
SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity, |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
U Tracer,Gtracer, |
CBOP |
8 |
I myTime,myIter,myThid) |
C !ROUTINE: GAD_ADVECTION |
9 |
C /==========================================================\ |
|
10 |
C | SUBROUTINE GAD_ADVECTION | |
C !INTERFACE: ========================================================== |
11 |
C | o Solves the pure advection tracer equation. | |
SUBROUTINE GAD_ADVECTION( |
12 |
C |==========================================================| |
I implicitAdvection, advectionScheme, vertAdvecScheme, |
13 |
C \==========================================================/ |
I tracerIdentity, |
14 |
IMPLICIT NONE |
I uVel, vVel, wVel, tracer, |
15 |
|
O gTracer, |
16 |
|
I bi,bj, myTime,myIter,myThid) |
17 |
|
|
18 |
|
C !DESCRIPTION: |
19 |
|
C Calculates the tendancy of a tracer due to advection. |
20 |
|
C It uses the multi-dimensional method given in \ref{sect:multiDimAdvection} |
21 |
|
C and can only be used for the non-linear advection schemes such as the |
22 |
|
C direct-space-time method and flux-limiters. |
23 |
|
C |
24 |
|
C The algorithm is as follows: |
25 |
|
C \begin{itemize} |
26 |
|
C \item{$\theta^{(n+1/3)} = \theta^{(n)} |
27 |
|
C - \Delta t \partial_x (u\theta^{(n)}) + \theta^{(n)} \partial_x u$} |
28 |
|
C \item{$\theta^{(n+2/3)} = \theta^{(n+1/3)} |
29 |
|
C - \Delta t \partial_y (v\theta^{(n+1/3)}) + \theta^{(n)} \partial_y v$} |
30 |
|
C \item{$\theta^{(n+3/3)} = \theta^{(n+2/3)} |
31 |
|
C - \Delta t \partial_r (w\theta^{(n+2/3)}) + \theta^{(n)} \partial_r w$} |
32 |
|
C \item{$G_\theta = ( \theta^{(n+3/3)} - \theta^{(n)} )/\Delta t$} |
33 |
|
C \end{itemize} |
34 |
|
C |
35 |
|
C The tendancy (output) is over-written by this routine. |
36 |
|
|
37 |
C == Global variables === |
C !USES: =============================================================== |
38 |
|
IMPLICIT NONE |
39 |
#include "SIZE.h" |
#include "SIZE.h" |
40 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
41 |
#include "PARAMS.h" |
#include "PARAMS.h" |
|
#include "DYNVARS.h" |
|
42 |
#include "GRID.h" |
#include "GRID.h" |
43 |
#include "GAD.h" |
#include "GAD.h" |
44 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
45 |
C == Routine arguments == |
# include "tamc.h" |
46 |
INTEGER bi,bj |
# include "tamc_keys.h" |
47 |
INTEGER advectionScheme |
# ifdef ALLOW_PTRACERS |
48 |
|
# include "PTRACERS_SIZE.h" |
49 |
|
# endif |
50 |
|
#endif |
51 |
|
#ifdef ALLOW_EXCH2 |
52 |
|
#include "W2_EXCH2_TOPOLOGY.h" |
53 |
|
#include "W2_EXCH2_PARAMS.h" |
54 |
|
#endif /* ALLOW_EXCH2 */ |
55 |
|
|
56 |
|
C !INPUT PARAMETERS: =================================================== |
57 |
|
C implicitAdvection :: implicit vertical advection (later on) |
58 |
|
C advectionScheme :: advection scheme to use (Horizontal plane) |
59 |
|
C vertAdvecScheme :: advection scheme to use (vertical direction) |
60 |
|
C tracerIdentity :: tracer identifier (required only for OBCS) |
61 |
|
C uVel :: velocity, zonal component |
62 |
|
C vVel :: velocity, meridional component |
63 |
|
C wVel :: velocity, vertical component |
64 |
|
C tracer :: tracer field |
65 |
|
C bi,bj :: tile indices |
66 |
|
C myTime :: current time |
67 |
|
C myIter :: iteration number |
68 |
|
C myThid :: thread number |
69 |
|
LOGICAL implicitAdvection |
70 |
|
INTEGER advectionScheme, vertAdvecScheme |
71 |
INTEGER tracerIdentity |
INTEGER tracerIdentity |
72 |
_RL Tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
_RL uVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
73 |
_RL Gtracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
_RL vVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
74 |
|
_RL wVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
75 |
|
_RL tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
76 |
|
INTEGER bi,bj |
77 |
_RL myTime |
_RL myTime |
78 |
INTEGER myIter |
INTEGER myIter |
79 |
INTEGER myThid |
INTEGER myThid |
80 |
|
|
81 |
C == Local variables |
C !OUTPUT PARAMETERS: ================================================== |
82 |
|
C gTracer :: tendancy array |
83 |
|
_RL gTracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
84 |
|
|
85 |
|
C !LOCAL VARIABLES: ==================================================== |
86 |
|
C maskUp :: 2-D array for mask at W points |
87 |
|
C iMin,iMax, :: loop range for called routines |
88 |
|
C jMin,jMax :: loop range for called routines |
89 |
|
C i,j,k :: loop indices |
90 |
|
C kup :: index into 2 1/2D array, toggles between 1 and 2 |
91 |
|
C kdown :: index into 2 1/2D array, toggles between 2 and 1 |
92 |
|
C kp1 :: =k+1 for k<Nr, =Nr for k=Nr |
93 |
|
C xA,yA :: areas of X and Y face of tracer cells |
94 |
|
C uTrans,vTrans :: 2-D arrays of volume transports at U,V points |
95 |
|
C rTrans :: 2-D arrays of volume transports at W points |
96 |
|
C rTransKp1 :: vertical volume transport at interface k+1 |
97 |
|
C af :: 2-D array for horizontal advective flux |
98 |
|
C fVerT :: 2 1/2D arrays for vertical advective flux |
99 |
|
C localTij :: 2-D array, temporary local copy of tracer fld |
100 |
|
C localTijk :: 3-D array, temporary local copy of tracer fld |
101 |
|
C kp1Msk :: flag (0,1) for over-riding mask for W levels |
102 |
|
C calc_fluxes_X :: logical to indicate to calculate fluxes in X dir |
103 |
|
C calc_fluxes_Y :: logical to indicate to calculate fluxes in Y dir |
104 |
|
C nipass :: number of passes in multi-dimensional method |
105 |
|
C ipass :: number of the current pass being made |
106 |
|
C myTile :: variables used to determine which cube face |
107 |
|
C nCFace :: owns a tile for cube grid runs using |
108 |
|
C :: multi-dim advection. |
109 |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
110 |
INTEGER iMin,iMax,jMin,jMax |
INTEGER iMin,iMax,jMin,jMax |
111 |
INTEGER i,j,k,kup,kDown,kp1 |
INTEGER i,j,k,kup,kDown |
112 |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
113 |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
114 |
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
115 |
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
116 |
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
117 |
|
_RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
118 |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
119 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
120 |
_RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
122 |
_RL kp1Msk |
_RL kp1Msk |
123 |
LOGICAL calc_fluxes_X,calc_fluxes_Y |
LOGICAL calc_fluxes_X,calc_fluxes_Y |
124 |
INTEGER nipass,ipass |
INTEGER nipass,ipass |
125 |
|
INTEGER myTile, nCFace |
126 |
|
LOGICAL southWestCorner |
127 |
|
LOGICAL southEastCorner |
128 |
|
LOGICAL northWestCorner |
129 |
|
LOGICAL northEastCorner |
130 |
|
CEOP |
131 |
|
|
132 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
133 |
|
act0 = tracerIdentity - 1 |
134 |
|
max0 = maxpass |
135 |
|
act1 = bi - myBxLo(myThid) |
136 |
|
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
137 |
|
act2 = bj - myByLo(myThid) |
138 |
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
139 |
|
act3 = myThid - 1 |
140 |
|
max3 = nTx*nTy |
141 |
|
act4 = ikey_dynamics - 1 |
142 |
|
igadkey = (act0 + 1) |
143 |
|
& + act1*max0 |
144 |
|
& + act2*max0*max1 |
145 |
|
& + act3*max0*max1*max2 |
146 |
|
& + act4*max0*max1*max2*max3 |
147 |
|
if (tracerIdentity.GT.maxpass) then |
148 |
|
print *, 'ph-pass gad_advection ', maxpass, tracerIdentity |
149 |
|
STOP 'maxpass seems smaller than tracerIdentity' |
150 |
|
endif |
151 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
152 |
|
|
153 |
C-- Set up work arrays with valid (i.e. not NaN) values |
C-- Set up work arrays with valid (i.e. not NaN) values |
154 |
C These inital values do not alter the numerical results. They |
C These inital values do not alter the numerical results. They |
164 |
rTrans(i,j) = 0. _d 0 |
rTrans(i,j) = 0. _d 0 |
165 |
fVerT(i,j,1) = 0. _d 0 |
fVerT(i,j,1) = 0. _d 0 |
166 |
fVerT(i,j,2) = 0. _d 0 |
fVerT(i,j,2) = 0. _d 0 |
167 |
|
rTransKp1(i,j)= 0. _d 0 |
168 |
ENDDO |
ENDDO |
169 |
ENDDO |
ENDDO |
170 |
|
|
175 |
|
|
176 |
C-- Start of k loop for horizontal fluxes |
C-- Start of k loop for horizontal fluxes |
177 |
DO k=1,Nr |
DO k=1,Nr |
178 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
179 |
|
kkey = (igadkey-1)*Nr + k |
180 |
|
CADJ STORE tracer(:,:,k,bi,bj) = |
181 |
|
CADJ & comlev1_bibj_k_gad, key=kkey, byte=isbyte |
182 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
183 |
|
|
184 |
C-- Get temporary terms used by tendency routines |
C-- Get temporary terms used by tendency routines |
185 |
CALL CALC_COMMON_FACTORS ( |
CALL CALC_COMMON_FACTORS ( |
187 |
O xA,yA,uTrans,vTrans,rTrans,maskUp, |
O xA,yA,uTrans,vTrans,rTrans,maskUp, |
188 |
I myThid) |
I myThid) |
189 |
|
|
190 |
|
#ifdef ALLOW_GMREDI |
191 |
|
C-- Residual transp = Bolus transp + Eulerian transp |
192 |
|
IF (useGMRedi) |
193 |
|
& CALL GMREDI_CALC_UVFLOW( |
194 |
|
& uTrans, vTrans, bi, bj, k, myThid) |
195 |
|
#endif /* ALLOW_GMREDI */ |
196 |
|
|
197 |
C-- Make local copy of tracer array |
C-- Make local copy of tracer array |
198 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
199 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
201 |
ENDDO |
ENDDO |
202 |
ENDDO |
ENDDO |
203 |
|
|
204 |
|
cph The following block is needed for useCubedSphereExchange only, |
205 |
|
cph but needs to be set for all cases to avoid spurious |
206 |
|
cph TAF dependencies |
207 |
|
southWestCorner = .TRUE. |
208 |
|
southEastCorner = .TRUE. |
209 |
|
northWestCorner = .TRUE. |
210 |
|
northEastCorner = .TRUE. |
211 |
|
#ifdef ALLOW_EXCH2 |
212 |
|
myTile = W2_myTileList(bi) |
213 |
|
nCFace = exch2_myFace(myTile) |
214 |
|
southWestCorner = exch2_isWedge(myTile).EQ.1 |
215 |
|
& .AND. exch2_isSedge(myTile).EQ.1 |
216 |
|
southEastCorner = exch2_isEedge(myTile).EQ.1 |
217 |
|
& .AND. exch2_isSedge(myTile).EQ.1 |
218 |
|
northEastCorner = exch2_isEedge(myTile).EQ.1 |
219 |
|
& .AND. exch2_isNedge(myTile).EQ.1 |
220 |
|
northWestCorner = exch2_isWedge(myTile).EQ.1 |
221 |
|
& .AND. exch2_isNedge(myTile).EQ.1 |
222 |
|
#else |
223 |
|
nCFace = bi |
224 |
|
#endif |
225 |
IF (useCubedSphereExchange) THEN |
IF (useCubedSphereExchange) THEN |
226 |
|
|
227 |
nipass=3 |
nipass=3 |
228 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
229 |
|
if ( nipass.GT.maxcube ) |
230 |
|
& STOP 'maxcube needs to be = 3' |
231 |
|
#endif |
232 |
ELSE |
ELSE |
233 |
nipass=1 |
nipass=1 |
234 |
ENDIF |
ENDIF |
235 |
nipass=1 |
cph nipass=1 |
236 |
|
|
237 |
C-- Multiple passes for different directions on different tiles |
C-- Multiple passes for different directions on different tiles |
238 |
|
C-- For cube need one pass for each of red, green and blue axes. |
239 |
DO ipass=1,nipass |
DO ipass=1,nipass |
240 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
241 |
|
passkey = ipass + (k-1) *maxcube |
242 |
|
& + (igadkey-1)*maxcube*Nr |
243 |
|
IF (nipass .GT. maxpass) THEN |
244 |
|
STOP 'GAD_ADVECTION: nipass > maxcube. check tamc.h' |
245 |
|
ENDIF |
246 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
247 |
|
|
248 |
IF (nipass.EQ.3) THEN |
IF (nipass.EQ.3) THEN |
249 |
calc_fluxes_X=.FALSE. |
calc_fluxes_X=.FALSE. |
250 |
calc_fluxes_Y=.FALSE. |
calc_fluxes_Y=.FALSE. |
251 |
IF (ipass.EQ.1 .AND. (bi.EQ.1 .OR. bi.EQ.2) ) THEN |
IF (ipass.EQ.1 .AND. (nCFace.EQ.1 .OR. nCFace.EQ.2) ) THEN |
252 |
calc_fluxes_X=.TRUE. |
calc_fluxes_X=.TRUE. |
253 |
ELSEIF (ipass.EQ.1 .AND. (bi.EQ.4 .OR. bi.EQ.5) ) THEN |
ELSEIF (ipass.EQ.1 .AND. (nCFace.EQ.4 .OR. nCFace.EQ.5) ) THEN |
254 |
calc_fluxes_Y=.TRUE. |
calc_fluxes_Y=.TRUE. |
255 |
ELSEIF (ipass.EQ.2 .AND. (bi.EQ.1 .OR. bi.EQ.6) ) THEN |
ELSEIF (ipass.EQ.2 .AND. (nCFace.EQ.1 .OR. nCFace.EQ.6) ) THEN |
256 |
calc_fluxes_Y=.TRUE. |
calc_fluxes_Y=.TRUE. |
257 |
ELSEIF (ipass.EQ.2 .AND. (bi.EQ.3 .OR. bi.EQ.4) ) THEN |
ELSEIF (ipass.EQ.2 .AND. (nCFace.EQ.3 .OR. nCFace.EQ.4) ) THEN |
258 |
calc_fluxes_X=.TRUE. |
calc_fluxes_X=.TRUE. |
259 |
ELSEIF (ipass.EQ.3 .AND. (bi.EQ.2 .OR. bi.EQ.3) ) THEN |
ELSEIF (ipass.EQ.3 .AND. (nCFace.EQ.2 .OR. nCFace.EQ.3) ) THEN |
260 |
calc_fluxes_Y=.TRUE. |
calc_fluxes_Y=.TRUE. |
261 |
ELSEIF (ipass.EQ.3 .AND. (bi.EQ.5 .OR. bi.EQ.6) ) THEN |
ELSEIF (ipass.EQ.3 .AND. (nCFace.EQ.5 .OR. nCFace.EQ.6) ) THEN |
262 |
calc_fluxes_X=.TRUE. |
calc_fluxes_X=.TRUE. |
263 |
ENDIF |
ENDIF |
264 |
ELSE |
ELSE |
271 |
|
|
272 |
C-- Internal exchange for calculations in X |
C-- Internal exchange for calculations in X |
273 |
IF (useCubedSphereExchange) THEN |
IF (useCubedSphereExchange) THEN |
274 |
DO j=1,Oly |
C-- For cube face corners we need to duplicate the |
275 |
DO i=1,Olx |
C-- i-1 and i+1 values into the null space as follows: |
276 |
localTij( 1-i , 1-j )=localTij( 1-j , i ) |
C |
277 |
localTij( 1-i ,sNy+j)=localTij( 1-j , sNy+1-i ) |
C |
278 |
localTij(sNx+i, 1-j )=localTij(sNx+j, i ) |
C o NW corner: copy T( 0,sNy ) into T( 0,sNy+1) e.g. |
279 |
localTij(sNx+i,sNy+j)=localTij(sNx+j, sNy+1-i ) |
C | |
280 |
|
C x T(0,sNy+1) | |
281 |
|
C /\ | |
282 |
|
C --||------------|----------- |
283 |
|
C || | |
284 |
|
C x T(0,sNy) | x T(1,sNy) |
285 |
|
C | |
286 |
|
C |
287 |
|
C o SW corner: copy T(0,1) into T(0,0) e.g. |
288 |
|
C | |
289 |
|
C x T(0,1) | x T(1,1) |
290 |
|
C || | |
291 |
|
C --||------------|----------- |
292 |
|
C \/ | |
293 |
|
C x T(0,0) | |
294 |
|
C | |
295 |
|
C |
296 |
|
C o NE corner: copy T(sNx+1,sNy ) into T(sNx+1,sNy+1) e.g. |
297 |
|
C | |
298 |
|
C | x T(sNx+1,sNy+1) |
299 |
|
C | /\ |
300 |
|
C ----------------|--||------- |
301 |
|
C | || |
302 |
|
C x T(sNx,sNy) | x T(sNx+1,sNy ) |
303 |
|
C | |
304 |
|
C o SE corner: copy T(sNx+1,1 ) into T(sNx+1,0 ) e.g. |
305 |
|
C | |
306 |
|
C x T(sNx,1) | x T(sNx+1, 1) |
307 |
|
C | || |
308 |
|
C ----------------|--||------- |
309 |
|
C | \/ |
310 |
|
C | x T(sNx+1, 0) |
311 |
|
IF ( southWestCorner ) THEN |
312 |
|
DO j=1,OLy |
313 |
|
DO i=1,OLx |
314 |
|
localTij( 1-i , 1-j )=localTij( 1-j , i ) |
315 |
|
ENDDO |
316 |
ENDDO |
ENDDO |
317 |
ENDDO |
ENDIF |
318 |
|
IF ( southEastCorner ) THEN |
319 |
|
DO J=1,OLy |
320 |
|
DO I=1,OLx |
321 |
|
localTij(sNx+I, 1-J )=localTij(sNx+J, I ) |
322 |
|
ENDDO |
323 |
|
ENDDO |
324 |
|
ENDIF |
325 |
|
IF ( northWestCorner ) THEN |
326 |
|
DO J=1,OLy |
327 |
|
DO I=1,OLx |
328 |
|
localTij( 1-I ,sNy+J)=localTij( 1-J , sNy+1-I ) |
329 |
|
ENDDO |
330 |
|
ENDDO |
331 |
|
ENDIF |
332 |
|
IF ( northEastCorner ) THEN |
333 |
|
DO J=1,OLy |
334 |
|
DO I=1,OLx |
335 |
|
localTij(sNx+I,sNy+J)=localTij(sNx+J, sNy+1-I ) |
336 |
|
ENDDO |
337 |
|
ENDDO |
338 |
|
ENDIF |
339 |
ENDIF |
ENDIF |
340 |
|
|
341 |
C- Advective flux in X |
C- Advective flux in X |
344 |
af(i,j) = 0. |
af(i,j) = 0. |
345 |
ENDDO |
ENDDO |
346 |
ENDDO |
ENDDO |
347 |
|
|
348 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
349 |
|
#ifndef DISABLE_MULTIDIM_ADVECTION |
350 |
|
CADJ STORE localTij(:,:) = |
351 |
|
CADJ & comlev1_bibj_k_gad_pass, key=passkey, byte=isbyte |
352 |
|
#endif |
353 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
354 |
|
|
355 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
356 |
CALL GAD_FLUXLIMIT_ADV_X( |
CALL GAD_FLUXLIMIT_ADV_X( |
357 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
362 |
CALL GAD_DST3FL_ADV_X( |
CALL GAD_DST3FL_ADV_X( |
363 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
364 |
ELSE |
ELSE |
365 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with multi-dim' |
366 |
ENDIF |
ENDIF |
367 |
|
|
368 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
369 |
DO i=1-Olx,sNx+Olx-1 |
DO i=1-Olx,sNx+Olx-1 |
370 |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
393 |
C-- Y direction |
C-- Y direction |
394 |
IF (calc_fluxes_Y) THEN |
IF (calc_fluxes_Y) THEN |
395 |
|
|
|
C-- Internal exchange for calculations in Y |
|
396 |
IF (useCubedSphereExchange) THEN |
IF (useCubedSphereExchange) THEN |
397 |
DO j=1,Oly |
C-- Internal exchange for calculations in Y |
398 |
DO i=1,Olx |
C-- For cube face corners we need to duplicate the |
399 |
localTij( 1-i , 1-j )=localTij( j , 1-i ) |
C-- j-1 and j+1 values into the null space as follows: |
400 |
localTij( 1-i ,sNy+j)=localTij( j ,sNy+i) |
C |
401 |
localTij(sNx+i, 1-j )=localTij(sNx+1-j, 1-i ) |
C o SW corner: copy T(0,1) into T(0,0) e.g. |
402 |
localTij(sNx+i,sNy+j)=localTij(sNx+1-j,sNy+i) |
C | |
403 |
|
C | x T(1,1) |
404 |
|
C | |
405 |
|
C ----------------|----------- |
406 |
|
C | |
407 |
|
C x T(0,0)<====== x T(1,0) |
408 |
|
C | |
409 |
|
C |
410 |
|
C o NW corner: copy T( 0,sNy ) into T( 0,sNy+1) e.g. |
411 |
|
C | |
412 |
|
C x T(0,sNy+1)<=== x T(1,sNy+1) |
413 |
|
C | |
414 |
|
C ----------------|----------- |
415 |
|
C | |
416 |
|
C | x T(1,sNy) |
417 |
|
C | |
418 |
|
C |
419 |
|
C o NE corner: copy T(sNx+1,sNy ) into T(sNx+1,sNy+1) e.g. |
420 |
|
C | |
421 |
|
C x T(sNx,sNy+1)=====>x T(sNx+1,sNy+1) |
422 |
|
C | |
423 |
|
C ----------------|----------- |
424 |
|
C | |
425 |
|
C x T(sNx,sNy) | |
426 |
|
C | |
427 |
|
C o SE corner: copy T(sNx+1,1 ) into T(sNx+1,0 ) e.g. |
428 |
|
C | |
429 |
|
C x T(sNx,1) | |
430 |
|
C | |
431 |
|
C ----------------|----------- |
432 |
|
C | |
433 |
|
C x T(sNx,0) =====>x T(sNx+1, 0) |
434 |
|
IF ( southWestCorner ) THEN |
435 |
|
DO J=1,Oly |
436 |
|
DO I=1,Olx |
437 |
|
localTij( 1-i , 1-j ) = localTij(j , 1-i ) |
438 |
|
ENDDO |
439 |
ENDDO |
ENDDO |
440 |
ENDDO |
ENDIF |
441 |
|
IF ( southEastCorner ) THEN |
442 |
|
DO J=1,Oly |
443 |
|
DO I=1,Olx |
444 |
|
localTij(sNx+i, 1-j ) = localTij(sNx+1-j, 1-i ) |
445 |
|
ENDDO |
446 |
|
ENDDO |
447 |
|
ENDIF |
448 |
|
IF ( northWestCorner ) THEN |
449 |
|
DO J=1,Oly |
450 |
|
DO I=1,Olx |
451 |
|
localTij( 1-i ,sNy+j) = localTij(j ,sNy+i) |
452 |
|
ENDDO |
453 |
|
ENDDO |
454 |
|
ENDIF |
455 |
|
IF ( northEastCorner ) THEN |
456 |
|
DO J=1,Oly |
457 |
|
DO I=1,Olx |
458 |
|
localTij(sNx+i,sNy+j) = localTij(sNx+1-j,sNy+i) |
459 |
|
ENDDO |
460 |
|
ENDDO |
461 |
|
ENDIF |
462 |
ENDIF |
ENDIF |
463 |
|
|
464 |
C- Advective flux in Y |
C- Advective flux in Y |
467 |
af(i,j) = 0. |
af(i,j) = 0. |
468 |
ENDDO |
ENDDO |
469 |
ENDDO |
ENDDO |
470 |
|
|
471 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
472 |
|
#ifndef DISABLE_MULTIDIM_ADVECTION |
473 |
|
CADJ STORE localTij(:,:) = |
474 |
|
CADJ & comlev1_bibj_k_gad_pass, key=passkey, byte=isbyte |
475 |
|
#endif |
476 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
477 |
|
|
478 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
479 |
CALL GAD_FLUXLIMIT_ADV_Y( |
CALL GAD_FLUXLIMIT_ADV_Y( |
480 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
487 |
ELSE |
ELSE |
488 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
489 |
ENDIF |
ENDIF |
490 |
|
|
491 |
DO j=1-Oly,sNy+Oly-1 |
DO j=1-Oly,sNy+Oly-1 |
492 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
493 |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
513 |
C-- End of Y direction |
C-- End of Y direction |
514 |
ENDIF |
ENDIF |
515 |
|
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
localTijk(i,j,k)=localTij(i,j) |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
516 |
C-- End of ipass loop |
C-- End of ipass loop |
517 |
ENDDO |
ENDDO |
518 |
|
|
519 |
|
IF ( implicitAdvection ) THEN |
520 |
|
C- explicit advection is done ; store tendency in gTracer: |
521 |
|
DO j=1-Oly,sNy+Oly |
522 |
|
DO i=1-Olx,sNx+Olx |
523 |
|
gTracer(i,j,k,bi,bj)= |
524 |
|
& (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer |
525 |
|
ENDDO |
526 |
|
ENDDO |
527 |
|
ELSE |
528 |
|
C- horizontal advection done; store intermediate result in 3D array: |
529 |
|
DO j=1-Oly,sNy+Oly |
530 |
|
DO i=1-Olx,sNx+Olx |
531 |
|
localTijk(i,j,k)=localTij(i,j) |
532 |
|
ENDDO |
533 |
|
ENDDO |
534 |
|
ENDIF |
535 |
|
|
536 |
C-- End of K loop for horizontal fluxes |
C-- End of K loop for horizontal fluxes |
537 |
ENDDO |
ENDDO |
538 |
|
|
539 |
|
IF ( .NOT.implicitAdvection ) THEN |
540 |
C-- Start of k loop for vertical flux |
C-- Start of k loop for vertical flux |
541 |
DO k=Nr,1,-1 |
DO k=Nr,1,-1 |
542 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
543 |
|
kkey = (igadkey-1)*Nr + k |
544 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
545 |
C-- kup Cycles through 1,2 to point to w-layer above |
C-- kup Cycles through 1,2 to point to w-layer above |
546 |
C-- kDown Cycles through 2,1 to point to w-layer below |
C-- kDown Cycles through 2,1 to point to w-layer below |
547 |
kup = 1+MOD(k+1,2) |
kup = 1+MOD(k+1,2) |
548 |
kDown= 1+MOD(k,2) |
kDown= 1+MOD(k,2) |
549 |
|
c kp1=min(Nr,k+1) |
550 |
|
kp1Msk=1. |
551 |
|
if (k.EQ.Nr) kp1Msk=0. |
552 |
|
|
553 |
|
C-- Compute Vertical transport |
554 |
|
#ifdef ALLOW_AIM |
555 |
|
C- a hack to prevent Water-Vapor vert.transport into the stratospheric level Nr |
556 |
|
IF ( k.EQ.1 .OR. |
557 |
|
& (useAIM .AND. tracerIdentity.EQ.GAD_SALINITY .AND. k.EQ.Nr) |
558 |
|
& ) THEN |
559 |
|
#else |
560 |
|
IF ( k.EQ.1 ) THEN |
561 |
|
#endif |
562 |
|
|
563 |
|
C- Surface interface : |
564 |
|
DO j=1-Oly,sNy+Oly |
565 |
|
DO i=1-Olx,sNx+Olx |
566 |
|
rTransKp1(i,j) = kp1Msk*rTrans(i,j) |
567 |
|
rTrans(i,j) = 0. |
568 |
|
fVerT(i,j,kUp) = 0. |
569 |
|
af(i,j) = 0. |
570 |
|
ENDDO |
571 |
|
ENDDO |
572 |
|
|
573 |
|
ELSE |
574 |
|
C- Interior interface : |
575 |
|
|
576 |
|
DO j=1-Oly,sNy+Oly |
577 |
|
DO i=1-Olx,sNx+Olx |
578 |
|
rTransKp1(i,j) = kp1Msk*rTrans(i,j) |
579 |
|
rTrans(i,j) = wVel(i,j,k,bi,bj)*rA(i,j,bi,bj) |
580 |
|
& *maskC(i,j,k-1,bi,bj) |
581 |
|
af(i,j) = 0. |
582 |
|
ENDDO |
583 |
|
ENDDO |
584 |
|
|
585 |
|
#ifdef ALLOW_GMREDI |
586 |
|
C-- Residual transp = Bolus transp + Eulerian transp |
587 |
|
IF (useGMRedi) |
588 |
|
& CALL GMREDI_CALC_WFLOW( |
589 |
|
& rTrans, bi, bj, k, myThid) |
590 |
|
#endif /* ALLOW_GMREDI */ |
591 |
|
|
592 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
593 |
|
CADJ STORE localTijk(:,:,k) |
594 |
|
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
595 |
|
CADJ STORE rTrans(:,:) |
596 |
|
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
597 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
598 |
|
|
|
C-- Get temporary terms used by tendency routines |
|
|
CALL CALC_COMMON_FACTORS ( |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k, |
|
|
O xA,yA,uTrans,vTrans,rTrans,maskUp, |
|
|
I myThid) |
|
|
|
|
|
C- Advective flux in R |
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
af(i,j) = 0. |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
|
C Note: wVel needs to be masked |
|
|
IF (K.GE.2) THEN |
|
599 |
C- Compute vertical advective flux in the interior: |
C- Compute vertical advective flux in the interior: |
600 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (vertAdvecScheme.EQ.ENUM_FLUX_LIMIT) THEN |
601 |
CALL GAD_FLUXLIMIT_ADV_R( |
CALL GAD_FLUXLIMIT_ADV_R( |
602 |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
603 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3 ) THEN |
604 |
CALL GAD_DST3_ADV_R( |
CALL GAD_DST3_ADV_R( |
605 |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
606 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
607 |
CALL GAD_DST3FL_ADV_R( |
CALL GAD_DST3FL_ADV_R( |
608 |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
609 |
ELSE |
ELSE |
610 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
611 |
ENDIF |
ENDIF |
|
C- Surface "correction" term at k>1 : |
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
af(i,j) = af(i,j) |
|
|
& + (maskC(i,j,k,bi,bj)-maskC(i,j,k-1,bi,bj))* |
|
|
& rTrans(i,j)*localTijk(i,j,k) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ELSE |
|
|
C- Surface "correction" term at k=1 : |
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
af(i,j) = rTrans(i,j)*localTijk(i,j,k) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
612 |
C- add the advective flux to fVerT |
C- add the advective flux to fVerT |
613 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
614 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
615 |
fVerT(i,j,kUp) = af(i,j) |
fVerT(i,j,kUp) = af(i,j) |
616 |
ENDDO |
ENDDO |
617 |
ENDDO |
ENDDO |
618 |
|
|
619 |
C-- Divergence of fluxes |
C- end Surface/Interior if bloc |
620 |
kp1=min(Nr,k+1) |
ENDIF |
621 |
kp1Msk=1. |
|
622 |
if (k.EQ.Nr) kp1Msk=0. |
#ifdef ALLOW_AUTODIFF_TAMC |
623 |
DO j=1-Oly,sNy+Oly |
CADJ STORE rTrans(:,:) |
624 |
DO i=1-Olx,sNx+Olx |
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
625 |
localTij(i,j)=localTijk(i,j,k)-deltaTtracer* |
CADJ STORE rTranskp1(:,:) |
626 |
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
627 |
& *recip_rA(i,j,bi,bj) |
#endif /* ALLOW_AUTODIFF_TAMC */ |
628 |
& *( fVerT(i,j,kUp)-fVerT(i,j,kDown) |
|
629 |
& -tracer(i,j,k,bi,bj)*rA(i,j,bi,bj)* |
C-- Divergence of vertical fluxes |
630 |
& (wVel(i,j,k,bi,bj)-kp1Msk*wVel(i,j,kp1,bi,bj)) |
DO j=1-Oly,sNy+Oly |
631 |
& )*rkFac |
DO i=1-Olx,sNx+Olx |
632 |
gTracer(i,j,k,bi,bj)= |
localTij(i,j)=localTijk(i,j,k)-deltaTtracer* |
633 |
& (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer |
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
634 |
ENDDO |
& *recip_rA(i,j,bi,bj) |
635 |
ENDDO |
& *( fVerT(i,j,kUp)-fVerT(i,j,kDown) |
636 |
|
& -tracer(i,j,k,bi,bj)*(rTrans(i,j)-rTransKp1(i,j)) |
637 |
|
& )*rkFac |
638 |
|
gTracer(i,j,k,bi,bj)= |
639 |
|
& (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer |
640 |
|
ENDDO |
641 |
|
ENDDO |
642 |
|
|
643 |
C-- End of K loop for vertical flux |
C-- End of K loop for vertical flux |
644 |
ENDDO |
ENDDO |
645 |
|
C-- end of if not.implicitAdvection block |
646 |
|
ENDIF |
647 |
|
|
648 |
RETURN |
RETURN |
649 |
END |
END |