3 |
|
|
4 |
#include "GAD_OPTIONS.h" |
#include "GAD_OPTIONS.h" |
5 |
|
|
6 |
|
CBOP |
7 |
|
C !ROUTINE: GAD_CALC_RHS |
8 |
|
|
9 |
|
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,uTrans,vTrans,rTrans,rTransKp1,maskUp, |
13 |
I diffKh, diffK4, KappaRT, Tracer, |
I uVel, vVel, wVel, |
14 |
I tracerIdentity, advectionScheme, |
I diffKh, diffK4, KappaR, Tracer, |
15 |
|
I tracerIdentity, advectionScheme, vertAdvecScheme, |
16 |
|
I calcAdvection, implicitAdvection, |
17 |
U fVerT, gTracer, |
U fVerT, gTracer, |
18 |
I myThid ) |
I myTime, myIter, myThid ) |
19 |
C /==========================================================\ |
|
20 |
C | SUBROUTINE GAD_CALC_RHS | |
C !DESCRIPTION: |
21 |
C |==========================================================| |
C Calculates the tendancy of a tracer due to advection and diffusion. |
22 |
C \==========================================================/ |
C It calculates the fluxes in each direction indepentently and then |
23 |
IMPLICIT NONE |
C sets the tendancy to the divergence of these fluxes. The advective |
24 |
|
C fluxes are only calculated here when using the linear advection schemes |
25 |
|
C otherwise only the diffusive and parameterized fluxes are calculated. |
26 |
|
C |
27 |
|
C Contributions to the flux are calculated and added: |
28 |
|
C \begin{equation*} |
29 |
|
C {\bf F} = {\bf F}_{adv} + {\bf F}_{diff} +{\bf F}_{GM} + {\bf F}_{KPP} |
30 |
|
C \end{equation*} |
31 |
|
C |
32 |
|
C The tendancy is the divergence of the fluxes: |
33 |
|
C \begin{equation*} |
34 |
|
C G_\theta = G_\theta + \nabla \cdot {\bf F} |
35 |
|
C \end{equation*} |
36 |
|
C |
37 |
|
C The tendancy is assumed to contain data on entry. |
38 |
|
|
39 |
C == GLobal variables == |
C !USES: =============================================================== |
40 |
|
IMPLICIT NONE |
41 |
#include "SIZE.h" |
#include "SIZE.h" |
42 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
43 |
#include "PARAMS.h" |
#include "PARAMS.h" |
44 |
#include "GRID.h" |
#include "GRID.h" |
45 |
#include "DYNVARS.h" |
#include "SURFACE.h" |
46 |
#include "GAD.h" |
#include "GAD.h" |
47 |
|
|
48 |
C == Routine arguments == |
#ifdef ALLOW_AUTODIFF_TAMC |
49 |
INTEGER k,kUp,kDown,kM1 |
#include "tamc.h" |
50 |
|
#include "tamc_keys.h" |
51 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
52 |
|
|
53 |
|
C !INPUT PARAMETERS: =================================================== |
54 |
|
C bi,bj :: tile indices |
55 |
|
C iMin,iMax :: loop range for called routines |
56 |
|
C jMin,jMax :: loop range for called routines |
57 |
|
C kup :: index into 2 1/2D array, toggles between 1|2 |
58 |
|
C kdown :: index into 2 1/2D array, toggles between 2|1 |
59 |
|
C kp1 :: =k+1 for k<Nr, =Nr for k=Nr |
60 |
|
C xA,yA :: areas of X and Y face of tracer cells |
61 |
|
C uTrans,vTrans :: 2-D arrays of volume transports at U,V points |
62 |
|
C rTrans :: 2-D arrays of volume transports at W points |
63 |
|
C rTransKp1 :: 2-D array of volume trans at W pts, interf k+1 |
64 |
|
C maskUp :: 2-D array for mask at W points |
65 |
|
C uVel,vVel,wVel :: 3 components of the velcity field (3-D array) |
66 |
|
C diffKh :: horizontal diffusion coefficient |
67 |
|
C diffK4 :: bi-harmonic diffusion coefficient |
68 |
|
C KappaR :: 2-D array for vertical diffusion coefficient, interf k |
69 |
|
C Tracer :: tracer field |
70 |
|
C tracerIdentity :: tracer identifier (required for KPP,GM) |
71 |
|
C advectionScheme :: advection scheme to use (Horizontal plane) |
72 |
|
C vertAdvecScheme :: advection scheme to use (Vertical direction) |
73 |
|
C calcAdvection :: =False if Advec computed with multiDim scheme |
74 |
|
C implicitAdvection:: =True if vertical Advec computed implicitly |
75 |
|
C myTime :: current time |
76 |
|
C myIter :: iteration number |
77 |
|
C myThid :: thread number |
78 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
79 |
|
INTEGER k,kUp,kDown,kM1 |
80 |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
81 |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
82 |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
83 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
84 |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
85 |
|
_RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
86 |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
87 |
|
_RL uVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
88 |
|
_RL vVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
89 |
|
_RL wVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
90 |
_RL diffKh, diffK4 |
_RL diffKh, diffK4 |
91 |
_RL KappaRT(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL KappaR(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
92 |
_RL Tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
_RL Tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
93 |
INTEGER tracerIdentity |
INTEGER tracerIdentity |
94 |
INTEGER advectionScheme |
INTEGER advectionScheme, vertAdvecScheme |
95 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
LOGICAL calcAdvection |
96 |
|
LOGICAL implicitAdvection |
97 |
|
_RL myTime |
98 |
|
INTEGER myIter, myThid |
99 |
|
|
100 |
|
C !OUTPUT PARAMETERS: ================================================== |
101 |
|
C gTracer :: tendancy array |
102 |
|
C fVerT :: 2 1/2D arrays for vertical advective flux |
103 |
_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) |
104 |
INTEGER myThid |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
105 |
|
|
106 |
C == Local variables == |
C !LOCAL VARIABLES: ==================================================== |
107 |
C I, J, K - Loop counters |
C i,j :: loop indices |
108 |
|
C df4 :: used for storing del^2 T for bi-harmonic term |
109 |
|
C fZon :: zonal flux |
110 |
|
C fmer :: meridional flux |
111 |
|
C af :: advective flux |
112 |
|
C df :: diffusive flux |
113 |
|
C localT :: local copy of tracer field |
114 |
INTEGER i,j |
INTEGER i,j |
|
LOGICAL TOP_LAYER |
|
|
_RL afFacT, dfFacT |
|
115 |
_RL df4 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL df4 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
116 |
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL fZon (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
117 |
_RL fMer (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL fMer (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 df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
120 |
_RL localT(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL localT(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
121 |
|
_RL advFac, rAdvFac |
122 |
|
CEOP |
123 |
|
|
124 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
125 |
C-- only the kUp part of fverT is set in this subroutine |
C-- only the kUp part of fverT is set in this subroutine |
126 |
C-- the kDown is still required |
C-- the kDown is still required |
127 |
fVerT(1,1,kDown) = fVerT(1,1,kDown) |
fVerT(1,1,kDown) = fVerT(1,1,kDown) |
128 |
#endif |
#endif |
129 |
|
|
130 |
|
advFac = 0. _d 0 |
131 |
|
IF (calcAdvection) advFac = 1. _d 0 |
132 |
|
rAdvFac = rkFac*advFac |
133 |
|
IF (implicitAdvection) rAdvFac = 0. _d 0 |
134 |
|
|
135 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
136 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
137 |
fZon(i,j) = 0.0 |
fZon(i,j) = 0. _d 0 |
138 |
fMer(i,j) = 0.0 |
fMer(i,j) = 0. _d 0 |
139 |
fVerT(i,j,kUp) = 0.0 |
fVerT(i,j,kUp) = 0. _d 0 |
140 |
|
df(i,j) = 0. _d 0 |
141 |
|
df4(i,j) = 0. _d 0 |
142 |
ENDDO |
ENDDO |
143 |
ENDDO |
ENDDO |
144 |
|
|
|
afFacT = 1. _d 0 |
|
|
dfFacT = 1. _d 0 |
|
|
TOP_LAYER = K .EQ. 1 |
|
|
|
|
145 |
C-- Make local copy of tracer array |
C-- Make local copy of tracer array |
146 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
147 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
151 |
|
|
152 |
C-- Unless we have already calculated the advection terms we initialize |
C-- Unless we have already calculated the advection terms we initialize |
153 |
C the tendency to zero. |
C the tendency to zero. |
154 |
IF (.NOT. multiDimAdvection .OR. |
C <== now done earlier at the beginning of thermodynamics. |
155 |
& advectionScheme.EQ.ENUM_CENTERED_2ND .OR. |
c IF (calcAdvection) THEN |
156 |
& advectionScheme.EQ.ENUM_UPWIND_3RD .OR. |
c DO j=1-Oly,sNy+Oly |
157 |
& advectionScheme.EQ.ENUM_CENTERED_4TH ) THEN |
c DO i=1-Olx,sNx+Olx |
158 |
DO j=1-Oly,sNy+Oly |
c gTracer(i,j,k,bi,bj)=0. _d 0 |
159 |
DO i=1-Olx,sNx+Olx |
c ENDDO |
160 |
gTracer(i,j,k,bi,bj)=0. |
c ENDDO |
161 |
ENDDO |
c ENDIF |
|
ENDDO |
|
|
ENDIF |
|
162 |
|
|
163 |
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 |
164 |
IF (diffK4 .NE. 0.) THEN |
IF (diffK4 .NE. 0.) THEN |
170 |
C-- Initialize net flux in X direction |
C-- Initialize net flux in X direction |
171 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
172 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
173 |
fZon(i,j) = 0. |
fZon(i,j) = 0. _d 0 |
174 |
ENDDO |
ENDDO |
175 |
ENDDO |
ENDDO |
176 |
|
|
177 |
C- Advective flux in X |
C- Advective flux in X |
178 |
IF (.NOT. multiDimAdvection .OR. |
IF (calcAdvection) THEN |
|
& advectionScheme.EQ.ENUM_CENTERED_2ND .OR. |
|
|
& advectionScheme.EQ.ENUM_UPWIND_3RD .OR. |
|
|
& advectionScheme.EQ.ENUM_CENTERED_4TH ) THEN |
|
179 |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
180 |
CALL GAD_C2_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
CALL GAD_C2_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
181 |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
182 |
CALL GAD_FLUXLIMIT_ADV_X( |
CALL GAD_FLUXLIMIT_ADV_X( bi,bj,k, deltaTtracer, |
183 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localT,af,myThid) |
I uTrans, uVel, maskW(1-Olx,1-Oly,k,bi,bj), localT, |
184 |
|
O af, myThid ) |
185 |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
186 |
CALL GAD_U3_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
CALL GAD_U3_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
187 |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
188 |
CALL GAD_C4_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
CALL GAD_C4_ADV_X(bi,bj,k,uTrans,localT,af,myThid) |
189 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
190 |
CALL GAD_DST3_ADV_X( |
CALL GAD_DST3_ADV_X( bi,bj,k, deltaTtracer, |
191 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localT,af,myThid) |
I uTrans, uVel, maskW(1-Olx,1-Oly,k,bi,bj), localT, |
192 |
|
O af, myThid ) |
193 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
194 |
CALL GAD_DST3FL_ADV_X( |
CALL GAD_DST3FL_ADV_X( bi,bj,k, deltaTtracer, |
195 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localT,af,myThid) |
I uTrans, uVel, maskW(1-Olx,1-Oly,k,bi,bj), localT, |
196 |
|
O af, myThid ) |
197 |
ELSE |
ELSE |
198 |
STOP 'GAD_CALC_RHS: Bad advectionScheme (X)' |
STOP 'GAD_CALC_RHS: Bad advectionScheme (X)' |
199 |
ENDIF |
ENDIF |
210 |
ELSE |
ELSE |
211 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
212 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
213 |
df(i,j) = 0. |
df(i,j) = 0. _d 0 |
214 |
ENDDO |
ENDDO |
215 |
ENDDO |
ENDDO |
216 |
ENDIF |
ENDIF |
221 |
C *note* should update GMREDI_XTRANSPORT to use localT and set df *aja* |
C *note* should update GMREDI_XTRANSPORT to use localT and set df *aja* |
222 |
CALL GMREDI_XTRANSPORT( |
CALL GMREDI_XTRANSPORT( |
223 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
I iMin,iMax,jMin,jMax,bi,bj,K, |
224 |
I xA,Tracer, |
I xA,Tracer,tracerIdentity, |
225 |
U df, |
U df, |
226 |
I myThid) |
I myThid) |
227 |
ENDIF |
ENDIF |
245 |
C-- Initialize net flux in Y direction |
C-- Initialize net flux in Y direction |
246 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
247 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
248 |
fMer(i,j) = 0. |
fMer(i,j) = 0. _d 0 |
249 |
ENDDO |
ENDDO |
250 |
ENDDO |
ENDDO |
251 |
|
|
252 |
C- Advective flux in Y |
C- Advective flux in Y |
253 |
IF (.NOT. multiDimAdvection .OR. |
IF (calcAdvection) THEN |
|
& advectionScheme.EQ.ENUM_CENTERED_2ND .OR. |
|
|
& advectionScheme.EQ.ENUM_UPWIND_3RD .OR. |
|
|
& advectionScheme.EQ.ENUM_CENTERED_4TH ) THEN |
|
254 |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
255 |
CALL GAD_C2_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
CALL GAD_C2_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
256 |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
257 |
CALL GAD_FLUXLIMIT_ADV_Y( |
CALL GAD_FLUXLIMIT_ADV_Y( bi,bj,k, deltaTtracer, |
258 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localT,af,myThid) |
I vTrans, vVel, maskS(1-Olx,1-Oly,k,bi,bj), localT, |
259 |
|
O af, myThid ) |
260 |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
261 |
CALL GAD_U3_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
CALL GAD_U3_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
262 |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
263 |
CALL GAD_C4_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
CALL GAD_C4_ADV_Y(bi,bj,k,vTrans,localT,af,myThid) |
264 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
265 |
CALL GAD_DST3_ADV_Y( |
CALL GAD_DST3_ADV_Y( bi,bj,k, deltaTtracer, |
266 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localT,af,myThid) |
I vTrans, vVel, maskS(1-Olx,1-Oly,k,bi,bj), localT, |
267 |
|
O af, myThid ) |
268 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
269 |
CALL GAD_DST3FL_ADV_Y( |
CALL GAD_DST3FL_ADV_Y( bi,bj,k, deltaTtracer, |
270 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localT,af,myThid) |
I vTrans, vVel, maskS(1-Olx,1-Oly,k,bi,bj), localT, |
271 |
|
O af, myThid ) |
272 |
ELSE |
ELSE |
273 |
STOP 'GAD_CALC_RHS: Bad advectionScheme (Y)' |
STOP 'GAD_CALC_RHS: Bad advectionScheme (Y)' |
274 |
ENDIF |
ENDIF |
285 |
ELSE |
ELSE |
286 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
287 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
288 |
df(i,j) = 0. |
df(i,j) = 0. _d 0 |
289 |
ENDDO |
ENDDO |
290 |
ENDDO |
ENDDO |
291 |
ENDIF |
ENDIF |
296 |
C *note* should update GMREDI_YTRANSPORT to use localT and set df *aja* |
C *note* should update GMREDI_YTRANSPORT to use localT and set df *aja* |
297 |
CALL GMREDI_YTRANSPORT( |
CALL GMREDI_YTRANSPORT( |
298 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
I iMin,iMax,jMin,jMax,bi,bj,K, |
299 |
I yA,Tracer, |
I yA,Tracer,tracerIdentity, |
300 |
U df, |
U df, |
301 |
I myThid) |
I myThid) |
302 |
ENDIF |
ENDIF |
317 |
ENDDO |
ENDDO |
318 |
ENDIF |
ENDIF |
319 |
|
|
320 |
C-- Initialize net flux in R |
C-- Compute vertical flux fVerT(kUp) at interface k (between k-1 & k): |
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
fVerT(i,j,kUp) = 0. |
|
|
ENDDO |
|
|
ENDDO |
|
|
|
|
321 |
C- Advective flux in R |
C- Advective flux in R |
322 |
IF (.NOT. multiDimAdvection .OR. |
#ifdef ALLOW_AIM |
323 |
& advectionScheme.EQ.ENUM_CENTERED_2ND .OR. |
C- a hack to prevent Water-Vapor vert.transport into the stratospheric level Nr |
324 |
& advectionScheme.EQ.ENUM_UPWIND_3RD .OR. |
IF (calcAdvection .AND. .NOT.implicitAdvection .AND. K.GE.2 .AND. |
325 |
& advectionScheme.EQ.ENUM_CENTERED_4TH ) THEN |
& (.NOT.useAIM .OR.tracerIdentity.NE.GAD_SALINITY .OR.K.LT.Nr) |
326 |
C Note: wVel needs to be masked |
& ) THEN |
327 |
IF (K.GE.2) THEN |
#else |
328 |
|
IF (calcAdvection .AND. .NOT.implicitAdvection .AND. K.GE.2) THEN |
329 |
|
#endif |
330 |
C- Compute vertical advective flux in the interior: |
C- Compute vertical advective flux in the interior: |
331 |
IF (advectionScheme.EQ.ENUM_CENTERED_2ND) THEN |
IF (vertAdvecScheme.EQ.ENUM_CENTERED_2ND) THEN |
332 |
CALL GAD_C2_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
CALL GAD_C2_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
333 |
ELSEIF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_FLUX_LIMIT) THEN |
334 |
CALL GAD_FLUXLIMIT_ADV_R( |
CALL GAD_FLUXLIMIT_ADV_R( |
335 |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
336 |
ELSEIF (advectionScheme.EQ.ENUM_UPWIND_3RD ) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_UPWIND_3RD ) THEN |
337 |
CALL GAD_U3_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
CALL GAD_U3_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
338 |
ELSEIF (advectionScheme.EQ.ENUM_CENTERED_4TH) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_CENTERED_4TH) THEN |
339 |
CALL GAD_C4_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
CALL GAD_C4_ADV_R(bi,bj,k,rTrans,tracer,af,myThid) |
340 |
ELSEIF (advectionScheme.EQ.ENUM_DST3 ) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3 ) THEN |
341 |
CALL GAD_DST3_ADV_R( |
CALL GAD_DST3_ADV_R( |
342 |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
343 |
ELSEIF (advectionScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
ELSEIF (vertAdvecScheme.EQ.ENUM_DST3_FLUX_LIMIT ) THEN |
344 |
CALL GAD_DST3FL_ADV_R( |
CALL GAD_DST3FL_ADV_R( |
345 |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
& bi,bj,k,deltaTtracer,rTrans,wVel,tracer,af,myThid) |
346 |
ELSE |
ELSE |
347 |
STOP 'GAD_CALC_RHS: Bad advectionScheme (R)' |
STOP 'GAD_CALC_RHS: Bad vertAdvecScheme (R)' |
348 |
ENDIF |
ENDIF |
349 |
C- Surface "correction" term at k>1 : |
C- add the advective flux to fVerT |
350 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
351 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
352 |
af(i,j) = af(i,j) |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + af(i,j) |
|
& + (maskC(i,j,k,bi,bj)-maskC(i,j,k-1,bi,bj))* |
|
|
& rTrans(i,j)*Tracer(i,j,k,bi,bj) |
|
353 |
ENDDO |
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)*Tracer(i,j,k,bi,bj) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
|
C- add the advective flux to fVerT |
|
|
DO j=1-Oly,sNy+Oly |
|
|
DO i=1-Olx,sNx+Olx |
|
|
fVerT(i,j,kUp) = fVerT(i,j,kUp) + afFacT*af(i,j) |
|
354 |
ENDDO |
ENDDO |
|
ENDDO |
|
355 |
ENDIF |
ENDIF |
356 |
|
|
357 |
C- Diffusive flux in R |
C- Diffusive flux in R |
360 |
IF (implicitDiffusion) THEN |
IF (implicitDiffusion) THEN |
361 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
362 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
363 |
df(i,j) = 0. |
df(i,j) = 0. _d 0 |
364 |
ENDDO |
ENDDO |
365 |
ENDDO |
ENDDO |
366 |
ELSE |
ELSE |
367 |
CALL GAD_DIFF_R(bi,bj,k,KappaRT,tracer,df,myThid) |
CALL GAD_DIFF_R(bi,bj,k,KappaR,tracer,df,myThid) |
368 |
ENDIF |
ENDIF |
|
c DO j=1-Oly,sNy+Oly |
|
|
c DO i=1-Olx,sNx+Olx |
|
|
c fVerT(i,j,kUp) = fVerT(i,j,kUp) + dfFacT*df(i,j)*maskUp(i,j) |
|
|
c ENDDO |
|
|
c ENDDO |
|
369 |
|
|
370 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
371 |
C- GM/Redi flux in R |
C- GM/Redi flux in R |
373 |
C *note* should update GMREDI_RTRANSPORT to set df *aja* |
C *note* should update GMREDI_RTRANSPORT to set df *aja* |
374 |
CALL GMREDI_RTRANSPORT( |
CALL GMREDI_RTRANSPORT( |
375 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
I iMin,iMax,jMin,jMax,bi,bj,K, |
376 |
I Tracer, |
I Tracer,tracerIdentity, |
377 |
U df, |
U df, |
378 |
I myThid) |
I myThid) |
|
c DO j=1-Oly,sNy+Oly |
|
|
c DO i=1-Olx,sNx+Olx |
|
|
c fVerT(i,j,kUp) = fVerT(i,j,kUp) + dfFacT*df(i,j)*maskUp(i,j) |
|
|
c ENDDO |
|
|
c ENDDO |
|
379 |
ENDIF |
ENDIF |
380 |
#endif |
#endif |
381 |
|
|
382 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
383 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
384 |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + dfFacT*df(i,j)*maskUp(i,j) |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) |
385 |
ENDDO |
ENDDO |
386 |
ENDDO |
ENDDO |
387 |
|
|
388 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
389 |
C- Add non local KPP transport term (ghat) to diffusive T flux. |
C- Set non local KPP transport term (ghat): |
390 |
IF (useKPP) THEN |
IF ( useKPP .AND. k.GE.2 ) THEN |
391 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
392 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
393 |
df(i,j) = 0. |
df(i,j) = 0. _d 0 |
394 |
ENDDO |
ENDDO |
395 |
ENDDO |
ENDDO |
396 |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
IF (tracerIdentity.EQ.GAD_TEMPERATURE) THEN |
|
C *note* should update KPP_TRANSPORT_T to set df *aja* |
|
397 |
CALL KPP_TRANSPORT_T( |
CALL KPP_TRANSPORT_T( |
398 |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
399 |
I KappaRT, |
O df ) |
|
U df ) |
|
400 |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
ELSEIF (tracerIdentity.EQ.GAD_SALINITY) THEN |
401 |
CALL KPP_TRANSPORT_S( |
CALL KPP_TRANSPORT_S( |
402 |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
403 |
I KappaRT, |
O df ) |
404 |
U df ) |
#ifdef ALLOW_PTRACERS |
405 |
|
ELSEIF (tracerIdentity .GE. GAD_TR1) THEN |
406 |
|
CALL KPP_TRANSPORT_PTR( |
407 |
|
I iMin,iMax,jMin,jMax,bi,bj,k,km1, |
408 |
|
I tracerIdentity-GAD_TR1+1, |
409 |
|
O df ) |
410 |
|
#endif |
411 |
ELSE |
ELSE |
412 |
|
PRINT*,'invalid tracer indentity: ', tracerIdentity |
413 |
STOP 'GAD_CALC_RHS: Ooops' |
STOP 'GAD_CALC_RHS: Ooops' |
414 |
ENDIF |
ENDIF |
415 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
416 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
417 |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + dfFacT*df(i,j)*maskUp(i,j) |
fVerT(i,j,kUp) = fVerT(i,j,kUp) + df(i,j)*maskUp(i,j) |
418 |
ENDDO |
ENDDO |
419 |
ENDDO |
ENDDO |
420 |
ENDIF |
ENDIF |
421 |
#endif |
#endif |
422 |
|
|
423 |
C-- Divergence of fluxes |
C-- Divergence of fluxes |
424 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly-1 |
425 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx-1 |
426 |
gTracer(i,j,k,bi,bj)=gTracer(i,j,k,bi,bj) |
gTracer(i,j,k,bi,bj)=gTracer(i,j,k,bi,bj) |
427 |
& -_recip_hFacC(i,j,k,bi,bj)*recip_drF(k) |
& -_recip_hFacC(i,j,k,bi,bj)*recip_drF(k)*recip_rA(i,j,bi,bj) |
428 |
& *recip_rA(i,j,bi,bj) |
& *( (fZon(i+1,j)-fZon(i,j)) |
429 |
& *( |
& +(fMer(i,j+1)-fMer(i,j)) |
430 |
& +( fZon(i+1,j)-fZon(i,j) ) |
& +(fVerT(i,j,kUp)-fVerT(i,j,kDown))*rkFac |
431 |
& +( fMer(i,j+1)-fMer(i,j) ) |
& -localT(i,j)*( (uTrans(i+1,j)-uTrans(i,j)) |
432 |
& +( fVerT(i,j,kUp)-fVerT(i,j,kDown) )*rkFac |
& +(vTrans(i,j+1)-vTrans(i,j)) |
433 |
|
& +(rTrans(i,j)-rTransKp1(i,j))*rAdvFac |
434 |
|
& )*advFac |
435 |
& ) |
& ) |
436 |
ENDDO |
ENDDO |
437 |
ENDDO |
ENDDO |
438 |
|
|
439 |
|
#ifdef ALLOW_DEBUG |
440 |
|
IF ( debugLevel .GE. debLevB |
441 |
|
& .AND. tracerIdentity.EQ.GAD_TEMPERATURE |
442 |
|
& .AND. k.EQ.2 .AND. myIter.EQ.1+nIter0 |
443 |
|
& .AND. nPx.EQ.1 .AND. nPy.EQ.1 |
444 |
|
& .AND. useCubedSphereExchange ) THEN |
445 |
|
CALL DEBUG_CS_CORNER_UV( ' fZon,fMer from GAD_CALC_RHS', |
446 |
|
& fZon,fMer, k, standardMessageUnit,bi,bj,myThid ) |
447 |
|
ENDIF |
448 |
|
#endif /* ALLOW_DEBUG */ |
449 |
|
|
450 |
RETURN |
RETURN |
451 |
END |
END |