36 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
37 |
#include "GRID.h" |
#include "GRID.h" |
38 |
|
|
|
#ifdef ALLOW_KPP |
|
|
#include "KPPMIX.h" |
|
|
#endif |
|
|
|
|
39 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
40 |
#include "tamc.h" |
#include "tamc.h" |
41 |
#include "tamc_keys.h" |
#include "tamc_keys.h" |
85 |
C anomaly. |
C anomaly. |
86 |
C etaSurfX, - Holds surface elevation gradient in X and Y. |
C etaSurfX, - Holds surface elevation gradient in X and Y. |
87 |
C etaSurfY |
C etaSurfY |
|
C K13, K23, K33 - Non-zero elements of small-angle approximation |
|
|
C diffusion tensor. |
|
|
C KapGM - Spatially varying Visbeck et. al mixing coeff. |
|
88 |
C KappaRT, - Total diffusion in vertical for T and S. |
C KappaRT, - Total diffusion in vertical for T and S. |
89 |
C KappaRS (background + spatially varying, isopycnal term). |
C KappaRS (background + spatially varying, isopycnal term). |
90 |
C iMin, iMax - Ranges and sub-block indices on which calculations |
C iMin, iMax - Ranges and sub-block indices on which calculations |
121 |
_RL rhotmp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhotmp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
122 |
_RL etaSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL etaSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
123 |
_RL etaSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL etaSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
_RL K13 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
|
|
_RL K23 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
|
|
_RL K33 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
|
|
_RL KapGM (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
124 |
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
125 |
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
126 |
_RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
127 |
_RL KappaRV (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRV (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
128 |
|
_RL sigmaX (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
129 |
|
_RL sigmaY (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
130 |
|
_RL sigmaR (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
131 |
|
|
132 |
#ifdef INCLUDE_CONVECT_CALL |
#ifdef INCLUDE_CONVECT_CALL |
133 |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
220 |
fMer(i,j) = 0. _d 0 |
fMer(i,j) = 0. _d 0 |
221 |
DO K=1,Nr |
DO K=1,Nr |
222 |
phiHyd (i,j,k) = 0. _d 0 |
phiHyd (i,j,k) = 0. _d 0 |
|
K13(i,j,k) = 0. _d 0 |
|
|
K23(i,j,k) = 0. _d 0 |
|
|
K33(i,j,k) = 0. _d 0 |
|
223 |
KappaRU(i,j,k) = 0. _d 0 |
KappaRU(i,j,k) = 0. _d 0 |
224 |
KappaRV(i,j,k) = 0. _d 0 |
KappaRV(i,j,k) = 0. _d 0 |
225 |
|
sigmaX(i,j,k) = 0. _d 0 |
226 |
|
sigmaY(i,j,k) = 0. _d 0 |
227 |
|
sigmaR(i,j,k) = 0. _d 0 |
228 |
ENDDO |
ENDDO |
229 |
rhoKM1 (i,j) = 0. _d 0 |
rhoKM1 (i,j) = 0. _d 0 |
230 |
rhok (i,j) = 0. _d 0 |
rhok (i,j) = 0. _d 0 |
247 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
248 |
C-- HPF directive to help TAMC |
C-- HPF directive to help TAMC |
249 |
!HPF$ INDEPENDENT, NEW (rTrans,rVel,fVerT,fVerS,fVerU,fVerV |
!HPF$ INDEPENDENT, NEW (rTrans,rVel,fVerT,fVerS,fVerU,fVerV |
250 |
!HPF$& ,phiHyd,K13,K23,K33,KapGM |
!HPF$& ,phiHyd, |
251 |
!HPF$& ,utrans,vtrans,maskc,xA,yA |
!HPF$& ,utrans,vtrans,maskc,xA,yA |
252 |
!HPF$& ,KappaRT,KappaRS,KappaRU,KappaRV |
!HPF$& ,KappaRT,KappaRS,KappaRU,KappaRV |
253 |
!HPF$& ) |
!HPF$& ) |
287 |
fVerV (i,j,1) = 0. _d 0 |
fVerV (i,j,1) = 0. _d 0 |
288 |
fVerV (i,j,2) = 0. _d 0 |
fVerV (i,j,2) = 0. _d 0 |
289 |
phiHyd(i,j,1) = 0. _d 0 |
phiHyd(i,j,1) = 0. _d 0 |
|
K13 (i,j,1) = 0. _d 0 |
|
|
K23 (i,j,1) = 0. _d 0 |
|
|
K33 (i,j,1) = 0. _d 0 |
|
|
KapGM (i,j) = GMkbackground |
|
290 |
ENDDO |
ENDDO |
291 |
ENDDO |
ENDDO |
292 |
|
|
365 |
#endif |
#endif |
366 |
|
|
367 |
IF ( (.NOT. BOTTOM_LAYER) |
IF ( (.NOT. BOTTOM_LAYER) |
|
#ifdef ALLOW_KPP |
|
|
& .AND. (.NOT.usingKPPmixing) ! CONVECT not needed with KPP mixing |
|
|
#endif |
|
368 |
& ) THEN |
& ) THEN |
369 |
C-- Check static stability with layer below |
C-- Check static stability with layer below |
370 |
C-- and mix as needed. |
C-- and mix as needed. |
424 |
I bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyKm1, |
I bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyKm1, |
425 |
U phiHyd, |
U phiHyd, |
426 |
I myThid ) |
I myThid ) |
427 |
|
CALL GRAD_SIGMA( |
428 |
|
I bi, bj, iMin, iMax, jMin, jMax, K, |
429 |
|
I rhoKm1, rhoKm1, rhoKm1, |
430 |
|
O sigmaX, sigmaY, sigmaR, |
431 |
|
I myThid ) |
432 |
|
|
433 |
C---------------------------------------------- |
C-- Start of downward loop |
|
C-- start of downward loop |
|
|
C---------------------------------------------- |
|
434 |
DO K=2,Nr |
DO K=2,Nr |
435 |
|
|
436 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
471 |
I myThid ) |
I myThid ) |
472 |
#endif |
#endif |
473 |
IF ( (.NOT. BOTTOM_LAYER) |
IF ( (.NOT. BOTTOM_LAYER) |
|
#ifdef ALLOW_KPP |
|
|
& .AND. (.NOT.usingKPPmixing) ! CONVECT not needed with KPP mixing |
|
|
#endif |
|
474 |
& ) THEN |
& ) THEN |
475 |
C-- Check static stability with layer below and mix as needed. |
C-- Check static stability with layer below and mix as needed. |
476 |
C-- Density of K+1 level (below W(K+1)) reference to K level. |
C-- Density of K+1 level (below W(K+1)) reference to K level. |
539 |
O rhoTmp, |
O rhoTmp, |
540 |
I myThid ) |
I myThid ) |
541 |
#endif |
#endif |
542 |
|
CALL GRAD_SIGMA( |
543 |
|
I bi, bj, iMin, iMax, jMin, jMax, K, |
544 |
|
I rhoK, rhotmp, rhoK, |
545 |
|
O sigmaX, sigmaY, sigmaR, |
546 |
|
I myThid ) |
547 |
|
|
|
#ifdef INCLUDE_CALC_ISOSLOPES_CALL |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
|
|
CADJ STORE rhoTmp(:,:) = comlev1_3d, key = kkey, byte = isbyte |
|
|
CADJ STORE rhok (:,:) = comlev1_3d, key = kkey, byte = isbyte |
|
|
CADJ STORE rhoKm1(:,:) = comlev1_3d, key = kkey, byte = isbyte |
|
|
CADJ STORE kapgm (:,:) = comlev1_3d, key = kkey, byte = isbyte |
|
|
#endif |
|
|
CALL CALC_ISOSLOPES( |
|
|
I bi, bj, iMin, iMax, jMin, jMax, K, |
|
|
I rhoKm1, rhoK, rhotmp, |
|
|
O K13, K23, K33, KapGM, |
|
|
I myThid ) |
|
|
#endif |
|
548 |
|
|
549 |
DO J=jMin,jMax |
DO J=jMin,jMax |
550 |
DO I=iMin,iMax |
DO I=iMin,iMax |
557 |
ENDDO |
ENDDO |
558 |
C-- end of k loop |
C-- end of k loop |
559 |
|
|
560 |
|
#ifdef ALLOW_GMREDI |
561 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
562 |
|
CADJ STORE rhoTmp(:,:) = comlev1_3d, key = kkey, byte = isbyte |
563 |
|
CADJ STORE rhok (:,:) = comlev1_3d, key = kkey, byte = isbyte |
564 |
|
CADJ STORE rhoKm1(:,:) = comlev1_3d, key = kkey, byte = isbyte |
565 |
|
#endif |
566 |
|
DO K=1, Nr |
567 |
|
IF (use_GMRedi) CALL GMREDI_CALC_TENSOR( |
568 |
|
I bi, bj, iMin, iMax, jMin, jMax, K, |
569 |
|
I sigmaX, sigmaY, sigmaR, |
570 |
|
I myThid ) |
571 |
|
ENDDO |
572 |
|
#endif |
573 |
|
|
574 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
575 |
CADJ STORE theta(:,:,:,bi,bj) = comlev1_2d, key = ikey, byte = isbyte |
CADJ STORE theta(:,:,:,bi,bj) = comlev1_2d, key = ikey, byte = isbyte |
576 |
CADJ STORE salt (:,:,:,bi,bj) = comlev1_2d, key = ikey, byte = isbyte |
CADJ STORE salt (:,:,:,bi,bj) = comlev1_2d, key = ikey, byte = isbyte |
579 |
#endif |
#endif |
580 |
|
|
581 |
#ifdef ALLOW_KPP |
#ifdef ALLOW_KPP |
|
C---------------------------------------------- |
|
582 |
C-- Compute KPP mixing coefficients |
C-- Compute KPP mixing coefficients |
583 |
C---------------------------------------------- |
CALL TIMER_START('KPP_CALC [DYNAMICS]', myThid) |
584 |
IF (usingKPPmixing) THEN |
CALL KPP_CALC( |
|
#ifdef ALLOW_AUTODIFF_TAMC |
|
|
CADJ STORE fu (:,: ,bi,bj) = comlev1_2d, key = ikey, byte = isbyte |
|
|
CADJ STORE fv (:,: ,bi,bj) = comlev1_2d, key = ikey, byte = isbyte |
|
|
#endif |
|
|
CALL TIMER_START('KVMIX (FIND KPP COEFFICIENTS) [DYNAMICS]' |
|
|
I , myThid) |
|
|
CALL KVMIX( |
|
585 |
I bi, bj, myTime, myThid ) |
I bi, bj, myTime, myThid ) |
586 |
CALL TIMER_STOP ('KVMIX (FIND KPP COEFFICIENTS) [DYNAMICS]' |
CALL TIMER_STOP ('KPP_CALC [DYNAMICS]', myThid) |
|
I , myThid) |
|
|
ENDIF |
|
587 |
#endif |
#endif |
588 |
|
|
589 |
C---------------------------------------------- |
C-- Start of upward loop |
|
C-- start of upward loop |
|
|
C---------------------------------------------- |
|
590 |
DO K = Nr, 1, -1 |
DO K = Nr, 1, -1 |
591 |
|
|
592 |
kM1 =max(1,k-1) ! Points to level above k (=k-1) |
kM1 =max(1,k-1) ! Points to level above k (=k-1) |
625 |
C-- Calculate the total vertical diffusivity |
C-- Calculate the total vertical diffusivity |
626 |
CALL CALC_DIFFUSIVITY( |
CALL CALC_DIFFUSIVITY( |
627 |
I bi,bj,iMin,iMax,jMin,jMax,K, |
I bi,bj,iMin,iMax,jMin,jMax,K, |
628 |
I maskC,maskUp,KapGM,K33, |
I maskC,maskUp, |
629 |
O KappaRT,KappaRS,KappaRU,KappaRV, |
O KappaRT,KappaRS,KappaRU,KappaRV, |
630 |
I myThid) |
I myThid) |
631 |
#endif |
#endif |
655 |
CALL CALC_GT( |
CALL CALC_GT( |
656 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
657 |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
658 |
I K13,K23,KappaRT,KapGM, |
I KappaRT, |
659 |
U aTerm,xTerm,fZon,fMer,fVerT, |
U aTerm,xTerm,fZon,fMer,fVerT, |
660 |
I myTime, myThid) |
I myTime, myThid) |
661 |
ENDIF |
ENDIF |
663 |
CALL CALC_GS( |
CALL CALC_GS( |
664 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
665 |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
666 |
I K13,K23,KappaRS,KapGM, |
I KappaRS, |
667 |
U aTerm,xTerm,fZon,fMer,fVerS, |
U aTerm,xTerm,fZon,fMer,fVerS, |
668 |
I myTime, myThid) |
I myTime, myThid) |
669 |
ENDIF |
ENDIF |
710 |
IF (taveFreq.GT.0.) THEN |
IF (taveFreq.GT.0.) THEN |
711 |
CALL DO_TIME_AVERAGES( |
CALL DO_TIME_AVERAGES( |
712 |
I myTime, myIter, bi, bj, K, kUp, kDown, |
I myTime, myIter, bi, bj, K, kUp, kDown, |
713 |
I K13, K23, rVel, KapGM, ConvectCount, |
I rVel, ConvectCount, |
714 |
I myThid ) |
I myThid ) |
715 |
ENDIF |
ENDIF |
716 |
#endif |
#endif |
810 |
C write(0,*) 'dynamics: rVel(2) ', |
C write(0,*) 'dynamics: rVel(2) ', |
811 |
C & minval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.), |
C & minval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.), |
812 |
C & maxval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.) |
C & maxval(rVel(1:sNx,1:sNy,2),mask=rVel(1:sNx,1:sNy,2).NE.0.) |
|
cblk write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)), |
|
|
cblk & maxval(K13(1:sNx,1:sNy,:)) |
|
|
cblk write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)), |
|
|
cblk & maxval(K23(1:sNx,1:sNy,:)) |
|
|
cblk write(0,*) 'dynamics: K33',minval(K33(1:sNx,1:sNy,:)), |
|
|
cblk & maxval(K33(1:sNx,1:sNy,:)) |
|
813 |
C write(0,*) 'dynamics: gT ',minval(gT(1:sNx,1:sNy,:,:,:)), |
C write(0,*) 'dynamics: gT ',minval(gT(1:sNx,1:sNy,:,:,:)), |
814 |
C & maxval(gT(1:sNx,1:sNy,:,:,:)) |
C & maxval(gT(1:sNx,1:sNy,:,:,:)) |
815 |
C write(0,*) 'dynamics: T ',minval(Theta(1:sNx,1:sNy,:,:,:)), |
C write(0,*) 'dynamics: T ',minval(Theta(1:sNx,1:sNy,:,:,:)), |