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 |
66 |
C rhoK, rhoKM1 - Density at current level, and level above |
C rhoK, rhoKM1 - Density 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 |
84 |
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
85 |
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
86 |
_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) |
|
87 |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
88 |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
89 |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
92 |
_RL phiHyd (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL phiHyd (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
93 |
_RL rhokm1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhokm1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
94 |
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
95 |
|
_RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
96 |
|
_RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
97 |
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRT (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
98 |
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRS (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
99 |
_RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL KappaRU (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
102 |
_RL sigmaY (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL sigmaY (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
103 |
_RL sigmaR (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL sigmaR (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
104 |
|
|
105 |
C This is currently also used by IVDC and Diagnostics |
C This is currently used by IVDC and Diagnostics |
|
C #ifdef INCLUDE_CONVECT_CALL |
|
106 |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL ConvectCount (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
|
C #endif |
|
107 |
|
|
108 |
INTEGER iMin, iMax |
INTEGER iMin, iMax |
109 |
INTEGER jMin, jMax |
INTEGER jMin, jMax |
111 |
INTEGER i, j |
INTEGER i, j |
112 |
INTEGER k, km1, kup, kDown |
INTEGER k, km1, kup, kDown |
113 |
|
|
114 |
|
Cjmc : add for phiHyd output <- but not working if multi tile per CPU |
115 |
|
c CHARACTER*(MAX_LEN_MBUF) suff |
116 |
|
c LOGICAL DIFFERENT_MULTIPLE |
117 |
|
c EXTERNAL DIFFERENT_MULTIPLE |
118 |
|
Cjmc(end) |
119 |
|
|
120 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
121 |
INTEGER isbyte |
INTEGER isbyte |
122 |
PARAMETER( isbyte = 4 ) |
PARAMETER( isbyte = 4 ) |
141 |
C =================== |
C =================== |
142 |
C This is where all the accelerations and tendencies (ie. |
C This is where all the accelerations and tendencies (ie. |
143 |
C physics, parameterizations etc...) are calculated |
C physics, parameterizations etc...) are calculated |
|
C rVel = sum_r ( div. u[n] ) |
|
144 |
C rho = rho ( theta[n], salt[n] ) |
C rho = rho ( theta[n], salt[n] ) |
145 |
C b = b(rho, theta) |
C b = b(rho, theta) |
146 |
C K31 = K31 ( rho ) |
C K31 = K31 ( rho ) |
147 |
C Gu[n] = Gu( u[n], v[n], rVel, b, ... ) |
C Gu[n] = Gu( u[n], v[n], wVel, b, ... ) |
148 |
C Gv[n] = Gv( u[n], v[n], rVel, b, ... ) |
C Gv[n] = Gv( u[n], v[n], wVel, b, ... ) |
149 |
C Gt[n] = Gt( theta[n], u[n], v[n], rVel, K31, ... ) |
C Gt[n] = Gt( theta[n], u[n], v[n], wVel, K31, ... ) |
150 |
C Gs[n] = Gs( salt[n], u[n], v[n], rVel, K31, ... ) |
C Gs[n] = Gs( salt[n], u[n], v[n], wVel, K31, ... ) |
151 |
C |
C |
152 |
C "Time-stepping" or "Prediction" |
C "Time-stepping" or "Prediction" |
153 |
C ================================ |
C ================================ |
197 |
ENDDO |
ENDDO |
198 |
rhoKM1 (i,j) = 0. _d 0 |
rhoKM1 (i,j) = 0. _d 0 |
199 |
rhok (i,j) = 0. _d 0 |
rhok (i,j) = 0. _d 0 |
200 |
maskC (i,j) = 0. _d 0 |
phiSurfX(i,j) = 0. _d 0 |
201 |
|
phiSurfY(i,j) = 0. _d 0 |
202 |
ENDDO |
ENDDO |
203 |
ENDDO |
ENDDO |
204 |
|
|
212 |
|
|
213 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
214 |
C-- HPF directive to help TAMC |
C-- HPF directive to help TAMC |
215 |
CHPF$ INDEPENDENT, NEW (rTrans,rVel,fVerT,fVerS,fVerU,fVerV |
CHPF$ INDEPENDENT, NEW (rTrans,fVerT,fVerS,fVerU,fVerV |
216 |
CHPF$& ,phiHyd,utrans,vtrans,maskc,xA,yA |
CHPF$& ,phiHyd,utrans,vtrans,xA,yA |
217 |
CHPF$& ,KappaRT,KappaRS,KappaRU,KappaRV |
CHPF$& ,KappaRT,KappaRS,KappaRU,KappaRV |
218 |
CHPF$& ) |
CHPF$& ) |
219 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
241 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
242 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
243 |
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 |
|
244 |
fVerT (i,j,1) = 0. _d 0 |
fVerT (i,j,1) = 0. _d 0 |
245 |
fVerT (i,j,2) = 0. _d 0 |
fVerT (i,j,2) = 0. _d 0 |
246 |
fVerS (i,j,1) = 0. _d 0 |
fVerS (i,j,1) = 0. _d 0 |
255 |
DO k=1,Nr |
DO k=1,Nr |
256 |
DO j=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
257 |
DO i=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
258 |
#ifdef INCLUDE_CONVECT_CALL |
C This is currently also used by IVDC and Diagnostics |
259 |
ConvectCount(i,j,k) = 0. |
ConvectCount(i,j,k) = 0. |
|
#endif |
|
260 |
KappaRT(i,j,k) = 0. _d 0 |
KappaRT(i,j,k) = 0. _d 0 |
261 |
KappaRS(i,j,k) = 0. _d 0 |
KappaRS(i,j,k) = 0. _d 0 |
262 |
ENDDO |
ENDDO |
286 |
|
|
287 |
#ifdef ALLOW_OBCS |
#ifdef ALLOW_OBCS |
288 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
289 |
C-- Calculate future values on open boundaries |
C-- Apply OBC to W if in N-H mode |
290 |
IF (useOBCS.AND.nonHydrostatic) THEN |
IF (useOBCS.AND.nonHydrostatic) THEN |
291 |
CALL OBCS_APPLY_W( bi, bj, k, wVel, myThid ) |
CALL OBCS_APPLY_W( bi, bj, k, wVel, myThid ) |
292 |
ENDIF |
ENDIF |
322 |
I rhoKm1, rhoK, |
I rhoKm1, rhoK, |
323 |
U ConvectCount, KappaRT, KappaRS, |
U ConvectCount, KappaRT, KappaRS, |
324 |
I myTime, myIter, myThid) |
I myTime, myIter, myThid) |
325 |
END IF |
ENDIF |
326 |
|
|
327 |
C-- end of diagnostic k loop (Nr:1) |
C-- end of diagnostic k loop (Nr:1) |
328 |
ENDDO |
ENDDO |
410 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
411 |
CPatrick Is this formula correct? |
CPatrick Is this formula correct? |
412 |
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 |
|
413 |
CADJ STORE rTrans(:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
CADJ STORE rTrans(:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
414 |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
CADJ STORE KappaRT(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
415 |
CADJ STORE KappaRS(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
CADJ STORE KappaRS(:,:,:) = comlev1_bibj_k, key = kkey, byte = isbyte |
417 |
|
|
418 |
C-- Get temporary terms used by tendency routines |
C-- Get temporary terms used by tendency routines |
419 |
CALL CALC_COMMON_FACTORS ( |
CALL CALC_COMMON_FACTORS ( |
420 |
I bi,bj,iMin,iMax,jMin,jMax,k,km1,kup,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k, |
421 |
O xA,yA,uTrans,vTrans,rTrans,rVel,maskC,maskUp, |
O xA,yA,uTrans,vTrans,rTrans,maskUp, |
422 |
I myThid) |
I myThid) |
423 |
|
|
424 |
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
#ifdef INCLUDE_CALC_DIFFUSIVITY_CALL |
425 |
C-- Calculate the total vertical diffusivity |
C-- Calculate the total vertical diffusivity |
426 |
CALL CALC_DIFFUSIVITY( |
CALL CALC_DIFFUSIVITY( |
427 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
I bi,bj,iMin,iMax,jMin,jMax,k, |
428 |
I maskC,maskup, |
I maskUp, |
429 |
O KappaRT,KappaRS,KappaRU,KappaRV, |
O KappaRT,KappaRS,KappaRU,KappaRV, |
430 |
I myThid) |
I myThid) |
431 |
#endif |
#endif |
435 |
IF ( tempStepping ) THEN |
IF ( tempStepping ) THEN |
436 |
CALL CALC_GT( |
CALL CALC_GT( |
437 |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
438 |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
439 |
I KappaRT, |
I KappaRT, |
440 |
U fVerT, |
U fVerT, |
441 |
I myTime, myThid) |
I myTime, myThid) |
448 |
IF ( saltStepping ) THEN |
IF ( saltStepping ) THEN |
449 |
CALL CALC_GS( |
CALL CALC_GS( |
450 |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,km1,kup,kDown, |
451 |
I xA,yA,uTrans,vTrans,rTrans,maskUp,maskC, |
I xA,yA,uTrans,vTrans,rTrans,maskUp, |
452 |
I KappaRS, |
I KappaRS, |
453 |
U fVerS, |
U fVerS, |
454 |
I myTime, myThid) |
I myTime, myThid) |
488 |
C-- Implicit diffusion |
C-- Implicit diffusion |
489 |
IF (implicitDiffusion) THEN |
IF (implicitDiffusion) THEN |
490 |
|
|
491 |
IF (tempStepping) THEN |
IF (tempStepping) THEN |
492 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
493 |
idkey = iikey + 1 |
idkey = iikey + 1 |
494 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
522 |
C-- End If implicitDiffusion |
C-- End If implicitDiffusion |
523 |
ENDIF |
ENDIF |
524 |
|
|
525 |
|
C-- Start computation of dynamics |
526 |
|
iMin = 1-OLx+2 |
527 |
|
iMax = sNx+OLx-1 |
528 |
|
jMin = 1-OLy+2 |
529 |
|
jMax = sNy+OLy-1 |
530 |
|
|
531 |
|
C-- Explicit part of the Surface Potentiel Gradient (add in TIMESTEP) |
532 |
|
C (note: this loop will be replaced by CALL CALC_GRAD_ETA) |
533 |
|
IF (implicSurfPress.NE.1.) THEN |
534 |
|
CALL CALC_GRAD_PHI_SURF( |
535 |
|
I bi,bj,iMin,iMax,jMin,jMax, |
536 |
|
I etaN, |
537 |
|
O phiSurfX,phiSurfY, |
538 |
|
I myThid ) |
539 |
|
ENDIF |
540 |
|
|
541 |
C-- Start of dynamics loop |
C-- Start of dynamics loop |
542 |
DO k=1,Nr |
DO k=1,Nr |
549 |
kup = 1+MOD(k+1,2) |
kup = 1+MOD(k+1,2) |
550 |
kDown= 1+MOD(k,2) |
kDown= 1+MOD(k,2) |
551 |
|
|
|
iMin = 1-OLx+2 |
|
|
iMax = sNx+OLx-1 |
|
|
jMin = 1-OLy+2 |
|
|
jMax = sNy+OLy-1 |
|
|
|
|
552 |
C-- Integrate hydrostatic balance for phiHyd with BC of |
C-- Integrate hydrostatic balance for phiHyd with BC of |
553 |
C phiHyd(z=0)=0 |
C phiHyd(z=0)=0 |
554 |
C distinguishe between Stagger and Non Stagger time stepping |
C distinguishe between Stagger and Non Stagger time stepping |
575 |
U fVerU, fVerV, |
U fVerU, fVerV, |
576 |
I myTime, myThid) |
I myTime, myThid) |
577 |
CALL TIMESTEP( |
CALL TIMESTEP( |
578 |
I bi,bj,iMin,iMax,jMin,jMax,k,phiHyd, |
I bi,bj,iMin,iMax,jMin,jMax,k, |
579 |
|
I phiHyd, phiSurfX, phiSurfY, |
580 |
I myIter, myThid) |
I myIter, myThid) |
581 |
|
|
582 |
#ifdef ALLOW_OBCS |
#ifdef ALLOW_OBCS |
654 |
C-- End If implicitViscosity.AND.momStepping |
C-- End If implicitViscosity.AND.momStepping |
655 |
ENDIF |
ENDIF |
656 |
|
|
657 |
|
Cjmc : add for phiHyd output <- but not working if multi tile per CPU |
658 |
|
c IF ( DIFFERENT_MULTIPLE(dumpFreq,myTime+deltaTClock,myTime) |
659 |
|
c & .AND. buoyancyRelation .eq. 'ATMOSPHERIC' ) THEN |
660 |
|
c WRITE(suff,'(I10.10)') myIter+1 |
661 |
|
c CALL WRITE_FLD_XYZ_RL('PH.',suff,phiHyd,myIter+1,myThid) |
662 |
|
c ENDIF |
663 |
|
Cjmc(end) |
664 |
|
|
665 |
|
#ifdef ALLOW_TIMEAVE |
666 |
|
IF (taveFreq.GT.0.) THEN |
667 |
|
CALL TIMEAVE_CUMULATE(phiHydtave, phiHyd, Nr, |
668 |
|
I deltaTclock, bi, bj, myThid) |
669 |
|
IF (ivdc_kappa.NE.0.) THEN |
670 |
|
CALL TIMEAVE_CUMULATE(ConvectCountTave, ConvectCount, Nr, |
671 |
|
I deltaTclock, bi, bj, myThid) |
672 |
|
ENDIF |
673 |
|
ENDIF |
674 |
|
#endif /* ALLOW_TIMEAVE */ |
675 |
|
|
676 |
ENDDO |
ENDDO |
677 |
ENDDO |
ENDDO |
678 |
|
|