1 |
cheisey |
1.32 |
C $Header: /u/u0/gcmpack/MITgcm/model/src/thermodynamics.F,v 1.31 2002/11/15 19:58:21 cheisey Exp $ |
2 |
adcroft |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "CPP_OPTIONS.h" |
5 |
jmc |
1.21 |
#ifdef ALLOW_AUTODIFF_TAMC |
6 |
|
|
# ifdef ALLOW_GMREDI |
7 |
|
|
# include "GMREDI_OPTIONS.h" |
8 |
|
|
# endif |
9 |
|
|
# ifdef ALLOW_KPP |
10 |
|
|
# include "KPP_OPTIONS.h" |
11 |
|
|
# endif |
12 |
cheisey |
1.31 |
cswdice --- add ---- |
13 |
cheisey |
1.32 |
#ifdef ALLOW_THERM_SEAICE |
14 |
cheisey |
1.31 |
#include "ICE.h" |
15 |
|
|
#endif |
16 |
|
|
cswdice ------ |
17 |
jmc |
1.21 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
18 |
adcroft |
1.1 |
|
19 |
cnh |
1.9 |
CBOP |
20 |
|
|
C !ROUTINE: THERMODYNAMICS |
21 |
|
|
C !INTERFACE: |
22 |
adcroft |
1.1 |
SUBROUTINE THERMODYNAMICS(myTime, myIter, myThid) |
23 |
cnh |
1.9 |
C !DESCRIPTION: \bv |
24 |
|
|
C *==========================================================* |
25 |
|
|
C | SUBROUTINE THERMODYNAMICS |
26 |
|
|
C | o Controlling routine for the prognostic part of the |
27 |
|
|
C | thermo-dynamics. |
28 |
|
|
C *=========================================================== |
29 |
|
|
C | The algorithm... |
30 |
|
|
C | |
31 |
|
|
C | "Correction Step" |
32 |
|
|
C | ================= |
33 |
|
|
C | Here we update the horizontal velocities with the surface |
34 |
|
|
C | pressure such that the resulting flow is either consistent |
35 |
|
|
C | with the free-surface evolution or the rigid-lid: |
36 |
|
|
C | U[n] = U* + dt x d/dx P |
37 |
|
|
C | V[n] = V* + dt x d/dy P |
38 |
|
|
C | |
39 |
|
|
C | "Calculation of Gs" |
40 |
|
|
C | =================== |
41 |
|
|
C | This is where all the accelerations and tendencies (ie. |
42 |
|
|
C | physics, parameterizations etc...) are calculated |
43 |
|
|
C | rho = rho ( theta[n], salt[n] ) |
44 |
|
|
C | b = b(rho, theta) |
45 |
|
|
C | K31 = K31 ( rho ) |
46 |
|
|
C | Gu[n] = Gu( u[n], v[n], wVel, b, ... ) |
47 |
|
|
C | Gv[n] = Gv( u[n], v[n], wVel, b, ... ) |
48 |
|
|
C | Gt[n] = Gt( theta[n], u[n], v[n], wVel, K31, ... ) |
49 |
|
|
C | Gs[n] = Gs( salt[n], u[n], v[n], wVel, K31, ... ) |
50 |
|
|
C | |
51 |
|
|
C | "Time-stepping" or "Prediction" |
52 |
|
|
C | ================================ |
53 |
|
|
C | The models variables are stepped forward with the appropriate |
54 |
|
|
C | time-stepping scheme (currently we use Adams-Bashforth II) |
55 |
|
|
C | - For momentum, the result is always *only* a "prediction" |
56 |
|
|
C | in that the flow may be divergent and will be "corrected" |
57 |
|
|
C | later with a surface pressure gradient. |
58 |
|
|
C | - Normally for tracers the result is the new field at time |
59 |
|
|
C | level [n+1} *BUT* in the case of implicit diffusion the result |
60 |
|
|
C | is also *only* a prediction. |
61 |
|
|
C | - We denote "predictors" with an asterisk (*). |
62 |
|
|
C | U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] ) |
63 |
|
|
C | V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] ) |
64 |
|
|
C | theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
65 |
|
|
C | salt[n+1] = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
66 |
|
|
C | With implicit diffusion: |
67 |
|
|
C | theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
68 |
|
|
C | salt* = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] ) |
69 |
|
|
C | (1 + dt * K * d_zz) theta[n] = theta* |
70 |
|
|
C | (1 + dt * K * d_zz) salt[n] = salt* |
71 |
|
|
C | |
72 |
|
|
C *==========================================================* |
73 |
|
|
C \ev |
74 |
|
|
|
75 |
|
|
C !USES: |
76 |
adcroft |
1.1 |
IMPLICIT NONE |
77 |
|
|
C == Global variables === |
78 |
|
|
#include "SIZE.h" |
79 |
|
|
#include "EEPARAMS.h" |
80 |
|
|
#include "PARAMS.h" |
81 |
|
|
#include "DYNVARS.h" |
82 |
|
|
#include "GRID.h" |
83 |
adcroft |
1.4 |
#include "GAD.h" |
84 |
adcroft |
1.1 |
#ifdef ALLOW_PASSIVE_TRACER |
85 |
|
|
#include "TR1.h" |
86 |
|
|
#endif |
87 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
88 |
|
|
# include "tamc.h" |
89 |
|
|
# include "tamc_keys.h" |
90 |
|
|
# include "FFIELDS.h" |
91 |
heimbach |
1.30 |
# include "EOS.h" |
92 |
adcroft |
1.1 |
# ifdef ALLOW_KPP |
93 |
|
|
# include "KPP.h" |
94 |
|
|
# endif |
95 |
|
|
# ifdef ALLOW_GMREDI |
96 |
|
|
# include "GMREDI.h" |
97 |
|
|
# endif |
98 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
99 |
|
|
#ifdef ALLOW_TIMEAVE |
100 |
|
|
#include "TIMEAVE_STATV.h" |
101 |
|
|
#endif |
102 |
|
|
|
103 |
cnh |
1.9 |
C !INPUT/OUTPUT PARAMETERS: |
104 |
adcroft |
1.1 |
C == Routine arguments == |
105 |
|
|
C myTime - Current time in simulation |
106 |
|
|
C myIter - Current iteration number in simulation |
107 |
|
|
C myThid - Thread number for this instance of the routine. |
108 |
|
|
_RL myTime |
109 |
|
|
INTEGER myIter |
110 |
|
|
INTEGER myThid |
111 |
|
|
|
112 |
cnh |
1.9 |
C !LOCAL VARIABLES: |
113 |
adcroft |
1.1 |
C == Local variables |
114 |
|
|
C xA, yA - Per block temporaries holding face areas |
115 |
|
|
C uTrans, vTrans, rTrans - Per block temporaries holding flow |
116 |
|
|
C transport |
117 |
|
|
C o uTrans: Zonal transport |
118 |
|
|
C o vTrans: Meridional transport |
119 |
|
|
C o rTrans: Vertical transport |
120 |
|
|
C maskUp o maskUp: land/water mask for W points |
121 |
|
|
C fVer[STUV] o fVer: Vertical flux term - note fVer |
122 |
|
|
C is "pipelined" in the vertical |
123 |
|
|
C so we need an fVer for each |
124 |
|
|
C variable. |
125 |
|
|
C rhoK, rhoKM1 - Density at current level, and level above |
126 |
|
|
C phiHyd - Hydrostatic part of the potential phiHydi. |
127 |
|
|
C In z coords phiHydiHyd is the hydrostatic |
128 |
|
|
C Potential (=pressure/rho0) anomaly |
129 |
|
|
C In p coords phiHydiHyd is the geopotential |
130 |
|
|
C surface height anomaly. |
131 |
|
|
C phiSurfX, - gradient of Surface potentiel (Pressure/rho, ocean) |
132 |
|
|
C phiSurfY or geopotentiel (atmos) in X and Y direction |
133 |
|
|
C KappaRT, - Total diffusion in vertical for T and S. |
134 |
|
|
C KappaRS (background + spatially varying, isopycnal term). |
135 |
|
|
C iMin, iMax - Ranges and sub-block indices on which calculations |
136 |
|
|
C jMin, jMax are applied. |
137 |
|
|
C bi, bj |
138 |
|
|
C k, kup, - Index for layer above and below. kup and kDown |
139 |
|
|
C kDown, km1 are switched with layer to be the appropriate |
140 |
|
|
C index into fVerTerm. |
141 |
|
|
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
142 |
|
|
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
143 |
|
|
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
144 |
|
|
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
145 |
|
|
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
146 |
|
|
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
147 |
|
|
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
148 |
|
|
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
149 |
|
|
_RL fVerTr1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
150 |
|
|
_RL phiHyd (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
151 |
|
|
_RL rhokm1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
152 |
|
|
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
153 |
|
|
_RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
154 |
|
|
_RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
155 |
|
|
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
156 |
|
|
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
157 |
|
|
_RL sigmaX (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
158 |
|
|
_RL sigmaY (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
159 |
|
|
_RL sigmaR (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
160 |
cnh |
1.9 |
C This is currently used by IVDC and Diagnostics |
161 |
adcroft |
1.1 |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
162 |
|
|
INTEGER iMin, iMax |
163 |
|
|
INTEGER jMin, jMax |
164 |
|
|
INTEGER bi, bj |
165 |
|
|
INTEGER i, j |
166 |
|
|
INTEGER k, km1, kup, kDown |
167 |
|
|
|
168 |
cnh |
1.9 |
CEOP |
169 |
adcroft |
1.1 |
|
170 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
171 |
|
|
C-- dummy statement to end declaration part |
172 |
|
|
ikey = 1 |
173 |
heimbach |
1.30 |
itdkey = 1 |
174 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
175 |
|
|
|
176 |
|
|
C-- Set up work arrays with valid (i.e. not NaN) values |
177 |
|
|
C These inital values do not alter the numerical results. They |
178 |
|
|
C just ensure that all memory references are to valid floating |
179 |
|
|
C point numbers. This prevents spurious hardware signals due to |
180 |
|
|
C uninitialised but inert locations. |
181 |
|
|
DO j=1-OLy,sNy+OLy |
182 |
|
|
DO i=1-OLx,sNx+OLx |
183 |
|
|
xA(i,j) = 0. _d 0 |
184 |
|
|
yA(i,j) = 0. _d 0 |
185 |
|
|
uTrans(i,j) = 0. _d 0 |
186 |
|
|
vTrans(i,j) = 0. _d 0 |
187 |
|
|
rhok (i,j) = 0. _d 0 |
188 |
|
|
phiSurfX(i,j) = 0. _d 0 |
189 |
|
|
phiSurfY(i,j) = 0. _d 0 |
190 |
|
|
ENDDO |
191 |
|
|
ENDDO |
192 |
|
|
|
193 |
|
|
|
194 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
195 |
|
|
C-- HPF directive to help TAMC |
196 |
|
|
CHPF$ INDEPENDENT |
197 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
198 |
|
|
|
199 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
200 |
|
|
|
201 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
202 |
|
|
C-- HPF directive to help TAMC |
203 |
heimbach |
1.2 |
CHPF$ INDEPENDENT, NEW (rTrans,fVerT,fVerS |
204 |
adcroft |
1.1 |
CHPF$& ,phiHyd,utrans,vtrans,xA,yA |
205 |
heimbach |
1.2 |
CHPF$& ,KappaRT,KappaRS |
206 |
adcroft |
1.1 |
CHPF$& ) |
207 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
208 |
|
|
|
209 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
210 |
|
|
|
211 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
212 |
|
|
act1 = bi - myBxLo(myThid) |
213 |
|
|
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
214 |
|
|
act2 = bj - myByLo(myThid) |
215 |
|
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
216 |
|
|
act3 = myThid - 1 |
217 |
|
|
max3 = nTx*nTy |
218 |
|
|
act4 = ikey_dynamics - 1 |
219 |
heimbach |
1.30 |
itdkey = (act1 + 1) + act2*max1 |
220 |
adcroft |
1.1 |
& + act3*max1*max2 |
221 |
|
|
& + act4*max1*max2*max3 |
222 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
223 |
|
|
|
224 |
|
|
C-- Set up work arrays that need valid initial values |
225 |
|
|
DO j=1-OLy,sNy+OLy |
226 |
|
|
DO i=1-OLx,sNx+OLx |
227 |
|
|
rTrans (i,j) = 0. _d 0 |
228 |
|
|
fVerT (i,j,1) = 0. _d 0 |
229 |
|
|
fVerT (i,j,2) = 0. _d 0 |
230 |
|
|
fVerS (i,j,1) = 0. _d 0 |
231 |
|
|
fVerS (i,j,2) = 0. _d 0 |
232 |
|
|
fVerTr1(i,j,1) = 0. _d 0 |
233 |
|
|
fVerTr1(i,j,2) = 0. _d 0 |
234 |
heimbach |
1.20 |
rhoKM1 (i,j) = 0. _d 0 |
235 |
adcroft |
1.1 |
ENDDO |
236 |
|
|
ENDDO |
237 |
|
|
|
238 |
|
|
DO k=1,Nr |
239 |
|
|
DO j=1-OLy,sNy+OLy |
240 |
|
|
DO i=1-OLx,sNx+OLx |
241 |
|
|
C This is currently also used by IVDC and Diagnostics |
242 |
heimbach |
1.30 |
phiHyd(i,j,k) = 0. _d 0 |
243 |
heimbach |
1.20 |
sigmaX(i,j,k) = 0. _d 0 |
244 |
|
|
sigmaY(i,j,k) = 0. _d 0 |
245 |
|
|
sigmaR(i,j,k) = 0. _d 0 |
246 |
adcroft |
1.1 |
ConvectCount(i,j,k) = 0. |
247 |
heimbach |
1.30 |
KappaRT(i,j,k) = 0. _d 0 |
248 |
|
|
KappaRS(i,j,k) = 0. _d 0 |
249 |
heimbach |
1.5 |
#ifdef ALLOW_AUTODIFF_TAMC |
250 |
heimbach |
1.30 |
cph all the following init. are necessary for TAF |
251 |
|
|
cph although some of these are re-initialised later. |
252 |
|
|
gT(i,j,k,bi,bj) = 0. _d 0 |
253 |
|
|
gS(i,j,k,bi,bj) = 0. _d 0 |
254 |
|
|
# ifdef ALLOW_PASSIVE_TRACER |
255 |
heimbach |
1.5 |
gTr1(i,j,k,bi,bj) = 0. _d 0 |
256 |
heimbach |
1.30 |
# endif |
257 |
|
|
# ifdef ALLOW_GMREDI |
258 |
|
|
Kwx(i,j,k,bi,bj) = 0. _d 0 |
259 |
|
|
Kwy(i,j,k,bi,bj) = 0. _d 0 |
260 |
|
|
Kwz(i,j,k,bi,bj) = 0. _d 0 |
261 |
|
|
# ifdef GM_NON_UNITY_DIAGONAL |
262 |
|
|
Kux(i,j,k,bi,bj) = 0. _d 0 |
263 |
|
|
Kvy(i,j,k,bi,bj) = 0. _d 0 |
264 |
|
|
# endif |
265 |
|
|
# ifdef GM_EXTRA_DIAGONAL |
266 |
|
|
Kuz(i,j,k,bi,bj) = 0. _d 0 |
267 |
|
|
Kvz(i,j,k,bi,bj) = 0. _d 0 |
268 |
|
|
# endif |
269 |
|
|
# ifdef GM_BOLUS_ADVEC |
270 |
|
|
GM_PsiX(i,j,k,bi,bj) = 0. _d 0 |
271 |
|
|
GM_PsiY(i,j,k,bi,bj) = 0. _d 0 |
272 |
|
|
# endif |
273 |
|
|
# endif /* ALLOW_GMREDI */ |
274 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
275 |
adcroft |
1.1 |
ENDDO |
276 |
|
|
ENDDO |
277 |
|
|
ENDDO |
278 |
|
|
|
279 |
jmc |
1.21 |
iMin = 1-OLx |
280 |
adcroft |
1.1 |
iMax = sNx+OLx |
281 |
jmc |
1.21 |
jMin = 1-OLy |
282 |
adcroft |
1.1 |
jMax = sNy+OLy |
283 |
|
|
|
284 |
|
|
|
285 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
286 |
heimbach |
1.30 |
CADJ STORE theta(:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
287 |
|
|
CADJ STORE salt (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
288 |
heimbach |
1.11 |
#ifdef ALLOW_KPP |
289 |
heimbach |
1.30 |
CADJ STORE uvel (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
290 |
|
|
CADJ STORE vvel (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
291 |
heimbach |
1.11 |
#endif |
292 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
293 |
|
|
|
294 |
|
|
C-- Start of diagnostic loop |
295 |
|
|
DO k=Nr,1,-1 |
296 |
|
|
|
297 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
298 |
|
|
C? Patrick, is this formula correct now that we change the loop range? |
299 |
|
|
C? Do we still need this? |
300 |
|
|
cph kkey formula corrected. |
301 |
|
|
cph Needed for rhok, rhokm1, in the case useGMREDI. |
302 |
heimbach |
1.30 |
kkey = (itdkey-1)*Nr + k |
303 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
304 |
|
|
|
305 |
|
|
C-- Integrate continuity vertically for vertical velocity |
306 |
jmc |
1.27 |
c CALL INTEGRATE_FOR_W( |
307 |
|
|
c I bi, bj, k, uVel, vVel, |
308 |
|
|
c O wVel, |
309 |
|
|
c I myThid ) |
310 |
adcroft |
1.1 |
|
311 |
|
|
#ifdef ALLOW_OBCS |
312 |
|
|
#ifdef ALLOW_NONHYDROSTATIC |
313 |
|
|
C-- Apply OBC to W if in N-H mode |
314 |
jmc |
1.27 |
c IF (useOBCS.AND.nonHydrostatic) THEN |
315 |
|
|
c CALL OBCS_APPLY_W( bi, bj, k, wVel, myThid ) |
316 |
|
|
c ENDIF |
317 |
adcroft |
1.1 |
#endif /* ALLOW_NONHYDROSTATIC */ |
318 |
|
|
#endif /* ALLOW_OBCS */ |
319 |
|
|
|
320 |
heimbach |
1.22 |
C-- Attention: by defining "SINGLE_LAYER_MODE" in CPP_OPTIONS.h |
321 |
|
|
C-- MOST of THERMODYNAMICS will be disabled |
322 |
|
|
#ifndef SINGLE_LAYER_MODE |
323 |
|
|
|
324 |
adcroft |
1.1 |
C-- Calculate gradients of potential density for isoneutral |
325 |
|
|
C slope terms (e.g. GM/Redi tensor or IVDC diffusivity) |
326 |
|
|
c IF ( k.GT.1 .AND. (useGMRedi.OR.ivdc_kappa.NE.0.) ) THEN |
327 |
|
|
IF ( useGMRedi .OR. (k.GT.1 .AND. ivdc_kappa.NE.0.) ) THEN |
328 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
329 |
|
|
CADJ STORE theta(:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
330 |
|
|
CADJ STORE salt (:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
331 |
heimbach |
1.30 |
CADJ STORE pressure(:,:,k,bi,bj) = |
332 |
|
|
CADJ & comlev1_bibj_k, key=kkey, byte=isbyte |
333 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
334 |
|
|
CALL FIND_RHO( |
335 |
mlosch |
1.26 |
I bi, bj, iMin, iMax, jMin, jMax, k, k, |
336 |
adcroft |
1.1 |
I theta, salt, |
337 |
|
|
O rhoK, |
338 |
|
|
I myThid ) |
339 |
heimbach |
1.30 |
|
340 |
adcroft |
1.1 |
IF (k.GT.1) THEN |
341 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
342 |
|
|
CADJ STORE theta(:,:,k-1,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
343 |
|
|
CADJ STORE salt (:,:,k-1,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
344 |
heimbach |
1.30 |
CADJ STORE pressure(:,:,k-1,bi,bj) = |
345 |
|
|
CADJ & comlev1_bibj_k, key=kkey, byte=isbyte |
346 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
347 |
|
|
CALL FIND_RHO( |
348 |
mlosch |
1.26 |
I bi, bj, iMin, iMax, jMin, jMax, k-1, k, |
349 |
adcroft |
1.1 |
I theta, salt, |
350 |
|
|
O rhoKm1, |
351 |
|
|
I myThid ) |
352 |
|
|
ENDIF |
353 |
|
|
CALL GRAD_SIGMA( |
354 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, k, |
355 |
|
|
I rhoK, rhoKm1, rhoK, |
356 |
|
|
O sigmaX, sigmaY, sigmaR, |
357 |
|
|
I myThid ) |
358 |
|
|
ENDIF |
359 |
|
|
|
360 |
heimbach |
1.30 |
#ifdef ALLOW_AUTODIFF_TAMC |
361 |
|
|
CADJ STORE rhok (:,:) = comlev1_bibj_k , key=kkey, byte=isbyte |
362 |
|
|
CADJ STORE rhokm1 (:,:) = comlev1_bibj_k , key=kkey, byte=isbyte |
363 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
364 |
adcroft |
1.1 |
C-- Implicit Vertical Diffusion for Convection |
365 |
|
|
c ==> should use sigmaR !!! |
366 |
|
|
IF (k.GT.1 .AND. ivdc_kappa.NE.0.) THEN |
367 |
|
|
CALL CALC_IVDC( |
368 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, k, |
369 |
|
|
I rhoKm1, rhoK, |
370 |
|
|
U ConvectCount, KappaRT, KappaRS, |
371 |
|
|
I myTime, myIter, myThid) |
372 |
|
|
ENDIF |
373 |
|
|
|
374 |
heimbach |
1.22 |
#endif /* SINGLE_LAYER_MODE */ |
375 |
|
|
|
376 |
adcroft |
1.1 |
C-- end of diagnostic k loop (Nr:1) |
377 |
|
|
ENDDO |
378 |
|
|
|
379 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
380 |
|
|
cph avoids recomputation of integrate_for_w |
381 |
heimbach |
1.30 |
CADJ STORE wvel (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
382 |
|
|
CADJ STORE pressure (:,:,:,bi,bj) = |
383 |
|
|
CADJ & comlev1_bibj, key=itdkey, byte=isbyte |
384 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
385 |
|
|
|
386 |
|
|
#ifdef ALLOW_OBCS |
387 |
|
|
C-- Calculate future values on open boundaries |
388 |
|
|
IF (useOBCS) THEN |
389 |
jmc |
1.16 |
CALL OBCS_CALC( bi, bj, myTime+deltaT, myIter+1, |
390 |
adcroft |
1.1 |
I uVel, vVel, wVel, theta, salt, |
391 |
|
|
I myThid ) |
392 |
|
|
ENDIF |
393 |
|
|
#endif /* ALLOW_OBCS */ |
394 |
|
|
|
395 |
cheisey |
1.31 |
|
396 |
|
|
c******************************************** |
397 |
|
|
cswdice --- add --- |
398 |
cheisey |
1.32 |
#ifdef ALLOW_THERM_SEAICE |
399 |
cheisey |
1.31 |
C-- Determines forcing terms based on external fields |
400 |
|
|
c-- including effects from ice |
401 |
|
|
CALL ICE_FORCING( |
402 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
403 |
|
|
I myThid ) |
404 |
|
|
#else |
405 |
|
|
|
406 |
|
|
cswdice --- end add --- |
407 |
|
|
|
408 |
adcroft |
1.1 |
C-- Determines forcing terms based on external fields |
409 |
|
|
C relaxation terms, etc. |
410 |
cheisey |
1.31 |
CALL EXTERNAL_FORCING_SURF( |
411 |
adcroft |
1.1 |
I bi, bj, iMin, iMax, jMin, jMax, |
412 |
|
|
I myThid ) |
413 |
cheisey |
1.31 |
cswdice --- add ---- |
414 |
|
|
#endif |
415 |
|
|
cswdice --- end add --- |
416 |
|
|
c****************************************** |
417 |
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
adcroft |
1.1 |
#ifdef ALLOW_AUTODIFF_TAMC |
422 |
|
|
cph needed for KPP |
423 |
|
|
CADJ STORE surfacetendencyU(:,:,bi,bj) |
424 |
heimbach |
1.30 |
CADJ & = comlev1_bibj, key=itdkey, byte=isbyte |
425 |
adcroft |
1.1 |
CADJ STORE surfacetendencyV(:,:,bi,bj) |
426 |
heimbach |
1.30 |
CADJ & = comlev1_bibj, key=itdkey, byte=isbyte |
427 |
adcroft |
1.1 |
CADJ STORE surfacetendencyS(:,:,bi,bj) |
428 |
heimbach |
1.30 |
CADJ & = comlev1_bibj, key=itdkey, byte=isbyte |
429 |
adcroft |
1.1 |
CADJ STORE surfacetendencyT(:,:,bi,bj) |
430 |
heimbach |
1.30 |
CADJ & = comlev1_bibj, key=itdkey, byte=isbyte |
431 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
432 |
|
|
|
433 |
heimbach |
1.22 |
C-- Attention: by defining "SINGLE_LAYER_MODE" in CPP_OPTIONS.h |
434 |
|
|
C-- MOST of THERMODYNAMICS will be disabled |
435 |
|
|
#ifndef SINGLE_LAYER_MODE |
436 |
|
|
|
437 |
adcroft |
1.1 |
#ifdef ALLOW_GMREDI |
438 |
|
|
|
439 |
heimbach |
1.22 |
#ifdef ALLOW_AUTODIFF_TAMC |
440 |
|
|
CADJ STORE sigmaX(:,:,k) = comlev1_bibj_k, key=kkey, byte=isbyte |
441 |
|
|
CADJ STORE sigmaY(:,:,k) = comlev1_bibj_k, key=kkey, byte=isbyte |
442 |
|
|
CADJ STORE sigmaR(:,:,k) = comlev1_bibj_k, key=kkey, byte=isbyte |
443 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
444 |
adcroft |
1.1 |
C-- Calculate iso-neutral slopes for the GM/Redi parameterisation |
445 |
|
|
IF (useGMRedi) THEN |
446 |
jmc |
1.15 |
CALL GMREDI_CALC_TENSOR( |
447 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
448 |
adcroft |
1.1 |
I sigmaX, sigmaY, sigmaR, |
449 |
|
|
I myThid ) |
450 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
451 |
|
|
ELSE |
452 |
jmc |
1.15 |
CALL GMREDI_CALC_TENSOR_DUMMY( |
453 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
454 |
adcroft |
1.1 |
I sigmaX, sigmaY, sigmaR, |
455 |
|
|
I myThid ) |
456 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
457 |
|
|
ENDIF |
458 |
|
|
|
459 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
460 |
heimbach |
1.30 |
CADJ STORE Kwx(:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
461 |
|
|
CADJ STORE Kwy(:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
462 |
|
|
CADJ STORE Kwz(:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
463 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
464 |
|
|
|
465 |
|
|
#endif /* ALLOW_GMREDI */ |
466 |
|
|
|
467 |
|
|
#ifdef ALLOW_KPP |
468 |
|
|
C-- Compute KPP mixing coefficients |
469 |
|
|
IF (useKPP) THEN |
470 |
|
|
CALL KPP_CALC( |
471 |
|
|
I bi, bj, myTime, myThid ) |
472 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
473 |
|
|
ELSE |
474 |
|
|
CALL KPP_CALC_DUMMY( |
475 |
|
|
I bi, bj, myTime, myThid ) |
476 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
477 |
|
|
ENDIF |
478 |
|
|
|
479 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
480 |
|
|
CADJ STORE KPPghat (:,:,:,bi,bj) |
481 |
|
|
CADJ & , KPPdiffKzT(:,:,:,bi,bj) |
482 |
|
|
CADJ & , KPPdiffKzS(:,:,:,bi,bj) |
483 |
|
|
CADJ & , KPPfrac (:,: ,bi,bj) |
484 |
heimbach |
1.30 |
CADJ & = comlev1_bibj, key=itdkey, byte=isbyte |
485 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
486 |
|
|
|
487 |
|
|
#endif /* ALLOW_KPP */ |
488 |
|
|
|
489 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
490 |
heimbach |
1.30 |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj, key=itdkey, byte=isbyte |
491 |
|
|
CADJ STORE KappaRS(:,:,:) = comlev1_bibj, key=itdkey, byte=isbyte |
492 |
|
|
CADJ STORE theta(:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
493 |
|
|
CADJ STORE salt (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
494 |
|
|
CADJ STORE uvel (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
495 |
|
|
CADJ STORE vvel (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
496 |
adcroft |
1.1 |
#ifdef ALLOW_PASSIVE_TRACER |
497 |
heimbach |
1.30 |
CADJ STORE tr1 (:,:,:,bi,bj) = comlev1_bibj, key=itdkey, byte=isbyte |
498 |
adcroft |
1.1 |
#endif |
499 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
500 |
|
|
|
501 |
|
|
#ifdef ALLOW_AIM |
502 |
|
|
C AIM - atmospheric intermediate model, physics package code. |
503 |
|
|
C note(jmc) : phiHyd=0 at this point but is not really used in Molteni Physics |
504 |
|
|
IF ( useAIM ) THEN |
505 |
|
|
CALL TIMER_START('AIM_DO_ATMOS_PHYS [DYNAMICS]', myThid) |
506 |
jmc |
1.28 |
CALL AIM_DO_ATMOS_PHYSICS( bi, bj, myTime, myThid ) |
507 |
adcroft |
1.1 |
CALL TIMER_STOP ('AIM_DO_ATMOS_PHYS [DYNAMICS]', myThid) |
508 |
|
|
ENDIF |
509 |
|
|
#endif /* ALLOW_AIM */ |
510 |
jmc |
1.14 |
|
511 |
|
|
#ifdef ALLOW_TIMEAVE |
512 |
|
|
IF (taveFreq.GT.0. .AND. ivdc_kappa.NE.0.) THEN |
513 |
|
|
CALL TIMEAVE_CUMULATE(ConvectCountTave, ConvectCount, Nr, |
514 |
|
|
I deltaTclock, bi, bj, myThid) |
515 |
|
|
ENDIF |
516 |
|
|
#endif /* ALLOW_TIMEAVE */ |
517 |
adcroft |
1.4 |
|
518 |
adcroft |
1.12 |
#ifndef DISABLE_MULTIDIM_ADVECTION |
519 |
adcroft |
1.4 |
C-- Some advection schemes are better calculated using a multi-dimensional |
520 |
|
|
C method in the absence of any other terms and, if used, is done here. |
521 |
adcroft |
1.13 |
C |
522 |
|
|
C The CPP flag DISABLE_MULTIDIM_ADVECTION is currently unset in GAD_OPTIONS.h |
523 |
|
|
C The default is to use multi-dimensinal advection for non-linear advection |
524 |
|
|
C schemes. However, for the sake of efficiency of the adjoint it is necessary |
525 |
|
|
C to be able to exclude this scheme to avoid excessive storage and |
526 |
|
|
C recomputation. It *is* differentiable, if you need it. |
527 |
|
|
C Edit GAD_OPTIONS.h and #define DISABLE_MULTIDIM_ADVECTION to |
528 |
|
|
C disable this section of code. |
529 |
jmc |
1.24 |
IF (tempMultiDimAdvec) THEN |
530 |
heimbach |
1.11 |
CALL GAD_ADVECTION(bi,bj,tempAdvScheme,GAD_TEMPERATURE, |
531 |
|
|
U theta,gT, |
532 |
adcroft |
1.6 |
I myTime,myIter,myThid) |
533 |
jmc |
1.23 |
ENDIF |
534 |
jmc |
1.24 |
IF (saltMultiDimAdvec) THEN |
535 |
heimbach |
1.11 |
CALL GAD_ADVECTION(bi,bj,saltAdvScheme,GAD_SALINITY, |
536 |
|
|
U salt,gS, |
537 |
adcroft |
1.6 |
I myTime,myIter,myThid) |
538 |
|
|
ENDIF |
539 |
adcroft |
1.17 |
C Since passive tracers are configurable separately from T,S we |
540 |
|
|
C call the multi-dimensional method for PTRACERS regardless |
541 |
|
|
C of whether multiDimAdvection is set or not. |
542 |
|
|
#ifdef ALLOW_PTRACERS |
543 |
|
|
IF ( usePTRACERS ) THEN |
544 |
|
|
CALL PTRACERS_ADVECTION( bi,bj,myIter,myTime,myThid ) |
545 |
|
|
ENDIF |
546 |
|
|
#endif /* ALLOW_PTRACERS */ |
547 |
adcroft |
1.12 |
#endif /* DISABLE_MULTIDIM_ADVECTION */ |
548 |
adcroft |
1.1 |
|
549 |
|
|
C-- Start of thermodynamics loop |
550 |
|
|
DO k=Nr,1,-1 |
551 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
552 |
|
|
C? Patrick Is this formula correct? |
553 |
|
|
cph Yes, but I rewrote it. |
554 |
|
|
cph Also, the KappaR? need the index and subscript k! |
555 |
heimbach |
1.30 |
kkey = (itdkey-1)*Nr + k |
556 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
557 |
|
|
|
558 |
|
|
C-- km1 Points to level above k (=k-1) |
559 |
|
|
C-- kup Cycles through 1,2 to point to layer above |
560 |
|
|
C-- kDown Cycles through 2,1 to point to current layer |
561 |
|
|
|
562 |
|
|
km1 = MAX(1,k-1) |
563 |
|
|
kup = 1+MOD(k+1,2) |
564 |
|
|
kDown= 1+MOD(k,2) |
565 |
|
|
|
566 |
|
|
iMin = 1-OLx |
567 |
|
|
iMax = sNx+OLx |
568 |
|
|
jMin = 1-OLy |
569 |
|
|
jMax = sNy+OLy |
570 |
|
|
|
571 |
|
|
C-- Get temporary terms used by tendency routines |
572 |
|
|
CALL CALC_COMMON_FACTORS ( |
573 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k, |
574 |
|
|
O xA,yA,uTrans,vTrans,rTrans,maskUp, |
575 |
|
|
I myThid) |
576 |
jmc |
1.19 |
|
577 |
|
|
#ifdef ALLOW_GMREDI |
578 |
|
|
C-- Residual transp = Bolus transp + Eulerian transp |
579 |
|
|
IF (useGMRedi) THEN |
580 |
|
|
CALL GMREDI_CALC_UVFLOW( |
581 |
|
|
& uTrans, vTrans, bi, bj, k, myThid) |
582 |
|
|
IF (K.GE.2) CALL GMREDI_CALC_WFLOW( |
583 |
|
|
& rTrans, bi, bj, k, myThid) |
584 |
|
|
ENDIF |
585 |
|
|
#endif /* ALLOW_GMREDI */ |
586 |
adcroft |
1.1 |
|
587 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
588 |
|
|
CADJ STORE KappaRT(:,:,k) = comlev1_bibj_k, key=kkey, byte=isbyte |
589 |
|
|
CADJ STORE KappaRS(:,:,k) = comlev1_bibj_k, key=kkey, byte=isbyte |
590 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
591 |
|
|
|
592 |
|
|
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
593 |
|
|
C-- Calculate the total vertical diffusivity |
594 |
|
|
CALL CALC_DIFFUSIVITY( |
595 |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k, |
596 |
|
|
I maskUp, |
597 |
heimbach |
1.2 |
O KappaRT,KappaRS, |
598 |
adcroft |
1.1 |
I myThid) |
599 |
|
|
#endif |
600 |
|
|
|
601 |
|
|
iMin = 1-OLx+2 |
602 |
|
|
iMax = sNx+OLx-1 |
603 |
|
|
jMin = 1-OLy+2 |
604 |
|
|
jMax = sNy+OLy-1 |
605 |
|
|
|
606 |
|
|
C-- Calculate active tracer tendencies (gT,gS,...) |
607 |
|
|
C and step forward storing result in gTnm1, gSnm1, etc. |
608 |
|
|
IF ( tempStepping ) THEN |
609 |
|
|
CALL CALC_GT( |
610 |
|
|
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
611 |
|
|
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
612 |
|
|
I KappaRT, |
613 |
|
|
U fVerT, |
614 |
adcroft |
1.7 |
I myTime,myIter,myThid) |
615 |
adcroft |
1.1 |
CALL TIMESTEP_TRACER( |
616 |
adcroft |
1.3 |
I bi,bj,iMin,iMax,jMin,jMax,k,tempAdvScheme, |
617 |
adcroft |
1.1 |
I theta, gT, |
618 |
|
|
I myIter, myThid) |
619 |
|
|
ENDIF |
620 |
cheisey |
1.32 |
cswdice ---- add --- |
621 |
|
|
#ifdef ALLOW_THERM_SEAICE |
622 |
|
|
if (k.eq.1) then |
623 |
|
|
call ICE_FREEZE(bi, bj, iMin, iMax, jMin, jMax, myThid ) |
624 |
|
|
endif |
625 |
|
|
#endif |
626 |
|
|
cswdice -- end add --- |
627 |
adcroft |
1.1 |
IF ( saltStepping ) THEN |
628 |
|
|
CALL CALC_GS( |
629 |
|
|
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
630 |
|
|
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
631 |
|
|
I KappaRS, |
632 |
|
|
U fVerS, |
633 |
adcroft |
1.7 |
I myTime,myIter,myThid) |
634 |
adcroft |
1.1 |
CALL TIMESTEP_TRACER( |
635 |
adcroft |
1.3 |
I bi,bj,iMin,iMax,jMin,jMax,k,saltAdvScheme, |
636 |
adcroft |
1.1 |
I salt, gS, |
637 |
|
|
I myIter, myThid) |
638 |
|
|
ENDIF |
639 |
|
|
#ifdef ALLOW_PASSIVE_TRACER |
640 |
|
|
IF ( tr1Stepping ) THEN |
641 |
|
|
CALL CALC_GTR1( |
642 |
|
|
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
643 |
|
|
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
644 |
|
|
I KappaRT, |
645 |
|
|
U fVerTr1, |
646 |
heimbach |
1.8 |
I myTime,myIter,myThid) |
647 |
adcroft |
1.1 |
CALL TIMESTEP_TRACER( |
648 |
adcroft |
1.3 |
I bi,bj,iMin,iMax,jMin,jMax,k,tracerAdvScheme, |
649 |
adcroft |
1.1 |
I Tr1, gTr1, |
650 |
heimbach |
1.8 |
I myIter,myThid) |
651 |
adcroft |
1.1 |
ENDIF |
652 |
|
|
#endif |
653 |
adcroft |
1.17 |
#ifdef ALLOW_PTRACERS |
654 |
|
|
IF ( usePTRACERS ) THEN |
655 |
|
|
CALL PTRACERS_INTEGERATE( |
656 |
|
|
I bi,bj,k, |
657 |
|
|
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
658 |
|
|
X KappaRS, |
659 |
|
|
I myIter,myTime,myThid) |
660 |
|
|
ENDIF |
661 |
|
|
#endif /* ALLOW_PTRACERS */ |
662 |
adcroft |
1.1 |
|
663 |
|
|
#ifdef ALLOW_OBCS |
664 |
|
|
C-- Apply open boundary conditions |
665 |
|
|
IF (useOBCS) THEN |
666 |
adcroft |
1.7 |
CALL OBCS_APPLY_TS( bi, bj, k, gT, gS, myThid ) |
667 |
adcroft |
1.1 |
END IF |
668 |
|
|
#endif /* ALLOW_OBCS */ |
669 |
|
|
|
670 |
|
|
C-- Freeze water |
671 |
heimbach |
1.29 |
IF ( allowFreezing .AND. .NOT. useSEAICE ) THEN |
672 |
adcroft |
1.1 |
#ifdef ALLOW_AUTODIFF_TAMC |
673 |
heimbach |
1.11 |
CADJ STORE gT(:,:,k,bi,bj) = comlev1_bibj_k |
674 |
adcroft |
1.1 |
CADJ & , key = kkey, byte = isbyte |
675 |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
676 |
|
|
CALL FREEZE( bi, bj, iMin, iMax, jMin, jMax, k, myThid ) |
677 |
|
|
END IF |
678 |
|
|
|
679 |
|
|
C-- end of thermodynamic k loop (Nr:1) |
680 |
|
|
ENDDO |
681 |
cheisey |
1.31 |
|
682 |
|
|
cswdice -- add --- |
683 |
cheisey |
1.32 |
#ifdef ALLOW_THERM_SEAICE |
684 |
cheisey |
1.31 |
c timeaveraging for ice model values |
685 |
|
|
CALL ICE_AVE(bi,bj,iMin,iMax,jMin,jMax,myThid ) |
686 |
|
|
#endif |
687 |
|
|
cswdice --- end add --- |
688 |
|
|
|
689 |
|
|
|
690 |
|
|
|
691 |
adcroft |
1.1 |
|
692 |
|
|
C-- Implicit diffusion |
693 |
|
|
IF (implicitDiffusion) THEN |
694 |
|
|
|
695 |
|
|
IF (tempStepping) THEN |
696 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
697 |
heimbach |
1.30 |
CADJ STORE gT(:,:,:,bi,bj) = comlev1_bibj , key=itdkey, byte=isbyte |
698 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
699 |
|
|
CALL IMPLDIFF( |
700 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
701 |
|
|
I deltaTtracer, KappaRT, recip_HFacC, |
702 |
adcroft |
1.7 |
U gT, |
703 |
adcroft |
1.1 |
I myThid ) |
704 |
|
|
ENDIF |
705 |
|
|
|
706 |
|
|
IF (saltStepping) THEN |
707 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
708 |
heimbach |
1.30 |
CADJ STORE gS(:,:,:,bi,bj) = comlev1_bibj , key=itdkey, byte=isbyte |
709 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
710 |
|
|
CALL IMPLDIFF( |
711 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
712 |
|
|
I deltaTtracer, KappaRS, recip_HFacC, |
713 |
adcroft |
1.7 |
U gS, |
714 |
adcroft |
1.1 |
I myThid ) |
715 |
|
|
ENDIF |
716 |
|
|
|
717 |
|
|
#ifdef ALLOW_PASSIVE_TRACER |
718 |
|
|
IF (tr1Stepping) THEN |
719 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
720 |
heimbach |
1.30 |
CADJ STORE gTr1(:,:,:,bi,bj) = comlev1_bibj , key=itdkey, byte=isbyte |
721 |
adcroft |
1.1 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
722 |
|
|
CALL IMPLDIFF( |
723 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
724 |
|
|
I deltaTtracer, KappaRT, recip_HFacC, |
725 |
adcroft |
1.7 |
U gTr1, |
726 |
adcroft |
1.1 |
I myThid ) |
727 |
|
|
ENDIF |
728 |
|
|
#endif |
729 |
|
|
|
730 |
adcroft |
1.17 |
#ifdef ALLOW_PTRACERS |
731 |
|
|
C Vertical diffusion (implicit) for passive tracers |
732 |
|
|
IF ( usePTRACERS ) THEN |
733 |
|
|
CALL PTRACERS_IMPLDIFF( bi,bj,KappaRS,myThid ) |
734 |
|
|
ENDIF |
735 |
|
|
#endif /* ALLOW_PTRACERS */ |
736 |
|
|
|
737 |
adcroft |
1.1 |
#ifdef ALLOW_OBCS |
738 |
|
|
C-- Apply open boundary conditions |
739 |
|
|
IF (useOBCS) THEN |
740 |
|
|
DO K=1,Nr |
741 |
adcroft |
1.7 |
CALL OBCS_APPLY_TS( bi, bj, k, gT, gS, myThid ) |
742 |
adcroft |
1.1 |
ENDDO |
743 |
|
|
END IF |
744 |
|
|
#endif /* ALLOW_OBCS */ |
745 |
|
|
|
746 |
|
|
C-- End If implicitDiffusion |
747 |
|
|
ENDIF |
748 |
heimbach |
1.22 |
|
749 |
|
|
#endif /* SINGLE_LAYER_MODE */ |
750 |
adcroft |
1.1 |
|
751 |
|
|
Ccs- |
752 |
|
|
ENDDO |
753 |
|
|
ENDDO |
754 |
|
|
|
755 |
|
|
#ifdef ALLOW_AIM |
756 |
jmc |
1.27 |
c IF ( useAIM ) THEN |
757 |
|
|
c CALL AIM_AIM2DYN_EXCHANGES( myTime, myThid ) |
758 |
|
|
c ENDIF |
759 |
adcroft |
1.1 |
#endif /* ALLOW_AIM */ |
760 |
jmc |
1.27 |
c IF ( staggerTimeStep ) THEN |
761 |
|
|
c IF ( useAIM .OR. useCubedSphereExchange ) THEN |
762 |
|
|
c IF (tempStepping) _EXCH_XYZ_R8(gT,myThid) |
763 |
|
|
c IF (saltStepping) _EXCH_XYZ_R8(gS,myThid) |
764 |
|
|
c ELSEIF ( useGMRedi .AND. Oly.LT.4 ) THEN |
765 |
|
|
cc .AND. GM_AdvForm .AND. .NOT.GM_AdvSeparate ) THEN |
766 |
|
|
c IF (tempMultiDimAdvec) _EXCH_XYZ_R8(gT,myThid) |
767 |
|
|
c IF (saltMultiDimAdvec) _EXCH_XYZ_R8(gS,myThid) |
768 |
|
|
c ENDIF |
769 |
|
|
c ENDIF |
770 |
adcroft |
1.17 |
|
771 |
|
|
#ifndef DISABLE_DEBUGMODE |
772 |
|
|
If (debugMode) THEN |
773 |
|
|
CALL DEBUG_STATS_RL(Nr,uVel,'Uvel (THERMODYNAMICS)',myThid) |
774 |
|
|
CALL DEBUG_STATS_RL(Nr,vVel,'Vvel (THERMODYNAMICS)',myThid) |
775 |
|
|
CALL DEBUG_STATS_RL(Nr,wVel,'Wvel (THERMODYNAMICS)',myThid) |
776 |
|
|
CALL DEBUG_STATS_RL(Nr,theta,'Theta (THERMODYNAMICS)',myThid) |
777 |
|
|
CALL DEBUG_STATS_RL(Nr,salt,'Salt (THERMODYNAMICS)',myThid) |
778 |
|
|
CALL DEBUG_STATS_RL(Nr,Gt,'Gt (THERMODYNAMICS)',myThid) |
779 |
|
|
CALL DEBUG_STATS_RL(Nr,Gs,'Gs (THERMODYNAMICS)',myThid) |
780 |
|
|
CALL DEBUG_STATS_RL(Nr,GtNm1,'GtNm1 (THERMODYNAMICS)',myThid) |
781 |
|
|
CALL DEBUG_STATS_RL(Nr,GsNm1,'GsNm1 (THERMODYNAMICS)',myThid) |
782 |
adcroft |
1.18 |
#ifdef ALLOW_PTRACERS |
783 |
|
|
IF ( usePTRACERS ) THEN |
784 |
|
|
CALL PTRACERS_DEBUG(myThid) |
785 |
|
|
ENDIF |
786 |
|
|
#endif /* ALLOW_PTRACERS */ |
787 |
adcroft |
1.17 |
ENDIF |
788 |
|
|
#endif |
789 |
adcroft |
1.1 |
|
790 |
|
|
RETURN |
791 |
|
|
END |