1 |
C $Header$ |
C $Header$ |
2 |
|
|
3 |
#include "CPP_EEOPTIONS.h" |
#include "CPP_OPTIONS.h" |
4 |
|
|
5 |
SUBROUTINE DYNAMICS(myTime, myIter, myThid) |
SUBROUTINE DYNAMICS(myTime, myIter, myThid) |
6 |
C /==========================================================\ |
C /==========================================================\ |
59 |
C is "pipelined" in the vertical |
C is "pipelined" in the vertical |
60 |
C so we need an fVer for each |
C so we need an fVer for each |
61 |
C variable. |
C variable. |
62 |
|
C rhoK, rhoKM1 - Density at current level, level above and level below. |
63 |
|
C rhoKP1 |
64 |
|
C buoyK, buoyKM1 - Buoyancy at current level and level above. |
65 |
|
C phiHyd - Hydrostatic part of the potential phi. |
66 |
|
C In z coords phiHyd is the hydrostatic pressure anomaly |
67 |
|
C In p coords phiHyd is the geopotential surface height anomaly. |
68 |
C iMin, iMax - Ranges and sub-block indices on which calculations |
C iMin, iMax - Ranges and sub-block indices on which calculations |
69 |
C jMin, jMax are applied. |
C jMin, jMax are applied. |
70 |
C bi, bj |
C bi, bj |
90 |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
91 |
_RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerU (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 pH (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
_RL phiHyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nz) |
94 |
_RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhokm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
95 |
_RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhokp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
96 |
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhok (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
97 |
|
_RL buoyKM1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
98 |
|
_RL buoyK (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
99 |
_RL rhotmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL rhotmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
100 |
_RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL pSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
101 |
_RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL pSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
186 |
rhok (i,j) = 0. _d 0 |
rhok (i,j) = 0. _d 0 |
187 |
rhokp1(i,j) = 0. _d 0 |
rhokp1(i,j) = 0. _d 0 |
188 |
rhotmp(i,j) = 0. _d 0 |
rhotmp(i,j) = 0. _d 0 |
189 |
|
buoyKM1(i,j) = 0. _d 0 |
190 |
|
buoyK (i,j) = 0. _d 0 |
191 |
maskC (i,j) = 0. _d 0 |
maskC (i,j) = 0. _d 0 |
192 |
ENDDO |
ENDDO |
193 |
ENDDO |
ENDDO |
213 |
K13(i,j,1) = 0. _d 0 |
K13(i,j,1) = 0. _d 0 |
214 |
K23(i,j,1) = 0. _d 0 |
K23(i,j,1) = 0. _d 0 |
215 |
K33(i,j,1) = 0. _d 0 |
K33(i,j,1) = 0. _d 0 |
216 |
KapGM(i,j) = 0. _d 0 |
KapGM(i,j) = GMkbackground |
217 |
ENDDO |
ENDDO |
218 |
ENDDO |
ENDDO |
219 |
|
|
233 |
|
|
234 |
C-- Update fields in top level according to tendency terms |
C-- Update fields in top level according to tendency terms |
235 |
CALL CORRECTION_STEP( |
CALL CORRECTION_STEP( |
236 |
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid) |
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myTime,myThid) |
237 |
|
|
238 |
|
IF ( .NOT. BOTTOM_LAYER ) THEN |
239 |
|
C-- Update fields in layer below according to tendency terms |
240 |
|
CALL CORRECTION_STEP( |
241 |
|
I bi,bj,iMin,iMax,jMin,jMax,K+1,pSurfX,pSurfY,myTime,myThid) |
242 |
|
ENDIF |
243 |
C-- Density of 1st level (below W(1)) reference to level 1 |
C-- Density of 1st level (below W(1)) reference to level 1 |
244 |
CALL FIND_RHO( |
CALL FIND_RHO( |
245 |
I bi, bj, iMin, iMax, jMin, jMax, K, K, eosType, |
I bi, bj, iMin, iMax, jMin, jMax, K, K, eosType, |
247 |
I myThid ) |
I myThid ) |
248 |
|
|
249 |
IF ( .NOT. BOTTOM_LAYER ) THEN |
IF ( .NOT. BOTTOM_LAYER ) THEN |
250 |
|
|
251 |
C-- Check static stability with layer below |
C-- Check static stability with layer below |
252 |
C and mix as needed. |
C and mix as needed. |
253 |
CALL FIND_RHO( |
CALL FIND_RHO( |
264 |
I myThid ) |
I myThid ) |
265 |
ENDIF |
ENDIF |
266 |
|
|
267 |
|
C-- Calculate buoyancy |
268 |
|
CALL CALC_BUOY( |
269 |
|
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1, |
270 |
|
O buoyKm1, |
271 |
|
I myThid ) |
272 |
|
|
273 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
274 |
CALL CALC_PH( |
CALL CALC_PHI_HYD( |
275 |
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoKm1, |
I bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyKm1, |
276 |
U pH, |
U phiHyd, |
277 |
I myThid ) |
I myThid ) |
278 |
|
|
279 |
DO K=2,Nz |
DO K=2,Nz |
280 |
|
|
281 |
BOTTOM_LAYER = K .EQ. Nz |
BOTTOM_LAYER = K .EQ. Nz |
282 |
|
IF ( .NOT. BOTTOM_LAYER ) THEN |
283 |
C-- Update fields in Kth level according to tendency terms |
C-- Update fields in layer below according to tendency terms |
284 |
CALL CORRECTION_STEP( |
CALL CORRECTION_STEP( |
285 |
I bi,bj,iMin,iMax,jMin,jMax,K,pSurfX,pSurfY,myThid) |
I bi,bj,iMin,iMax,jMin,jMax,K+1,pSurfX,pSurfY,myTime,myThid) |
286 |
|
ENDIF |
287 |
C-- Density of K level (below W(K)) reference to K level |
C-- Density of K level (below W(K)) reference to K level |
288 |
CALL FIND_RHO( |
CALL FIND_RHO( |
289 |
I bi, bj, iMin, iMax, jMin, jMax, K, K, eosType, |
I bi, bj, iMin, iMax, jMin, jMax, K, K, eosType, |
306 |
O rhoK, |
O rhoK, |
307 |
I myThid ) |
I myThid ) |
308 |
ENDIF |
ENDIF |
309 |
|
|
310 |
|
C-- Calculate buoyancy |
311 |
|
CALL CALC_BUOY( |
312 |
|
I bi,bj,iMin,iMax,jMin,jMax,K,rhoK, |
313 |
|
O buoyK, |
314 |
|
I myThid ) |
315 |
|
|
316 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
C-- Integrate hydrostatic balance for pH with BC of pH(z=0)=0 |
317 |
CALL CALC_PH( |
CALL CALC_PHI_HYD( |
318 |
I bi,bj,iMin,iMax,jMin,jMax,K,rhoKm1,rhoK, |
I bi,bj,iMin,iMax,jMin,jMax,K,buoyKm1,buoyK, |
319 |
U pH, |
U phiHyd, |
320 |
I myThid ) |
I myThid ) |
321 |
C-- Calculate iso-neutral slopes for the GM/Redi parameterisation |
C-- Calculate iso-neutral slopes for the GM/Redi parameterisation |
322 |
CALL FIND_RHO( |
CALL FIND_RHO( |
330 |
I myThid ) |
I myThid ) |
331 |
DO J=jMin,jMax |
DO J=jMin,jMax |
332 |
DO I=iMin,iMax |
DO I=iMin,iMax |
333 |
rhoKm1(I,J)=rhoK(I,J) |
rhoKm1(I,J) =rhoK(I,J) |
334 |
|
buoyKm1(I,J)=buoyK(I,J) |
335 |
ENDDO |
ENDDO |
336 |
ENDDO |
ENDDO |
337 |
|
|
364 |
CALL CALC_MOM_RHS( |
CALL CALC_MOM_RHS( |
365 |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown, |
366 |
I xA,yA,uTrans,vTrans,wTrans,wVel,maskC, |
I xA,yA,uTrans,vTrans,wTrans,wVel,maskC, |
367 |
I pH, |
I phiHyd, |
368 |
U aTerm,xTerm,cTerm,mTerm,pTerm, |
U aTerm,xTerm,cTerm,mTerm,pTerm, |
369 |
U fZon, fMer, fVerU, fVerV, |
U fZon, fMer, fVerU, fVerV, |
370 |
I myThid) |
I myThid) |
374 |
IF ( tempStepping ) THEN |
IF ( tempStepping ) THEN |
375 |
CALL CALC_GT( |
CALL CALC_GT( |
376 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
377 |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
I xA,yA,uTrans,vTrans,wTrans,maskUp,maskC, |
378 |
I K13,K23,KappaZT,KapGM, |
I K13,K23,KappaZT,KapGM, |
379 |
U aTerm,xTerm,fZon,fMer,fVerT, |
U aTerm,xTerm,fZon,fMer,fVerT, |
380 |
I myThid) |
I myThid) |
382 |
IF ( saltStepping ) THEN |
IF ( saltStepping ) THEN |
383 |
CALL CALC_GS( |
CALL CALC_GS( |
384 |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax, k,kM1,kUp,kDown, |
385 |
I xA,yA,uTrans,vTrans,wTrans,maskUp, |
I xA,yA,uTrans,vTrans,wTrans,maskUp,maskC, |
386 |
I K13,K23,KappaZS,KapGM, |
I K13,K23,KappaZS,KapGM, |
387 |
U aTerm,xTerm,fZon,fMer,fVerS, |
U aTerm,xTerm,fZon,fMer,fVerS, |
388 |
I myThid) |
I myThid) |
399 |
I xA,yA, |
I xA,yA, |
400 |
I myThid) |
I myThid) |
401 |
|
|
402 |
|
C-- Cumulative diagnostic calculations (ie. time-averaging) |
403 |
|
#ifdef ALLOW_DIAGNOSTICS |
404 |
|
IF (taveFreq.GT.0.) THEN |
405 |
|
CALL DO_TIME_AVERAGES( |
406 |
|
I myTime, myIter, bi, bj, K, kUp, kDown, |
407 |
|
I K13, K23, wVel, KapGM, |
408 |
|
I myThid ) |
409 |
|
ENDIF |
410 |
|
#endif |
411 |
|
|
412 |
ENDDO ! K |
ENDDO ! K |
413 |
|
|
414 |
C-- Implicit diffusion |
C-- Implicit diffusion |
423 |
|
|
424 |
C write(0,*) 'dynamics: pS ',minval(cg2d_x(1:sNx,1:sNy,:,:)), |
C write(0,*) 'dynamics: pS ',minval(cg2d_x(1:sNx,1:sNy,:,:)), |
425 |
C & maxval(cg2d_x(1:sNx,1:sNy,:,:)) |
C & maxval(cg2d_x(1:sNx,1:sNy,:,:)) |
426 |
write(0,*) 'dynamics: U ',minval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.), |
C write(0,*) 'dynamics: U ',minval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.), |
427 |
& maxval(uVel(1:sNx,1:sNy,1,:,:)) |
C & maxval(uVel(1:sNx,1:sNy,1,:,:),mask=uVel(1:sNx,1:sNy,1,:,:).NE.0.) |
428 |
write(0,*) 'dynamics: V ',minval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.), |
C write(0,*) 'dynamics: V ',minval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.), |
429 |
& maxval(vVel(1:sNx,1:sNy,1,:,:)) |
C & maxval(vVel(1:sNx,1:sNy,1,:,:),mask=vVel(1:sNx,1:sNy,1,:,:).NE.0.) |
430 |
write(0,*) 'dynamics: wVel(1) ', |
C write(0,*) 'dynamics: wVel(1) ', |
431 |
& minval(wVel(1:sNx,1:sNy,1),mask=wVel(1:sNx,1:sNy,1).NE.0.), |
C & minval(wVel(1:sNx,1:sNy,1),mask=wVel(1:sNx,1:sNy,1).NE.0.), |
432 |
& maxval(wVel(1:sNx,1:sNy,1)) |
C & maxval(wVel(1:sNx,1:sNy,1),mask=wVel(1:sNx,1:sNy,1).NE.0.) |
433 |
write(0,*) 'dynamics: wVel(2) ', |
C write(0,*) 'dynamics: wVel(2) ', |
434 |
& minval(wVel(1:sNx,1:sNy,2),mask=wVel(1:sNx,1:sNy,2).NE.0.), |
C & minval(wVel(1:sNx,1:sNy,2),mask=wVel(1:sNx,1:sNy,2).NE.0.), |
435 |
& maxval(wVel(1:sNx,1:sNy,2)) |
C & maxval(wVel(1:sNx,1:sNy,2),mask=wVel(1:sNx,1:sNy,2).NE.0.) |
436 |
cblk write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)), |
cblk write(0,*) 'dynamics: K13',minval(K13(1:sNx,1:sNy,:)), |
437 |
cblk & maxval(K13(1:sNx,1:sNy,:)) |
cblk & maxval(K13(1:sNx,1:sNy,:)) |
438 |
cblk write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)), |
cblk write(0,*) 'dynamics: K23',minval(K23(1:sNx,1:sNy,:)), |
447 |
C & maxval(gS(1:sNx,1:sNy,:,:,:)) |
C & maxval(gS(1:sNx,1:sNy,:,:,:)) |
448 |
C write(0,*) 'dynamics: S ',minval(salt(1:sNx,1:sNy,:,:,:)), |
C write(0,*) 'dynamics: S ',minval(salt(1:sNx,1:sNy,:,:,:)), |
449 |
C & maxval(salt(1:sNx,1:sNy,:,:,:)) |
C & maxval(salt(1:sNx,1:sNy,:,:,:)) |
450 |
write(0,*) 'dynamics: pH ',minval(pH/(Gravity*Rhonil),mask=ph.NE.0.), |
C write(0,*) 'dynamics: pH ',minval(pH/(Gravity*Rhonil),mask=ph.NE.0.), |
451 |
& maxval(pH/(Gravity*Rhonil)) |
C & maxval(pH/(Gravity*Rhonil)) |
452 |
|
|
453 |
RETURN |
RETURN |
454 |
END |
END |