1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
C $Name$ |
3 |
|
|
|
CBOI |
|
|
C !TITLE: pkg/generic\_advdiff |
|
|
C !AUTHORS: adcroft@mit.edu |
|
|
C !INTRODUCTION: Generic Advection Diffusion Package |
|
|
C |
|
|
C Package "generic\_advdiff" provides a common set of routines for calculating |
|
|
C advective/diffusive fluxes for tracers (cell centered quantities on a C-grid). |
|
|
C |
|
|
C Many different advection schemes are available: the standard centered |
|
|
C second order, centered fourth order and upwind biased third order schemes |
|
|
C are known as linear methods and require some stable time-stepping method |
|
|
C such as Adams-Bashforth. Alternatives such as flux-limited schemes are |
|
|
C stable in the forward sense and are best combined with the multi-dimensional |
|
|
C method provided in gad\_advection. |
|
|
C |
|
|
C There are two high-level routines: |
|
|
C \begin{itemize} |
|
|
C \item{GAD\_CALC\_RHS} calculates all fluxes at time level "n" and is used |
|
|
C for the standard linear schemes. This must be used in conjuction with |
|
|
C Adams-Bashforth time-stepping. Diffusive and parameterized fluxes are |
|
|
C always calculated here. |
|
|
C \item{GAD\_ADVECTION} calculates just the advective fluxes using the |
|
|
C non-linear schemes and can not be used in conjuction with Adams-Bashforth |
|
|
C time-stepping. |
|
|
C \end{itemize} |
|
|
CEOI |
|
|
|
|
4 |
#include "GAD_OPTIONS.h" |
#include "GAD_OPTIONS.h" |
5 |
|
#undef MULTIDIM_OLD_VERSION |
6 |
|
|
7 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
8 |
CBOP |
CBOP |
9 |
C !ROUTINE: GAD_ADVECTION |
C !ROUTINE: GAD_ADVECTION |
10 |
|
|
11 |
C !INTERFACE: ========================================================== |
C !INTERFACE: ========================================================== |
12 |
SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity, |
SUBROUTINE GAD_ADVECTION( |
13 |
U Tracer,Gtracer, |
I implicitAdvection, advectionScheme, vertAdvecScheme, |
14 |
I myTime,myIter,myThid) |
I tracerIdentity, |
15 |
|
I uVel, vVel, wVel, tracer, |
16 |
|
O gTracer, |
17 |
|
I bi,bj, myTime,myIter,myThid) |
18 |
|
|
19 |
C !DESCRIPTION: |
C !DESCRIPTION: |
20 |
C Calculates the tendancy of a tracer due to advection. |
C Calculates the tendancy of a tracer due to advection. |
40 |
#include "SIZE.h" |
#include "SIZE.h" |
41 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
42 |
#include "PARAMS.h" |
#include "PARAMS.h" |
|
#include "DYNVARS.h" |
|
43 |
#include "GRID.h" |
#include "GRID.h" |
44 |
#include "GAD.h" |
#include "GAD.h" |
45 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
46 |
# include "tamc.h" |
# include "tamc.h" |
47 |
# include "tamc_keys.h" |
# include "tamc_keys.h" |
48 |
|
# ifdef ALLOW_PTRACERS |
49 |
|
# include "PTRACERS_SIZE.h" |
50 |
|
# endif |
51 |
#endif |
#endif |
52 |
|
#ifdef ALLOW_EXCH2 |
53 |
|
#include "W2_EXCH2_TOPOLOGY.h" |
54 |
|
#include "W2_EXCH2_PARAMS.h" |
55 |
|
#endif /* ALLOW_EXCH2 */ |
56 |
|
|
57 |
C !INPUT PARAMETERS: =================================================== |
C !INPUT PARAMETERS: =================================================== |
58 |
C bi,bj :: tile indices |
C implicitAdvection :: implicit vertical advection (later on) |
59 |
C advectionScheme :: advection scheme to use |
C advectionScheme :: advection scheme to use (Horizontal plane) |
60 |
C tracerIdentity :: identifier for the tracer (required only for OBCS) |
C vertAdvecScheme :: advection scheme to use (vertical direction) |
61 |
C Tracer :: tracer field |
C tracerIdentity :: tracer identifier (required only for OBCS) |
62 |
C myTime :: current time |
C uVel :: velocity, zonal component |
63 |
C myIter :: iteration number |
C vVel :: velocity, meridional component |
64 |
C myThid :: thread number |
C wVel :: velocity, vertical component |
65 |
INTEGER bi,bj |
C tracer :: tracer field |
66 |
INTEGER advectionScheme |
C bi,bj :: tile indices |
67 |
|
C myTime :: current time |
68 |
|
C myIter :: iteration number |
69 |
|
C myThid :: thread number |
70 |
|
LOGICAL implicitAdvection |
71 |
|
INTEGER advectionScheme, vertAdvecScheme |
72 |
INTEGER tracerIdentity |
INTEGER tracerIdentity |
73 |
_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) |
74 |
|
_RL vVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
75 |
|
_RL wVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
76 |
|
_RL tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
77 |
|
INTEGER bi,bj |
78 |
_RL myTime |
_RL myTime |
79 |
INTEGER myIter |
INTEGER myIter |
80 |
INTEGER myThid |
INTEGER myThid |
81 |
|
|
82 |
C !OUTPUT PARAMETERS: ================================================== |
C !OUTPUT PARAMETERS: ================================================== |
83 |
C gTracer :: tendancy array |
C gTracer :: tendancy array |
84 |
_RL gTracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
_RL gTracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
85 |
|
|
86 |
C !LOCAL VARIABLES: ==================================================== |
C !LOCAL VARIABLES: ==================================================== |
87 |
C maskUp :: 2-D array for mask at W points |
C maskUp :: 2-D array for mask at W points |
88 |
C iMin,iMax,jMin,jMax :: loop range for called routines |
C maskLocW :: 2-D array for mask at West points |
89 |
C i,j,k :: loop indices |
C maskLocS :: 2-D array for mask at South points |
90 |
C kup :: index into 2 1/2D array, toggles between 1 and 2 |
C iMin,iMax, :: loop range for called routines |
91 |
C kdown :: index into 2 1/2D array, toggles between 2 and 1 |
C jMin,jMax :: loop range for called routines |
92 |
C kp1 :: =k+1 for k<Nr, =Nr for k=Nr |
C [iMin,iMax]Upd :: loop range to update tracer field |
93 |
C xA,yA :: areas of X and Y face of tracer cells |
C [jMin,jMax]Upd :: loop range to update tracer field |
94 |
C uTrans,vTrans,rTrans :: 2-D arrays of volume transports at U,V and W points |
C i,j,k :: loop indices |
95 |
C rTransKp1 :: vertical volume transport at interface k+1 |
C kup :: index into 2 1/2D array, toggles between 1 and 2 |
96 |
C af :: 2-D array for horizontal advective flux |
C kdown :: index into 2 1/2D array, toggles between 2 and 1 |
97 |
C fVerT :: 2 1/2D arrays for vertical advective flux |
C kp1 :: =k+1 for k<Nr, =Nr for k=Nr |
98 |
C localTij :: 2-D array used as temporary local copy of tracer fld |
C xA,yA :: areas of X and Y face of tracer cells |
99 |
C localTijk :: 3-D array used as temporary local copy of tracer fld |
C uTrans,vTrans :: 2-D arrays of volume transports at U,V points |
100 |
C kp1Msk :: flag (0,1) to act as over-riding mask for W levels |
C rTrans :: 2-D arrays of volume transports at W points |
101 |
C calc_fluxes_X :: logical to indicate to calculate fluxes in X dir |
C rTransKp1 :: vertical volume transport at interface k+1 |
102 |
C calc_fluxes_Y :: logical to indicate to calculate fluxes in Y dir |
C af :: 2-D array for horizontal advective flux |
103 |
C nipass :: number of passes to make in multi-dimensional method |
C afx :: 2-D array for horizontal advective flux, x direction |
104 |
C ipass :: number of the current pass being made |
C afy :: 2-D array for horizontal advective flux, y direction |
105 |
|
C fVerT :: 2 1/2D arrays for vertical advective flux |
106 |
|
C localTij :: 2-D array, temporary local copy of tracer fld |
107 |
|
C localTijk :: 3-D array, temporary local copy of tracer fld |
108 |
|
C kp1Msk :: flag (0,1) for over-riding mask for W levels |
109 |
|
C calc_fluxes_X :: logical to indicate to calculate fluxes in X dir |
110 |
|
C calc_fluxes_Y :: logical to indicate to calculate fluxes in Y dir |
111 |
|
C interiorOnly :: only update the interior of myTile, but not the edges |
112 |
|
C overlapOnly :: only update the edges of myTile, but not the interior |
113 |
|
C nipass :: number of passes in multi-dimensional method |
114 |
|
C ipass :: number of the current pass being made |
115 |
|
C myTile :: variables used to determine which cube face |
116 |
|
C nCFace :: owns a tile for cube grid runs using |
117 |
|
C :: multi-dim advection. |
118 |
|
C [N,S,E,W]_edge :: true if N,S,E,W edge of myTile is an Edge of the cube |
119 |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
120 |
|
_RS maskLocW(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
121 |
|
_RS maskLocS(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
122 |
INTEGER iMin,iMax,jMin,jMax |
INTEGER iMin,iMax,jMin,jMax |
123 |
|
INTEGER iMinUpd,iMaxUpd,jMinUpd,jMaxUpd |
124 |
INTEGER i,j,k,kup,kDown |
INTEGER i,j,k,kup,kDown |
125 |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
126 |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
129 |
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
130 |
_RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
131 |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
132 |
|
_RL afx (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
133 |
|
_RL afy (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
134 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
135 |
_RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL localTij(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
136 |
_RL localTijk(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL localTijk(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
137 |
_RL kp1Msk |
_RL kp1Msk |
138 |
LOGICAL calc_fluxes_X,calc_fluxes_Y |
LOGICAL calc_fluxes_X, calc_fluxes_Y, withSigns |
139 |
|
LOGICAL interiorOnly, overlapOnly |
140 |
INTEGER nipass,ipass |
INTEGER nipass,ipass |
141 |
|
INTEGER myTile, nCFace |
142 |
|
LOGICAL N_edge, S_edge, E_edge, W_edge |
143 |
CEOP |
CEOP |
144 |
|
|
145 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
157 |
& + act2*max0*max1 |
& + act2*max0*max1 |
158 |
& + act3*max0*max1*max2 |
& + act3*max0*max1*max2 |
159 |
& + act4*max0*max1*max2*max3 |
& + act4*max0*max1*max2*max3 |
160 |
if (tracerIdentity.GT.maxpass) |
if (tracerIdentity.GT.maxpass) then |
161 |
& STOP 'maxpass seems smaller than tracerIdentity' |
print *, 'ph-pass gad_advection ', maxpass, tracerIdentity |
162 |
|
STOP 'maxpass seems smaller than tracerIdentity' |
163 |
|
endif |
164 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
165 |
|
|
166 |
C-- Set up work arrays with valid (i.e. not NaN) values |
C-- Set up work arrays with valid (i.e. not NaN) values |
181 |
ENDDO |
ENDDO |
182 |
ENDDO |
ENDDO |
183 |
|
|
184 |
|
C-- Set tile-specific parameters for horizontal fluxes |
185 |
|
IF (useCubedSphereExchange) THEN |
186 |
|
nipass=3 |
187 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
188 |
|
IF ( nipass.GT.maxcube ) STOP 'maxcube needs to be = 3' |
189 |
|
#endif |
190 |
|
#ifdef ALLOW_EXCH2 |
191 |
|
myTile = W2_myTileList(bi) |
192 |
|
nCFace = exch2_myFace(myTile) |
193 |
|
N_edge = exch2_isNedge(myTile).EQ.1 |
194 |
|
S_edge = exch2_isSedge(myTile).EQ.1 |
195 |
|
E_edge = exch2_isEedge(myTile).EQ.1 |
196 |
|
W_edge = exch2_isWedge(myTile).EQ.1 |
197 |
|
#else |
198 |
|
nCFace = bi |
199 |
|
N_edge = .TRUE. |
200 |
|
S_edge = .TRUE. |
201 |
|
E_edge = .TRUE. |
202 |
|
W_edge = .TRUE. |
203 |
|
#endif |
204 |
|
ELSE |
205 |
|
nipass=2 |
206 |
|
N_edge = .FALSE. |
207 |
|
S_edge = .FALSE. |
208 |
|
E_edge = .FALSE. |
209 |
|
W_edge = .FALSE. |
210 |
|
ENDIF |
211 |
|
|
212 |
iMin = 1-OLx |
iMin = 1-OLx |
213 |
iMax = sNx+OLx |
iMax = sNx+OLx |
214 |
jMin = 1-OLy |
jMin = 1-OLy |
230 |
|
|
231 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
232 |
C-- Residual transp = Bolus transp + Eulerian transp |
C-- Residual transp = Bolus transp + Eulerian transp |
233 |
IF (useGMRedi) |
IF (useGMRedi) |
234 |
& CALL GMREDI_CALC_UVFLOW( |
& CALL GMREDI_CALC_UVFLOW( |
235 |
& uTrans, vTrans, bi, bj, k, myThid) |
& uTrans, vTrans, bi, bj, k, myThid) |
236 |
#endif /* ALLOW_GMREDI */ |
#endif /* ALLOW_GMREDI */ |
237 |
|
|
238 |
C-- Make local copy of tracer array |
C-- Make local copy of tracer array and mask West & South |
239 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
240 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
241 |
localTij(i,j)=tracer(i,j,k,bi,bj) |
localTij(i,j)=tracer(i,j,k,bi,bj) |
242 |
|
maskLocW(i,j)=maskW(i,j,k,bi,bj) |
243 |
|
maskLocS(i,j)=maskS(i,j,k,bi,bj) |
244 |
ENDDO |
ENDDO |
245 |
ENDDO |
ENDDO |
246 |
|
|
247 |
IF (useCubedSphereExchange) THEN |
IF (useCubedSphereExchange) THEN |
248 |
nipass=3 |
withSigns = .FALSE. |
249 |
#ifdef ALLOW_AUTODIFF_TAMC |
CALL FILL_CS_CORNER_UV_RS( |
250 |
if ( nipass.GT.maxcube ) |
& withSigns, maskLocW,maskLocS, bi,bj, myThid ) |
|
& STOP 'maxcube needs to be = 3' |
|
|
#endif |
|
|
ELSE |
|
|
nipass=1 |
|
251 |
ENDIF |
ENDIF |
|
cph nipass=1 |
|
252 |
|
|
253 |
C-- Multiple passes for different directions on different tiles |
C-- Multiple passes for different directions on different tiles |
254 |
|
C-- For cube need one pass for each of red, green and blue axes. |
255 |
DO ipass=1,nipass |
DO ipass=1,nipass |
256 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
257 |
passkey = ipass + (k-1) *maxcube |
passkey = ipass + (k-1) *maxcube |
261 |
ENDIF |
ENDIF |
262 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
263 |
|
|
264 |
IF (nipass.EQ.3) THEN |
interiorOnly = .FALSE. |
265 |
calc_fluxes_X=.FALSE. |
overlapOnly = .FALSE. |
266 |
calc_fluxes_Y=.FALSE. |
IF (useCubedSphereExchange) THEN |
267 |
IF (ipass.EQ.1 .AND. (bi.EQ.1 .OR. bi.EQ.2) ) THEN |
#ifdef MULTIDIM_OLD_VERSION |
268 |
calc_fluxes_X=.TRUE. |
C- CubedSphere : pass 3 times, with full update of local tracer field |
269 |
ELSEIF (ipass.EQ.1 .AND. (bi.EQ.4 .OR. bi.EQ.5) ) THEN |
IF (ipass.EQ.1) THEN |
270 |
calc_fluxes_Y=.TRUE. |
calc_fluxes_X = nCFace.EQ.1 .OR. nCFace.EQ.2 |
271 |
ELSEIF (ipass.EQ.2 .AND. (bi.EQ.1 .OR. bi.EQ.6) ) THEN |
calc_fluxes_Y = nCFace.EQ.4 .OR. nCFace.EQ.5 |
272 |
calc_fluxes_Y=.TRUE. |
ELSEIF (ipass.EQ.2) THEN |
273 |
ELSEIF (ipass.EQ.2 .AND. (bi.EQ.3 .OR. bi.EQ.4) ) THEN |
calc_fluxes_X = nCFace.EQ.3 .OR. nCFace.EQ.4 |
274 |
calc_fluxes_X=.TRUE. |
calc_fluxes_Y = nCFace.EQ.6 .OR. nCFace.EQ.1 |
275 |
ELSEIF (ipass.EQ.3 .AND. (bi.EQ.2 .OR. bi.EQ.3) ) THEN |
#else /* MULTIDIM_OLD_VERSION */ |
276 |
calc_fluxes_Y=.TRUE. |
C- CubedSphere : pass 3 times, with partial update of local tracer field |
277 |
ELSEIF (ipass.EQ.3 .AND. (bi.EQ.5 .OR. bi.EQ.6) ) THEN |
IF (ipass.EQ.1) THEN |
278 |
calc_fluxes_X=.TRUE. |
overlapOnly = MOD(nCFace,3).EQ.0 |
279 |
|
interiorOnly = MOD(nCFace,3).NE.0 |
280 |
|
calc_fluxes_X = nCFace.EQ.6 .OR. nCFace.EQ.1 .OR. nCFace.EQ.2 |
281 |
|
calc_fluxes_Y = nCFace.EQ.3 .OR. nCFace.EQ.4 .OR. nCFace.EQ.5 |
282 |
|
ELSEIF (ipass.EQ.2) THEN |
283 |
|
overlapOnly = MOD(nCFace,3).EQ.2 |
284 |
|
calc_fluxes_X = nCFace.EQ.2 .OR. nCFace.EQ.3 .OR. nCFace.EQ.4 |
285 |
|
calc_fluxes_Y = nCFace.EQ.5 .OR. nCFace.EQ.6 .OR. nCFace.EQ.1 |
286 |
|
#endif /* MULTIDIM_OLD_VERSION */ |
287 |
|
ELSE |
288 |
|
calc_fluxes_X = nCFace.EQ.5 .OR. nCFace.EQ.6 |
289 |
|
calc_fluxes_Y = nCFace.EQ.2 .OR. nCFace.EQ.3 |
290 |
ENDIF |
ENDIF |
291 |
ELSE |
ELSE |
292 |
calc_fluxes_X=.TRUE. |
C- not CubedSphere |
293 |
calc_fluxes_Y=.TRUE. |
calc_fluxes_X = MOD(ipass,2).EQ.1 |
294 |
|
calc_fluxes_Y = .NOT.calc_fluxes_X |
295 |
ENDIF |
ENDIF |
296 |
|
|
297 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
298 |
C-- X direction |
C-- X direction |
299 |
IF (calc_fluxes_X) THEN |
IF (calc_fluxes_X) THEN |
300 |
|
|
301 |
C-- Internal exchange for calculations in X |
C- Do not compute fluxes if |
302 |
IF (useCubedSphereExchange) THEN |
C a) needed in overlap only |
303 |
DO j=1,Oly |
C and b) the overlap of myTile are not cube-face Edges |
304 |
DO i=1,Olx |
IF ( .NOT.overlapOnly .OR. N_edge .OR. S_edge ) THEN |
305 |
localTij( 1-i , 1-j )=localTij( 1-j , i ) |
|
306 |
localTij( 1-i ,sNy+j)=localTij( 1-j , sNy+1-i ) |
C- Internal exchange for calculations in X |
307 |
localTij(sNx+i, 1-j )=localTij(sNx+j, i ) |
#ifdef MULTIDIM_OLD_VERSION |
308 |
localTij(sNx+i,sNy+j)=localTij(sNx+j, sNy+1-i ) |
IF ( useCubedSphereExchange ) THEN |
309 |
ENDDO |
#else |
310 |
ENDDO |
IF ( useCubedSphereExchange .AND. |
311 |
ENDIF |
& ( overlapOnly .OR. ipass.EQ.1 ) ) THEN |
312 |
|
#endif |
313 |
|
CALL FILL_CS_CORNER_TR_RL( .TRUE., localTij, bi,bj, myThid ) |
314 |
|
ENDIF |
315 |
|
|
316 |
C- Advective flux in X |
C- Advective flux in X |
317 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
318 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
319 |
af(i,j) = 0. |
af(i,j) = 0. |
320 |
ENDDO |
ENDDO |
321 |
ENDDO |
ENDDO |
322 |
|
|
323 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
324 |
#ifndef DISABLE_MULTIDIM_ADVECTION |
#ifndef DISABLE_MULTIDIM_ADVECTION |
327 |
#endif |
#endif |
328 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
329 |
|
|
330 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
331 |
CALL GAD_FLUXLIMIT_ADV_X( |
CALL GAD_FLUXLIMIT_ADV_X( bi,bj,k, deltaTtracer, |
332 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
I uTrans, uVel, maskLocW, localTij, |
333 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
O af, myThid ) |
334 |
CALL GAD_DST3_ADV_X( |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
335 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
CALL GAD_DST3_ADV_X( bi,bj,k, deltaTtracer, |
336 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
I uTrans, uVel, maskLocW, localTij, |
337 |
CALL GAD_DST3FL_ADV_X( |
O af, myThid ) |
338 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
339 |
ELSE |
CALL GAD_DST3FL_ADV_X( bi,bj,k, deltaTtracer, |
340 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with multi-dim' |
I uTrans, uVel, maskLocW, localTij, |
341 |
ENDIF |
O af, myThid ) |
342 |
|
ELSE |
343 |
|
STOP 'GAD_ADVECTION: adv. scheme incompatibale with multi-dim' |
344 |
|
ENDIF |
345 |
|
|
346 |
DO j=1-Oly,sNy+Oly |
C- Advective flux in X : done |
347 |
DO i=1-Olx,sNx+Olx-1 |
ENDIF |
348 |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
|
349 |
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
C- Internal exchange for next calculations in Y |
350 |
& *recip_rA(i,j,bi,bj) |
IF ( overlapOnly .AND. ipass.EQ.1 ) THEN |
351 |
& *( af(i+1,j)-af(i,j) |
CALL FILL_CS_CORNER_TR_RL(.FALSE., localTij, bi,bj, myThid ) |
352 |
& -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j)) |
ENDIF |
353 |
& ) |
|
354 |
ENDDO |
C- Update the local tracer field where needed: |
355 |
ENDDO |
|
356 |
|
C update in overlap-Only |
357 |
|
IF ( overlapOnly ) THEN |
358 |
|
iMinUpd = 1-Olx+1 |
359 |
|
iMaxUpd = sNx+Olx-1 |
360 |
|
C- notes: these 2 lines below have no real effect (because recip_hFac=0 |
361 |
|
C in corner region) but safer to keep them. |
362 |
|
IF ( W_edge ) iMinUpd = 1 |
363 |
|
IF ( E_edge ) iMaxUpd = sNx |
364 |
|
|
365 |
|
IF ( S_edge ) THEN |
366 |
|
DO j=1-Oly,0 |
367 |
|
DO i=iMinUpd,iMaxUpd |
368 |
|
localTij(i,j)=localTij(i,j)-deltaTtracer* |
369 |
|
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
370 |
|
& *recip_rA(i,j,bi,bj) |
371 |
|
& *( af(i+1,j)-af(i,j) |
372 |
|
& -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j)) |
373 |
|
& ) |
374 |
|
ENDDO |
375 |
|
ENDDO |
376 |
|
ENDIF |
377 |
|
IF ( N_edge ) THEN |
378 |
|
DO j=sNy+1,sNy+Oly |
379 |
|
DO i=iMinUpd,iMaxUpd |
380 |
|
localTij(i,j)=localTij(i,j)-deltaTtracer* |
381 |
|
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
382 |
|
& *recip_rA(i,j,bi,bj) |
383 |
|
& *( af(i+1,j)-af(i,j) |
384 |
|
& -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j)) |
385 |
|
& ) |
386 |
|
ENDDO |
387 |
|
ENDDO |
388 |
|
ENDIF |
389 |
|
|
390 |
|
ELSE |
391 |
|
C do not only update the overlap |
392 |
|
jMinUpd = 1-Oly |
393 |
|
jMaxUpd = sNy+Oly |
394 |
|
IF ( interiorOnly .AND. S_edge ) jMinUpd = 1 |
395 |
|
IF ( interiorOnly .AND. N_edge ) jMaxUpd = sNy |
396 |
|
DO j=jMinUpd,jMaxUpd |
397 |
|
DO i=1-Olx+1,sNx+Olx-1 |
398 |
|
localTij(i,j)=localTij(i,j)-deltaTtracer* |
399 |
|
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
400 |
|
& *recip_rA(i,j,bi,bj) |
401 |
|
& *( af(i+1,j)-af(i,j) |
402 |
|
& -tracer(i,j,k,bi,bj)*(uTrans(i+1,j)-uTrans(i,j)) |
403 |
|
& ) |
404 |
|
ENDDO |
405 |
|
ENDDO |
406 |
|
C- keep advective flux (for diagnostics) |
407 |
|
DO j=1-Oly,sNy+Oly |
408 |
|
DO i=1-Olx,sNx+Olx |
409 |
|
afx(i,j) = af(i,j) |
410 |
|
ENDDO |
411 |
|
ENDDO |
412 |
|
|
413 |
#ifdef ALLOW_OBCS |
#ifdef ALLOW_OBCS |
414 |
C-- Apply open boundary conditions |
C- Apply open boundary conditions |
415 |
IF (useOBCS) THEN |
IF ( useOBCS ) THEN |
416 |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
417 |
CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid ) |
CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid ) |
418 |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
419 |
CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid ) |
CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid ) |
420 |
END IF |
ENDIF |
421 |
END IF |
ENDIF |
422 |
#endif /* ALLOW_OBCS */ |
#endif /* ALLOW_OBCS */ |
423 |
|
|
424 |
|
C- end if/else update overlap-Only |
425 |
|
ENDIF |
426 |
|
|
427 |
C-- End of X direction |
C-- End of X direction |
428 |
ENDIF |
ENDIF |
429 |
|
|
430 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
431 |
C-- Y direction |
C-- Y direction |
432 |
IF (calc_fluxes_Y) THEN |
IF (calc_fluxes_Y) THEN |
433 |
|
|
434 |
C-- Internal exchange for calculations in Y |
C- Do not compute fluxes if |
435 |
IF (useCubedSphereExchange) THEN |
C a) needed in overlap only |
436 |
DO j=1,Oly |
C and b) the overlap of myTile are not cube-face edges |
437 |
DO i=1,Olx |
IF ( .NOT.overlapOnly .OR. E_edge .OR. W_edge ) THEN |
438 |
localTij( 1-i , 1-j )=localTij( j , 1-i ) |
|
439 |
localTij( 1-i ,sNy+j)=localTij( j ,sNy+i) |
C- Internal exchange for calculations in Y |
440 |
localTij(sNx+i, 1-j )=localTij(sNx+1-j, 1-i ) |
#ifdef MULTIDIM_OLD_VERSION |
441 |
localTij(sNx+i,sNy+j)=localTij(sNx+1-j,sNy+i) |
IF ( useCubedSphereExchange ) THEN |
442 |
ENDDO |
#else |
443 |
ENDDO |
IF ( useCubedSphereExchange .AND. |
444 |
ENDIF |
& ( overlapOnly .OR. ipass.EQ.1 ) ) THEN |
445 |
|
#endif |
446 |
|
CALL FILL_CS_CORNER_TR_RL(.FALSE., localTij, bi,bj, myThid ) |
447 |
|
ENDIF |
448 |
|
|
449 |
C- Advective flux in Y |
C- Advective flux in Y |
450 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
451 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
452 |
af(i,j) = 0. |
af(i,j) = 0. |
453 |
ENDDO |
ENDDO |
454 |
ENDDO |
ENDDO |
455 |
|
|
456 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
457 |
#ifndef DISABLE_MULTIDIM_ADVECTION |
#ifndef DISABLE_MULTIDIM_ADVECTION |
460 |
#endif |
#endif |
461 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
462 |
|
|
463 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
464 |
CALL GAD_FLUXLIMIT_ADV_Y( |
CALL GAD_FLUXLIMIT_ADV_Y( bi,bj,k, deltaTtracer, |
465 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
I vTrans, vVel, maskLocS, localTij, |
466 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
O af, myThid ) |
467 |
CALL GAD_DST3_ADV_Y( |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
468 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
CALL GAD_DST3_ADV_Y( bi,bj,k, deltaTtracer, |
469 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
I vTrans, vVel, maskLocS, localTij, |
470 |
CALL GAD_DST3FL_ADV_Y( |
O af, myThid ) |
471 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
472 |
ELSE |
CALL GAD_DST3FL_ADV_Y( bi,bj,k, deltaTtracer, |
473 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
I vTrans, vVel, maskLocS, localTij, |
474 |
ENDIF |
O af, myThid ) |
475 |
|
ELSE |
476 |
|
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
477 |
|
ENDIF |
478 |
|
|
479 |
DO j=1-Oly,sNy+Oly-1 |
C- Advective flux in Y : done |
480 |
DO i=1-Olx,sNx+Olx |
ENDIF |
481 |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
|
482 |
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
C- Internal exchange for next calculations in X |
483 |
& *recip_rA(i,j,bi,bj) |
IF ( overlapOnly .AND. ipass.EQ.1 ) THEN |
484 |
& *( af(i,j+1)-af(i,j) |
CALL FILL_CS_CORNER_TR_RL( .TRUE., localTij, bi,bj, myThid ) |
485 |
& -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j)) |
ENDIF |
486 |
& ) |
|
487 |
ENDDO |
C- Update the local tracer field where needed: |
488 |
ENDDO |
|
489 |
|
C update in overlap-Only |
490 |
|
IF ( overlapOnly ) THEN |
491 |
|
jMinUpd = 1-Oly+1 |
492 |
|
jMaxUpd = sNy+Oly-1 |
493 |
|
C- notes: these 2 lines below have no real effect (because recip_hFac=0 |
494 |
|
C in corner region) but safer to keep them. |
495 |
|
IF ( S_edge ) jMinUpd = 1 |
496 |
|
IF ( N_edge ) jMaxUpd = sNy |
497 |
|
|
498 |
|
IF ( W_edge ) THEN |
499 |
|
DO j=jMinUpd,jMaxUpd |
500 |
|
DO i=1-Olx,0 |
501 |
|
localTij(i,j)=localTij(i,j)-deltaTtracer* |
502 |
|
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
503 |
|
& *recip_rA(i,j,bi,bj) |
504 |
|
& *( af(i,j+1)-af(i,j) |
505 |
|
& -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j)) |
506 |
|
& ) |
507 |
|
ENDDO |
508 |
|
ENDDO |
509 |
|
ENDIF |
510 |
|
IF ( E_edge ) THEN |
511 |
|
DO j=jMinUpd,jMaxUpd |
512 |
|
DO i=sNx+1,sNx+Olx |
513 |
|
localTij(i,j)=localTij(i,j)-deltaTtracer* |
514 |
|
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
515 |
|
& *recip_rA(i,j,bi,bj) |
516 |
|
& *( af(i,j+1)-af(i,j) |
517 |
|
& -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j)) |
518 |
|
& ) |
519 |
|
ENDDO |
520 |
|
ENDDO |
521 |
|
ENDIF |
522 |
|
|
523 |
|
ELSE |
524 |
|
C do not only update the overlap |
525 |
|
iMinUpd = 1-Olx |
526 |
|
iMaxUpd = sNx+Olx |
527 |
|
IF ( interiorOnly .AND. W_edge ) iMinUpd = 1 |
528 |
|
IF ( interiorOnly .AND. E_edge ) iMaxUpd = sNx |
529 |
|
DO j=1-Oly+1,sNy+Oly-1 |
530 |
|
DO i=iMinUpd,iMaxUpd |
531 |
|
localTij(i,j)=localTij(i,j)-deltaTtracer* |
532 |
|
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
533 |
|
& *recip_rA(i,j,bi,bj) |
534 |
|
& *( af(i,j+1)-af(i,j) |
535 |
|
& -tracer(i,j,k,bi,bj)*(vTrans(i,j+1)-vTrans(i,j)) |
536 |
|
& ) |
537 |
|
ENDDO |
538 |
|
ENDDO |
539 |
|
C- keep advective flux (for diagnostics) |
540 |
|
DO j=1-Oly,sNy+Oly |
541 |
|
DO i=1-Olx,sNx+Olx |
542 |
|
afy(i,j) = af(i,j) |
543 |
|
ENDDO |
544 |
|
ENDDO |
545 |
|
|
546 |
#ifdef ALLOW_OBCS |
#ifdef ALLOW_OBCS |
547 |
C-- Apply open boundary conditions |
C- Apply open boundary conditions |
548 |
IF (useOBCS) THEN |
IF (useOBCS) THEN |
549 |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
550 |
CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid ) |
CALL OBCS_APPLY_TLOC( bi, bj, k, localTij, myThid ) |
551 |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
552 |
CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid ) |
CALL OBCS_APPLY_SLOC( bi, bj, k, localTij, myThid ) |
553 |
END IF |
ENDIF |
554 |
END IF |
ENDIF |
555 |
#endif /* ALLOW_OBCS */ |
#endif /* ALLOW_OBCS */ |
556 |
|
|
557 |
|
C end if/else update overlap-Only |
558 |
|
ENDIF |
559 |
|
|
560 |
C-- End of Y direction |
C-- End of Y direction |
561 |
ENDIF |
ENDIF |
562 |
|
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
localTijk(i,j,k)=localTij(i,j) |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
563 |
C-- End of ipass loop |
C-- End of ipass loop |
564 |
ENDDO |
ENDDO |
565 |
|
|
566 |
|
IF ( implicitAdvection ) THEN |
567 |
|
C- explicit advection is done ; store tendency in gTracer: |
568 |
|
DO j=1-Oly,sNy+Oly |
569 |
|
DO i=1-Olx,sNx+Olx |
570 |
|
gTracer(i,j,k,bi,bj)= |
571 |
|
& (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer |
572 |
|
ENDDO |
573 |
|
ENDDO |
574 |
|
ELSE |
575 |
|
C- horizontal advection done; store intermediate result in 3D array: |
576 |
|
DO j=1-Oly,sNy+Oly |
577 |
|
DO i=1-Olx,sNx+Olx |
578 |
|
localTijk(i,j,k)=localTij(i,j) |
579 |
|
ENDDO |
580 |
|
ENDDO |
581 |
|
ENDIF |
582 |
|
|
583 |
|
#ifdef ALLOW_DEBUG |
584 |
|
IF ( debugLevel .GE. debLevB |
585 |
|
& .AND. tracerIdentity.EQ.GAD_TEMPERATURE |
586 |
|
& .AND. k.LE.3 .AND. myIter.EQ.1+nIter0 |
587 |
|
& .AND. nPx.EQ.1 .AND. nPy.EQ.1 |
588 |
|
& .AND. useCubedSphereExchange ) THEN |
589 |
|
CALL DEBUG_CS_CORNER_UV( ' afx,afy from GAD_ADVECTION', |
590 |
|
& afx,afy, k, standardMessageUnit,bi,bj,myThid ) |
591 |
|
ENDIF |
592 |
|
#endif /* ALLOW_DEBUG */ |
593 |
|
|
594 |
C-- End of K loop for horizontal fluxes |
C-- End of K loop for horizontal fluxes |
595 |
ENDDO |
ENDDO |
596 |
|
|
597 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
598 |
|
|
599 |
|
IF ( .NOT.implicitAdvection ) THEN |
600 |
C-- Start of k loop for vertical flux |
C-- Start of k loop for vertical flux |
601 |
DO k=Nr,1,-1 |
DO k=Nr,1,-1 |
602 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
603 |
kkey = (ikey-1)*Nr + k |
kkey = (igadkey-1)*Nr + k |
604 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
|
|
|
605 |
C-- kup Cycles through 1,2 to point to w-layer above |
C-- kup Cycles through 1,2 to point to w-layer above |
606 |
C-- kDown Cycles through 2,1 to point to w-layer below |
C-- kDown Cycles through 2,1 to point to w-layer below |
607 |
kup = 1+MOD(k+1,2) |
kup = 1+MOD(k+1,2) |
608 |
kDown= 1+MOD(k,2) |
kDown= 1+MOD(k,2) |
609 |
c kp1=min(Nr,k+1) |
c kp1=min(Nr,k+1) |
610 |
kp1Msk=1. |
kp1Msk=1. |
611 |
if (k.EQ.Nr) kp1Msk=0. |
if (k.EQ.Nr) kp1Msk=0. |
|
|
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
|
|
CADJ STORE localTijk(:,:,k) |
|
|
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
|
|
CADJ STORE rTrans(:,:) |
|
|
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
|
612 |
|
|
613 |
C-- Compute Vertical transport |
C-- Compute Vertical transport |
614 |
C Note: wVel needs to be masked |
#ifdef ALLOW_AIM |
615 |
|
C- a hack to prevent Water-Vapor vert.transport into the stratospheric level Nr |
616 |
|
IF ( k.EQ.1 .OR. |
617 |
|
& (useAIM .AND. tracerIdentity.EQ.GAD_SALINITY .AND. k.EQ.Nr) |
618 |
|
& ) THEN |
619 |
|
#else |
620 |
|
IF ( k.EQ.1 ) THEN |
621 |
|
#endif |
622 |
|
|
|
IF (k.EQ.1) THEN |
|
623 |
C- Surface interface : |
C- Surface interface : |
624 |
|
DO j=1-Oly,sNy+Oly |
625 |
|
DO i=1-Olx,sNx+Olx |
626 |
|
rTransKp1(i,j) = kp1Msk*rTrans(i,j) |
627 |
|
rTrans(i,j) = 0. |
628 |
|
fVerT(i,j,kUp) = 0. |
629 |
|
ENDDO |
630 |
|
ENDDO |
631 |
|
|
632 |
DO j=1-Oly,sNy+Oly |
ELSE |
|
DO i=1-Olx,sNx+Olx |
|
|
rTransKp1(i,j) = rTrans(i,j) |
|
|
rTrans(i,j) = 0. |
|
|
fVerT(i,j,kUp) = 0. |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
|
ELSE |
|
633 |
C- Interior interface : |
C- Interior interface : |
634 |
DO j=1-Oly,sNy+Oly |
|
635 |
DO i=1-Olx,sNx+Olx |
DO j=1-Oly,sNy+Oly |
636 |
rTransKp1(i,j) = kp1Msk*rTrans(i,j) |
DO i=1-Olx,sNx+Olx |
637 |
rTrans(i,j) = wVel(i,j,k,bi,bj)*rA(i,j,bi,bj) |
rTransKp1(i,j) = kp1Msk*rTrans(i,j) |
638 |
& *maskC(i,j,k-1,bi,bj) |
rTrans(i,j) = wVel(i,j,k,bi,bj)*rA(i,j,bi,bj) |
639 |
af(i,j) = 0. |
& *maskC(i,j,k-1,bi,bj) |
640 |
ENDDO |
fVerT(i,j,kUp) = 0. |
641 |
ENDDO |
ENDDO |
642 |
|
ENDDO |
643 |
|
|
644 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
645 |
C-- Residual transp = Bolus transp + Eulerian transp |
C-- Residual transp = Bolus transp + Eulerian transp |
646 |
IF (useGMRedi) |
IF (useGMRedi) |
647 |
& CALL GMREDI_CALC_WFLOW( |
& CALL GMREDI_CALC_WFLOW( |
648 |
& rTrans, bi, bj, k, myThid) |
& rTrans, bi, bj, k, myThid) |
649 |
#endif /* ALLOW_GMREDI */ |
#endif /* ALLOW_GMREDI */ |
650 |
|
|
651 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
652 |
|
CADJ STORE localTijk(:,:,k) |
653 |
|
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
654 |
|
CADJ STORE rTrans(:,:) |
655 |
|
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
656 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
657 |
|
|
658 |
C- Compute vertical advective flux in the interior: |
C- Compute vertical advective flux in the interior: |
659 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (vertAdvecScheme.EQ.ENUM_FLUX_LIMIT) THEN |
660 |
CALL GAD_FLUXLIMIT_ADV_R( |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
661 |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
CALL GAD_FLUXLIMIT_ADV_R( bi,bj,k, deltaTtracer, |
662 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
I rTrans, wVel, localTijk, |
663 |
CALL GAD_DST3_ADV_R( |
O fVerT(1-Olx,1-Oly,kUp), myThid ) |
664 |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3 ) THEN |
665 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
CALL GAD_DST3_ADV_R( bi,bj,k, deltaTtracer, |
666 |
CALL GAD_DST3FL_ADV_R( |
I rTrans, wVel, localTijk, |
667 |
& bi,bj,k,deltaTtracer,rTrans,wVel,localTijk,af,myThid) |
O fVerT(1-Olx,1-Oly,kUp), myThid ) |
668 |
ELSE |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
669 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
CALL GAD_DST3FL_ADV_R( bi,bj,k, deltaTtracer, |
670 |
ENDIF |
I rTrans, wVel, localTijk, |
671 |
C- add the advective flux to fVerT |
O fVerT(1-Olx,1-Oly,kUp), myThid ) |
672 |
DO j=1-Oly,sNy+Oly |
ELSE |
673 |
DO i=1-Olx,sNx+Olx |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
674 |
fVerT(i,j,kUp) = af(i,j) |
ENDIF |
|
ENDDO |
|
|
ENDDO |
|
675 |
|
|
676 |
C- end Surface/Interior if bloc |
C- end Surface/Interior if bloc |
677 |
ENDIF |
ENDIF |
678 |
|
|
679 |
C-- Divergence of fluxes |
#ifdef ALLOW_AUTODIFF_TAMC |
680 |
DO j=1-Oly,sNy+Oly |
CADJ STORE rTrans(:,:) |
681 |
DO i=1-Olx,sNx+Olx |
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
682 |
localTij(i,j)=localTijk(i,j,k)-deltaTtracer* |
CADJ STORE rTranskp1(:,:) |
683 |
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
CADJ & = comlev1_bibj_k_gad, key=kkey, byte=isbyte |
684 |
& *recip_rA(i,j,bi,bj) |
#endif /* ALLOW_AUTODIFF_TAMC */ |
685 |
& *( fVerT(i,j,kUp)-fVerT(i,j,kDown) |
|
686 |
& -tracer(i,j,k,bi,bj)*(rTrans(i,j)-rTransKp1(i,j)) |
C-- Divergence of vertical fluxes |
687 |
& )*rkFac |
DO j=1-Oly,sNy+Oly |
688 |
gTracer(i,j,k,bi,bj)= |
DO i=1-Olx,sNx+Olx |
689 |
& (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer |
localTij(i,j)=localTijk(i,j,k)-deltaTtracer* |
690 |
ENDDO |
& _recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
691 |
ENDDO |
& *recip_rA(i,j,bi,bj) |
692 |
|
& *( fVerT(i,j,kUp)-fVerT(i,j,kDown) |
693 |
|
& -tracer(i,j,k,bi,bj)*(rTrans(i,j)-rTransKp1(i,j)) |
694 |
|
& )*rkFac |
695 |
|
gTracer(i,j,k,bi,bj)= |
696 |
|
& (localTij(i,j)-tracer(i,j,k,bi,bj))/deltaTtracer |
697 |
|
ENDDO |
698 |
|
ENDDO |
699 |
|
|
700 |
C-- End of K loop for vertical flux |
C-- End of K loop for vertical flux |
701 |
ENDDO |
ENDDO |
702 |
|
C-- end of if not.implicitAdvection block |
703 |
|
ENDIF |
704 |
|
|
705 |
RETURN |
RETURN |
706 |
END |
END |