15 |
SUBROUTINE DYNAMICS(myTime, myIter, myThid) |
SUBROUTINE DYNAMICS(myTime, myIter, myThid) |
16 |
C !DESCRIPTION: \bv |
C !DESCRIPTION: \bv |
17 |
C *==========================================================* |
C *==========================================================* |
18 |
C | SUBROUTINE DYNAMICS |
C | SUBROUTINE DYNAMICS |
19 |
C | o Controlling routine for the explicit part of the model |
C | o Controlling routine for the explicit part of the model |
20 |
C | dynamics. |
C | dynamics. |
21 |
C *==========================================================* |
C *==========================================================* |
22 |
C | This routine evaluates the "dynamics" terms for each |
C | This routine evaluates the "dynamics" terms for each |
23 |
C | block of ocean in turn. Because the blocks of ocean have |
C | block of ocean in turn. Because the blocks of ocean have |
24 |
C | overlap regions they are independent of one another. |
C | overlap regions they are independent of one another. |
25 |
C | If terms involving lateral integrals are needed in this |
C | If terms involving lateral integrals are needed in this |
26 |
C | routine care will be needed. Similarly finite-difference |
C | routine care will be needed. Similarly finite-difference |
27 |
C | operations with stencils wider than the overlap region |
C | operations with stencils wider than the overlap region |
28 |
C | require special consideration. |
C | require special consideration. |
29 |
C | The algorithm... |
C | The algorithm... |
30 |
C | |
C | |
31 |
C | "Correction Step" |
C | "Correction Step" |
93 |
# endif |
# endif |
94 |
# ifdef ALLOW_PTRACERS |
# ifdef ALLOW_PTRACERS |
95 |
# include "PTRACERS_SIZE.h" |
# include "PTRACERS_SIZE.h" |
96 |
# include "PTRACERS.h" |
# include "PTRACERS_FIELDS.h" |
97 |
# endif |
# endif |
98 |
# ifdef ALLOW_OBCS |
# ifdef ALLOW_OBCS |
99 |
# include "OBCS.h" |
# include "OBCS.h" |
139 |
|
|
140 |
C !INPUT/OUTPUT PARAMETERS: |
C !INPUT/OUTPUT PARAMETERS: |
141 |
C == Routine arguments == |
C == Routine arguments == |
142 |
C myTime - Current time in simulation |
C myTime :: Current time in simulation |
143 |
C myIter - Current iteration number in simulation |
C myIter :: Current iteration number in simulation |
144 |
C myThid - Thread number for this instance of the routine. |
C myThid :: Thread number for this instance of the routine. |
145 |
_RL myTime |
_RL myTime |
146 |
INTEGER myIter |
INTEGER myIter |
147 |
INTEGER myThid |
INTEGER myThid |
148 |
|
|
149 |
|
C !FUNCTIONS: |
150 |
|
#ifdef ALLOW_DIAGNOSTICS |
151 |
|
LOGICAL DIAGNOSTICS_IS_ON |
152 |
|
EXTERNAL DIAGNOSTICS_IS_ON |
153 |
|
#endif |
154 |
|
|
155 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
156 |
C == Local variables |
C == Local variables |
157 |
C fVer[UV] o fVer: Vertical flux term - note fVer |
C fVer[UV] o fVer: Vertical flux term - note fVer |
168 |
C phiSurfY or geopotential (atmos) in X and Y direction |
C phiSurfY or geopotential (atmos) in X and Y direction |
169 |
C guDissip :: dissipation tendency (all explicit terms), u component |
C guDissip :: dissipation tendency (all explicit terms), u component |
170 |
C gvDissip :: dissipation tendency (all explicit terms), v component |
C gvDissip :: dissipation tendency (all explicit terms), v component |
171 |
C KappaRU:: vertical viscosity |
C KappaRU :: vertical viscosity |
172 |
C KappaRV:: vertical viscosity |
C KappaRV :: vertical viscosity |
173 |
C iMin, iMax - Ranges and sub-block indices on which calculations |
C iMin, iMax - Ranges and sub-block indices on which calculations |
174 |
C jMin, jMax are applied. |
C jMin, jMax are applied. |
175 |
C bi, bj |
C bi, bj |
176 |
C k, kup, - Index for layer above and below. kup and kDown |
C k, kup, - Index for layer above and below. kup and kDown |
177 |
C kDown, km1 are switched with layer to be the appropriate |
C kDown, km1 are switched with layer to be the appropriate |
178 |
C index into fVerTerm. |
C index into fVerTerm. |
179 |
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
180 |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
196 |
INTEGER k, km1, kp1, kup, kDown |
INTEGER k, km1, kp1, kup, kDown |
197 |
|
|
198 |
#ifdef ALLOW_DIAGNOSTICS |
#ifdef ALLOW_DIAGNOSTICS |
199 |
|
LOGICAL dPhiHydDiagIsOn |
200 |
_RL tmpFac |
_RL tmpFac |
201 |
#endif /* ALLOW_DIAGNOSTICS */ |
#endif /* ALLOW_DIAGNOSTICS */ |
202 |
|
|
251 |
& CALL DEBUG_ENTER( 'DYNAMICS', myThid ) |
& CALL DEBUG_ENTER( 'DYNAMICS', myThid ) |
252 |
#endif |
#endif |
253 |
|
|
254 |
|
#ifdef ALLOW_DIAGNOSTICS |
255 |
|
dPhiHydDiagIsOn = .FALSE. |
256 |
|
IF ( useDiagnostics ) |
257 |
|
& dPhiHydDiagIsOn = DIAGNOSTICS_IS_ON( 'Um_dPHdx', myThid ) |
258 |
|
& .OR. DIAGNOSTICS_IS_ON( 'Vm_dPHdy', myThid ) |
259 |
|
#endif |
260 |
|
|
261 |
C-- Call to routine for calculation of |
C-- Call to routine for calculation of |
262 |
C Eliassen-Palm-flux-forced U-tendency, |
C Eliassen-Palm-flux-forced U-tendency, |
263 |
C if desired: |
C if desired: |
301 |
C point numbers. This prevents spurious hardware signals due to |
C point numbers. This prevents spurious hardware signals due to |
302 |
C uninitialised but inert locations. |
C uninitialised but inert locations. |
303 |
|
|
304 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
305 |
DO k=1,Nr |
DO k=1,Nr |
306 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
307 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
308 |
KappaRU(i,j,k) = 0. _d 0 |
KappaRU(i,j,k) = 0. _d 0 |
309 |
KappaRV(i,j,k) = 0. _d 0 |
KappaRV(i,j,k) = 0. _d 0 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
|
310 |
cph( |
cph( |
311 |
c-- need some re-initialisation here to break dependencies |
c-- need some re-initialisation here to break dependencies |
312 |
cph) |
cph) |
313 |
gU(i,j,k,bi,bj) = 0. _d 0 |
gU(i,j,k,bi,bj) = 0. _d 0 |
314 |
gV(i,j,k,bi,bj) = 0. _d 0 |
gV(i,j,k,bi,bj) = 0. _d 0 |
|
#endif |
|
315 |
ENDDO |
ENDDO |
316 |
ENDDO |
ENDDO |
317 |
ENDDO |
ENDDO |
318 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
319 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
320 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
321 |
fVerU (i,j,1) = 0. _d 0 |
fVerU (i,j,1) = 0. _d 0 |
324 |
fVerV (i,j,2) = 0. _d 0 |
fVerV (i,j,2) = 0. _d 0 |
325 |
phiHydF (i,j) = 0. _d 0 |
phiHydF (i,j) = 0. _d 0 |
326 |
phiHydC (i,j) = 0. _d 0 |
phiHydC (i,j) = 0. _d 0 |
327 |
|
#ifndef INCLUDE_PHIHYD_CALCULATION_CODE |
328 |
dPhiHydX(i,j) = 0. _d 0 |
dPhiHydX(i,j) = 0. _d 0 |
329 |
dPhiHydY(i,j) = 0. _d 0 |
dPhiHydY(i,j) = 0. _d 0 |
330 |
|
#endif |
331 |
phiSurfX(i,j) = 0. _d 0 |
phiSurfX(i,j) = 0. _d 0 |
332 |
phiSurfY(i,j) = 0. _d 0 |
phiSurfY(i,j) = 0. _d 0 |
333 |
guDissip(i,j) = 0. _d 0 |
guDissip(i,j) = 0. _d 0 |
334 |
gvDissip(i,j) = 0. _d 0 |
gvDissip(i,j) = 0. _d 0 |
335 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
336 |
|
phiHydLow(i,j,bi,bj) = 0. _d 0 |
337 |
|
# ifdef NONLIN_FRSURF |
338 |
|
# ifndef DISABLE_RSTAR_CODE |
339 |
|
dWtransC(i,j,bi,bj) = 0. _d 0 |
340 |
|
dWtransU(i,j,bi,bj) = 0. _d 0 |
341 |
|
dWtransV(i,j,bi,bj) = 0. _d 0 |
342 |
|
# endif |
343 |
|
# endif |
344 |
|
#endif |
345 |
ENDDO |
ENDDO |
346 |
ENDDO |
ENDDO |
347 |
|
|
353 |
|
|
354 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
355 |
CADJ STORE wvel (:,:,:,bi,bj) = |
CADJ STORE wvel (:,:,:,bi,bj) = |
356 |
CADJ & comlev1_bibj, key = idynkey, byte = isbyte |
CADJ & comlev1_bibj, key=idynkey, byte=isbyte |
357 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
358 |
|
|
359 |
C-- Explicit part of the Surface Potentiel Gradient (add in TIMESTEP) |
C-- Explicit part of the Surface Potentiel Gradient (add in TIMESTEP) |
376 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
377 |
|
|
378 |
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
379 |
C-- Calculate the total vertical diffusivity |
C-- Calculate the total vertical viscosity |
380 |
|
CALL CALC_VISCOSITY( |
381 |
|
I bi,bj, iMin,iMax,jMin,jMax, |
382 |
|
O KappaRU, KappaRV, |
383 |
|
I myThid ) |
384 |
|
#else |
385 |
DO k=1,Nr |
DO k=1,Nr |
386 |
CALL CALC_VISCOSITY( |
DO j=1-OLy,sNy+OLy |
387 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
DO i=1-OLx,sNx+OLx |
388 |
O KappaRU,KappaRV, |
KappaRU(i,j,k) = 0. _d 0 |
389 |
I myThid) |
KappaRV(i,j,k) = 0. _d 0 |
390 |
ENDDO |
ENDDO |
391 |
|
ENDDO |
392 |
|
ENDDO |
393 |
#endif |
#endif |
394 |
|
|
395 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
411 |
kup = 1+MOD(k+1,2) |
kup = 1+MOD(k+1,2) |
412 |
kDown= 1+MOD(k,2) |
kDown= 1+MOD(k,2) |
413 |
|
|
414 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
415 |
kkey = (idynkey-1)*Nr + k |
kkey = (idynkey-1)*Nr + k |
416 |
c |
c |
417 |
CADJ STORE totphihyd (:,:,k,bi,bj) |
CADJ STORE totphihyd (:,:,k,bi,bj) |
418 |
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
419 |
|
CADJ STORE phihydlow (:,:,bi,bj) |
420 |
|
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
421 |
CADJ STORE theta (:,:,k,bi,bj) |
CADJ STORE theta (:,:,k,bi,bj) |
422 |
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
423 |
CADJ STORE salt (:,:,k,bi,bj) |
CADJ STORE salt (:,:,k,bi,bj) |
467 |
# endif |
# endif |
468 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
469 |
|
|
470 |
C-- Integrate hydrostatic balance for phiHyd with BC of |
C-- Integrate hydrostatic balance for phiHyd with BC of |
471 |
C phiHyd(z=0)=0 |
C phiHyd(z=0)=0 |
472 |
IF ( implicitIntGravWave ) THEN |
IF ( implicitIntGravWave ) THEN |
473 |
CALL CALC_PHI_HYD( |
CALL CALC_PHI_HYD( |
484 |
O phiHydC, dPhiHydX, dPhiHydY, |
O phiHydC, dPhiHydX, dPhiHydY, |
485 |
I myTime, myIter, myThid ) |
I myTime, myIter, myThid ) |
486 |
ENDIF |
ENDIF |
487 |
|
#ifdef ALLOW_DIAGNOSTICS |
488 |
|
IF ( dPhiHydDiagIsOn ) THEN |
489 |
|
tmpFac = -1. _d 0 |
490 |
|
CALL DIAGNOSTICS_SCALE_FILL( dPhiHydX, tmpFac, 1, |
491 |
|
& 'Um_dPHdx', k, 1, 2, bi, bj, myThid ) |
492 |
|
CALL DIAGNOSTICS_SCALE_FILL( dPhiHydY, tmpFac, 1, |
493 |
|
& 'Vm_dPHdy', k, 1, 2, bi, bj, myThid ) |
494 |
|
ENDIF |
495 |
|
#endif /* ALLOW_DIAGNOSTICS */ |
496 |
|
|
497 |
C-- Calculate accelerations in the momentum equations (gU, gV, ...) |
C-- Calculate accelerations in the momentum equations (gU, gV, ...) |
498 |
C and step forward storing the result in gU, gV, etc... |
C and step forward storing the result in gU, gV, etc... |
499 |
IF ( momStepping ) THEN |
IF ( momStepping ) THEN |
500 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
501 |
|
# ifdef NONLIN_FRSURF |
502 |
|
# ifndef DISABLE_RSTAR_CODE |
503 |
|
CADJ STORE dWtransC(:,:,bi,bj) |
504 |
|
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
505 |
|
CADJ STORE dWtransU(:,:,bi,bj) |
506 |
|
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
507 |
|
CADJ STORE dWtransV(:,:,bi,bj) |
508 |
|
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
509 |
|
# endif |
510 |
|
# endif |
511 |
|
#endif |
512 |
IF (.NOT. vectorInvariantMomentum) THEN |
IF (.NOT. vectorInvariantMomentum) THEN |
513 |
#ifdef ALLOW_MOM_FLUXFORM |
#ifdef ALLOW_MOM_FLUXFORM |
514 |
C |
C |
522 |
ELSE |
ELSE |
523 |
#ifdef ALLOW_MOM_VECINV |
#ifdef ALLOW_MOM_VECINV |
524 |
C |
C |
525 |
# ifdef ALLOW_AUTODIFF_TAMC |
# ifdef ALLOW_AUTODIFF_TAMC |
526 |
# ifdef NONLIN_FRSURF |
# ifdef NONLIN_FRSURF |
527 |
CADJ STORE fVerU(:,:,:) |
CADJ STORE fVerU(:,:,:) |
528 |
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
657 |
C In order to compare the variance of phiHydLow of a p/z-coordinate |
C In order to compare the variance of phiHydLow of a p/z-coordinate |
658 |
C run with etaH of a z/p-coordinate run the drift of phiHydLow |
C run with etaH of a z/p-coordinate run the drift of phiHydLow |
659 |
C has to be removed by something like the following subroutine: |
C has to be removed by something like the following subroutine: |
660 |
C CALL REMOVE_MEAN_RL( 1, phiHydLow, maskH, maskH, rA, drF, |
C CALL REMOVE_MEAN_RL( 1, phiHydLow, maskInC, maskInC, rA, drF, |
661 |
C & 'phiHydLow', myThid ) |
C & 'phiHydLow', myTime, myThid ) |
662 |
Cml) |
Cml) |
663 |
|
|
664 |
#ifdef ALLOW_DIAGNOSTICS |
#ifdef ALLOW_DIAGNOSTICS |
699 |
#endif |
#endif |
700 |
|
|
701 |
#ifdef DYNAMICS_GUGV_EXCH_CHECK |
#ifdef DYNAMICS_GUGV_EXCH_CHECK |
702 |
C- jmc: For safety checking only: This Exchange here should not change |
C- jmc: For safety checking only: This Exchange here should not change |
703 |
C the solution. If solution changes, it means something is wrong, |
C the solution. If solution changes, it means something is wrong, |
704 |
C but it does not mean that it is less wrong with this exchange. |
C but it does not mean that it is less wrong with this exchange. |
705 |
IF ( debugLevel .GT. debLevB ) THEN |
IF ( debugLevel .GT. debLevB ) THEN |
706 |
CALL EXCH_UV_XYZ_RL(gU,gV,.TRUE.,myThid) |
CALL EXCH_UV_XYZ_RL(gU,gV,.TRUE.,myThid) |