/[MITgcm]/MITgcm/pkg/mom_fluxform/mom_fluxform.F
ViewVC logotype

Diff of /MITgcm/pkg/mom_fluxform/mom_fluxform.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.31 by heimbach, Thu Dec 8 15:44:34 2005 UTC revision 1.50 by jmc, Wed Feb 12 00:45:56 2014 UTC
# Line 26  C stresses as well as internal viscous s Line 26  C stresses as well as internal viscous s
26  CEOI  CEOI
27    
28  #include "MOM_FLUXFORM_OPTIONS.h"  #include "MOM_FLUXFORM_OPTIONS.h"
29    #ifdef ALLOW_MOM_COMMON
30    # include "MOM_COMMON_OPTIONS.h"
31    #endif
32    
33  CBOP  CBOP
34  C !ROUTINE: MOM_FLUXFORM  C !ROUTINE: MOM_FLUXFORM
35    
36  C !INTERFACE: ==========================================================  C !INTERFACE: ==========================================================
37        SUBROUTINE MOM_FLUXFORM(        SUBROUTINE MOM_FLUXFORM(
38       I        bi,bj,iMin,iMax,jMin,jMax,k,kUp,kDown,       I        bi,bj,k,iMin,iMax,jMin,jMax,
39       I        KappaRU, KappaRV,       I        KappaRU, KappaRV,
40       U        fVerU, fVerV,       U        fVerUkm, fVerVkm,
41         O        fVerUkp, fVerVkp,
42       O        guDiss, gvDiss,       O        guDiss, gvDiss,
43       I        myTime, myIter, myThid)       I        myTime, myIter, myThid )
44    
45  C !DESCRIPTION:  C !DESCRIPTION:
46  C Calculates all the horizontal accelerations except for the implicit surface  C Calculates all the horizontal accelerations except for the implicit surface
47  C pressure gradient and implciit vertical viscosity.  C pressure gradient and implicit vertical viscosity.
48    
49  C !USES: ===============================================================  C !USES: ===============================================================
50  C     == Global variables ==  C     == Global variables ==
51        IMPLICIT NONE        IMPLICIT NONE
52  #include "SIZE.h"  #include "SIZE.h"
 #include "DYNVARS.h"  
 #include "FFIELDS.h"  
53  #include "EEPARAMS.h"  #include "EEPARAMS.h"
54  #include "PARAMS.h"  #include "PARAMS.h"
55  #include "GRID.h"  #include "GRID.h"
56    #include "DYNVARS.h"
57    #include "FFIELDS.h"
58  #include "SURFACE.h"  #include "SURFACE.h"
59    #ifdef ALLOW_MOM_COMMON
60    # include "MOM_VISC.h"
61    #endif
62    #ifdef ALLOW_AUTODIFF_TAMC
63    # include "tamc.h"
64    # include "tamc_keys.h"
65    # include "MOM_FLUXFORM.h"
66    #endif
67    
68  C !INPUT PARAMETERS: ===================================================  C !INPUT PARAMETERS: ===================================================
69  C  bi,bj                :: tile indices  C  bi,bj                :: current tile indices
70  C  iMin,iMax,jMin,jMAx  :: loop ranges  C  k                    :: current vertical level
71  C  k                    :: vertical level  C  iMin,iMax,jMin,jMax  :: loop ranges
 C  kUp                  :: =1 or 2 for consecutive k  
 C  kDown                :: =2 or 1 for consecutive k  
72  C  KappaRU              :: vertical viscosity  C  KappaRU              :: vertical viscosity
73  C  KappaRV              :: vertical viscosity  C  KappaRV              :: vertical viscosity
74  C  fVerU                :: vertical flux of U, 2 1/2 dim for pipe-lining  C  fVerUkm              :: vertical advective flux of U, interface above (k-1/2)
75  C  fVerV                :: vertical flux of V, 2 1/2 dim for pipe-lining  C  fVerVkm              :: vertical advective flux of V, interface above (k-1/2)
76    C  fVerUkp              :: vertical advective flux of U, interface below (k+1/2)
77    C  fVerVkp              :: vertical advective flux of V, interface below (k+1/2)
78  C  guDiss               :: dissipation tendency (all explicit terms), u component  C  guDiss               :: dissipation tendency (all explicit terms), u component
79  C  gvDiss               :: dissipation tendency (all explicit terms), v component  C  gvDiss               :: dissipation tendency (all explicit terms), v component
80  C  myTime               :: current time  C  myTime               :: current time
81  C  myIter               :: current time-step number  C  myIter               :: current time-step number
82  C  myThid               :: thread number  C  myThid               :: my Thread Id number
83        INTEGER bi,bj,iMin,iMax,jMin,jMax        INTEGER bi,bj,k
84        INTEGER k,kUp,kDown        INTEGER iMin,iMax,jMin,jMax
85        _RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)        _RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
86        _RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)        _RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
87        _RL fVerU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerUkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
88        _RL fVerV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)        _RL fVerVkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
89          _RL fVerUkp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
90          _RL fVerVkp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
91        _RL guDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL guDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
92        _RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
93        _RL     myTime        _RL     myTime
# Line 91  C  cF                   :: Coriolis acce Line 105  C  cF                   :: Coriolis acce
105  C  mT                   :: Metric terms  C  mT                   :: Metric terms
106  C  fZon                 :: zonal fluxes  C  fZon                 :: zonal fluxes
107  C  fMer                 :: meridional fluxes  C  fMer                 :: meridional fluxes
108  C  fVrUp,fVrDw          :: vertical viscous fluxes at interface k-1 & k  C  fVrUp,fVrDw          :: vertical viscous fluxes at interface k & k+1
109        INTEGER i,j        INTEGER i,j
110    #ifdef ALLOW_AUTODIFF_TAMC
111          INTEGER imomkey
112    #endif
113        _RL vF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL vF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
114        _RL v4F(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL v4F(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
115        _RL cF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL cF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
# Line 101  C  fVrUp,fVrDw          :: vertical visc Line 118  C  fVrUp,fVrDw          :: vertical visc
118        _RL fMer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL fMer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
119        _RL fVrUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL fVrUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
120        _RL fVrDw(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RL fVrDw(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
121  C     afFacMom      - Tracer parameters for turning terms  C     afFacMom     :: Tracer parameters for turning terms on and off.
122  C     vfFacMom        on and off.  C     vfFacMom
123  C     pfFacMom        afFacMom - Advective terms  C     pfFacMom        afFacMom - Advective terms
124  C     cfFacMom        vfFacMom - Eddy viscosity terms  C     cfFacMom        vfFacMom - Eddy viscosity terms
125  C     mTFacMom        pfFacMom - Pressure terms  C     mtFacMom        pfFacMom - Pressure terms
126  C                     cfFacMom - Coriolis terms  C                     cfFacMom - Coriolis terms
127  C                     foFacMom - Forcing  C                     foFacMom - Forcing
128  C                     mTFacMom - Metric term  C                     mtFacMom - Metric term
129  C     uDudxFac, AhDudxFac, etc ... individual term parameters for switching terms off  C     uDudxFac, AhDudxFac, etc ... individual term parameters for switching terms off
130        _RS    hFacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS    hFacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
131          _RS   h0FacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
132        _RS  r_hFacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS  r_hFacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
133        _RS      xA(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS      xA(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
134        _RS      yA(1-OLx:sNx+OLx,1-OLy:sNy+OLy)        _RS      yA(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
# Line 137  C     uDudxFac, AhDudxFac, etc ... indiv Line 155  C     uDudxFac, AhDudxFac, etc ... indiv
155        _RL  ArDudrFac        _RL  ArDudrFac
156        _RL  fuFac        _RL  fuFac
157        _RL  mtFacU        _RL  mtFacU
158          _RL  mtNHFacU
159        _RL  uDvdxFac        _RL  uDvdxFac
160        _RL  AhDvdxFac        _RL  AhDvdxFac
161        _RL  vDvdyFac        _RL  vDvdyFac
# Line 145  C     uDudxFac, AhDudxFac, etc ... indiv Line 164  C     uDudxFac, AhDudxFac, etc ... indiv
164        _RL  ArDvdrFac        _RL  ArDvdrFac
165        _RL  fvFac        _RL  fvFac
166        _RL  mtFacV        _RL  mtFacV
167          _RL  mtNHFacV
168        _RL  sideMaskFac        _RL  sideMaskFac
169        LOGICAL bottomDragTerms,harmonic,biharmonic,useVariableViscosity        LOGICAL bottomDragTerms
170  CEOP  CEOP
171    #ifdef MOM_BOUNDARY_CONSERVE
172          COMMON / MOM_FLUXFORM_LOCAL / uBnd, vBnd
173          _RL  uBnd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
174          _RL  vBnd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
175    #endif /* MOM_BOUNDARY_CONSERVE */
176    
177    #ifdef ALLOW_AUTODIFF_TAMC
178              act0 = k - 1
179              max0 = Nr
180              act1 = bi - myBxLo(myThid)
181              max1 = myBxHi(myThid) - myBxLo(myThid) + 1
182              act2 = bj - myByLo(myThid)
183              max2 = myByHi(myThid) - myByLo(myThid) + 1
184              act3 = myThid - 1
185              max3 = nTx*nTy
186              act4 = ikey_dynamics - 1
187              imomkey = (act0 + 1)
188         &                    + act1*max0
189         &                    + act2*max0*max1
190         &                    + act3*max0*max1*max2
191         &                    + act4*max0*max1*max2*max3
192    #endif /* ALLOW_AUTODIFF_TAMC */
193    
194  C     Initialise intermediate terms  C     Initialise intermediate terms
195        DO j=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
# Line 162  C     Initialise intermediate terms Line 204  C     Initialise intermediate terms
204          fVrDw(i,j)= 0.          fVrDw(i,j)= 0.
205          rTransU(i,j)= 0.          rTransU(i,j)= 0.
206          rTransV(i,j)= 0.          rTransV(i,j)= 0.
207    c       KE(i,j)     = 0.
208            hDiv(i,j)   = 0.
209            vort3(i,j)  = 0.
210          strain(i,j) = 0.          strain(i,j) = 0.
211          tension(i,j)= 0.          tension(i,j)= 0.
212          guDiss(i,j) = 0.          guDiss(i,j) = 0.
213          gvDiss(i,j) = 0.          gvDiss(i,j) = 0.
 #ifdef ALLOW_AUTODIFF_TAMC  
         vort3(i,j)   = 0. _d 0  
         strain(i,j)  = 0. _d 0  
         tension(i,j) = 0. _d 0  
 #endif  
214         ENDDO         ENDDO
215        ENDDO        ENDDO
216    
# Line 182  C     o U momentum equation Line 222  C     o U momentum equation
222        AhDudyFac    = vfFacMom*1.        AhDudyFac    = vfFacMom*1.
223        rVelDudrFac  = afFacMom*1.        rVelDudrFac  = afFacMom*1.
224        ArDudrFac    = vfFacMom*1.        ArDudrFac    = vfFacMom*1.
225        mTFacU       = mtFacMom*1.        mtFacU       = mtFacMom*1.
226          mtNHFacU     = 1.
227        fuFac        = cfFacMom*1.        fuFac        = cfFacMom*1.
228  C     o V momentum equation  C     o V momentum equation
229        uDvdxFac     = afFacMom*1.        uDvdxFac     = afFacMom*1.
# Line 191  C     o V momentum equation Line 232  C     o V momentum equation
232        AhDvdyFac    = vfFacMom*1.        AhDvdyFac    = vfFacMom*1.
233        rVelDvdrFac  = afFacMom*1.        rVelDvdrFac  = afFacMom*1.
234        ArDvdrFac    = vfFacMom*1.        ArDvdrFac    = vfFacMom*1.
235        mTFacV       = mtFacMom*1.        mtFacV       = mtFacMom*1.
236          mtNHFacV     = 1.
237        fvFac        = cfFacMom*1.        fvFac        = cfFacMom*1.
238    
239        IF (implicitViscosity) THEN        IF (implicitViscosity) THEN
# Line 216  C       vorticity at a no-slip boundary Line 258  C       vorticity at a no-slip boundary
258        ENDIF        ENDIF
259    
260  C--   Calculate open water fraction at vorticity points  C--   Calculate open water fraction at vorticity points
261        CALL MOM_CALC_HFACZ(bi,bj,k,hFacZ,r_hFacZ,myThid)        CALL MOM_CALC_HFACZ( bi,bj,k,hFacZ,r_hFacZ,myThid )
262    
263  C---- Calculate common quantities used in both U and V equations  C---- Calculate common quantities used in both U and V equations
264  C     Calculate tracer cell face open areas  C     Calculate tracer cell face open areas
265        DO j=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
266         DO i=1-OLx,sNx+OLx         DO i=1-OLx,sNx+OLx
267          xA(i,j) = _dyG(i,j,bi,bj)          xA(i,j) = _dyG(i,j,bi,bj)*deepFacC(k)
268       &   *drF(k)*_hFacW(i,j,k,bi,bj)       &          *drF(k)*_hFacW(i,j,k,bi,bj)
269          yA(i,j) = _dxG(i,j,bi,bj)          yA(i,j) = _dxG(i,j,bi,bj)*deepFacC(k)
270       &   *drF(k)*_hFacS(i,j,k,bi,bj)       &          *drF(k)*_hFacS(i,j,k,bi,bj)
271            h0FacZ(i,j) = hFacZ(i,j)
272         ENDDO         ENDDO
273        ENDDO        ENDDO
274    #ifdef NONLIN_FRSURF
275          IF ( momViscosity .AND. no_slip_sides
276         &                  .AND. nonlinFreeSurf.GT.0 ) THEN
277            DO j=2-OLy,sNy+OLy
278             DO i=2-OLx,sNx+OLx
279              h0FacZ(i,j) = MIN(
280         &       MIN( h0FacW(i,j,k,bi,bj), h0FacW(i,j-1,k,bi,bj) ),
281         &       MIN( h0FacS(i,j,k,bi,bj), h0FacS(i-1,j,k,bi,bj) ) )
282             ENDDO
283            ENDDO
284           ENDIF
285    #endif /* NONLIN_FRSURF */
286    
287  C     Make local copies of horizontal flow field  C     Make local copies of horizontal flow field
288        DO j=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
# Line 238  C     Make local copies of horizontal fl Line 293  C     Make local copies of horizontal fl
293        ENDDO        ENDDO
294    
295  C     Calculate velocity field "volume transports" through tracer cell faces.  C     Calculate velocity field "volume transports" through tracer cell faces.
296    C     anelastic: transports are scaled by rhoFacC (~ mass transport)
297        DO j=1-OLy,sNy+OLy        DO j=1-OLy,sNy+OLy
298         DO i=1-OLx,sNx+OLx         DO i=1-OLx,sNx+OLx
299          uTrans(i,j) = uFld(i,j)*xA(i,j)          uTrans(i,j) = uFld(i,j)*xA(i,j)*rhoFacC(k)
300          vTrans(i,j) = vFld(i,j)*yA(i,j)          vTrans(i,j) = vFld(i,j)*yA(i,j)*rhoFacC(k)
301         ENDDO         ENDDO
302        ENDDO        ENDDO
303    
304        CALL MOM_CALC_KE(bi,bj,k,2,uFld,vFld,KE,myThid)        CALL MOM_CALC_KE( bi,bj,k,2,uFld,vFld,KE,myThid )
305        IF ( momViscosity) THEN        IF ( useVariableVisc ) THEN
306          CALL MOM_CALC_HDIV(bi,bj,k,2,uFld,vFld,hDiv,myThid)          CALL MOM_CALC_HDIV( bi,bj,k,2,uFld,vFld,hDiv,myThid )
307          CALL MOM_CALC_RELVORT3(bi,bj,k,uFld,vFld,hFacZ,vort3,myThid)          CALL MOM_CALC_RELVORT3( bi,bj,k,uFld,vFld,hFacZ,vort3,myThid )
308          CALL MOM_CALC_TENSION(bi,bj,k,uFld,vFld,tension,myThid)          CALL MOM_CALC_TENSION( bi,bj,k,uFld,vFld,tension,myThid )
309          CALL MOM_CALC_STRAIN(bi,bj,k,uFld,vFld,hFacZ,strain,myThid)          CALL MOM_CALC_STRAIN( bi,bj,k,uFld,vFld,hFacZ,strain,myThid )
310          DO j=1-Oly,sNy+Oly          DO j=1-OLy,sNy+OLy
311           DO i=1-Olx,sNx+Olx           DO i=1-OLx,sNx+OLx
312             IF ( hFacZ(i,j).EQ.0. ) THEN             IF ( hFacZ(i,j).EQ.0. ) THEN
313               vort3(i,j)  = sideMaskFac*vort3(i,j)               vort3(i,j)  = sideMaskFac*vort3(i,j)
314               strain(i,j) = sideMaskFac*strain(i,j)               strain(i,j) = sideMaskFac*strain(i,j)
# Line 269  C     Calculate velocity field "volume t Line 325  C     Calculate velocity field "volume t
325  #endif  #endif
326        ENDIF        ENDIF
327    
328  C---  First call (k=1): compute vertical adv. flux fVerU(kUp) & fVerV(kUp)  C---  First call (k=1): compute vertical adv. flux fVerUkm & fVerVkm
329        IF (momAdvection.AND.k.EQ.1) THEN        IF (momAdvection.AND.k.EQ.1) THEN
330    
331    #ifdef MOM_BOUNDARY_CONSERVE
332            CALL MOM_UV_BOUNDARY( bi, bj, k,
333         I                        uVel, vVel,
334         O                        uBnd(1-OLx,1-OLy,k,bi,bj),
335         O                        vBnd(1-OLx,1-OLy,k,bi,bj),
336         I                        myTime, myIter, myThid )
337    #endif /* MOM_BOUNDARY_CONSERVE */
338    
339  C-    Calculate vertical transports above U & V points (West & South face):  C-    Calculate vertical transports above U & V points (West & South face):
340    
341    #ifdef ALLOW_AUTODIFF_TAMC
342    # ifdef NONLIN_FRSURF
343    #  ifndef DISABLE_RSTAR_CODE
344    CADJ STORE dwtransc(:,:,bi,bj) =
345    CADJ &     comlev1_bibj_k, key = imomkey, byte = isbyte
346    CADJ STORE dwtransu(:,:,bi,bj) =
347    CADJ &     comlev1_bibj_k, key = imomkey, byte = isbyte
348    CADJ STORE dwtransv(:,:,bi,bj) =
349    CADJ &     comlev1_bibj_k, key = imomkey, byte = isbyte
350    #  endif
351    # endif /* NONLIN_FRSURF */
352    #endif /* ALLOW_AUTODIFF_TAMC */
353          CALL MOM_CALC_RTRANS( k, bi, bj,          CALL MOM_CALC_RTRANS( k, bi, bj,
354       O                        rTransU, rTransV,       O                        rTransU, rTransV,
355       I                        myTime, myIter, myThid)       I                        myTime, myIter, myThid )
356    
357  C-    Free surface correction term (flux at k=1)  C-    Free surface correction term (flux at k=1)
358          CALL MOM_U_ADV_WU( bi,bj,k,uVel,wVel,rTransU,          CALL MOM_U_ADV_WU( bi,bj,k,uVel,wVel,rTransU,
359       O                     fVerU(1-OLx,1-OLy,kUp), myThid )       O                     fVerUkm, myThid )
360    
361          CALL MOM_V_ADV_WV( bi,bj,k,vVel,wVel,rTransV,          CALL MOM_V_ADV_WV( bi,bj,k,vVel,wVel,rTransV,
362       O                     fVerV(1-OLx,1-OLy,kUp), myThid )       O                     fVerVkm, myThid )
363    
364  C---  endif momAdvection & k=1  C---  endif momAdvection & k=1
365        ENDIF        ENDIF
366    
   
367  C---  Calculate vertical transports (at k+1) below U & V points :  C---  Calculate vertical transports (at k+1) below U & V points :
368        IF (momAdvection) THEN        IF (momAdvection) THEN
369          CALL MOM_CALC_RTRANS( k+1, bi, bj,          CALL MOM_CALC_RTRANS( k+1, bi, bj,
370       O                        rTransU, rTransV,       O                        rTransU, rTransV,
371       I                        myTime, myIter, myThid)       I                        myTime, myIter, myThid )
372          ENDIF
373    
374    #ifdef MOM_BOUNDARY_CONSERVE
375          IF ( momAdvection .AND. k.LT.Nr ) THEN
376            CALL MOM_UV_BOUNDARY( bi, bj, k+1,
377         I                        uVel, vVel,
378         O                        uBnd(1-OLx,1-OLy,k+1,bi,bj),
379         O                        vBnd(1-OLx,1-OLy,k+1,bi,bj),
380         I                        myTime, myIter, myThid )
381        ENDIF        ENDIF
382    #endif /* MOM_BOUNDARY_CONSERVE */
383    
384        IF (momViscosity) THEN        IF (momViscosity) THEN
385         CALL MOM_CALC_VISC(         DO j=1-OLy,sNy+OLy
386       I        bi,bj,k,          DO i=1-OLx,sNx+OLx
387       O        viscAh_Z,viscAh_D,viscA4_Z,viscA4_D,           viscAh_D(i,j) = viscAhD
388       O        harmonic,biharmonic,useVariableViscosity,           viscAh_Z(i,j) = viscAhZ
389       I        hDiv,vort3,tension,strain,KE,hFacZ,           viscA4_D(i,j) = viscA4D
390       I        myThid)           viscA4_Z(i,j) = viscA4Z
391            ENDDO
392           ENDDO
393           IF ( useVariableVisc ) THEN
394            CALL MOM_CALC_VISC( bi, bj, k,
395         O           viscAh_Z, viscAh_D, viscA4_Z, viscA4_D,
396         I           hDiv, vort3, tension, strain, KE, hFacZ,
397         I           myThid )
398           ENDIF
399        ENDIF        ENDIF
400    
401  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
# Line 311  C---- Zonal momentum equation starts her Line 405  C---- Zonal momentum equation starts her
405        IF (momAdvection) THEN        IF (momAdvection) THEN
406  C---  Calculate mean fluxes (advection)   between cells for zonal flow.  C---  Calculate mean fluxes (advection)   between cells for zonal flow.
407    
408    #ifdef MOM_BOUNDARY_CONSERVE
409            CALL MOM_U_ADV_UU( bi,bj,k,uTrans,uBnd(1-OLx,1-OLy,k,bi,bj),
410         O                     fZon,myThid )
411            CALL MOM_U_ADV_VU( bi,bj,k,vTrans,uBnd(1-OLx,1-OLy,k,bi,bj),
412         O                     fMer,myThid )
413            CALL MOM_U_ADV_WU(
414         I                     bi,bj,k+1,uBnd,wVel,rTransU,
415         O                     fVerUkp, myThid )
416    #else /* MOM_BOUNDARY_CONSERVE */
417  C--   Zonal flux (fZon is at east face of "u" cell)  C--   Zonal flux (fZon is at east face of "u" cell)
418  C     Mean flow component of zonal flux -> fZon  C     Mean flow component of zonal flux -> fZon
419          CALL MOM_U_ADV_UU(bi,bj,k,uTrans,uFld,fZon,myThid)          CALL MOM_U_ADV_UU( bi,bj,k,uTrans,uFld,fZon,myThid )
420    
421  C--   Meridional flux (fMer is at south face of "u" cell)  C--   Meridional flux (fMer is at south face of "u" cell)
422  C     Mean flow component of meridional flux -> fMer  C     Mean flow component of meridional flux -> fMer
423          CALL MOM_U_ADV_VU(bi,bj,k,vTrans,uFld,fMer,myThid)          CALL MOM_U_ADV_VU( bi,bj,k,vTrans,uFld,fMer,myThid )
424    
425  C--   Vertical flux (fVer is at upper face of "u" cell)  C--   Vertical flux (fVer is at upper face of "u" cell)
426  C     Mean flow component of vertical flux (at k+1) -> fVer  C     Mean flow component of vertical flux (at k+1) -> fVer
427          CALL MOM_U_ADV_WU(          CALL MOM_U_ADV_WU(
428       I                     bi,bj,k+1,uVel,wVel,rTransU,       I                     bi,bj,k+1,uVel,wVel,rTransU,
429       O                     fVerU(1-OLx,1-OLy,kDown), myThid )       O                     fVerUkp, myThid )
430    #endif /* MOM_BOUNDARY_CONSERVE */
431    
432  C--   Tendency is minus divergence of the fluxes + coriolis + pressure term  C--   Tendency is minus divergence of the fluxes + coriolis + pressure term
433          DO j=jMin,jMax          DO j=jMin,jMax
# Line 334  C--   Tendency is minus divergence of th Line 438  C--   Tendency is minus divergence of th
438       &      ( 0.5 _d 0*(rA(i,j,bi,bj)+rA(i-1,j,bi,bj)) )       &      ( 0.5 _d 0*(rA(i,j,bi,bj)+rA(i-1,j,bi,bj)) )
439  #else  #else
440       &     -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)       &     -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)
441       &     *recip_rAw(i,j,bi,bj)       &     *recip_rAw(i,j,bi,bj)*recip_deepFac2C(k)*recip_rhoFacC(k)
442  #endif  #endif
443       &    *( ( fZon(i,j  )     - fZon(i-1,j) )*uDudxFac       &     *( ( fZon(i,j  )  - fZon(i-1,j)  )*uDudxFac
444       &      +( fMer(i,j+1)     - fMer(i,  j) )*vDudyFac       &       +( fMer(i,j+1)  - fMer(i,  j)  )*vDudyFac
445       &      +(fVerU(i,j,kDown) - fVerU(i,j,kUp))*rkSign*rVelDudrFac       &       +( fVerUkp(i,j) - fVerUkm(i,j) )*rkSign*rVelDudrFac
446       &     )       &     )
447           ENDDO           ENDDO
448          ENDDO          ENDDO
449    
450  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
451          IF ( useDiagnostics ) THEN          IF ( useDiagnostics ) THEN
452            CALL DIAGNOSTICS_FILL(fZon,'ADVx_Um ',k,1,2,bi,bj,myThid)            CALL DIAGNOSTICS_FILL( fZon,  'ADVx_Um ',k,1,2,bi,bj,myThid)
453            CALL DIAGNOSTICS_FILL(fMer,'ADVy_Um ',k,1,2,bi,bj,myThid)            CALL DIAGNOSTICS_FILL( fMer,  'ADVy_Um ',k,1,2,bi,bj,myThid)
454            CALL DIAGNOSTICS_FILL(fVerU(1-Olx,1-Oly,kUp),            CALL DIAGNOSTICS_FILL(fVerUkm,'ADVrE_Um',k,1,2,bi,bj,myThid)
      &                               'ADVrE_Um',k,1,2,bi,bj,myThid)  
455          ENDIF          ENDIF
456  #endif  #endif
457    
# Line 375  C-- account for 3.D divergence of the fl Line 478  C-- account for 3.D divergence of the fl
478  # endif /* DISABLE_RSTAR_CODE */  # endif /* DISABLE_RSTAR_CODE */
479  #endif /* NONLIN_FRSURF */  #endif /* NONLIN_FRSURF */
480    
481    #ifdef ALLOW_ADDFLUID
482            IF ( selectAddFluid.GE.1 ) THEN
483             DO j=jMin,jMax
484              DO i=iMin,iMax
485               gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)
486         &     + uVel(i,j,k,bi,bj)*mass2rUnit*0.5 _d 0
487         &      *( addMass(i-1,j,k,bi,bj) + addMass(i,j,k,bi,bj) )
488         &      *_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)*recip_rhoFacC(k)
489         &      * recip_rAw(i,j,bi,bj)*recip_deepFac2C(k)
490              ENDDO
491             ENDDO
492            ENDIF
493    #endif /* ALLOW_ADDFLUID */
494    
495        ELSE        ELSE
496  C-    if momAdvection / else  C-    if momAdvection / else
497          DO j=1-OLy,sNy+OLy          DO j=1-OLy,sNy+OLy
# Line 390  C-    endif momAdvection. Line 507  C-    endif momAdvection.
507  C---  Calculate eddy fluxes (dissipation) between cells for zonal flow.  C---  Calculate eddy fluxes (dissipation) between cells for zonal flow.
508    
509  C     Bi-harmonic term del^2 U -> v4F  C     Bi-harmonic term del^2 U -> v4F
510          IF (biharmonic)          IF ( useBiharmonicVisc )
511       &  CALL MOM_U_DEL2U(bi,bj,k,uFld,hFacZ,v4f,myThid)       &  CALL MOM_U_DEL2U( bi, bj, k, uFld, hFacZ, h0FacZ,
512         O                    v4f, myThid )
513    
514  C     Laplacian and bi-harmonic terms, Zonal  Fluxes -> fZon  C     Laplacian and bi-harmonic terms, Zonal  Fluxes -> fZon
515          CALL MOM_U_XVISCFLUX(bi,bj,k,uFld,v4F,fZon,          CALL MOM_U_XVISCFLUX( bi,bj,k,uFld,v4F,fZon,
516       I    viscAh_D,viscA4_D,myThid)       I                        viscAh_D,viscA4_D,myThid )
517    
518  C     Laplacian and bi-harmonic termis, Merid Fluxes -> fMer  C     Laplacian and bi-harmonic termis, Merid Fluxes -> fMer
519          CALL MOM_U_YVISCFLUX(bi,bj,k,uFld,v4F,hFacZ,fMer,          CALL MOM_U_YVISCFLUX( bi,bj,k,uFld,v4F,hFacZ,fMer,
520       I    viscAh_Z,viscA4_Z,myThid)       I                        viscAh_Z,viscA4_Z,myThid )
521    
522  C     Eddy component of vertical flux (interior component only) -> fVrUp & fVrDw  C     Eddy component of vertical flux (interior component only) -> fVrUp & fVrDw
523         IF (.NOT.implicitViscosity) THEN         IF (.NOT.implicitViscosity) THEN
524          CALL MOM_U_RVISCFLUX(bi,bj, k, uVel,KappaRU,fVrUp,myThid)          CALL MOM_U_RVISCFLUX( bi,bj, k, uVel,KappaRU,fVrUp,myThid )
525          CALL MOM_U_RVISCFLUX(bi,bj,k+1,uVel,KappaRU,fVrDw,myThid)          CALL MOM_U_RVISCFLUX( bi,bj,k+1,uVel,KappaRU,fVrDw,myThid )
526         ENDIF         ENDIF
527    
528  C--   Tendency is minus divergence of the fluxes  C--   Tendency is minus divergence of the fluxes
529    C     anelastic: hor.visc.fluxes are not scaled by rhoFac (by vert.visc.flx is)
530          DO j=jMin,jMax          DO j=jMin,jMax
531           DO i=iMin,iMax           DO i=iMin,iMax
532            guDiss(i,j) =            guDiss(i,j) =
# Line 416  C--   Tendency is minus divergence of th Line 535  C--   Tendency is minus divergence of th
535       &      ( 0.5 _d 0*(rA(i,j,bi,bj)+rA(i-1,j,bi,bj)) )       &      ( 0.5 _d 0*(rA(i,j,bi,bj)+rA(i-1,j,bi,bj)) )
536  #else  #else
537       &     -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)       &     -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)
538       &     *recip_rAw(i,j,bi,bj)       &     *recip_rAw(i,j,bi,bj)*recip_deepFac2C(k)
539  #endif  #endif
540       &    *( ( fZon(i,j  ) - fZon(i-1,j) )*AhDudxFac       &     *( ( fZon(i,j  ) - fZon(i-1,j) )*AhDudxFac
541       &      +( fMer(i,j+1) - fMer(i,  j) )*AhDudyFac       &       +( fMer(i,j+1) - fMer(i,  j) )*AhDudyFac
542       &      +( fVrDw(i,j)  - fVrUp(i,j) )*rkSign*ArDudrFac       &       +( fVrDw(i,j)  - fVrUp(i,j)  )*rkSign*ArDudrFac
543         &                                     *recip_rhoFacC(k)
544       &     )       &     )
545           ENDDO           ENDDO
546          ENDDO          ENDDO
# Line 434  C--   Tendency is minus divergence of th Line 554  C--   Tendency is minus divergence of th
554          ENDIF          ENDIF
555  #endif  #endif
556    
557  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
558          IF (no_slip_sides) THEN          IF (no_slip_sides) THEN
559  C-     No-slip BCs impose a drag at walls...  C-     No-slip BCs impose a drag at walls...
560           CALL MOM_U_SIDEDRAG(           CALL MOM_U_SIDEDRAG( bi, bj, k,
561       I        bi,bj,k,       I        uFld, v4f, h0FacZ,
562       I        uFld, v4f, hFacZ,       I        viscAh_Z, viscA4_Z,
563       I        viscAh_Z,viscA4_Z,       I        useHarmonicVisc, useBiharmonicVisc, useVariableVisc,
      I        harmonic,biharmonic,useVariableViscosity,  
564       O        vF,       O        vF,
565       I        myThid)       I        myThid )
566           DO j=jMin,jMax           DO j=jMin,jMax
567            DO i=iMin,iMax            DO i=iMin,iMax
568             gUdiss(i,j) = gUdiss(i,j) + vF(i,j)             gUdiss(i,j) = gUdiss(i,j) + vF(i,j)
# Line 452  C-     No-slip BCs impose a drag at wall Line 571  C-     No-slip BCs impose a drag at wall
571          ENDIF          ENDIF
572  C-    No-slip BCs impose a drag at bottom  C-    No-slip BCs impose a drag at bottom
573          IF (bottomDragTerms) THEN          IF (bottomDragTerms) THEN
574           CALL MOM_U_BOTTOMDRAG(bi,bj,k,uFld,KE,KappaRU,vF,myThid)           CALL MOM_U_BOTTOMDRAG( bi,bj,k,uFld,KE,KappaRU,vF,myThid )
575             DO j=jMin,jMax
576              DO i=iMin,iMax
577               gUdiss(i,j) = gUdiss(i,j) + vF(i,j)
578              ENDDO
579             ENDDO
580            ENDIF
581    
582    #ifdef ALLOW_SHELFICE
583            IF (useShelfIce) THEN
584             CALL SHELFICE_U_DRAG( bi,bj,k,uFld,KE,KappaRU,vF,myThid )
585           DO j=jMin,jMax           DO j=jMin,jMax
586            DO i=iMin,iMax            DO i=iMin,iMax
587             gUdiss(i,j) = gUdiss(i,j) + vF(i,j)             gUdiss(i,j) = gUdiss(i,j) + vF(i,j)
588            ENDDO            ENDDO
589           ENDDO           ENDDO
590          ENDIF          ENDIF
591    #endif /* ALLOW_SHELFICE */
592    
593  C-    endif momViscosity  C-    endif momViscosity
594        ENDIF        ENDIF
# Line 471  c    I     myTime,myThid) Line 601  c    I     myTime,myThid)
601    
602  C--   Metric terms for curvilinear grid systems  C--   Metric terms for curvilinear grid systems
603        IF (useNHMTerms) THEN        IF (useNHMTerms) THEN
604  C      o Non-hydrosatic metric terms  C      o Non-Hydrostatic (spherical) metric terms
605         CALL MOM_U_METRIC_NH(bi,bj,k,uFld,wVel,mT,myThid)         CALL MOM_U_METRIC_NH( bi,bj,k,uFld,wVel,mT,myThid )
606         DO j=jMin,jMax         DO j=jMin,jMax
607          DO i=iMin,iMax          DO i=iMin,iMax
608           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)+mtNHFacU*mT(i,j)
609          ENDDO          ENDDO
610         ENDDO         ENDDO
611        ENDIF        ENDIF
612        IF (usingSphericalPolarMTerms) THEN        IF ( usingSphericalPolarGrid .AND. metricTerms ) THEN
613         CALL MOM_U_METRIC_SPHERE(bi,bj,k,uFld,vFld,mT,myThid)  C      o Spherical polar grid metric terms
614           CALL MOM_U_METRIC_SPHERE( bi,bj,k,uFld,vFld,mT,myThid )
615         DO j=jMin,jMax         DO j=jMin,jMax
616          DO i=iMin,iMax          DO i=iMin,iMax
617           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)
618          ENDDO          ENDDO
619         ENDDO         ENDDO
620        ENDIF        ENDIF
621        IF (usingCylindricalGrid) THEN        IF ( usingCylindricalGrid .AND. metricTerms ) THEN
622           CALL MOM_U_METRIC_CYLINDER(bi,bj,k,uFld,vFld,mT,myThid)  C      o Cylindrical grid metric terms
623           DO j=jMin,jMax         CALL MOM_U_METRIC_CYLINDER( bi,bj,k,uFld,vFld,mT,myThid )
624            DO i=iMin,iMax         DO j=jMin,jMax
625               gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mTFacU*mT(i,j)          DO i=iMin,iMax
626            ENDDO           gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mtFacU*mT(i,j)
627            ENDDO
628         ENDDO         ENDDO
629        ENDIF        ENDIF
630    
# Line 501  C---+----1----+----2----+----3----+----4 Line 633  C---+----1----+----2----+----3----+----4
633  C---- Meridional momentum equation starts here  C---- Meridional momentum equation starts here
634    
635        IF (momAdvection) THEN        IF (momAdvection) THEN
636    
637    #ifdef MOM_BOUNDARY_CONSERVE
638            CALL MOM_V_ADV_UV( bi,bj,k,uTrans,vBnd(1-OLx,1-OLy,k,bi,bj),
639         O                     fZon,myThid )
640            CALL MOM_V_ADV_VV( bi,bj,k,vTrans,vBnd(1-OLx,1-OLy,k,bi,bj),
641         O                     fMer,myThid )
642            CALL MOM_V_ADV_WV( bi,bj,k+1,vBnd,wVel,rTransV,
643         O                     fVerVkp, myThid )
644    #else /* MOM_BOUNDARY_CONSERVE */
645  C---  Calculate mean fluxes (advection)   between cells for meridional flow.  C---  Calculate mean fluxes (advection)   between cells for meridional flow.
646  C     Mean flow component of zonal flux -> fZon  C     Mean flow component of zonal flux -> fZon
647          CALL MOM_V_ADV_UV(bi,bj,k,uTrans,vFld,fZon,myThid)          CALL MOM_V_ADV_UV( bi,bj,k,uTrans,vFld,fZon,myThid )
648    
649  C--   Meridional flux (fMer is at north face of "v" cell)  C--   Meridional flux (fMer is at north face of "v" cell)
650  C     Mean flow component of meridional flux -> fMer  C     Mean flow component of meridional flux -> fMer
651          CALL MOM_V_ADV_VV(bi,bj,k,vTrans,vFld,fMer,myThid)          CALL MOM_V_ADV_VV( bi,bj,k,vTrans,vFld,fMer,myThid )
652    
653  C--   Vertical flux (fVer is at upper face of "v" cell)  C--   Vertical flux (fVer is at upper face of "v" cell)
654  C     Mean flow component of vertical flux (at k+1) -> fVerV  C     Mean flow component of vertical flux (at k+1) -> fVerV
655          CALL MOM_V_ADV_WV(          CALL MOM_V_ADV_WV( bi,bj,k+1,vVel,wVel,rTransV,
656       I                     bi,bj,k+1,vVel,wVel,rTransV,       O                     fVerVkp, myThid )
657       O                     fVerV(1-OLx,1-OLy,kDown), myThid )  #endif /* MOM_BOUNDARY_CONSERVE */
658    
659  C--   Tendency is minus divergence of the fluxes + coriolis + pressure term  C--   Tendency is minus divergence of the fluxes + coriolis + pressure term
660          DO j=jMin,jMax          DO j=jMin,jMax
# Line 524  C--   Tendency is minus divergence of th Line 665  C--   Tendency is minus divergence of th
665       &      ( 0.5 _d 0*(_rA(i,j,bi,bj)+_rA(i,j-1,bi,bj)) )       &      ( 0.5 _d 0*(_rA(i,j,bi,bj)+_rA(i,j-1,bi,bj)) )
666  #else  #else
667       &     -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)       &     -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)
668       &      *recip_rAs(i,j,bi,bj)       &     *recip_rAs(i,j,bi,bj)*recip_deepFac2C(k)*recip_rhoFacC(k)
669  #endif  #endif
670       &    *( ( fZon(i+1,j)     - fZon(i,j  ) )*uDvdxFac       &     *( ( fZon(i+1,j)  - fZon(i,j  )  )*uDvdxFac
671       &      +( fMer(i,  j)     - fMer(i,j-1) )*vDvdyFac       &       +( fMer(i,  j)  - fMer(i,j-1)  )*vDvdyFac
672       &      +(fVerV(i,j,kDown) - fVerV(i,j,kUp))*rkSign*rVelDvdrFac       &       +( fVerVkp(i,j) - fVerVkm(i,j) )*rkSign*rVelDvdrFac
673       &     )       &     )
674           ENDDO           ENDDO
675          ENDDO          ENDDO
676    
677  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
678          IF ( useDiagnostics ) THEN          IF ( useDiagnostics ) THEN
679            CALL DIAGNOSTICS_FILL(fZon,'ADVx_Vm ',k,1,2,bi,bj,myThid)            CALL DIAGNOSTICS_FILL( fZon,  'ADVx_Vm ',k,1,2,bi,bj,myThid)
680            CALL DIAGNOSTICS_FILL(fMer,'ADVy_Vm ',k,1,2,bi,bj,myThid)            CALL DIAGNOSTICS_FILL( fMer,  'ADVy_Vm ',k,1,2,bi,bj,myThid)
681            CALL DIAGNOSTICS_FILL(fVerV(1-Olx,1-Oly,kUp),            CALL DIAGNOSTICS_FILL(fVerVkm,'ADVrE_Vm',k,1,2,bi,bj,myThid)
      &                               'ADVrE_Vm',k,1,2,bi,bj,myThid)  
682          ENDIF          ENDIF
683  #endif  #endif
684    
# Line 565  C-- account for 3.D divergence of the fl Line 705  C-- account for 3.D divergence of the fl
705  # endif /* DISABLE_RSTAR_CODE */  # endif /* DISABLE_RSTAR_CODE */
706  #endif /* NONLIN_FRSURF */  #endif /* NONLIN_FRSURF */
707    
708    #ifdef ALLOW_ADDFLUID
709            IF ( selectAddFluid.GE.1 ) THEN
710             DO j=jMin,jMax
711              DO i=iMin,iMax
712               gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)
713         &     + vVel(i,j,k,bi,bj)*mass2rUnit*0.5 _d 0
714         &      *( addMass(i,j-1,k,bi,bj) + addMass(i,j,k,bi,bj) )
715         &      *_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)*recip_rhoFacC(k)
716         &      * recip_rAs(i,j,bi,bj)*recip_deepFac2C(k)
717              ENDDO
718             ENDDO
719            ENDIF
720    #endif /* ALLOW_ADDFLUID */
721    
722        ELSE        ELSE
723  C-    if momAdvection / else  C-    if momAdvection / else
724          DO j=1-OLy,sNy+OLy          DO j=1-OLy,sNy+OLy
# Line 579  C-    endif momAdvection. Line 733  C-    endif momAdvection.
733        IF (momViscosity) THEN        IF (momViscosity) THEN
734  C---  Calculate eddy fluxes (dissipation) between cells for meridional flow.  C---  Calculate eddy fluxes (dissipation) between cells for meridional flow.
735  C     Bi-harmonic term del^2 V -> v4F  C     Bi-harmonic term del^2 V -> v4F
736          IF (biharmonic)          IF ( useBiharmonicVisc )
737       &  CALL MOM_V_DEL2V(bi,bj,k,vFld,hFacZ,v4f,myThid)       &  CALL MOM_V_DEL2V( bi, bj, k, vFld, hFacZ, h0FacZ,
738         O                    v4f, myThid )
739    
740  C     Laplacian and bi-harmonic terms, Zonal  Fluxes -> fZon  C     Laplacian and bi-harmonic terms, Zonal  Fluxes -> fZon
741          CALL MOM_V_XVISCFLUX(bi,bj,k,vFld,v4f,hFacZ,fZon,          CALL MOM_V_XVISCFLUX( bi,bj,k,vFld,v4f,hFacZ,fZon,
742       I    viscAh_Z,viscA4_Z,myThid)       I                        viscAh_Z,viscA4_Z,myThid )
743    
744  C     Laplacian and bi-harmonic termis, Merid Fluxes -> fMer  C     Laplacian and bi-harmonic termis, Merid Fluxes -> fMer
745          CALL MOM_V_YVISCFLUX(bi,bj,k,vFld,v4f,fMer,          CALL MOM_V_YVISCFLUX( bi,bj,k,vFld,v4f,fMer,
746       I    viscAh_D,viscA4_D,myThid)       I                        viscAh_D,viscA4_D,myThid )
747    
748  C     Eddy component of vertical flux (interior component only) -> fVrUp & fVrDw  C     Eddy component of vertical flux (interior component only) -> fVrUp & fVrDw
749         IF (.NOT.implicitViscosity) THEN         IF (.NOT.implicitViscosity) THEN
750          CALL MOM_V_RVISCFLUX(bi,bj, k, vVel,KappaRV,fVrUp,myThid)          CALL MOM_V_RVISCFLUX( bi,bj, k, vVel,KappaRV,fVrUp,myThid )
751          CALL MOM_V_RVISCFLUX(bi,bj,k+1,vVel,KappaRV,fVrDw,myThid)          CALL MOM_V_RVISCFLUX( bi,bj,k+1,vVel,KappaRV,fVrDw,myThid )
752         ENDIF         ENDIF
753    
754  C--   Tendency is minus divergence of the fluxes + coriolis + pressure term  C--   Tendency is minus divergence of the fluxes + coriolis + pressure term
755    C     anelastic: hor.visc.fluxes are not scaled by rhoFac (by vert.visc.flx is)
756          DO j=jMin,jMax          DO j=jMin,jMax
757           DO i=iMin,iMax           DO i=iMin,iMax
758            gvDiss(i,j) =            gvDiss(i,j) =
# Line 605  C--   Tendency is minus divergence of th Line 761  C--   Tendency is minus divergence of th
761       &      ( 0.5 _d 0*(_rA(i,j,bi,bj)+_rA(i,j-1,bi,bj)) )       &      ( 0.5 _d 0*(_rA(i,j,bi,bj)+_rA(i,j-1,bi,bj)) )
762  #else  #else
763       &     -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)       &     -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)
764       &      *recip_rAs(i,j,bi,bj)       &      *recip_rAs(i,j,bi,bj)*recip_deepFac2C(k)
765  #endif  #endif
766       &    *( ( fZon(i+1,j)  - fZon(i,j  ) )*AhDvdxFac       &     *( ( fZon(i+1,j)  - fZon(i,j  ) )*AhDvdxFac
767       &      +( fMer(i,  j)  - fMer(i,j-1) )*AhDvdyFac       &       +( fMer(i,  j)  - fMer(i,j-1) )*AhDvdyFac
768       &      +( fVrDw(i,j)   - fVrUp(i,j) )*rkSign*ArDvdrFac       &       +( fVrDw(i,j)   - fVrUp(i,j) )*rkSign*ArDvdrFac
769         &                                     *recip_rhoFacC(k)
770       &     )       &     )
771           ENDDO           ENDDO
772          ENDDO          ENDDO
# Line 623  C--   Tendency is minus divergence of th Line 780  C--   Tendency is minus divergence of th
780          ENDIF          ENDIF
781  #endif  #endif
782    
783  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
784        IF (no_slip_sides) THEN          IF (no_slip_sides) THEN
785  C-     No-slip BCs impose a drag at walls...  C-     No-slip BCs impose a drag at walls...
786           CALL MOM_V_SIDEDRAG(           CALL MOM_V_SIDEDRAG( bi, bj, k,
787       I        bi,bj,k,       I        vFld, v4f, h0FacZ,
788       I        vFld, v4f, hFacZ,       I        viscAh_Z, viscA4_Z,
789       I        viscAh_Z,viscA4_Z,       I        useHarmonicVisc, useBiharmonicVisc, useVariableVisc,
      I        harmonic,biharmonic,useVariableViscosity,  
790       O        vF,       O        vF,
791       I        myThid)       I        myThid )
792           DO j=jMin,jMax           DO j=jMin,jMax
793            DO i=iMin,iMax            DO i=iMin,iMax
794             gvDiss(i,j) = gvDiss(i,j) + vF(i,j)             gvDiss(i,j) = gvDiss(i,j) + vF(i,j)
# Line 641  C-     No-slip BCs impose a drag at wall Line 797  C-     No-slip BCs impose a drag at wall
797          ENDIF          ENDIF
798  C-    No-slip BCs impose a drag at bottom  C-    No-slip BCs impose a drag at bottom
799          IF (bottomDragTerms) THEN          IF (bottomDragTerms) THEN
800           CALL MOM_V_BOTTOMDRAG(bi,bj,k,vFld,KE,KappaRV,vF,myThid)           CALL MOM_V_BOTTOMDRAG( bi,bj,k,vFld,KE,KappaRV,vF,myThid )
801             DO j=jMin,jMax
802              DO i=iMin,iMax
803               gvDiss(i,j) = gvDiss(i,j) + vF(i,j)
804              ENDDO
805             ENDDO
806            ENDIF
807    
808    #ifdef ALLOW_SHELFICE
809            IF (useShelfIce) THEN
810             CALL SHELFICE_V_DRAG( bi,bj,k,vFld,KE,KappaRV,vF,myThid )
811           DO j=jMin,jMax           DO j=jMin,jMax
812            DO i=iMin,iMax            DO i=iMin,iMax
813             gvDiss(i,j) = gvDiss(i,j) + vF(i,j)             gvDiss(i,j) = gvDiss(i,j) + vF(i,j)
814            ENDDO            ENDDO
815           ENDDO           ENDDO
816          ENDIF          ENDIF
817    #endif /* ALLOW_SHELFICE */
818    
819  C-    endif momViscosity  C-    endif momViscosity
820        ENDIF        ENDIF
# Line 660  c    I     myTime,myThid) Line 827  c    I     myTime,myThid)
827    
828  C--   Metric terms for curvilinear grid systems  C--   Metric terms for curvilinear grid systems
829        IF (useNHMTerms) THEN        IF (useNHMTerms) THEN
830  C      o Spherical polar grid metric terms  C      o Non-Hydrostatic (spherical) metric terms
831         CALL MOM_V_METRIC_NH(bi,bj,k,vFld,wVel,mT,myThid)         CALL MOM_V_METRIC_NH( bi,bj,k,vFld,wVel,mT,myThid )
832         DO j=jMin,jMax         DO j=jMin,jMax
833          DO i=iMin,iMax          DO i=iMin,iMax
834           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)+mtNHFacV*mT(i,j)
835          ENDDO          ENDDO
836         ENDDO         ENDDO
837        ENDIF        ENDIF
838        IF (usingSphericalPolarMTerms) THEN        IF ( usingSphericalPolarGrid .AND. metricTerms ) THEN
839         CALL MOM_V_METRIC_SPHERE(bi,bj,k,uFld,mT,myThid)  C      o Spherical polar grid metric terms
840           CALL MOM_V_METRIC_SPHERE( bi,bj,k,uFld,mT,myThid )
841         DO j=jMin,jMax         DO j=jMin,jMax
842          DO i=iMin,iMax          DO i=iMin,iMax
843           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)
844          ENDDO          ENDDO
845         ENDDO         ENDDO
846        ENDIF        ENDIF
847        IF (usingCylindricalGrid) THEN        IF ( usingCylindricalGrid .AND. metricTerms ) THEN
848           CALL MOM_V_METRIC_CYLINDER(bi,bj,k,uFld,vFld,mT,myThid)  C      o Cylindrical grid metric terms
849           DO j=jMin,jMax         CALL MOM_V_METRIC_CYLINDER( bi,bj,k,uFld,vFld,mT,myThid )
850              DO i=iMin,iMax         DO j=jMin,jMax
851                 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mTFacV*mT(i,j)          DO i=iMin,iMax
852              ENDDO           gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mtFacV*mT(i,j)
853           ENDDO          ENDDO
854           ENDDO
855        ENDIF        ENDIF
856    
857  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
858    
859  C--   Coriolis term  C--   Coriolis term (call to CD_CODE_SCHEME has been moved to timestep.F)
 C     Note. As coded here, coriolis will not work with "thin walls"  
 c     IF (useCDscheme) THEN  
 c       CALL MOM_CDSCHEME(bi,bj,k,dPhiHydX,dPhiHydY,myThid)  
 c     ELSE  
860        IF (.NOT.useCDscheme) THEN        IF (.NOT.useCDscheme) THEN
861          CALL MOM_U_CORIOLIS(bi,bj,k,vFld,cf,myThid)          CALL MOM_U_CORIOLIS( bi,bj,k,vFld,cf,myThid )
862          DO j=jMin,jMax          DO j=jMin,jMax
863           DO i=iMin,iMax           DO i=iMin,iMax
864            gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j)            gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j)
# Line 703  c     ELSE Line 868  c     ELSE
868          IF ( useDiagnostics )          IF ( useDiagnostics )
869       &    CALL DIAGNOSTICS_FILL(cf,'Um_Cori ',k,1,2,bi,bj,myThid)       &    CALL DIAGNOSTICS_FILL(cf,'Um_Cori ',k,1,2,bi,bj,myThid)
870  #endif  #endif
871          CALL MOM_V_CORIOLIS(bi,bj,k,uFld,cf,myThid)          CALL MOM_V_CORIOLIS( bi,bj,k,uFld,cf,myThid )
872          DO j=jMin,jMax          DO j=jMin,jMax
873           DO i=iMin,iMax           DO i=iMin,iMax
874            gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j)            gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j)
# Line 715  c     ELSE Line 880  c     ELSE
880  #endif  #endif
881        ENDIF        ENDIF
882    
883        IF (nonHydrostatic.OR.quasiHydrostatic) THEN  C--   3.D Coriolis term (horizontal momentum, Eastward component: -fprime*w)
884         CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,cf,myThid)        IF ( use3dCoriolis ) THEN
885         DO j=jMin,jMax          CALL MOM_U_CORIOLIS_NH( bi,bj,k,wVel,cf,myThid )
886          DO i=iMin,iMax          DO j=jMin,jMax
887           gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j)           DO i=iMin,iMax
888              gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j)
889             ENDDO
890          ENDDO          ENDDO
891         ENDDO         IF ( usingCurvilinearGrid ) THEN
892    C-     presently, non zero angleSinC array only supported with Curvilinear-Grid
893            CALL MOM_V_CORIOLIS_NH( bi,bj,k,wVel,cf,myThid )
894            DO j=jMin,jMax
895             DO i=iMin,iMax
896              gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j)
897             ENDDO
898            ENDDO
899           ENDIF
900        ENDIF        ENDIF
901    
902  C--   Set du/dt & dv/dt on boundaries to zero  C--   Set du/dt & dv/dt on boundaries to zero
# Line 737  C--   Set du/dt & dv/dt on boundaries to Line 912  C--   Set du/dt & dv/dt on boundaries to
912  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
913        IF ( useDiagnostics ) THEN        IF ( useDiagnostics ) THEN
914          CALL DIAGNOSTICS_FILL(KE,    'momKE   ',k,1,2,bi,bj,myThid)          CALL DIAGNOSTICS_FILL(KE,    'momKE   ',k,1,2,bi,bj,myThid)
915          CALL DIAGNOSTICS_FILL(gU(1-Olx,1-Oly,k,bi,bj),          CALL DIAGNOSTICS_FILL(gU(1-OLx,1-OLy,k,bi,bj),
916       &                               'Um_Advec',k,1,2,bi,bj,myThid)       &                               'Um_Advec',k,1,2,bi,bj,myThid)
917          CALL DIAGNOSTICS_FILL(gV(1-Olx,1-Oly,k,bi,bj),          CALL DIAGNOSTICS_FILL(gV(1-OLx,1-OLy,k,bi,bj),
918       &                               'Vm_Advec',k,1,2,bi,bj,myThid)       &                               'Vm_Advec',k,1,2,bi,bj,myThid)
919         IF (momViscosity) THEN         IF (momViscosity) THEN
920          CALL DIAGNOSTICS_FILL(guDiss,'Um_Diss ',k,1,2,bi,bj,myThid)          CALL DIAGNOSTICS_FILL(guDiss,'Um_Diss ',k,1,2,bi,bj,myThid)

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.22