4 |
CBOI |
CBOI |
5 |
C !TITLE: pkg/mom\_advdiff |
C !TITLE: pkg/mom\_advdiff |
6 |
C !AUTHORS: adcroft@mit.edu |
C !AUTHORS: adcroft@mit.edu |
7 |
C !INTRODUCTION: |
C !INTRODUCTION: Flux-form Momentum Equations Package |
|
C \section{Flux-form Momentum Equations Package} |
|
8 |
C |
C |
9 |
C Package "mom\_fluxform" provides methods for calculating explicit terms |
C Package "mom\_fluxform" provides methods for calculating explicit terms |
10 |
C in the momentum equation cast in flux-form: |
C in the momentum equation cast in flux-form: |
33 |
C !INTERFACE: ========================================================== |
C !INTERFACE: ========================================================== |
34 |
SUBROUTINE MOM_FLUXFORM( |
SUBROUTINE MOM_FLUXFORM( |
35 |
I bi,bj,iMin,iMax,jMin,jMax,k,kUp,kDown, |
I bi,bj,iMin,iMax,jMin,jMax,k,kUp,kDown, |
36 |
I phi_hyd,KappaRU,KappaRV, |
I phi_hyd,dPhihydX,dPhiHydY,KappaRU,KappaRV, |
37 |
U fVerU, fVerV, |
U fVerU, fVerV, |
38 |
I myCurrentTime,myIter,myThid) |
I myTime,myIter,myThid) |
39 |
|
|
40 |
C !DESCRIPTION: |
C !DESCRIPTION: |
41 |
C Calculates all the horizontal accelerations except for the implicit surface |
C Calculates all the horizontal accelerations except for the implicit surface |
59 |
C kUp :: =1 or 2 for consecutive k |
C kUp :: =1 or 2 for consecutive k |
60 |
C kDown :: =2 or 1 for consecutive k |
C kDown :: =2 or 1 for consecutive k |
61 |
C phi_hyd :: hydrostatic pressure (perturbation) |
C phi_hyd :: hydrostatic pressure (perturbation) |
62 |
|
C dPhiHydX,Y :: Gradient (X & Y dir.) of Hydrostatic Potential |
63 |
C KappaRU :: vertical viscosity |
C KappaRU :: vertical viscosity |
64 |
C KappaRV :: vertical viscosity |
C KappaRV :: vertical viscosity |
65 |
C fVerU :: vertical flux of U, 2 1/2 dim for pipe-lining |
C fVerU :: vertical flux of U, 2 1/2 dim for pipe-lining |
66 |
C fVerV :: vertical flux of V, 2 1/2 dim for pipe-lining |
C fVerV :: vertical flux of V, 2 1/2 dim for pipe-lining |
67 |
C myCurrentTime :: current time |
C myTime :: current time |
68 |
C myIter :: current time-step number |
C myIter :: current time-step number |
69 |
C myThid :: thread number |
C myThid :: thread number |
70 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
71 |
INTEGER k,kUp,kDown |
INTEGER k,kUp,kDown |
72 |
_RL phi_hyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL phi_hyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
73 |
|
_RL dPhiHydX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
74 |
|
_RL dPhiHydY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
75 |
_RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
76 |
_RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
77 |
_RL fVerU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
78 |
_RL fVerV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
79 |
_RL myCurrentTime |
_RL myTime |
80 |
INTEGER myIter |
INTEGER myIter |
81 |
INTEGER myThid |
INTEGER myThid |
82 |
|
|
122 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
123 |
_RL uFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL uFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
124 |
_RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
125 |
|
_RL rTransU(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
126 |
|
_RL rTransV(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
127 |
C I,J,K - Loop counters |
C I,J,K - Loop counters |
128 |
C rVelMaskOverride - Factor for imposing special surface boundary conditions |
C rVelMaskOverride - Factor for imposing special surface boundary conditions |
129 |
C ( set according to free-surface condition ). |
C ( set according to free-surface condition ). |
179 |
pF(i,j) = 0. |
pF(i,j) = 0. |
180 |
fZon(i,j) = 0. |
fZon(i,j) = 0. |
181 |
fMer(i,j) = 0. |
fMer(i,j) = 0. |
182 |
|
rTransU(i,j) = 0. |
183 |
|
rTransV(i,j) = 0. |
184 |
ENDDO |
ENDDO |
185 |
ENDDO |
ENDDO |
186 |
|
|
257 |
|
|
258 |
CALL MOM_CALC_KE(bi,bj,k,uFld,vFld,KE,myThid) |
CALL MOM_CALC_KE(bi,bj,k,uFld,vFld,KE,myThid) |
259 |
|
|
260 |
|
C--- First call (k=1): compute vertical adv. flux fVerU(kUp) & fVerV(kUp) |
261 |
|
IF (momAdvection.AND.k.EQ.1) THEN |
262 |
|
|
263 |
|
C- Calculate vertical transports above U & V points (West & South face): |
264 |
|
CALL MOM_CALC_RTRANS( k, bi, bj, |
265 |
|
O rTransU, rTransV, |
266 |
|
I myTime, myIter, myThid) |
267 |
|
|
268 |
|
C- Free surface correction term (flux at k=1) |
269 |
|
CALL MOM_U_ADV_WU(bi,bj,k,uVel,wVel,rTransU,af,myThid) |
270 |
|
DO j=jMin,jMax |
271 |
|
DO i=iMin,iMax |
272 |
|
fVerU(i,j,kUp) = af(i,j) |
273 |
|
ENDDO |
274 |
|
ENDDO |
275 |
|
|
276 |
|
CALL MOM_V_ADV_WV(bi,bj,k,vVel,wVel,rTransV,af,myThid) |
277 |
|
DO j=jMin,jMax |
278 |
|
DO i=iMin,iMax |
279 |
|
fVerV(i,j,kUp) = af(i,j) |
280 |
|
ENDDO |
281 |
|
ENDDO |
282 |
|
|
283 |
|
C--- endif momAdvection & k=1 |
284 |
|
ENDIF |
285 |
|
|
286 |
|
|
287 |
|
C--- Calculate vertical transports (at k+1) below U & V points : |
288 |
|
IF (momAdvection) THEN |
289 |
|
CALL MOM_CALC_RTRANS( k+1, bi, bj, |
290 |
|
O rTransU, rTransV, |
291 |
|
I myTime, myIter, myThid) |
292 |
|
ENDIF |
293 |
|
|
294 |
|
|
295 |
C---- Zonal momentum equation starts here |
C---- Zonal momentum equation starts here |
296 |
|
|
297 |
C Bi-harmonic term del^2 U -> v4F |
C Bi-harmonic term del^2 U -> v4F |
336 |
|
|
337 |
C-- Vertical flux (fVer is at upper face of "u" cell) |
C-- Vertical flux (fVer is at upper face of "u" cell) |
338 |
|
|
|
C-- Free surface correction term (flux at k=1) |
|
|
IF (momAdvection.AND.k.EQ.1) THEN |
|
|
CALL MOM_U_ADV_WU(bi,bj,k,uVel,wVel,af,myThid) |
|
|
DO j=jMin,jMax |
|
|
DO i=iMin,iMax |
|
|
fVerU(i,j,kUp) = af(i,j) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
339 |
C Mean flow component of vertical flux (at k+1) -> aF |
C Mean flow component of vertical flux (at k+1) -> aF |
340 |
IF (momAdvection) |
IF (momAdvection) |
341 |
& CALL MOM_U_ADV_WU(bi,bj,k+1,uVel,wVel,af,myThid) |
& CALL MOM_U_ADV_WU(bi,bj,k+1,uVel,wVel,rTransU,af,myThid) |
342 |
|
|
343 |
C Eddy component of vertical flux (interior component only) -> vrF |
C Eddy component of vertical flux (interior component only) -> vrF |
344 |
IF (momViscosity.AND..NOT.implicitViscosity) |
IF (momViscosity.AND..NOT.implicitViscosity) |
351 |
ENDDO |
ENDDO |
352 |
ENDDO |
ENDDO |
353 |
|
|
|
C--- Hydrostatic term ( -1/rhoConst . dphi/dx ) |
|
|
IF (momPressureForcing) THEN |
|
|
DO j=jMin,jMax |
|
|
DO i=iMin,iMax |
|
|
pf(i,j) = - _recip_dxC(i,j,bi,bj) |
|
|
& *(phi_hyd(i,j,k)-phi_hyd(i-1,j,k)) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
|
|
|
354 |
C-- Tendency is minus divergence of the fluxes + coriolis + pressure term |
C-- Tendency is minus divergence of the fluxes + coriolis + pressure term |
355 |
DO j=jMin,jMax |
DO j=jMin,jMax |
356 |
DO i=iMin,iMax |
DO i=iMin,iMax |
366 |
& +fMer(i,j+1) - fMer(i ,j) |
& +fMer(i,j+1) - fMer(i ,j) |
367 |
& +fVerU(i,j,kUp)*rkFac - fVerU(i,j,kDown)*rkFac |
& +fVerU(i,j,kUp)*rkFac - fVerU(i,j,kDown)*rkFac |
368 |
& ) |
& ) |
369 |
& _PHM( +phxFac * pf(i,j) ) |
& - phxFac*dPhiHydX(i,j) |
370 |
ENDDO |
ENDDO |
371 |
ENDDO |
ENDDO |
372 |
|
|
373 |
|
#ifdef NONLIN_FRSURF |
374 |
|
C-- account for 3.D divergence of the flow in rStar coordinate: |
375 |
|
IF ( momAdvection .AND. select_rStar.GT.0 ) THEN |
376 |
|
DO j=jMin,jMax |
377 |
|
DO i=iMin,iMax |
378 |
|
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj) |
379 |
|
& - (rStarExpW(i,j,bi,bj) - 1. _d 0)/deltaTfreesurf |
380 |
|
& *uVel(i,j,k,bi,bj) |
381 |
|
ENDDO |
382 |
|
ENDDO |
383 |
|
ENDIF |
384 |
|
IF ( momAdvection .AND. select_rStar.LT.0 ) THEN |
385 |
|
DO j=jMin,jMax |
386 |
|
DO i=iMin,iMax |
387 |
|
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj) |
388 |
|
& - rStarDhWDt(i,j,bi,bj)*uVel(i,j,k,bi,bj) |
389 |
|
ENDDO |
390 |
|
ENDDO |
391 |
|
ENDIF |
392 |
|
#endif /* NONLIN_FRSURF */ |
393 |
|
|
394 |
C-- No-slip and drag BCs appear as body forces in cell abutting topography |
C-- No-slip and drag BCs appear as body forces in cell abutting topography |
395 |
IF (momViscosity.AND.no_slip_sides) THEN |
IF (momViscosity.AND.no_slip_sides) THEN |
396 |
C- No-slip BCs impose a drag at walls... |
C- No-slip BCs impose a drag at walls... |
415 |
IF (momForcing) |
IF (momForcing) |
416 |
& CALL EXTERNAL_FORCING_U( |
& CALL EXTERNAL_FORCING_U( |
417 |
I iMin,iMax,jMin,jMax,bi,bj,k, |
I iMin,iMax,jMin,jMax,bi,bj,k, |
418 |
I myCurrentTime,myThid) |
I myTime,myThid) |
419 |
|
|
420 |
C-- Metric terms for curvilinear grid systems |
C-- Metric terms for curvilinear grid systems |
421 |
IF (usingSphericalPolarMTerms) THEN |
IF (useNHMTerms) THEN |
422 |
C o Spherical polar grid metric terms |
C o Non-hydrosatic metric terms |
423 |
CALL MOM_U_METRIC_NH(bi,bj,k,uFld,wVel,mT,myThid) |
CALL MOM_U_METRIC_NH(bi,bj,k,uFld,wVel,mT,myThid) |
424 |
DO j=jMin,jMax |
DO j=jMin,jMax |
425 |
DO i=iMin,iMax |
DO i=iMin,iMax |
426 |
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mTFacU*mT(i,j) |
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mTFacU*mT(i,j) |
427 |
ENDDO |
ENDDO |
428 |
ENDDO |
ENDDO |
429 |
|
ENDIF |
430 |
|
IF (usingSphericalPolarMTerms) THEN |
431 |
CALL MOM_U_METRIC_SPHERE(bi,bj,k,uFld,vFld,mT,myThid) |
CALL MOM_U_METRIC_SPHERE(bi,bj,k,uFld,vFld,mT,myThid) |
432 |
DO j=jMin,jMax |
DO j=jMin,jMax |
433 |
DO i=iMin,iMax |
DO i=iMin,iMax |
488 |
|
|
489 |
C-- Vertical flux (fVer is at upper face of "v" cell) |
C-- Vertical flux (fVer is at upper face of "v" cell) |
490 |
|
|
|
C-- Free surface correction term (flux at k=1) |
|
|
IF (momAdvection.AND.k.EQ.1) THEN |
|
|
CALL MOM_V_ADV_WV(bi,bj,k,vVel,wVel,af,myThid) |
|
|
DO j=jMin,jMax |
|
|
DO i=iMin,iMax |
|
|
fVerV(i,j,kUp) = af(i,j) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
491 |
C o Mean flow component of vertical flux |
C o Mean flow component of vertical flux |
492 |
IF (momAdvection) |
IF (momAdvection) |
493 |
& CALL MOM_V_ADV_WV(bi,bj,k+1,vVel,wVel,af,myThid) |
& CALL MOM_V_ADV_WV(bi,bj,k+1,vVel,wVel,rTransV,af,myThid) |
494 |
|
|
495 |
C Eddy component of vertical flux (interior component only) -> vrF |
C Eddy component of vertical flux (interior component only) -> vrF |
496 |
IF (momViscosity.AND..NOT.implicitViscosity) |
IF (momViscosity.AND..NOT.implicitViscosity) |
503 |
ENDDO |
ENDDO |
504 |
ENDDO |
ENDDO |
505 |
|
|
|
C--- Hydorstatic term (-1/rhoConst . dphi/dy ) |
|
|
IF (momPressureForcing) THEN |
|
|
DO j=jMin,jMax |
|
|
DO i=iMin,iMax |
|
|
pF(i,j) = -_recip_dyC(i,j,bi,bj) |
|
|
& *(phi_hyd(i,j,k)-phi_hyd(i,j-1,k)) |
|
|
ENDDO |
|
|
ENDDO |
|
|
ENDIF |
|
|
|
|
506 |
C-- Tendency is minus divergence of the fluxes + coriolis + pressure term |
C-- Tendency is minus divergence of the fluxes + coriolis + pressure term |
507 |
DO j=jMin,jMax |
DO j=jMin,jMax |
508 |
DO i=iMin,iMax |
DO i=iMin,iMax |
518 |
& +fMer(i,j ) - fMer(i,j-1) |
& +fMer(i,j ) - fMer(i,j-1) |
519 |
& +fVerV(i,j,kUp)*rkFac - fVerV(i,j,kDown)*rkFac |
& +fVerV(i,j,kUp)*rkFac - fVerV(i,j,kDown)*rkFac |
520 |
& ) |
& ) |
521 |
& _PHM( +phyFac*pf(i,j) ) |
& - phyFac*dPhiHydY(i,j) |
522 |
ENDDO |
ENDDO |
523 |
ENDDO |
ENDDO |
524 |
|
|
525 |
|
#ifdef NONLIN_FRSURF |
526 |
|
C-- account for 3.D divergence of the flow in rStar coordinate: |
527 |
|
IF ( momAdvection .AND. select_rStar.GT.0 ) THEN |
528 |
|
DO j=jMin,jMax |
529 |
|
DO i=iMin,iMax |
530 |
|
gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj) |
531 |
|
& - (rStarExpS(i,j,bi,bj) - 1. _d 0)/deltaTfreesurf |
532 |
|
& *vVel(i,j,k,bi,bj) |
533 |
|
ENDDO |
534 |
|
ENDDO |
535 |
|
ENDIF |
536 |
|
IF ( momAdvection .AND. select_rStar.LT.0 ) THEN |
537 |
|
DO j=jMin,jMax |
538 |
|
DO i=iMin,iMax |
539 |
|
gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj) |
540 |
|
& - rStarDhSDt(i,j,bi,bj)*vVel(i,j,k,bi,bj) |
541 |
|
ENDDO |
542 |
|
ENDDO |
543 |
|
ENDIF |
544 |
|
#endif /* NONLIN_FRSURF */ |
545 |
|
|
546 |
C-- No-slip and drag BCs appear as body forces in cell abutting topography |
C-- No-slip and drag BCs appear as body forces in cell abutting topography |
547 |
IF (momViscosity.AND.no_slip_sides) THEN |
IF (momViscosity.AND.no_slip_sides) THEN |
548 |
C- No-slip BCs impose a drag at walls... |
C- No-slip BCs impose a drag at walls... |
567 |
IF (momForcing) |
IF (momForcing) |
568 |
& CALL EXTERNAL_FORCING_V( |
& CALL EXTERNAL_FORCING_V( |
569 |
I iMin,iMax,jMin,jMax,bi,bj,k, |
I iMin,iMax,jMin,jMax,bi,bj,k, |
570 |
I myCurrentTime,myThid) |
I myTime,myThid) |
571 |
|
|
572 |
C-- Metric terms for curvilinear grid systems |
C-- Metric terms for curvilinear grid systems |
573 |
IF (usingSphericalPolarMTerms) THEN |
IF (useNHMTerms) THEN |
574 |
C o Spherical polar grid metric terms |
C o Spherical polar grid metric terms |
575 |
CALL MOM_V_METRIC_NH(bi,bj,k,vFld,wVel,mT,myThid) |
CALL MOM_V_METRIC_NH(bi,bj,k,vFld,wVel,mT,myThid) |
576 |
DO j=jMin,jMax |
DO j=jMin,jMax |
578 |
gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mTFacV*mT(i,j) |
gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mTFacV*mT(i,j) |
579 |
ENDDO |
ENDDO |
580 |
ENDDO |
ENDDO |
581 |
|
ENDIF |
582 |
|
IF (usingSphericalPolarMTerms) THEN |
583 |
CALL MOM_V_METRIC_SPHERE(bi,bj,k,uFld,mT,myThid) |
CALL MOM_V_METRIC_SPHERE(bi,bj,k,uFld,mT,myThid) |
584 |
DO j=jMin,jMax |
DO j=jMin,jMax |
585 |
DO i=iMin,iMax |
DO i=iMin,iMax |
598 |
C-- Coriolis term |
C-- Coriolis term |
599 |
C Note. As coded here, coriolis will not work with "thin walls" |
C Note. As coded here, coriolis will not work with "thin walls" |
600 |
#ifdef INCLUDE_CD_CODE |
#ifdef INCLUDE_CD_CODE |
601 |
CALL MOM_CDSCHEME(bi,bj,k,phi_hyd,myThid) |
CALL MOM_CDSCHEME(bi,bj,k,phi_hyd,dPhiHydX,dPhiHydY,myThid) |
602 |
#else |
#else |
603 |
CALL MOM_U_CORIOLIS(bi,bj,k,vFld,cf,myThid) |
CALL MOM_U_CORIOLIS(bi,bj,k,vFld,cf,myThid) |
604 |
DO j=jMin,jMax |
DO j=jMin,jMax |
613 |
ENDDO |
ENDDO |
614 |
ENDDO |
ENDDO |
615 |
#endif /* INCLUDE_CD_CODE */ |
#endif /* INCLUDE_CD_CODE */ |
616 |
|
IF (nonHydrostatic.OR.quasiHydrostatic) THEN |
617 |
|
CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,cf,myThid) |
618 |
|
DO j=jMin,jMax |
619 |
|
DO i=iMin,iMax |
620 |
|
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j) |
621 |
|
ENDDO |
622 |
|
ENDDO |
623 |
|
ENDIF |
624 |
|
|
625 |
RETURN |
RETURN |
626 |
END |
END |