--- MITgcm/pkg/mom_fluxform/mom_fluxform.F 2003/01/26 21:18:50 1.8 +++ MITgcm/pkg/mom_fluxform/mom_fluxform.F 2003/10/11 16:37:55 1.15 @@ -1,4 +1,4 @@ -C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/pkg/mom_fluxform/mom_fluxform.F,v 1.8 2003/01/26 21:18:50 jmc Exp $ +C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/pkg/mom_fluxform/mom_fluxform.F,v 1.15 2003/10/11 16:37:55 jmc Exp $ C $Name: $ CBOI @@ -25,7 +25,7 @@ C stresses as well as internal viscous stresses. CEOI -#include "CPP_OPTIONS.h" +#include "MOM_FLUXFORM_OPTIONS.h" CBOP C !ROUTINE: MOM_FLUXFORM @@ -33,7 +33,7 @@ C !INTERFACE: ========================================================== SUBROUTINE MOM_FLUXFORM( I bi,bj,iMin,iMax,jMin,jMax,k,kUp,kDown, - I phi_hyd,KappaRU,KappaRV, + I dPhihydX,dPhiHydY,KappaRU,KappaRV, U fVerU, fVerV, I myTime,myIter,myThid) @@ -58,7 +58,7 @@ C k :: vertical level C kUp :: =1 or 2 for consecutive k C kDown :: =2 or 1 for consecutive k -C phi_hyd :: hydrostatic pressure (perturbation) +C dPhiHydX,Y :: Gradient (X & Y dir.) of Hydrostatic Potential C KappaRU :: vertical viscosity C KappaRV :: vertical viscosity C fVerU :: vertical flux of U, 2 1/2 dim for pipe-lining @@ -68,7 +68,8 @@ C myThid :: thread number INTEGER bi,bj,iMin,iMax,jMin,jMax INTEGER k,kUp,kDown - _RL phi_hyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) + _RL dPhiHydX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) + _RL dPhiHydY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) _RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) _RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) _RL fVerU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2) @@ -178,6 +179,14 @@ fMer(i,j) = 0. rTransU(i,j) = 0. rTransV(i,j) = 0. +#ifdef ALLOW_AUTODIFF_TAMC +C- jmc: this is wrong, but at least with #ifdef/endif TAMC, it does not break +C the forward code ; (same thing in mom_vectinv) + fVerU(i,j,1) = 0. _d 0 + fVerU(i,j,2) = 0. _d 0 + fVerV(i,j,1) = 0. _d 0 + fVerV(i,j,2) = 0. _d 0 +#endif ENDDO ENDDO @@ -292,7 +301,7 @@ C---- Zonal momentum equation starts here C Bi-harmonic term del^2 U -> v4F - IF (momViscosity) + IF (momViscosity .AND. viscA4.NE.0. ) & CALL MOM_U_DEL2U(bi,bj,k,uFld,hFacZ,v4f,myThid) C--- Calculate mean and eddy fluxes between cells for zonal flow. @@ -325,7 +334,7 @@ & CALL MOM_U_YVISCFLUX(bi,bj,k,uFld,v4F,hFacZ,vF,myThid) C Combine fluxes -> fMer - DO j=jMin,jMax + DO j=jMin,jMax+1 DO i=iMin,iMax fMer(i,j) = vDudyFac*aF(i,j) + AhDudyFac*vF(i,j) ENDDO @@ -348,16 +357,6 @@ ENDDO ENDDO -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 - C-- Tendency is minus divergence of the fluxes + coriolis + pressure term DO j=jMin,jMax DO i=iMin,iMax @@ -373,7 +372,7 @@ & +fMer(i,j+1) - fMer(i ,j) & +fVerU(i,j,kUp)*rkFac - fVerU(i,j,kDown)*rkFac & ) - & _PHM( +phxFac * pf(i,j) ) + & - phxFac*dPhiHydX(i,j) ENDDO ENDDO @@ -418,11 +417,11 @@ ENDDO ENDIF -C-- Forcing term - IF (momForcing) - & CALL EXTERNAL_FORCING_U( - I iMin,iMax,jMin,jMax,bi,bj,k, - I myTime,myThid) +C-- Forcing term (moved to timestep.F) +c IF (momForcing) +c & CALL EXTERNAL_FORCING_U( +c I iMin,iMax,jMin,jMax,bi,bj,k, +c I myTime,myThid) C-- Metric terms for curvilinear grid systems IF (useNHMTerms) THEN @@ -454,7 +453,7 @@ C---- Meridional momentum equation starts here C Bi-harmonic term del^2 V -> v4F - IF (momViscosity) + IF (momViscosity .AND. viscA4.NE.0. ) & CALL MOM_V_DEL2V(bi,bj,k,vFld,hFacZ,v4f,myThid) C--- Calculate mean and eddy fluxes between cells for meridional flow. @@ -471,7 +470,7 @@ C Combine fluxes -> fZon DO j=jMin,jMax - DO i=iMin,iMax + DO i=iMin,iMax+1 fZon(i,j) = uDvdxFac*aF(i,j) + AhDvdxFac*vF(i,j) ENDDO ENDDO @@ -510,16 +509,6 @@ ENDDO ENDDO -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 - C-- Tendency is minus divergence of the fluxes + coriolis + pressure term DO j=jMin,jMax DO i=iMin,iMax @@ -535,7 +524,7 @@ & +fMer(i,j ) - fMer(i,j-1) & +fVerV(i,j,kUp)*rkFac - fVerV(i,j,kDown)*rkFac & ) - & _PHM( +phyFac*pf(i,j) ) + & - phyFac*dPhiHydY(i,j) ENDDO ENDDO @@ -580,11 +569,11 @@ ENDDO ENDIF -C-- Forcing term - IF (momForcing) - & CALL EXTERNAL_FORCING_V( - I iMin,iMax,jMin,jMax,bi,bj,k, - I myTime,myThid) +C-- Forcing term (moved to timestep.F) +c IF (momForcing) +c & CALL EXTERNAL_FORCING_V( +c I iMin,iMax,jMin,jMax,bi,bj,k, +c I myTime,myThid) C-- Metric terms for curvilinear grid systems IF (useNHMTerms) THEN @@ -614,22 +603,24 @@ C-- Coriolis term C Note. As coded here, coriolis will not work with "thin walls" -#ifdef INCLUDE_CD_CODE - CALL MOM_CDSCHEME(bi,bj,k,phi_hyd,myThid) -#else - CALL MOM_U_CORIOLIS(bi,bj,k,vFld,cf,myThid) - DO j=jMin,jMax - DO i=iMin,iMax - gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j) - ENDDO - ENDDO - CALL MOM_V_CORIOLIS(bi,bj,k,uFld,cf,myThid) - DO j=jMin,jMax - DO i=iMin,iMax - gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j) - ENDDO - ENDDO -#endif /* INCLUDE_CD_CODE */ +c IF (useCDscheme) THEN +c CALL MOM_CDSCHEME(bi,bj,k,dPhiHydX,dPhiHydY,myThid) +c ELSE + IF (.NOT.useCDscheme) THEN + CALL MOM_U_CORIOLIS(bi,bj,k,vFld,cf,myThid) + DO j=jMin,jMax + DO i=iMin,iMax + gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j) + ENDDO + ENDDO + CALL MOM_V_CORIOLIS(bi,bj,k,uFld,cf,myThid) + DO j=jMin,jMax + DO i=iMin,iMax + gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j) + ENDDO + ENDDO + ENDIF + IF (nonHydrostatic.OR.quasiHydrostatic) THEN CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,cf,myThid) DO j=jMin,jMax