1 |
C $Header$ |
C $Header$ |
2 |
|
C $Name$ |
3 |
|
|
4 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
5 |
|
|
26 |
C == Global variables === |
C == Global variables === |
27 |
#include "SIZE.h" |
#include "SIZE.h" |
28 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
|
#include "CG2D.h" |
|
29 |
#include "PARAMS.h" |
#include "PARAMS.h" |
30 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
31 |
#include "GRID.h" |
#include "GRID.h" |
39 |
# include "KPP.h" |
# include "KPP.h" |
40 |
#endif |
#endif |
41 |
|
|
42 |
|
#ifdef ALLOW_TIMEAVE |
43 |
|
#include "TIMEAVE_STATV.h" |
44 |
|
#endif |
45 |
|
|
46 |
C == Routine arguments == |
C == Routine arguments == |
47 |
C myTime - Current time in simulation |
C myTime - Current time in simulation |
48 |
C myIter - Current iteration number in simulation |
C myIter - Current iteration number in simulation |
55 |
C xA, yA - Per block temporaries holding face areas |
C xA, yA - Per block temporaries holding face areas |
56 |
C uTrans, vTrans, rTrans - Per block temporaries holding flow |
C uTrans, vTrans, rTrans - Per block temporaries holding flow |
57 |
C transport |
C transport |
58 |
C rVel o uTrans: Zonal transport |
C o uTrans: Zonal transport |
59 |
C o vTrans: Meridional transport |
C o vTrans: Meridional transport |
60 |
C o rTrans: Vertical transport |
C o rTrans: Vertical transport |
61 |
C o rVel: Vertical velocity at upper and |
C maskUp o maskUp: land/water mask for W points |
|
C lower cell faces. |
|
|
C maskC,maskUp o maskC: land/water mask for tracer cells |
|
|
C o maskUp: land/water mask for W points |
|
62 |
C fVer[STUV] o fVer: Vertical flux term - note fVer |
C fVer[STUV] o fVer: Vertical flux term - note fVer |
63 |
C is "pipelined" in the vertical |
C is "pipelined" in the vertical |
64 |
C so we need an fVer for each |
C so we need an fVer for each |
65 |
C variable. |
C variable. |
66 |
C rhoK, rhoKM1 - Density at current level, level above and level |
C rhoK, rhoKM1 - Density at current level, and level above |
|
C below. |
|
|
C rhoKP1 |
|
|
C buoyK, buoyKM1 - Buoyancy at current level and level above. |
|
67 |
C phiHyd - Hydrostatic part of the potential phiHydi. |
C phiHyd - Hydrostatic part of the potential phiHydi. |
68 |
C In z coords phiHydiHyd is the hydrostatic |
C In z coords phiHydiHyd is the hydrostatic |
69 |
C pressure anomaly |
C Potential (=pressure/rho0) anomaly |
70 |
C In p coords phiHydiHyd is the geopotential |
C In p coords phiHydiHyd is the geopotential |
71 |
C surface height |
C surface height anomaly. |
72 |
C anomaly. |
C phiSurfX, - gradient of Surface potentiel (Pressure/rho, ocean) |
73 |
C etaSurfX, - Holds surface elevation gradient in X and Y. |
C phiSurfY or geopotentiel (atmos) in X and Y direction |
|
C etaSurfY |
|
74 |
C KappaRT, - Total diffusion in vertical for T and S. |
C KappaRT, - Total diffusion in vertical for T and S. |
75 |
C KappaRS (background + spatially varying, isopycnal term). |
C KappaRS (background + spatially varying, isopycnal term). |
76 |
C iMin, iMax - Ranges and sub-block indices on which calculations |
C iMin, iMax - Ranges and sub-block indices on which calculations |
79 |
C k, kup, - Index for layer above and below. kup and kDown |
C k, kup, - Index for layer above and below. kup and kDown |
80 |
C kDown, km1 are switched with layer to be the appropriate |
C kDown, km1 are switched with layer to be the appropriate |
81 |
C index into fVerTerm. |
C index into fVerTerm. |
82 |
|
C tauAB - Adams-Bashforth timestepping weight: 0=forward ; 1/2=Adams-Bashf. |
83 |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
84 |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
85 |
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
86 |
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
87 |
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
_RL rVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
|
|
_RS maskC (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
88 |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
89 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
90 |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
92 |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
93 |
_RL phiHyd (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL phiHyd (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
94 |
_RL rhokm1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhokm1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
_RL rhokp1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
95 |
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
96 |
_RL buoyKM1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
97 |
_RL buoyK (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
_RL rhotmp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
98 |
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
99 |
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
100 |
_RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
102 |
_RL sigmaX (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL sigmaX (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
103 |
_RL sigmaY (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL sigmaY (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
104 |
_RL sigmaR (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL sigmaR (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
105 |
|
_RL tauAB |
106 |
|
|
107 |
C This is currently also used by IVDC and Diagnostics |
C This is currently used by IVDC and Diagnostics |
|
C #ifdef INCLUDE_CONVECT_CALL |
|
108 |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
|
C #endif |
|
109 |
|
|
110 |
INTEGER iMin, iMax |
INTEGER iMin, iMax |
111 |
INTEGER jMin, jMax |
INTEGER jMin, jMax |
113 |
INTEGER i, j |
INTEGER i, j |
114 |
INTEGER k, km1, kup, kDown |
INTEGER k, km1, kup, kDown |
115 |
|
|
116 |
|
Cjmc : add for phiHyd output <- but not working if multi tile per CPU |
117 |
|
c CHARACTER*(MAX_LEN_MBUF) suff |
118 |
|
c LOGICAL DIFFERENT_MULTIPLE |
119 |
|
c EXTERNAL DIFFERENT_MULTIPLE |
120 |
|
Cjmc(end) |
121 |
|
|
122 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
123 |
INTEGER isbyte |
INTEGER isbyte |
124 |
PARAMETER( isbyte = 4 ) |
PARAMETER( isbyte = 4 ) |
143 |
C =================== |
C =================== |
144 |
C This is where all the accelerations and tendencies (ie. |
C This is where all the accelerations and tendencies (ie. |
145 |
C physics, parameterizations etc...) are calculated |
C physics, parameterizations etc...) are calculated |
|
C rVel = sum_r ( div. u[n] ) |
|
146 |
C rho = rho ( theta[n], salt[n] ) |
C rho = rho ( theta[n], salt[n] ) |
147 |
C b = b(rho, theta) |
C b = b(rho, theta) |
148 |
C K31 = K31 ( rho ) |
C K31 = K31 ( rho ) |
149 |
C Gu[n] = Gu( u[n], v[n], rVel, b, ... ) |
C Gu[n] = Gu( u[n], v[n], wVel, b, ... ) |
150 |
C Gv[n] = Gv( u[n], v[n], rVel, b, ... ) |
C Gv[n] = Gv( u[n], v[n], wVel, b, ... ) |
151 |
C Gt[n] = Gt( theta[n], u[n], v[n], rVel, K31, ... ) |
C Gt[n] = Gt( theta[n], u[n], v[n], wVel, K31, ... ) |
152 |
C Gs[n] = Gs( salt[n], u[n], v[n], rVel, K31, ... ) |
C Gs[n] = Gs( salt[n], u[n], v[n], wVel, K31, ... ) |
153 |
C |
C |
154 |
C "Time-stepping" or "Prediction" |
C "Time-stepping" or "Prediction" |
155 |
C ================================ |
C ================================ |
190 |
uTrans(i,j) = 0. _d 0 |
uTrans(i,j) = 0. _d 0 |
191 |
vTrans(i,j) = 0. _d 0 |
vTrans(i,j) = 0. _d 0 |
192 |
DO k=1,Nr |
DO k=1,Nr |
193 |
phiHyd (i,j,k) = 0. _d 0 |
phiHyd(i,j,k) = 0. _d 0 |
194 |
KappaRU(i,j,k) = 0. _d 0 |
KappaRU(i,j,k) = 0. _d 0 |
195 |
KappaRV(i,j,k) = 0. _d 0 |
KappaRV(i,j,k) = 0. _d 0 |
196 |
sigmaX(i,j,k) = 0. _d 0 |
sigmaX(i,j,k) = 0. _d 0 |
199 |
ENDDO |
ENDDO |
200 |
rhoKM1 (i,j) = 0. _d 0 |
rhoKM1 (i,j) = 0. _d 0 |
201 |
rhok (i,j) = 0. _d 0 |
rhok (i,j) = 0. _d 0 |
202 |
rhoKP1 (i,j) = 0. _d 0 |
phiSurfX(i,j) = 0. _d 0 |
203 |
rhoTMP (i,j) = 0. _d 0 |
phiSurfY(i,j) = 0. _d 0 |
|
buoyKM1(i,j) = 0. _d 0 |
|
|
buoyK (i,j) = 0. _d 0 |
|
|
maskC (i,j) = 0. _d 0 |
|
204 |
ENDDO |
ENDDO |
205 |
ENDDO |
ENDDO |
206 |
|
|
214 |
|
|
215 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
216 |
C-- HPF directive to help TAMC |
C-- HPF directive to help TAMC |
217 |
CHPF$ INDEPENDENT, NEW (rTrans,rVel,fVerT,fVerS,fVerU,fVerV |
CHPF$ INDEPENDENT, NEW (rTrans,fVerT,fVerS,fVerU,fVerV |
218 |
CHPF$& ,phiHyd,utrans,vtrans,maskc,xA,yA |
CHPF$& ,phiHyd,utrans,vtrans,xA,yA |
219 |
CHPF$& ,KappaRT,KappaRS,KappaRU,KappaRV |
CHPF$& ,KappaRT,KappaRS,KappaRU,KappaRV |
220 |
CHPF$& ) |
CHPF$& ) |
221 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
243 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
244 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
245 |
rTrans(i,j) = 0. _d 0 |
rTrans(i,j) = 0. _d 0 |
|
rVel (i,j,1) = 0. _d 0 |
|
|
rVel (i,j,2) = 0. _d 0 |
|
246 |
fVerT (i,j,1) = 0. _d 0 |
fVerT (i,j,1) = 0. _d 0 |
247 |
fVerT (i,j,2) = 0. _d 0 |
fVerT (i,j,2) = 0. _d 0 |
248 |
fVerS (i,j,1) = 0. _d 0 |
fVerS (i,j,1) = 0. _d 0 |
251 |
fVerU (i,j,2) = 0. _d 0 |
fVerU (i,j,2) = 0. _d 0 |
252 |
fVerV (i,j,1) = 0. _d 0 |
fVerV (i,j,1) = 0. _d 0 |
253 |
fVerV (i,j,2) = 0. _d 0 |
fVerV (i,j,2) = 0. _d 0 |
|
phiHyd(i,j,1) = 0. _d 0 |
|
254 |
ENDDO |
ENDDO |
255 |
ENDDO |
ENDDO |
256 |
|
|
257 |
DO k=1,Nr |
DO k=1,Nr |
258 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
259 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
260 |
#ifdef INCLUDE_CONVECT_CALL |
C This is currently also used by IVDC and Diagnostics |
261 |
ConvectCount(i,j,k) = 0. |
ConvectCount(i,j,k) = 0. |
|
#endif |
|
262 |
KappaRT(i,j,k) = 0. _d 0 |
KappaRT(i,j,k) = 0. _d 0 |
263 |
KappaRS(i,j,k) = 0. _d 0 |
KappaRS(i,j,k) = 0. _d 0 |
264 |
ENDDO |
ENDDO |
280 |
kkey = (ikey-1)*(Nr-2+1) + (k-2) + 1 |
kkey = (ikey-1)*(Nr-2+1) + (k-2) + 1 |
281 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
282 |
|
|
|
#ifdef ALLOW_OBCS |
|
|
C-- Calculate future values on open boundaries |
|
|
IF (openBoundaries) THEN |
|
|
Caja CALL CYCLE_OBCS( k, bi, bj, myThid ) |
|
|
c new args! CALL SET_OBCS( k, bi, bj, myTime, myThid ) |
|
|
c +deltaT? |
|
|
ENDIF |
|
|
#endif |
|
|
|
|
283 |
C-- Integrate continuity vertically for vertical velocity |
C-- Integrate continuity vertically for vertical velocity |
284 |
CALL INTEGRATE_FOR_W( |
CALL INTEGRATE_FOR_W( |
285 |
I bi, bj, k, uVel, vVel, |
I bi, bj, k, uVel, vVel, |
286 |
O wVel, |
O wVel, |
287 |
I myThid ) |
I myThid ) |
288 |
#ifdef ALLOW_OBCS |
|
289 |
IF (openBoundaries) THEN |
#ifdef ALLOW_OBCS |
290 |
c new subr CALL OBCS_APPLY_W( bi, bj, k, wVel, myThid ) |
#ifdef ALLOW_NONHYDROSTATIC |
291 |
|
C-- Apply OBC to W if in N-H mode |
292 |
|
IF (useOBCS.AND.nonHydrostatic) THEN |
293 |
|
CALL OBCS_APPLY_W( bi, bj, k, wVel, myThid ) |
294 |
ENDIF |
ENDIF |
295 |
#endif |
#endif /* ALLOW_NONHYDROSTATIC */ |
296 |
|
#endif /* ALLOW_OBCS */ |
297 |
|
|
298 |
C-- Calculate gradients of potential density for isoneutral |
C-- Calculate gradients of potential density for isoneutral |
299 |
C slope terms (e.g. GM/Redi tensor or IVDC diffusivity) |
C slope terms (e.g. GM/Redi tensor or IVDC diffusivity) |
300 |
IF ( k.GT.1 .AND. (useGMRedi.OR.ivdc_kappa.NE.0.) ) THEN |
c IF ( k.GT.1 .AND. (useGMRedi.OR.ivdc_kappa.NE.0.) ) THEN |
301 |
|
IF ( useGMRedi .OR. (k.GT.1 .AND. ivdc_kappa.NE.0.) ) THEN |
302 |
CALL FIND_RHO( |
CALL FIND_RHO( |
303 |
I bi, bj, iMin, iMax, jMin, jMax, k, k, eosType, |
I bi, bj, iMin, iMax, jMin, jMax, k, k, eosType, |
304 |
|
I theta, salt, |
305 |
O rhoK, |
O rhoK, |
306 |
I myThid ) |
I myThid ) |
307 |
CALL FIND_RHO( |
IF (k.GT.1) CALL FIND_RHO( |
308 |
I bi, bj, iMin, iMax, jMin, jMax, k-1, k, eosType, |
I bi, bj, iMin, iMax, jMin, jMax, k-1, k, eosType, |
309 |
|
I theta, salt, |
310 |
O rhoKm1, |
O rhoKm1, |
311 |
I myThid ) |
I myThid ) |
312 |
CALL GRAD_SIGMA( |
CALL GRAD_SIGMA( |
317 |
ENDIF |
ENDIF |
318 |
|
|
319 |
C-- Implicit Vertical Diffusion for Convection |
C-- Implicit Vertical Diffusion for Convection |
320 |
|
c ==> should use sigmaR !!! |
321 |
IF (k.GT.1 .AND. ivdc_kappa.NE.0.) THEN |
IF (k.GT.1 .AND. ivdc_kappa.NE.0.) THEN |
322 |
CALL CALC_IVDC( |
CALL CALC_IVDC( |
323 |
I bi, bj, iMin, iMax, jMin, jMax, k, |
I bi, bj, iMin, iMax, jMin, jMax, k, |
324 |
I rhoKm1, rhoK, |
I rhoKm1, rhoK, |
|
c should use sigmaR !!! |
|
325 |
U ConvectCount, KappaRT, KappaRS, |
U ConvectCount, KappaRT, KappaRS, |
326 |
I myTime, myIter, myThid) |
I myTime, myIter, myThid) |
327 |
END IF |
ENDIF |
328 |
|
|
329 |
C-- end of diagnostic k loop (Nr:1) |
C-- end of diagnostic k loop (Nr:1) |
330 |
ENDDO |
ENDDO |
331 |
|
|
332 |
|
#ifdef ALLOW_OBCS |
333 |
|
C-- Calculate future values on open boundaries |
334 |
|
IF (useOBCS) THEN |
335 |
|
CALL OBCS_CALC( bi, bj, myTime+deltaT, |
336 |
|
I uVel, vVel, wVel, theta, salt, |
337 |
|
I myThid ) |
338 |
|
ENDIF |
339 |
|
#endif /* ALLOW_OBCS */ |
340 |
|
|
341 |
|
C-- Determines forcing terms based on external fields |
342 |
|
C relaxation terms, etc. |
343 |
|
CALL EXTERNAL_FORCING_SURF( |
344 |
|
I bi, bj, iMin, iMax, jMin, jMax, |
345 |
|
I myThid ) |
346 |
|
|
347 |
#ifdef ALLOW_GMREDI |
#ifdef ALLOW_GMREDI |
348 |
C-- Calculate iso-neutral slopes for the GM/Redi parameterisation |
C-- Calculate iso-neutral slopes for the GM/Redi parameterisation |
349 |
IF (useGMRedi) THEN |
IF (useGMRedi) THEN |
353 |
I sigmaX, sigmaY, sigmaR, |
I sigmaX, sigmaY, sigmaR, |
354 |
I myThid ) |
I myThid ) |
355 |
ENDDO |
ENDDO |
356 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
357 |
|
ELSE |
358 |
|
DO k=1, Nr |
359 |
|
CALL GMREDI_CALC_TENSOR_DUMMY( |
360 |
|
I bi, bj, iMin, iMax, jMin, jMax, k, |
361 |
|
I sigmaX, sigmaY, sigmaR, |
362 |
|
I myThid ) |
363 |
|
ENDDO |
364 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
365 |
ENDIF |
ENDIF |
366 |
#endif /* ALLOW_GMREDI */ |
#endif /* ALLOW_GMREDI */ |
367 |
|
|
373 |
ENDIF |
ENDIF |
374 |
#endif /* ALLOW_KPP */ |
#endif /* ALLOW_KPP */ |
375 |
|
|
|
C-- Determines forcing terms based on external fields |
|
|
C relaxation terms, etc. |
|
|
CALL EXTERNAL_FORCING_SURF( |
|
|
I bi, bj, iMin, iMax, jMin, jMax, |
|
|
I myThid ) |
|
|
|
|
376 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
377 |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj, key = ikey, byte = isbyte |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj, key = ikey, byte = isbyte |
378 |
CADJ STORE KappaRS(:,:,:) = comlev1_bibj, key = ikey, byte = isbyte |
CADJ STORE KappaRS(:,:,:) = comlev1_bibj, key = ikey, byte = isbyte |
382 |
CADJ STORE vvel (:,:,:,bi,bj) = comlev1_bibj, key = ikey, byte = isbyte |
CADJ STORE vvel (:,:,:,bi,bj) = comlev1_bibj, key = ikey, byte = isbyte |
383 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
384 |
|
|
385 |
|
#ifdef ALLOW_AIM |
386 |
|
C AIM - atmospheric intermediate model, physics package code. |
387 |
|
C note(jmc) : phiHyd=0 at this point but is not really used in Molteni Physics |
388 |
|
IF ( useAIM ) THEN |
389 |
|
CALL TIMER_START('AIM_DO_ATMOS_PHYS [DYNAMICS]', myThid) |
390 |
|
CALL AIM_DO_ATMOS_PHYSICS( phiHyd, myTime, myThid ) |
391 |
|
CALL TIMER_STOP ('AIM_DO_ATMOS_PHYS [DYNAMICS]', myThid) |
392 |
|
ENDIF |
393 |
|
#endif /* ALLOW_AIM */ |
394 |
|
|
395 |
|
|
396 |
C-- Start of thermodynamics loop |
C-- Start of thermodynamics loop |
412 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
413 |
CPatrick Is this formula correct? |
CPatrick Is this formula correct? |
414 |
kkey = (ikey-1)*(Nr-1+1) + (k-1) + 1 |
kkey = (ikey-1)*(Nr-1+1) + (k-1) + 1 |
|
CADJ STORE rvel (:,:,kDown) = comlev1_bibj_k, key = kkey, byte = isbyte |
|
415 |
CADJ STORE rTrans(:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
CADJ STORE rTrans(:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
416 |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
417 |
CADJ STORE KappaRS(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
CADJ STORE KappaRS(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
419 |
|
|
420 |
C-- Get temporary terms used by tendency routines |
C-- Get temporary terms used by tendency routines |
421 |
CALL CALC_COMMON_FACTORS ( |
CALL CALC_COMMON_FACTORS ( |
422 |
I bi,bj,iMin,iMax,jMin,jMax,k,km1,kup,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k, |
423 |
O xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp, |
O xA,yA,uTrans,vTrans,rTrans,maskUp, |
424 |
I myThid) |
I myThid) |
425 |
|
|
426 |
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
427 |
C-- Calculate the total vertical diffusivity |
C-- Calculate the total vertical diffusivity |
428 |
CALL CALC_DIFFUSIVITY( |
CALL CALC_DIFFUSIVITY( |
429 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
I bi,bj,iMin,iMax,jMin,jMax,k, |
430 |
I maskC,maskup, |
I maskUp, |
431 |
O KappaRT,KappaRS,KappaRU,KappaRV, |
O KappaRT,KappaRS,KappaRU,KappaRV, |
432 |
I myThid) |
I myThid) |
433 |
#endif |
#endif |
437 |
IF ( tempStepping ) THEN |
IF ( tempStepping ) THEN |
438 |
CALL CALC_GT( |
CALL CALC_GT( |
439 |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
440 |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
441 |
I KappaRT, |
I KappaRT, |
442 |
U fVerT, |
U fVerT, |
443 |
I myTime, myThid) |
I myTime, myThid) |
444 |
|
tauAB = 0.5d0 + abEps |
445 |
CALL TIMESTEP_TRACER( |
CALL TIMESTEP_TRACER( |
446 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
I bi,bj,iMin,iMax,jMin,jMax,k,tauAB, |
447 |
I theta, gT, |
I theta, gT, |
448 |
U gTnm1, |
U gTnm1, |
449 |
I myIter, myThid) |
I myIter, myThid) |
451 |
IF ( saltStepping ) THEN |
IF ( saltStepping ) THEN |
452 |
CALL CALC_GS( |
CALL CALC_GS( |
453 |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
454 |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
455 |
I KappaRS, |
I KappaRS, |
456 |
U fVerS, |
U fVerS, |
457 |
I myTime, myThid) |
I myTime, myThid) |
458 |
|
tauAB = 0.5d0 + abEps |
459 |
CALL TIMESTEP_TRACER( |
CALL TIMESTEP_TRACER( |
460 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
I bi,bj,iMin,iMax,jMin,jMax,k,tauAB, |
461 |
I salt, gS, |
I salt, gS, |
462 |
U gSnm1, |
U gSnm1, |
463 |
I myIter, myThid) |
I myIter, myThid) |
464 |
ENDIF |
ENDIF |
465 |
#ifdef ALLOW_OBCS |
|
466 |
|
#ifdef ALLOW_OBCS |
467 |
C-- Apply open boundary conditions |
C-- Apply open boundary conditions |
468 |
IF (openBoundaries) THEN |
IF (useOBCS) THEN |
469 |
#ifdef ALLOW_AUTODIFF_TAMC |
CALL OBCS_APPLY_TS( bi, bj, k, gTnm1, gSnm1, myThid ) |
|
CADJ STORE gwnm1(:,:,k,bi,bj) = comlev1_bibj_k |
|
|
CADJ & , key = kkey, byte = isbyte |
|
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
|
|
c new subr CALL OBCS_APPLY_TS( bi, bj, k, myThid ) |
|
470 |
END IF |
END IF |
471 |
#endif |
#endif /* ALLOW_OBCS */ |
472 |
|
|
473 |
C-- Freeze water |
C-- Freeze water |
474 |
IF (allowFreezing) THEN |
IF (allowFreezing) THEN |
475 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
492 |
C-- Implicit diffusion |
C-- Implicit diffusion |
493 |
IF (implicitDiffusion) THEN |
IF (implicitDiffusion) THEN |
494 |
|
|
495 |
IF (tempStepping) THEN |
IF (tempStepping) THEN |
496 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
497 |
idkey = iikey + 1 |
idkey = iikey + 1 |
498 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
514 |
I myThid ) |
I myThid ) |
515 |
ENDIF |
ENDIF |
516 |
|
|
517 |
|
#ifdef ALLOW_OBCS |
518 |
|
C-- Apply open boundary conditions |
519 |
|
IF (useOBCS) THEN |
520 |
|
DO K=1,Nr |
521 |
|
CALL OBCS_APPLY_TS( bi, bj, k, gTnm1, gSnm1, myThid ) |
522 |
|
ENDDO |
523 |
|
END IF |
524 |
|
#endif /* ALLOW_OBCS */ |
525 |
|
|
526 |
C-- End If implicitDiffusion |
C-- End If implicitDiffusion |
527 |
ENDIF |
ENDIF |
528 |
|
|
529 |
|
C-- Start computation of dynamics |
530 |
|
iMin = 1-OLx+2 |
531 |
|
iMax = sNx+OLx-1 |
532 |
|
jMin = 1-OLy+2 |
533 |
|
jMax = sNy+OLy-1 |
534 |
|
|
535 |
|
C-- Explicit part of the Surface Potentiel Gradient (add in TIMESTEP) |
536 |
|
C (note: this loop will be replaced by CALL CALC_GRAD_ETA) |
537 |
|
IF (implicSurfPress.NE.1.) THEN |
538 |
|
CALL CALC_GRAD_PHI_SURF( |
539 |
|
I bi,bj,iMin,iMax,jMin,jMax, |
540 |
|
I etaN, |
541 |
|
O phiSurfX,phiSurfY, |
542 |
|
I myThid ) |
543 |
|
ENDIF |
544 |
|
|
545 |
C-- Start of dynamics loop |
C-- Start of dynamics loop |
546 |
DO k=1,Nr |
DO k=1,Nr |
553 |
kup = 1+MOD(k+1,2) |
kup = 1+MOD(k+1,2) |
554 |
kDown= 1+MOD(k,2) |
kDown= 1+MOD(k,2) |
555 |
|
|
|
iMin = 1-OLx+2 |
|
|
iMax = sNx+OLx-1 |
|
|
jMin = 1-OLy+2 |
|
|
jMax = sNy+OLy-1 |
|
|
|
|
|
C-- Calculate buoyancy |
|
|
CALL FIND_RHO( |
|
|
I bi, bj, iMin, iMax, jMin, jMax, km1, km1, eosType, |
|
|
O rhoKm1, |
|
|
I myThid ) |
|
|
CALL CALC_BUOYANCY( |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k,rhoKm1, |
|
|
O buoyKm1, |
|
|
I myThid ) |
|
|
CALL FIND_RHO( |
|
|
I bi, bj, iMin, iMax, jMin, jMax, k, k, eosType, |
|
|
O rhoK, |
|
|
I myThid ) |
|
|
CALL CALC_BUOYANCY( |
|
|
I bi,bj,iMin,iMax,jMin,jMax,k,rhoK, |
|
|
O buoyK, |
|
|
I myThid ) |
|
|
|
|
556 |
C-- Integrate hydrostatic balance for phiHyd with BC of |
C-- Integrate hydrostatic balance for phiHyd with BC of |
557 |
C-- phiHyd(z=0)=0 |
C phiHyd(z=0)=0 |
558 |
CALL CALC_PHI_HYD( |
C distinguishe between Stagger and Non Stagger time stepping |
559 |
I bi,bj,iMin,iMax,jMin,jMax,k,buoyKm1,buoyK, |
IF (staggerTimeStep) THEN |
560 |
|
CALL CALC_PHI_HYD( |
561 |
|
I bi,bj,iMin,iMax,jMin,jMax,k, |
562 |
|
I gTnm1, gSnm1, |
563 |
U phiHyd, |
U phiHyd, |
564 |
I myThid ) |
I myThid ) |
565 |
|
ELSE |
566 |
|
CALL CALC_PHI_HYD( |
567 |
|
I bi,bj,iMin,iMax,jMin,jMax,k, |
568 |
|
I theta, salt, |
569 |
|
U phiHyd, |
570 |
|
I myThid ) |
571 |
|
ENDIF |
572 |
|
|
573 |
C-- Calculate accelerations in the momentum equations (gU, gV, ...) |
C-- Calculate accelerations in the momentum equations (gU, gV, ...) |
574 |
C and step forward storing the result in gUnm1, gVnm1, etc... |
C and step forward storing the result in gUnm1, gVnm1, etc... |
580 |
I myTime, myThid) |
I myTime, myThid) |
581 |
CALL TIMESTEP( |
CALL TIMESTEP( |
582 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
I bi,bj,iMin,iMax,jMin,jMax,k, |
583 |
|
I phiHyd, phiSurfX, phiSurfY, |
584 |
I myIter, myThid) |
I myIter, myThid) |
585 |
|
|
586 |
|
#ifdef ALLOW_OBCS |
587 |
|
C-- Apply open boundary conditions |
588 |
|
IF (useOBCS) THEN |
589 |
|
CALL OBCS_APPLY_UV( bi, bj, k, gUnm1, gVnm1, myThid ) |
590 |
|
END IF |
591 |
|
#endif /* ALLOW_OBCS */ |
592 |
|
|
593 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
594 |
#ifdef INCLUDE_CD_CODE |
#ifdef INCLUDE_CD_CODE |
595 |
ELSE |
ELSE |
628 |
U gVNm1, |
U gVNm1, |
629 |
I myThid ) |
I myThid ) |
630 |
|
|
631 |
|
#ifdef ALLOW_OBCS |
632 |
|
C-- Apply open boundary conditions |
633 |
|
IF (useOBCS) THEN |
634 |
|
DO K=1,Nr |
635 |
|
CALL OBCS_APPLY_UV( bi, bj, k, gUnm1, gVnm1, myThid ) |
636 |
|
ENDDO |
637 |
|
END IF |
638 |
|
#endif /* ALLOW_OBCS */ |
639 |
|
|
640 |
#ifdef INCLUDE_CD_CODE |
#ifdef INCLUDE_CD_CODE |
641 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
642 |
idkey = iikey + 5 |
idkey = iikey + 5 |
658 |
C-- End If implicitViscosity.AND.momStepping |
C-- End If implicitViscosity.AND.momStepping |
659 |
ENDIF |
ENDIF |
660 |
|
|
661 |
|
Cjmc : add for phiHyd output <- but not working if multi tile per CPU |
662 |
|
c IF ( DIFFERENT_MULTIPLE(dumpFreq,myTime+deltaTClock,myTime) |
663 |
|
c & .AND. buoyancyRelation .eq. 'ATMOSPHERIC' ) THEN |
664 |
|
c WRITE(suff,'(I10.10)') myIter+1 |
665 |
|
c CALL WRITE_FLD_XYZ_RL('PH.',suff,phiHyd,myIter+1,myThid) |
666 |
|
c ENDIF |
667 |
|
Cjmc(end) |
668 |
|
|
669 |
|
#ifdef ALLOW_TIMEAVE |
670 |
|
IF (taveFreq.GT.0.) THEN |
671 |
|
IF ( bi.EQ.1 .AND. bj.EQ.1 ) THEN |
672 |
|
CALL TIMEAVE_CUMULATE(phiHydtave, phiHyd, Nr, |
673 |
|
I deltaTclock, bi, bj, myThid) |
674 |
|
ENDIF |
675 |
|
IF (ivdc_kappa.NE.0.) THEN |
676 |
|
CALL TIMEAVE_CUMULATE(ConvectCountTave, ConvectCount, Nr, |
677 |
|
I deltaTclock, bi, bj, myThid) |
678 |
|
ENDIF |
679 |
|
ENDIF |
680 |
|
#endif /* ALLOW_TIMEAVE */ |
681 |
|
|
682 |
ENDDO |
ENDDO |
683 |
ENDDO |
ENDDO |
684 |
|
|
685 |
RETURN |
RETURN |
686 |
END |
END |
|
|
|
|
|
|
|
C-- Cumulative diagnostic calculations (ie. time-averaging) |
|
|
#ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE |
|
|
c IF (taveFreq.GT.0.) THEN |
|
|
c CALL DO_TIME_AVERAGES( |
|
|
c I myTime, myIter, bi, bj, k, kup, kDown, |
|
|
c I ConvectCount, |
|
|
c I myThid ) |
|
|
c ENDIF |
|
|
#endif |
|
|
|
|