7 |
C !ROUTINE: GAD_CALC_RHS |
C !ROUTINE: GAD_CALC_RHS |
8 |
|
|
9 |
C !INTERFACE: ========================================================== |
C !INTERFACE: ========================================================== |
10 |
SUBROUTINE GAD_CALC_RHS( |
SUBROUTINE GAD_CALC_RHS( |
11 |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
12 |
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
I xA, yA, maskUp, uFld, vFld, wFld, |
13 |
I diffKh, diffK4, KappaRT, Tracer, |
I uTrans, vTrans, rTrans, rTransKp1, |
14 |
I tracerIdentity, advectionScheme, calcAdvection, |
I diffKh, diffK4, KappaR, TracerN, TracAB, |
15 |
|
I tracerIdentity, advectionScheme, vertAdvecScheme, |
16 |
|
I calcAdvection, implicitAdvection, applyAB_onTracer, |
17 |
U fVerT, gTracer, |
U fVerT, gTracer, |
18 |
I myThid ) |
I myTime, myIter, myThid ) |
19 |
|
|
20 |
C !DESCRIPTION: |
C !DESCRIPTION: |
21 |
C Calculates the tendancy of a tracer due to advection and diffusion. |
C Calculates the tendency of a tracer due to advection and diffusion. |
22 |
C It calculates the fluxes in each direction indepentently and then |
C It calculates the fluxes in each direction indepentently and then |
23 |
C sets the tendancy to the divergence of these fluxes. The advective |
C sets the tendency to the divergence of these fluxes. The advective |
24 |
C fluxes are only calculated here when using the linear advection schemes |
C fluxes are only calculated here when using the linear advection schemes |
25 |
C otherwise only the diffusive and parameterized fluxes are calculated. |
C otherwise only the diffusive and parameterized fluxes are calculated. |
26 |
C |
C |
29 |
C {\bf F} = {\bf F}_{adv} + {\bf F}_{diff} +{\bf F}_{GM} + {\bf F}_{KPP} |
C {\bf F} = {\bf F}_{adv} + {\bf F}_{diff} +{\bf F}_{GM} + {\bf F}_{KPP} |
30 |
C \end{equation*} |
C \end{equation*} |
31 |
C |
C |
32 |
C The tendancy is the divergence of the fluxes: |
C The tendency is the divergence of the fluxes: |
33 |
C \begin{equation*} |
C \begin{equation*} |
34 |
C G_\theta = G_\theta + \nabla \cdot {\bf F} |
C G_\theta = G_\theta + \nabla \cdot {\bf F} |
35 |
C \end{equation*} |
C \end{equation*} |
36 |
C |
C |
37 |
C The tendancy is assumed to contain data on entry. |
C The tendency is assumed to contain data on entry. |
38 |
|
|
39 |
C !USES: =============================================================== |
C !USES: =============================================================== |
40 |
IMPLICIT NONE |
IMPLICIT NONE |
42 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
43 |
#include "PARAMS.h" |
#include "PARAMS.h" |
44 |
#include "GRID.h" |
#include "GRID.h" |
|
#include "DYNVARS.h" |
|
45 |
#include "SURFACE.h" |
#include "SURFACE.h" |
46 |
#include "GAD.h" |
#include "GAD.h" |
47 |
|
|
51 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
52 |
|
|
53 |
C !INPUT PARAMETERS: =================================================== |
C !INPUT PARAMETERS: =================================================== |
54 |
C bi,bj :: tile indices |
C bi,bj :: tile indices |
55 |
C iMin,iMax,jMin,jMax :: loop range for called routines |
C iMin,iMax :: loop range for called routines |
56 |
C kup :: index into 2 1/2D array, toggles between 1 and 2 |
C jMin,jMax :: loop range for called routines |
57 |
C kdown :: index into 2 1/2D array, toggles between 2 and 1 |
C k :: vertical index |
58 |
C kp1 :: =k+1 for k<Nr, =Nr for k=Nr |
C kM1 :: =k-1 for k>1, =1 for k=1 |
59 |
C xA,yA :: areas of X and Y face of tracer cells |
C kUp :: index into 2 1/2D array, toggles between 1|2 |
60 |
C uTrans,vTrans,rTrans :: 2-D arrays of volume transports at U,V and W points |
C kDown :: index into 2 1/2D array, toggles between 2|1 |
61 |
C maskUp :: 2-D array for mask at W points |
C xA,yA :: areas of X and Y face of tracer cells |
62 |
C diffKh :: horizontal diffusion coefficient |
C maskUp :: 2-D array for mask at W points |
63 |
C diffK4 :: bi-harmonic diffusion coefficient |
C uFld,vFld,wFld :: Local copy of velocity field (3 components) |
64 |
C KappaRT :: 3-D array for vertical diffusion coefficient |
C uTrans,vTrans :: 2-D arrays of volume transports at U,V points |
65 |
C Tracer :: tracer field |
C rTrans :: 2-D arrays of volume transports at W points |
66 |
C tracerIdentity :: identifier for the tracer (required only for KPP) |
C rTransKp1 :: 2-D array of volume trans at W pts, interf k+1 |
67 |
C advectionScheme :: advection scheme to use |
C diffKh :: horizontal diffusion coefficient |
68 |
C calcAdvection :: =False if Advec terms computed with multiDim scheme |
C diffK4 :: bi-harmonic diffusion coefficient |
69 |
C myThid :: thread number |
C KappaR :: 2-D array for vertical diffusion coefficient, interf k |
70 |
|
C TracerN :: tracer field @ time-step n (Note: only used |
71 |
|
C if applying AB on tracer field rather than on tendency gTr) |
72 |
|
C TracAB :: current tracer field (@ time-step n if applying AB on gTr |
73 |
|
C or extrapolated fwd in time to n+1/2 if applying AB on Tr) |
74 |
|
C tracerIdentity :: tracer identifier (required for KPP,GM) |
75 |
|
C advectionScheme :: advection scheme to use (Horizontal plane) |
76 |
|
C vertAdvecScheme :: advection scheme to use (Vertical direction) |
77 |
|
C calcAdvection :: =False if Advec computed with multiDim scheme |
78 |
|
C implicitAdvection:: =True if vertical Advec computed implicitly |
79 |
|
C applyAB_onTracer :: apply Adams-Bashforth on Tracer (rather than on gTr) |
80 |
|
C myTime :: current time |
81 |
|
C myIter :: iteration number |
82 |
|
C myThid :: thread number |
83 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
84 |
INTEGER k,kUp,kDown,kM1 |
INTEGER k,kUp,kDown,kM1 |
85 |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
86 |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
87 |
|
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
88 |
|
_RL uFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
89 |
|
_RL vFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
90 |
|
_RL wFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
91 |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
92 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
93 |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
94 |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
95 |
_RL diffKh, diffK4 |
_RL diffKh, diffK4 |
96 |
_RL KappaRT(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL KappaR(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
97 |
_RL Tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
_RL TracerN(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
98 |
|
_RL TracAB (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
99 |
INTEGER tracerIdentity |
INTEGER tracerIdentity |
100 |
INTEGER advectionScheme |
INTEGER advectionScheme, vertAdvecScheme |
101 |
LOGICAL calcAdvection |
LOGICAL calcAdvection |
102 |
INTEGER myThid |
LOGICAL implicitAdvection, applyAB_onTracer |
103 |
|
_RL myTime |
104 |
|
INTEGER myIter, myThid |
105 |
|
|
106 |
C !OUTPUT PARAMETERS: ================================================== |
C !OUTPUT PARAMETERS: ================================================== |
107 |
C gTracer :: tendancy array |
C gTracer :: tendency array |
108 |
C fVerT :: 2 1/2D arrays for vertical advective flux |
C fVerT :: 2 1/2D arrays for vertical advective flux |
109 |
_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) |
110 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
111 |
|
|
112 |
C !LOCAL VARIABLES: ==================================================== |
C !LOCAL VARIABLES: ==================================================== |
113 |
C i,j :: loop indices |
C i,j :: loop indices |
114 |
C df4 :: used for storing del^2 T for bi-harmonic term |
C df4 :: used for storing del^2 T for bi-harmonic term |
115 |
C fZon :: zonal flux |
C fZon :: zonal flux |
116 |
C fmer :: meridional flux |
C fMer :: meridional flux |
117 |
C af :: advective flux |
C af :: advective flux |
118 |
C df :: diffusive flux |
C df :: diffusive flux |
119 |
C localT :: local copy of tracer field |
C localT :: local copy of tracer field |
120 |
|
C locABT :: local copy of (AB-extrapolated) tracer field |
121 |
|
#ifdef ALLOW_DIAGNOSTICS |
122 |
|
CHARACTER*8 diagName |
123 |
|
CHARACTER*4 GAD_DIAG_SUFX, diagSufx |
124 |
|
EXTERNAL GAD_DIAG_SUFX |
125 |
|
#endif |
126 |
INTEGER i,j |
INTEGER i,j |
127 |
_RL df4 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL df4 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
128 |
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
130 |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL af (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
131 |
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
132 |
_RL localT(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL localT(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
133 |
|
_RL locABT(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
134 |
|
_RL advFac, rAdvFac |
135 |
CEOP |
CEOP |
136 |
|
|
137 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
140 |
fVerT(1,1,kDown) = fVerT(1,1,kDown) |
fVerT(1,1,kDown) = fVerT(1,1,kDown) |
141 |
#endif |
#endif |
142 |
|
|
143 |
|
#ifdef ALLOW_DIAGNOSTICS |
144 |
|
C-- Set diagnostic suffix for the current tracer |
145 |
|
IF ( useDiagnostics ) THEN |
146 |
|
diagSufx = GAD_DIAG_SUFX( tracerIdentity, myThid ) |
147 |
|
ENDIF |
148 |
|
#endif |
149 |
|
|
150 |
|
advFac = 0. _d 0 |
151 |
|
IF (calcAdvection) advFac = 1. _d 0 |
152 |
|
rAdvFac = rkSign*advFac |
153 |
|
IF (implicitAdvection) rAdvFac = 0. _d 0 |
154 |
|
|
155 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
156 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
157 |
fZon(i,j) = 0. _d 0 |
fZon(i,j) = 0. _d 0 |
159 |
fVerT(i,j,kUp) = 0. _d 0 |
fVerT(i,j,kUp) = 0. _d 0 |
160 |
df(i,j) = 0. _d 0 |
df(i,j) = 0. _d 0 |
161 |
df4(i,j) = 0. _d 0 |
df4(i,j) = 0. _d 0 |
|
localT(i,j) = 0. _d 0 |
|
162 |
ENDDO |
ENDDO |
163 |
ENDDO |
ENDDO |
164 |
|
|
165 |
C-- Make local copy of tracer array |
C-- Make local copy of tracer array |
166 |
DO j=1-OLy,sNy+OLy |
IF ( applyAB_onTracer ) THEN |
167 |
DO i=1-OLx,sNx+OLx |
DO j=1-OLy,sNy+OLy |
168 |
localT(i,j)=tracer(i,j,k,bi,bj) |
DO i=1-OLx,sNx+OLx |
169 |
ENDDO |
localT(i,j)=TracerN(i,j,k,bi,bj) |
170 |
ENDDO |
locABT(i,j)= TracAB(i,j,k,bi,bj) |
171 |
|
ENDDO |
172 |
|
ENDDO |
173 |
|
ELSE |
174 |
|
DO j=1-OLy,sNy+OLy |
175 |
|
DO i=1-OLx,sNx+OLx |
176 |
|
localT(i,j)= TracAB(i,j,k,bi,bj) |
177 |
|
locABT(i,j)= TracAB(i,j,k,bi,bj) |
178 |
|
ENDDO |
179 |
|
ENDDO |
180 |
|
ENDIF |
181 |
|
|
182 |
C-- Unless we have already calculated the advection terms we initialize |
C-- Unless we have already calculated the advection terms we initialize |
183 |
C the tendency to zero. |
C the tendency to zero. |
184 |
IF (calcAdvection) THEN |
C <== now done earlier at the beginning of thermodynamics. |
185 |
DO j=1-Oly,sNy+Oly |
c IF (calcAdvection) THEN |
186 |
DO i=1-Olx,sNx+Olx |
c DO j=1-Oly,sNy+Oly |
187 |
gTracer(i,j,k,bi,bj)=0. _d 0 |
c DO i=1-Olx,sNx+Olx |
188 |
ENDDO |
c gTracer(i,j,k,bi,bj)=0. _d 0 |
189 |
ENDDO |
c ENDDO |
190 |
ENDIF |
c ENDDO |
191 |
|
c ENDIF |
192 |
|
|
193 |
C-- Pre-calculate del^2 T if bi-harmonic coefficient is non-zero |
C-- Pre-calculate del^2 T if bi-harmonic coefficient is non-zero |
194 |
IF (diffK4 .NE. 0.) THEN |
IF (diffK4 .NE. 0.) THEN |
206 |
|
|
207 |
C- Advective flux in X |
C- Advective flux in X |
208 |
IF (calcAdvection) THEN |
IF (calcAdvection) THEN |
209 |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
210 |
CALL GAD_C2_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
CALL GAD_C2_ADV_X(bi,bj,k,uTrans,locABT,af,myThid) |
211 |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
ELSEIF ( advectionScheme.EQ.ENUM_UPWIND_1RST |
212 |
CALL GAD_FLUXLIMIT_ADV_X( |
& .OR. advectionScheme.EQ.ENUM_DST2 ) THEN |
213 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localT,af,myThid) |
CALL GAD_DST2U1_ADV_X( bi,bj,k, advectionScheme, |
214 |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
I dTtracerLev(k), uTrans, uFld, locABT, |
215 |
CALL GAD_U3_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
O af, myThid ) |
216 |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
217 |
CALL GAD_C4_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
CALL GAD_FLUXLIMIT_ADV_X( bi,bj,k, dTtracerLev(k), |
218 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
I uTrans, uFld, maskW(1-Olx,1-Oly,k,bi,bj), locABT, |
219 |
CALL GAD_DST3_ADV_X( |
O af, myThid ) |
220 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localT,af,myThid) |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
221 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
CALL GAD_U3_ADV_X(bi,bj,k,uTrans,locABT,af,myThid) |
222 |
CALL GAD_DST3FL_ADV_X( |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
223 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localT,af,myThid) |
CALL GAD_C4_ADV_X(bi,bj,k,uTrans,locABT,af,myThid) |
224 |
ELSE |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
225 |
STOP 'GAD_CALC_RHS: Bad advectionScheme (X)' |
CALL GAD_DST3_ADV_X( bi,bj,k, dTtracerLev(k), |
226 |
ENDIF |
I uTrans, uFld, maskW(1-Olx,1-Oly,k,bi,bj), locABT, |
227 |
DO j=1-Oly,sNy+Oly |
O af, myThid ) |
228 |
DO i=1-Olx,sNx+Olx |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
229 |
fZon(i,j) = fZon(i,j) + af(i,j) |
IF ( inAdMode ) THEN |
230 |
ENDDO |
cph This block is to trick the adjoint: |
231 |
ENDDO |
cph IF inAdExact=.FALSE., we want to use DST3 |
232 |
|
cph with limiters in forward, but without limiters in reverse. |
233 |
|
CALL GAD_DST3_ADV_X( bi,bj,k, dTtracerLev(k), |
234 |
|
I uTrans, uFld, maskW(1-Olx,1-Oly,k,bi,bj), locABT, |
235 |
|
O af, myThid ) |
236 |
|
ELSE |
237 |
|
CALL GAD_DST3FL_ADV_X( bi,bj,k, dTtracerLev(k), |
238 |
|
I uTrans, uFld, maskW(1-Olx,1-Oly,k,bi,bj), locABT, |
239 |
|
O af, myThid ) |
240 |
|
ENDIF |
241 |
|
ELSE |
242 |
|
STOP 'GAD_CALC_RHS: Bad advectionScheme (X)' |
243 |
|
ENDIF |
244 |
|
DO j=1-Oly,sNy+Oly |
245 |
|
DO i=1-Olx,sNx+Olx |
246 |
|
fZon(i,j) = fZon(i,j) + af(i,j) |
247 |
|
ENDDO |
248 |
|
ENDDO |
249 |
|
#ifdef ALLOW_DIAGNOSTICS |
250 |
|
IF ( useDiagnostics ) THEN |
251 |
|
diagName = 'ADVx'//diagSufx |
252 |
|
CALL DIAGNOSTICS_FILL(af,diagName, k,1, 2,bi,bj, myThid) |
253 |
|
ENDIF |
254 |
|
#endif |
255 |
ENDIF |
ENDIF |
256 |
|
|
257 |
C- Diffusive flux in X |
C- Diffusive flux in X |
265 |
ENDDO |
ENDDO |
266 |
ENDIF |
ENDIF |
267 |
|
|
268 |
|
C- Add bi-harmonic diffusive flux in X |
269 |
|
IF (diffK4 .NE. 0.) THEN |
270 |
|
CALL GAD_BIHARM_X(bi,bj,k,xA,df4,diffK4,df,myThid) |
271 |
|
ENDIF |
272 |
|
|
273 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
274 |
C- GM/Redi flux in X |
C- GM/Redi flux in X |
275 |
IF (useGMRedi) THEN |
IF (useGMRedi) THEN |
276 |
C *note* should update GMREDI_XTRANSPORT to use localT and set df *aja* |
C *note* should update GMREDI_XTRANSPORT to set df *aja* |
277 |
CALL GMREDI_XTRANSPORT( |
IF ( applyAB_onTracer ) THEN |
278 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
CALL GMREDI_XTRANSPORT( |
279 |
I xA,Tracer,tracerIdentity, |
I iMin,iMax,jMin,jMax,bi,bj,k, |
280 |
U df, |
I xA,TracerN,tracerIdentity, |
281 |
I myThid) |
U df, |
282 |
|
I myThid) |
283 |
|
ELSE |
284 |
|
CALL GMREDI_XTRANSPORT( |
285 |
|
I iMin,iMax,jMin,jMax,bi,bj,k, |
286 |
|
I xA,TracAB, tracerIdentity, |
287 |
|
U df, |
288 |
|
I myThid) |
289 |
|
ENDIF |
290 |
ENDIF |
ENDIF |
291 |
#endif |
#endif |
292 |
|
C anelastic: advect.fluxes are scaled by rhoFac but hor.diff. flx are not |
293 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
294 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
295 |
fZon(i,j) = fZon(i,j) + df(i,j) |
fZon(i,j) = fZon(i,j) + df(i,j)*rhoFacC(k) |
296 |
ENDDO |
ENDDO |
297 |
ENDDO |
ENDDO |
298 |
|
|
299 |
C- Bi-harmonic duffusive flux in X |
#ifdef ALLOW_DIAGNOSTICS |
300 |
IF (diffK4 .NE. 0.) THEN |
C- Diagnostics of Tracer flux in X dir (mainly Diffusive term), |
301 |
CALL GAD_BIHARM_X(bi,bj,k,xA,df4,diffK4,df,myThid) |
C excluding advective terms: |
302 |
DO j=1-Oly,sNy+Oly |
IF ( useDiagnostics .AND. |
303 |
DO i=1-Olx,sNx+Olx |
& (diffKh.NE.0. .OR. diffK4 .NE.0. .OR. useGMRedi) ) THEN |
304 |
fZon(i,j) = fZon(i,j) + df(i,j) |
diagName = 'DFxE'//diagSufx |
305 |
ENDDO |
CALL DIAGNOSTICS_FILL(df,diagName, k,1, 2,bi,bj, myThid) |
|
ENDDO |
|
306 |
ENDIF |
ENDIF |
307 |
|
#endif |
308 |
|
|
309 |
C-- Initialize net flux in Y direction |
C-- Initialize net flux in Y direction |
310 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
315 |
|
|
316 |
C- Advective flux in Y |
C- Advective flux in Y |
317 |
IF (calcAdvection) THEN |
IF (calcAdvection) THEN |
318 |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
319 |
CALL GAD_C2_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
CALL GAD_C2_ADV_Y(bi,bj,k,vTrans,locABT,af,myThid) |
320 |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
ELSEIF ( advectionScheme.EQ.ENUM_UPWIND_1RST |
321 |
CALL GAD_FLUXLIMIT_ADV_Y( |
& .OR. advectionScheme.EQ.ENUM_DST2 ) THEN |
322 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localT,af,myThid) |
CALL GAD_DST2U1_ADV_Y( bi,bj,k, advectionScheme, |
323 |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
I dTtracerLev(k), vTrans, vFld, locABT, |
324 |
CALL GAD_U3_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
O af, myThid ) |
325 |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
326 |
CALL GAD_C4_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
CALL GAD_FLUXLIMIT_ADV_Y( bi,bj,k, dTtracerLev(k), |
327 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
I vTrans, vFld, maskS(1-Olx,1-Oly,k,bi,bj), locABT, |
328 |
CALL GAD_DST3_ADV_Y( |
O af, myThid ) |
329 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localT,af,myThid) |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
330 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
CALL GAD_U3_ADV_Y(bi,bj,k,vTrans,locABT,af,myThid) |
331 |
CALL GAD_DST3FL_ADV_Y( |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
332 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localT,af,myThid) |
CALL GAD_C4_ADV_Y(bi,bj,k,vTrans,locABT,af,myThid) |
333 |
ELSE |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
334 |
STOP 'GAD_CALC_RHS: Bad advectionScheme (Y)' |
CALL GAD_DST3_ADV_Y( bi,bj,k, dTtracerLev(k), |
335 |
ENDIF |
I vTrans, vFld, maskS(1-Olx,1-Oly,k,bi,bj), locABT, |
336 |
DO j=1-Oly,sNy+Oly |
O af, myThid ) |
337 |
DO i=1-Olx,sNx+Olx |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
338 |
fMer(i,j) = fMer(i,j) + af(i,j) |
IF ( inAdMode ) THEN |
339 |
ENDDO |
cph This block is to trick the adjoint: |
340 |
ENDDO |
cph IF inAdExact=.FALSE., we want to use DST3 |
341 |
|
cph with limiters in forward, but without limiters in reverse. |
342 |
|
CALL GAD_DST3_ADV_Y( bi,bj,k, dTtracerLev(k), |
343 |
|
I vTrans, vFld, maskS(1-Olx,1-Oly,k,bi,bj), locABT, |
344 |
|
O af, myThid ) |
345 |
|
ELSE |
346 |
|
CALL GAD_DST3FL_ADV_Y( bi,bj,k, dTtracerLev(k), |
347 |
|
I vTrans, vFld, maskS(1-Olx,1-Oly,k,bi,bj), locABT, |
348 |
|
O af, myThid ) |
349 |
|
ENDIF |
350 |
|
ELSE |
351 |
|
STOP 'GAD_CALC_RHS: Bad advectionScheme (Y)' |
352 |
|
ENDIF |
353 |
|
DO j=1-Oly,sNy+Oly |
354 |
|
DO i=1-Olx,sNx+Olx |
355 |
|
fMer(i,j) = fMer(i,j) + af(i,j) |
356 |
|
ENDDO |
357 |
|
ENDDO |
358 |
|
#ifdef ALLOW_DIAGNOSTICS |
359 |
|
IF ( useDiagnostics ) THEN |
360 |
|
diagName = 'ADVy'//diagSufx |
361 |
|
CALL DIAGNOSTICS_FILL(af,diagName, k,1, 2,bi,bj, myThid) |
362 |
|
ENDIF |
363 |
|
#endif |
364 |
ENDIF |
ENDIF |
365 |
|
|
366 |
C- Diffusive flux in Y |
C- Diffusive flux in Y |
374 |
ENDDO |
ENDDO |
375 |
ENDIF |
ENDIF |
376 |
|
|
377 |
|
C- Add bi-harmonic flux in Y |
378 |
|
IF (diffK4 .NE. 0.) THEN |
379 |
|
CALL GAD_BIHARM_Y(bi,bj,k,yA,df4,diffK4,df,myThid) |
380 |
|
ENDIF |
381 |
|
|
382 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
383 |
C- GM/Redi flux in Y |
C- GM/Redi flux in Y |
384 |
IF (useGMRedi) THEN |
IF (useGMRedi) THEN |
385 |
C *note* should update GMREDI_YTRANSPORT to use localT and set df *aja* |
C *note* should update GMREDI_YTRANSPORT to set df *aja* |
386 |
CALL GMREDI_YTRANSPORT( |
IF ( applyAB_onTracer ) THEN |
387 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
CALL GMREDI_YTRANSPORT( |
388 |
I yA,Tracer,tracerIdentity, |
I iMin,iMax,jMin,jMax,bi,bj,k, |
389 |
U df, |
I yA,TracerN,tracerIdentity, |
390 |
I myThid) |
U df, |
391 |
|
I myThid) |
392 |
|
ELSE |
393 |
|
CALL GMREDI_YTRANSPORT( |
394 |
|
I iMin,iMax,jMin,jMax,bi,bj,k, |
395 |
|
I yA,TracAB, tracerIdentity, |
396 |
|
U df, |
397 |
|
I myThid) |
398 |
|
ENDIF |
399 |
ENDIF |
ENDIF |
400 |
#endif |
#endif |
401 |
|
C anelastic: advect.fluxes are scaled by rhoFac but hor.diff. flx are not |
402 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
403 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
404 |
fMer(i,j) = fMer(i,j) + df(i,j) |
fMer(i,j) = fMer(i,j) + df(i,j)*rhoFacC(k) |
405 |
ENDDO |
ENDDO |
406 |
ENDDO |
ENDDO |
407 |
|
|
408 |
C- Bi-harmonic flux in Y |
#ifdef ALLOW_DIAGNOSTICS |
409 |
IF (diffK4 .NE. 0.) THEN |
C- Diagnostics of Tracer flux in Y dir (mainly Diffusive terms), |
410 |
CALL GAD_BIHARM_Y(bi,bj,k,yA,df4,diffK4,df,myThid) |
C excluding advective terms: |
411 |
DO j=1-Oly,sNy+Oly |
IF ( useDiagnostics .AND. |
412 |
DO i=1-Olx,sNx+Olx |
& (diffKh.NE.0. .OR. diffK4 .NE.0. .OR. useGMRedi) ) THEN |
413 |
fMer(i,j) = fMer(i,j) + df(i,j) |
diagName = 'DFyE'//diagSufx |
414 |
ENDDO |
CALL DIAGNOSTICS_FILL(df,diagName, k,1, 2,bi,bj, myThid) |
|
ENDDO |
|
415 |
ENDIF |
ENDIF |
416 |
|
#endif |
|
#ifdef NONLIN_FRSURF |
|
|
C-- Compute vertical flux fVerT(kDown) at interface k+1 (between k & k+1): |
|
|
IF ( calcAdvection .AND. K.EQ.Nr .AND. |
|
|
& useRealFreshWaterFlux .AND. |
|
|
& buoyancyRelation .EQ. 'OCEANICP' ) THEN |
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
fVerT(i,j,kDown) = convertEmP2rUnit*PmEpR(i,j,bi,bj) |
|
|
& *rA(i,j,bi,bj)*maskC(i,j,k,bi,bj)*Tracer(i,j,k,bi,bj) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
|
#endif /* NONLIN_FRSURF */ |
|
417 |
|
|
418 |
C-- Compute vertical flux fVerT(kUp) at interface k (between k-1 & k): |
C-- Compute vertical flux fVerT(kUp) at interface k (between k-1 & k): |
419 |
C- Advective flux in R |
C- Advective flux in R |
420 |
IF (calcAdvection) THEN |
#ifdef ALLOW_AIM |
421 |
C Note: wVel needs to be masked |
C- a hack to prevent Water-Vapor vert.transport into the stratospheric level Nr |
422 |
IF (K.GE.2) THEN |
IF (calcAdvection .AND. .NOT.implicitAdvection .AND. k.GE.2 .AND. |
423 |
|
& (.NOT.useAIM .OR.tracerIdentity.NE.GAD_SALINITY .OR.k.LT.Nr) |
424 |
|
& ) THEN |
425 |
|
#else |
426 |
|
IF (calcAdvection .AND. .NOT.implicitAdvection .AND. k.GE.2) THEN |
427 |
|
#endif |
428 |
C- Compute vertical advective flux in the interior: |
C- Compute vertical advective flux in the interior: |
429 |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
IF (vertAdvecScheme.EQ.ENUM_CENTERED_2ND) THEN |
430 |
CALL GAD_C2_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
CALL GAD_C2_ADV_R(bi,bj,k,rTrans,TracAB,af,myThid) |
431 |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
ELSEIF ( vertAdvecScheme.EQ.ENUM_UPWIND_1RST |
432 |
CALL GAD_FLUXLIMIT_ADV_R( |
& .OR. vertAdvecScheme.EQ.ENUM_DST2 ) THEN |
433 |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
CALL GAD_DST2U1_ADV_R( bi,bj,k, vertAdvecScheme, |
434 |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
I dTtracerLev(k),rTrans,wFld,TracAB(1-Olx,1-Oly,1,bi,bj), |
435 |
CALL GAD_U3_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
O af, myThid ) |
436 |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_FLUX_LIMIT) THEN |
437 |
CALL GAD_C4_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
CALL GAD_FLUXLIMIT_ADV_R( bi,bj,k, |
438 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
I dTtracerLev(k),rTrans,wFld,TracAB(1-Olx,1-Oly,1,bi,bj), |
439 |
CALL GAD_DST3_ADV_R( |
O af, myThid ) |
440 |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
ELSEIF (vertAdvecScheme.EQ.ENUM_UPWIND_3RD ) THEN |
441 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
CALL GAD_U3_ADV_R(bi,bj,k,rTrans,TracAB,af,myThid) |
442 |
CALL GAD_DST3FL_ADV_R( |
ELSEIF (vertAdvecScheme.EQ.ENUM_CENTERED_4TH) THEN |
443 |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
CALL GAD_C4_ADV_R(bi,bj,k,rTrans,TracAB,af,myThid) |
444 |
ELSE |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3 ) THEN |
445 |
STOP 'GAD_CALC_RHS: Bad advectionScheme (R)' |
CALL GAD_DST3_ADV_R( bi,bj,k, |
446 |
ENDIF |
I dTtracerLev(k),rTrans,wFld,TracAB(1-Olx,1-Oly,1,bi,bj), |
447 |
C- Surface "correction" term at k>1 : |
O af, myThid ) |
448 |
DO j=1-Oly,sNy+Oly |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
449 |
DO i=1-Olx,sNx+Olx |
cph This block is to trick the adjoint: |
450 |
af(i,j) = af(i,j) |
cph IF inAdExact=.FALSE., we want to use DST3 |
451 |
& + (maskC(i,j,k,bi,bj)-maskC(i,j,k-1,bi,bj))* |
cph with limiters in forward, but without limiters in reverse. |
452 |
& rTrans(i,j)*Tracer(i,j,k,bi,bj) |
IF ( inAdMode ) THEN |
453 |
ENDDO |
CALL GAD_DST3_ADV_R( bi,bj,k, |
454 |
ENDDO |
I dTtracerLev(k),rTrans,wFld,TracAB(1-Olx,1-Oly,1,bi,bj), |
455 |
ELSE |
O af, myThid ) |
456 |
C- Surface "correction" term at k=1 : |
ELSE |
457 |
DO j=1-Oly,sNy+Oly |
CALL GAD_DST3FL_ADV_R( bi,bj,k, |
458 |
DO i=1-Olx,sNx+Olx |
I dTtracerLev(k),rTrans,wFld,TracAB(1-Olx,1-Oly,1,bi,bj), |
459 |
af(i,j) = rTrans(i,j)*Tracer(i,j,k,bi,bj) |
O af, myThid ) |
460 |
ENDDO |
ENDIF |
461 |
ENDDO |
ELSE |
462 |
ENDIF |
STOP 'GAD_CALC_RHS: Bad vertAdvecScheme (R)' |
463 |
C- add the advective flux to fVerT |
ENDIF |
464 |
DO j=1-Oly,sNy+Oly |
C- add the advective flux to fVerT |
465 |
DO i=1-Olx,sNx+Olx |
DO j=1-Oly,sNy+Oly |
466 |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + af(i,j) |
DO i=1-Olx,sNx+Olx |
467 |
ENDDO |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + af(i,j) |
468 |
ENDDO |
ENDDO |
469 |
|
ENDDO |
470 |
|
#ifdef ALLOW_DIAGNOSTICS |
471 |
|
IF ( useDiagnostics ) THEN |
472 |
|
diagName = 'ADVr'//diagSufx |
473 |
|
CALL DIAGNOSTICS_FILL(af,diagName, k,1, 2,bi,bj, myThid) |
474 |
|
C- note: needs to explicitly increment the counter since DIAGNOSTICS_FILL |
475 |
|
C does it only if k=1 (never the case here) |
476 |
|
IF ( k.EQ.2 ) CALL DIAGNOSTICS_COUNT(diagName,bi,bj,myThid) |
477 |
|
ENDIF |
478 |
|
#endif |
479 |
ENDIF |
ENDIF |
480 |
|
|
481 |
C- Diffusive flux in R |
C- Diffusive flux in R |
488 |
ENDDO |
ENDDO |
489 |
ENDDO |
ENDDO |
490 |
ELSE |
ELSE |
491 |
CALL GAD_DIFF_R(bi,bj,k,KappaRT,tracer,df,myThid) |
IF ( applyAB_onTracer ) THEN |
492 |
|
CALL GAD_DIFF_R(bi,bj,k,KappaR,TracerN,df,myThid) |
493 |
|
ELSE |
494 |
|
CALL GAD_DIFF_R(bi,bj,k,KappaR,TracAB, df,myThid) |
495 |
|
ENDIF |
496 |
ENDIF |
ENDIF |
497 |
|
|
498 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
499 |
C- GM/Redi flux in R |
C- GM/Redi flux in R |
500 |
IF (useGMRedi) THEN |
IF (useGMRedi) THEN |
501 |
C *note* should update GMREDI_RTRANSPORT to set df *aja* |
C *note* should update GMREDI_RTRANSPORT to set df *aja* |
502 |
CALL GMREDI_RTRANSPORT( |
IF ( applyAB_onTracer ) THEN |
503 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
CALL GMREDI_RTRANSPORT( |
504 |
I Tracer,tracerIdentity, |
I iMin,iMax,jMin,jMax,bi,bj,k, |
505 |
U df, |
I TracerN,tracerIdentity, |
506 |
I myThid) |
U df, |
507 |
|
I myThid) |
508 |
|
ELSE |
509 |
|
CALL GMREDI_RTRANSPORT( |
510 |
|
I iMin,iMax,jMin,jMax,bi,bj,k, |
511 |
|
I TracAB, tracerIdentity, |
512 |
|
U df, |
513 |
|
I myThid) |
514 |
|
ENDIF |
515 |
ENDIF |
ENDIF |
516 |
#endif |
#endif |
517 |
|
|
521 |
ENDDO |
ENDDO |
522 |
ENDDO |
ENDDO |
523 |
|
|
524 |
|
#ifdef ALLOW_DIAGNOSTICS |
525 |
|
C- Diagnostics of Tracer flux in R dir (mainly Diffusive terms), |
526 |
|
C Explicit terms only & excluding advective terms: |
527 |
|
IF ( useDiagnostics .AND. |
528 |
|
& (.NOT.implicitDiffusion .OR. useGMRedi) ) THEN |
529 |
|
diagName = 'DFrE'//diagSufx |
530 |
|
CALL DIAGNOSTICS_FILL(df,diagName, k,1, 2,bi,bj, myThid) |
531 |
|
ENDIF |
532 |
|
#endif |
533 |
|
|
534 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
535 |
C- Add non local KPP transport term (ghat) to diffusive T flux. |
C- Set non local KPP transport term (ghat): |
536 |
IF (useKPP) THEN |
IF ( useKPP .AND. k.GE.2 ) THEN |
537 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
538 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
539 |
df(i,j) = 0. _d 0 |
df(i,j) = 0. _d 0 |
540 |
ENDDO |
ENDDO |
541 |
ENDDO |
ENDDO |
542 |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
|
C *note* should update KPP_TRANSPORT_T to set df *aja* |
|
543 |
CALL KPP_TRANSPORT_T( |
CALL KPP_TRANSPORT_T( |
544 |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
545 |
I KappaRT, |
O df ) |
|
U df ) |
|
546 |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
547 |
CALL KPP_TRANSPORT_S( |
CALL KPP_TRANSPORT_S( |
548 |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
549 |
I KappaRT, |
O df ) |
550 |
U df ) |
#ifdef ALLOW_PTRACERS |
551 |
|
ELSEIF (tracerIdentity .GE. GAD_TR1) THEN |
552 |
|
CALL KPP_TRANSPORT_PTR( |
553 |
|
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
554 |
|
I tracerIdentity-GAD_TR1+1, |
555 |
|
O df ) |
556 |
|
#endif |
557 |
ELSE |
ELSE |
558 |
|
PRINT*,'invalid tracer indentity: ', tracerIdentity |
559 |
STOP 'GAD_CALC_RHS: Ooops' |
STOP 'GAD_CALC_RHS: Ooops' |
560 |
ENDIF |
ENDIF |
561 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
562 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
563 |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) |
fVerT(i,j,kUp) = fVerT(i,j,kUp) |
564 |
|
& + df(i,j)*maskUp(i,j)*rhoFacF(k) |
565 |
ENDDO |
ENDDO |
566 |
ENDDO |
ENDDO |
567 |
ENDIF |
ENDIF |
568 |
#endif |
#endif |
569 |
|
|
570 |
C-- Divergence of fluxes |
C-- Divergence of fluxes |
571 |
|
C Anelastic: scale vertical fluxes by rhoFac and leave Horizontal fluxes unchanged |
572 |
DO j=1-Oly,sNy+Oly-1 |
DO j=1-Oly,sNy+Oly-1 |
573 |
DO i=1-Olx,sNx+Olx-1 |
DO i=1-Olx,sNx+Olx-1 |
574 |
gTracer(i,j,k,bi,bj)=gTracer(i,j,k,bi,bj) |
gTracer(i,j,k,bi,bj)=gTracer(i,j,k,bi,bj) |
575 |
& -_recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
& -_recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
576 |
& *recip_rA(i,j,bi,bj) |
& *recip_rA(i,j,bi,bj)*recip_deepFac2C(k)*recip_rhoFacC(k) |
577 |
& *( |
& *( (fZon(i+1,j)-fZon(i,j)) |
578 |
& +( fZon(i+1,j)-fZon(i,j) ) |
& +(fMer(i,j+1)-fMer(i,j)) |
579 |
& +( fMer(i,j+1)-fMer(i,j) ) |
& +(fVerT(i,j,kDown)-fVerT(i,j,kUp))*rkSign |
580 |
& +( fVerT(i,j,kUp)-fVerT(i,j,kDown) )*rkFac |
& -localT(i,j)*( (uTrans(i+1,j)-uTrans(i,j)) |
581 |
|
& +(vTrans(i,j+1)-vTrans(i,j)) |
582 |
|
& +(rTransKp1(i,j)-rTrans(i,j))*rAdvFac |
583 |
|
& )*advFac |
584 |
& ) |
& ) |
585 |
ENDDO |
ENDDO |
586 |
ENDDO |
ENDDO |
587 |
|
|
588 |
#ifdef NONLIN_FRSURF |
#ifdef ALLOW_DEBUG |
589 |
C-- account for 3.D divergence of the flow in rStar coordinate: |
IF ( debugLevel .GE. debLevB |
590 |
IF (calcAdvection .AND. select_rStar.GT.0) THEN |
& .AND. tracerIdentity.EQ.GAD_TEMPERATURE |
591 |
DO j=1-Oly,sNy+Oly-1 |
& .AND. k.EQ.2 .AND. myIter.EQ.1+nIter0 |
592 |
DO i=1-Olx,sNx+Olx-1 |
& .AND. nPx.EQ.1 .AND. nPy.EQ.1 |
593 |
gTracer(i,j,k,bi,bj) = gTracer(i,j,k,bi,bj) |
& .AND. useCubedSphereExchange ) THEN |
594 |
& - (rStarExpC(i,j,bi,bj) - 1. _d 0)/deltaTfreesurf |
CALL DEBUG_CS_CORNER_UV( ' fZon,fMer from GAD_CALC_RHS', |
595 |
& *tracer(i,j,k,bi,bj)*maskC(i,j,k,bi,bj) |
& fZon,fMer, k, standardMessageUnit,bi,bj,myThid ) |
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
|
IF (calcAdvection .AND. select_rStar.LT.0) THEN |
|
|
DO j=1-Oly,sNy+Oly-1 |
|
|
DO i=1-Olx,sNx+Olx-1 |
|
|
gTracer(i,j,k,bi,bj) = gTracer(i,j,k,bi,bj) |
|
|
& - rStarDhCDt(i,j,bi,bj) |
|
|
& *tracer(i,j,k,bi,bj)*maskC(i,j,k,bi,bj) |
|
|
ENDDO |
|
|
ENDDO |
|
596 |
ENDIF |
ENDIF |
597 |
#endif /* NONLIN_FRSURF */ |
#endif /* ALLOW_DEBUG */ |
|
|
|
598 |
|
|
599 |
RETURN |
RETURN |
600 |
END |
END |