4 |
#include "MOM_VECINV_OPTIONS.h" |
#include "MOM_VECINV_OPTIONS.h" |
5 |
|
|
6 |
SUBROUTINE MOM_VECINV( |
SUBROUTINE MOM_VECINV( |
7 |
I bi,bj,iMin,iMax,jMin,jMax,k,kUp,kDown, |
I bi,bj,k,iMin,iMax,jMin,jMax, |
8 |
I KappaRU, KappaRV, |
I KappaRU, KappaRV, |
9 |
U fVerU, fVerV, |
I fVerUkm, fVerVkm, |
10 |
|
O fVerUkp, fVerVkp, |
11 |
O guDiss, gvDiss, |
O guDiss, gvDiss, |
12 |
I myTime, myIter, myThid) |
I myTime, myIter, myThid ) |
13 |
C /==========================================================\ |
C *==========================================================* |
14 |
C | S/R MOM_VECINV | |
C | S/R MOM_VECINV | |
15 |
C | o Form the right hand-side of the momentum equation. | |
C | o Form the right hand-side of the momentum equation. | |
16 |
C |==========================================================| |
C *==========================================================* |
17 |
C | Terms are evaluated one layer at a time working from | |
C | Terms are evaluated one layer at a time working from | |
18 |
C | the bottom to the top. The vertically integrated | |
C | the bottom to the top. The vertically integrated | |
19 |
C | barotropic flow tendency term is evluated by summing the | |
C | barotropic flow tendency term is evluated by summing the | |
24 |
C | form produces a diffusive flux that does not scale with | |
C | form produces a diffusive flux that does not scale with | |
25 |
C | open-area. Need to do something to solidfy this and to | |
C | open-area. Need to do something to solidfy this and to | |
26 |
C | deal "properly" with thin walls. | |
C | deal "properly" with thin walls. | |
27 |
C \==========================================================/ |
C *==========================================================* |
28 |
IMPLICIT NONE |
IMPLICIT NONE |
29 |
|
|
30 |
C == Global variables == |
C == Global variables == |
45 |
#endif |
#endif |
46 |
|
|
47 |
C == Routine arguments == |
C == Routine arguments == |
48 |
C fVerU :: Flux of momentum in the vertical direction, out of the upper |
C bi,bj :: current tile indices |
49 |
C fVerV :: face of a cell K ( flux into the cell above ). |
C k :: current vertical level |
50 |
C guDiss :: dissipation tendency (all explicit terms), u component |
C iMin,iMax,jMin,jMax :: loop ranges |
51 |
C gvDiss :: dissipation tendency (all explicit terms), v component |
C fVerU :: Flux of momentum in the vertical direction, out of the upper |
52 |
C bi, bj, iMin, iMax, jMin, jMax - Range of points for which calculation |
C fVerV :: face of a cell K ( flux into the cell above ). |
53 |
C results will be set. |
C fVerUkm :: vertical viscous flux of U, interface above (k-1/2) |
54 |
C kUp, kDown - Index for upper and lower layers. |
C fVerVkm :: vertical viscous flux of V, interface above (k-1/2) |
55 |
C myThid :: my Thread Id number |
C fVerUkp :: vertical viscous flux of U, interface below (k+1/2) |
56 |
|
C fVerVkp :: vertical viscous flux of V, interface below (k+1/2) |
57 |
|
|
58 |
|
C guDiss :: dissipation tendency (all explicit terms), u component |
59 |
|
C gvDiss :: dissipation tendency (all explicit terms), v component |
60 |
|
C myTime :: current time |
61 |
|
C myIter :: current time-step number |
62 |
|
C myThid :: my Thread Id number |
63 |
|
INTEGER bi,bj,k |
64 |
|
INTEGER iMin,iMax,jMin,jMax |
65 |
_RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
66 |
_RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
_RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
67 |
_RL fVerU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerUkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
_RL fVerV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) |
_RL fVerVkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
69 |
|
_RL fVerUkp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
|
_RL fVerVkp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
71 |
_RL guDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL guDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
72 |
_RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
|
INTEGER kUp,kDown |
|
73 |
_RL myTime |
_RL myTime |
74 |
INTEGER myIter |
INTEGER myIter |
75 |
INTEGER myThid |
INTEGER myThid |
|
INTEGER bi,bj,iMin,iMax,jMin,jMax |
|
76 |
|
|
77 |
#ifdef ALLOW_MOM_VECINV |
#ifdef ALLOW_MOM_VECINV |
78 |
|
|
103 |
_RL viscAh_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL viscAh_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
104 |
_RL viscA4_Z(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL viscA4_Z(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
105 |
_RL viscA4_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RL viscA4_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
106 |
C i,j,k :: Loop counters |
C i,j :: Loop counters |
107 |
INTEGER i,j,k |
INTEGER i,j |
108 |
C xxxFac - On-off tracer parameters used for switching terms off. |
C xxxFac :: On-off tracer parameters used for switching terms off. |
109 |
_RL ArDudrFac |
_RL ArDudrFac |
110 |
_RL ArDvdrFac |
_RL ArDvdrFac |
111 |
_RL sideMaskFac |
_RL sideMaskFac |
126 |
C-- the kUp is still required |
C-- the kUp is still required |
127 |
C-- In the case of mom_fluxform Kup is set as well |
C-- In the case of mom_fluxform Kup is set as well |
128 |
C-- (at least in part) |
C-- (at least in part) |
129 |
fVerU(1,1,kUp) = fVerU(1,1,kUp) |
fVerUkm(1,1) = fVerUkm(1,1) |
130 |
fVerV(1,1,kUp) = fVerV(1,1,kUp) |
fVerVkm(1,1) = fVerVkm(1,1) |
131 |
#endif |
#endif |
132 |
|
|
133 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
166 |
offsets(i) = 0 |
offsets(i) = 0 |
167 |
ENDDO |
ENDDO |
168 |
offsets(3) = k |
offsets(3) = k |
169 |
C write(*,*) 'offsets = ',(offsets(i),i=1,9) |
c write(*,*) 'offsets = ',(offsets(i),i=1,9) |
170 |
ENDIF |
ENDIF |
171 |
#endif /* ALLOW_MNC */ |
#endif /* ALLOW_MNC */ |
172 |
|
|
173 |
C Initialise intermediate terms |
C-- Initialise intermediate terms |
174 |
DO J=1-OLy,sNy+OLy |
DO j=1-OLy,sNy+OLy |
175 |
DO I=1-OLx,sNx+OLx |
DO i=1-OLx,sNx+OLx |
176 |
vF(i,j) = 0. |
vF(i,j) = 0. |
177 |
vrF(i,j) = 0. |
vrF(i,j) = 0. |
178 |
uCf(i,j) = 0. |
uCf(i,j) = 0. |
186 |
vort3(i,j) = 0. |
vort3(i,j) = 0. |
187 |
omega3(i,j)= 0. |
omega3(i,j)= 0. |
188 |
KE(i,j) = 0. |
KE(i,j) = 0. |
189 |
c hDiv(i,j) = 0. |
C- need to initialise hDiv for MOM_VI_DEL2UV(call FILL_CS_CORNER_TR_RL) |
190 |
|
hDiv(i,j) = 0. |
191 |
viscAh_Z(i,j) = 0. |
viscAh_Z(i,j) = 0. |
192 |
viscAh_D(i,j) = 0. |
viscAh_D(i,j) = 0. |
193 |
viscA4_Z(i,j) = 0. |
viscA4_Z(i,j) = 0. |
247 |
C and mask relative vorticity (free-slip case): |
C and mask relative vorticity (free-slip case): |
248 |
|
|
249 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
250 |
CADJ STORE vort3(:,:) = |
CADJ STORE vort3(:,:) = |
251 |
CADJ & comlev1_bibj_k, key = imomkey, byte = isbyte |
CADJ & comlev1_bibj_k, key = imomkey, byte = isbyte |
252 |
#endif |
#endif |
253 |
|
|
258 |
CALL MOM_CALC_STRAIN(bi,bj,k,uFld,vFld,hFacZ,strain,myThid) |
CALL MOM_CALC_STRAIN(bi,bj,k,uFld,vFld,hFacZ,strain,myThid) |
259 |
|
|
260 |
C- account for no-slip / free-slip BC: |
C- account for no-slip / free-slip BC: |
261 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
262 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
263 |
IF ( hFacZ(i,j).EQ.0. ) THEN |
IF ( hFacZ(i,j).EQ.0. ) THEN |
264 |
vort3(i,j) = sideMaskFac*vort3(i,j) |
vort3(i,j) = sideMaskFac*vort3(i,j) |
265 |
strain(i,j) = sideMaskFac*strain(i,j) |
strain(i,j) = sideMaskFac*strain(i,j) |
283 |
CALL MOM_CALC_HDIV(bi,bj,k,2,del2u,del2v,dStar,myThid) |
CALL MOM_CALC_HDIV(bi,bj,k,2,del2u,del2v,dStar,myThid) |
284 |
CALL MOM_CALC_RELVORT3(bi,bj,k, |
CALL MOM_CALC_RELVORT3(bi,bj,k, |
285 |
& del2u,del2v,hFacZ,zStar,myThid) |
& del2u,del2v,hFacZ,zStar,myThid) |
286 |
|
IF ( writeDiag ) THEN |
287 |
|
CALL WRITE_LOCAL_RL( 'del2u', 'I10', 1, del2u, |
288 |
|
& bi,bj,k, myIter, myThid ) |
289 |
|
CALL WRITE_LOCAL_RL( 'del2v', 'I10', 1, del2v, |
290 |
|
& bi,bj,k, myIter, myThid ) |
291 |
|
CALL WRITE_LOCAL_RL( 'dStar', 'I10', 1, dStar, |
292 |
|
& bi,bj,k, myIter, myThid ) |
293 |
|
CALL WRITE_LOCAL_RL( 'zStar', 'I10', 1, zStar, |
294 |
|
& bi,bj,k, myIter, myThid ) |
295 |
|
ENDIF |
296 |
ENDIF |
ENDIF |
297 |
|
|
298 |
C- Strain diagnostics: |
C- Strain diagnostics: |
318 |
C in terms of tension and strain |
C in terms of tension and strain |
319 |
IF (useStrainTensionVisc) THEN |
IF (useStrainTensionVisc) THEN |
320 |
C mask strain as if free-slip since side-drag is computed separately |
C mask strain as if free-slip since side-drag is computed separately |
321 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
322 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
323 |
IF ( hFacZ(i,j).EQ.0. ) strain(i,j) = 0. _d 0 |
IF ( hFacZ(i,j).EQ.0. ) strain(i,j) = 0. _d 0 |
324 |
ENDDO |
ENDDO |
325 |
ENDDO |
ENDDO |
355 |
C Combine fluxes |
C Combine fluxes |
356 |
DO j=jMin,jMax |
DO j=jMin,jMax |
357 |
DO i=iMin,iMax |
DO i=iMin,iMax |
358 |
fVerU(i,j,kDown) = ArDudrFac*vrF(i,j) |
fVerUkp(i,j) = ArDudrFac*vrF(i,j) |
359 |
ENDDO |
ENDDO |
360 |
ENDDO |
ENDDO |
361 |
|
|
362 |
C-- Tendency is minus divergence of the fluxes |
C-- Tendency is minus divergence of the fluxes |
363 |
DO j=2-Oly,sNy+Oly-1 |
DO j=jMin,jMax |
364 |
DO i=2-Olx,sNx+Olx-1 |
DO i=iMin,iMax |
365 |
guDiss(i,j) = guDiss(i,j) |
guDiss(i,j) = guDiss(i,j) |
366 |
& -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k) |
& -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k) |
367 |
& *recip_rAw(i,j,bi,bj) |
& *recip_rAw(i,j,bi,bj) |
368 |
& *( |
& *( fVerUkp(i,j) - fVerUkm(i,j) )*rkSign |
|
& fVerU(i,j,kDown) - fVerU(i,j,kUp) |
|
|
& )*rkSign |
|
369 |
ENDDO |
ENDDO |
370 |
ENDDO |
ENDDO |
371 |
ENDIF |
ENDIF |
418 |
C Combine fluxes -> fVerV |
C Combine fluxes -> fVerV |
419 |
DO j=jMin,jMax |
DO j=jMin,jMax |
420 |
DO i=iMin,iMax |
DO i=iMin,iMax |
421 |
fVerV(i,j,kDown) = ArDvdrFac*vrF(i,j) |
fVerVkp(i,j) = ArDvdrFac*vrF(i,j) |
422 |
ENDDO |
ENDDO |
423 |
ENDDO |
ENDDO |
424 |
|
|
427 |
DO i=iMin,iMax |
DO i=iMin,iMax |
428 |
gvDiss(i,j) = gvDiss(i,j) |
gvDiss(i,j) = gvDiss(i,j) |
429 |
& -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k) |
& -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k) |
430 |
& *recip_rAs(i,j,bi,bj) |
& *recip_rAs(i,j,bi,bj) |
431 |
& *( |
& *( fVerVkp(i,j) - fVerVkm(i,j) )*rkSign |
|
& fVerV(i,j,kDown) - fVerV(i,j,kUp) |
|
|
& )*rkSign |
|
432 |
ENDDO |
ENDDO |
433 |
ENDDO |
ENDDO |
434 |
ENDIF |
ENDIF |
460 |
ENDIF |
ENDIF |
461 |
#ifdef ALLOW_SHELFICE |
#ifdef ALLOW_SHELFICE |
462 |
IF (useShelfIce.AND.momViscosity.AND.bottomDragTerms) THEN |
IF (useShelfIce.AND.momViscosity.AND.bottomDragTerms) THEN |
463 |
CALL SHELFICE_V_DRAG(bi,bj,k,vFld,KE,KappaRU,vF,myThid) |
CALL SHELFICE_V_DRAG(bi,bj,k,vFld,KE,KappaRV,vF,myThid) |
464 |
DO j=jMin,jMax |
DO j=jMin,jMax |
465 |
DO i=iMin,iMax |
DO i=iMin,iMax |
466 |
gvDiss(i,j) = gvDiss(i,j) + vF(i,j) |
gvDiss(i,j) = gvDiss(i,j) + vF(i,j) |
492 |
|
|
493 |
C--- Prepare for Advection & Coriolis terms: |
C--- Prepare for Advection & Coriolis terms: |
494 |
C- Mask relative vorticity and calculate absolute vorticity |
C- Mask relative vorticity and calculate absolute vorticity |
495 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
496 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
497 |
IF ( hFacZ(i,j).EQ.0. ) vort3(i,j) = 0. |
IF ( hFacZ(i,j).EQ.0. ) vort3(i,j) = 0. |
498 |
ENDDO |
ENDDO |
499 |
ENDDO |
ENDDO |
553 |
|
|
554 |
IF (momAdvection) THEN |
IF (momAdvection) THEN |
555 |
C-- Horizontal advection of relative (or absolute) vorticity |
C-- Horizontal advection of relative (or absolute) vorticity |
556 |
IF (highOrderVorticity.AND.useAbsVorticity) THEN |
IF ( (highOrderVorticity.OR.upwindVorticity) |
557 |
|
& .AND.useAbsVorticity ) THEN |
558 |
CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,omega3,r_hFacZ, |
CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,omega3,r_hFacZ, |
559 |
& uCf,myThid) |
& uCf,myThid) |
560 |
ELSEIF (highOrderVorticity) THEN |
ELSEIF ( (highOrderVorticity.OR.upwindVorticity) ) THEN |
561 |
CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,vort3, r_hFacZ, |
CALL MOM_VI_U_CORIOLIS_C4(bi,bj,k,vFld,vort3, r_hFacZ, |
562 |
& uCf,myThid) |
& uCf,myThid) |
563 |
ELSEIF (useAbsVorticity) THEN |
ELSEIF ( useAbsVorticity ) THEN |
564 |
CALL MOM_VI_U_CORIOLIS(bi,bj,K,vFld,omega3,hFacZ,r_hFacZ, |
CALL MOM_VI_U_CORIOLIS(bi,bj,K,vFld,omega3,hFacZ,r_hFacZ, |
565 |
& uCf,myThid) |
& uCf,myThid) |
566 |
ELSE |
ELSE |
572 |
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+uCf(i,j) |
gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+uCf(i,j) |
573 |
ENDDO |
ENDDO |
574 |
ENDDO |
ENDDO |
575 |
IF (highOrderVorticity.AND.useAbsVorticity) THEN |
IF ( (highOrderVorticity.OR.upwindVorticity) |
576 |
|
& .AND.useAbsVorticity ) THEN |
577 |
CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,omega3,r_hFacZ, |
CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,omega3,r_hFacZ, |
578 |
& vCf,myThid) |
& vCf,myThid) |
579 |
ELSEIF (highOrderVorticity) THEN |
ELSEIF ( (highOrderVorticity.OR.upwindVorticity) ) THEN |
580 |
CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,vort3, r_hFacZ, |
CALL MOM_VI_V_CORIOLIS_C4(bi,bj,K,uFld,vort3, r_hFacZ, |
581 |
& vCf,myThid) |
& vCf,myThid) |
582 |
ELSEIF (useAbsVorticity) THEN |
ELSEIF ( useAbsVorticity ) THEN |
583 |
CALL MOM_VI_V_CORIOLIS(bi,bj,K,uFld,omega3,hFacZ,r_hFacZ, |
CALL MOM_VI_V_CORIOLIS(bi,bj,K,uFld,omega3,hFacZ,r_hFacZ, |
584 |
& vCf,myThid) |
& vCf,myThid) |
585 |
ELSE |
ELSE |
675 |
C-- end if momAdvection |
C-- end if momAdvection |
676 |
ENDIF |
ENDIF |
677 |
|
|
678 |
C-- 3.D Coriolis term (horizontal momentum, Eastward component: -f'*w) |
C-- 3.D Coriolis term (horizontal momentum, Eastward component: -fprime*w) |
679 |
IF ( use3dCoriolis ) THEN |
IF ( use3dCoriolis ) THEN |
680 |
CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,uCf,myThid) |
CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,uCf,myThid) |
681 |
DO j=jMin,jMax |
DO j=jMin,jMax |
719 |
ENDDO |
ENDDO |
720 |
|
|
721 |
#ifdef ALLOW_DEBUG |
#ifdef ALLOW_DEBUG |
722 |
IF ( debugLevel .GE. debLevB |
IF ( debugLevel .GE. debLevC |
723 |
& .AND. k.EQ.4 .AND. myIter.EQ.nIter0 |
& .AND. k.EQ.4 .AND. myIter.EQ.nIter0 |
724 |
& .AND. nPx.EQ.1 .AND. nPy.EQ.1 |
& .AND. nPx.EQ.1 .AND. nPy.EQ.1 |
725 |
& .AND. useCubedSphereExchange ) THEN |
& .AND. useCubedSphereExchange ) THEN |
764 |
CALL DIAGNOSTICS_FILL(guDiss, 'Um_Diss ',k,1,2,bi,bj,myThid) |
CALL DIAGNOSTICS_FILL(guDiss, 'Um_Diss ',k,1,2,bi,bj,myThid) |
765 |
CALL DIAGNOSTICS_FILL(gvDiss, 'Vm_Diss ',k,1,2,bi,bj,myThid) |
CALL DIAGNOSTICS_FILL(gvDiss, 'Vm_Diss ',k,1,2,bi,bj,myThid) |
766 |
ENDIF |
ENDIF |
767 |
CALL DIAGNOSTICS_FILL(gU(1-Olx,1-Oly,k,bi,bj), |
CALL DIAGNOSTICS_FILL(gU(1-OLx,1-OLy,k,bi,bj), |
768 |
& 'Um_Advec',k,1,2,bi,bj,myThid) |
& 'Um_Advec',k,1,2,bi,bj,myThid) |
769 |
CALL DIAGNOSTICS_FILL(gV(1-Olx,1-Oly,k,bi,bj), |
CALL DIAGNOSTICS_FILL(gV(1-OLx,1-OLy,k,bi,bj), |
770 |
& 'Vm_Advec',k,1,2,bi,bj,myThid) |
& 'Vm_Advec',k,1,2,bi,bj,myThid) |
771 |
ENDIF |
ENDIF |
772 |
#endif /* ALLOW_DIAGNOSTICS */ |
#endif /* ALLOW_DIAGNOSTICS */ |