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

Contents of /MITgcm/pkg/mom_fluxform/mom_fluxform.F

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


Revision 1.48 - (show annotations) (download)
Mon Feb 3 22:55:44 2014 UTC (10 years, 3 months ago) by jmc
Branch: MAIN
Changes since 1.47: +2 -6 lines
- remove comment related to "thin wall" (most likely related to CD-Scheme)

1 C $Header: /u/gcmpack/MITgcm/pkg/mom_fluxform/mom_fluxform.F,v 1.47 2013/08/01 20:11:34 jmc Exp $
2 C $Name: $
3
4 CBOI
5 C !TITLE: pkg/mom\_advdiff
6 C !AUTHORS: adcroft@mit.edu
7 C !INTRODUCTION: Flux-form Momentum Equations Package
8 C
9 C Package "mom\_fluxform" provides methods for calculating explicit terms
10 C in the momentum equation cast in flux-form:
11 C \begin{eqnarray*}
12 C G^u & = & -\frac{1}{\rho} \partial_x \phi_h
13 C -\nabla \cdot {\bf v} u
14 C -fv
15 C +\frac{1}{\rho} \nabla \cdot {\bf \tau}^x
16 C + \mbox{metrics}
17 C \\
18 C G^v & = & -\frac{1}{\rho} \partial_y \phi_h
19 C -\nabla \cdot {\bf v} v
20 C +fu
21 C +\frac{1}{\rho} \nabla \cdot {\bf \tau}^y
22 C + \mbox{metrics}
23 C \end{eqnarray*}
24 C where ${\bf v}=(u,v,w)$ and $\tau$, the stress tensor, includes surface
25 C stresses as well as internal viscous stresses.
26 CEOI
27
28 #include "MOM_FLUXFORM_OPTIONS.h"
29 #ifdef ALLOW_MOM_COMMON
30 # include "MOM_COMMON_OPTIONS.h"
31 #endif
32
33 CBOP
34 C !ROUTINE: MOM_FLUXFORM
35
36 C !INTERFACE: ==========================================================
37 SUBROUTINE MOM_FLUXFORM(
38 I bi,bj,k,iMin,iMax,jMin,jMax,
39 I KappaRU, KappaRV,
40 U fVerUkm, fVerVkm,
41 O fVerUkp, fVerVkp,
42 O guDiss, gvDiss,
43 I myTime, myIter, myThid )
44
45 C !DESCRIPTION:
46 C Calculates all the horizontal accelerations except for the implicit surface
47 C pressure gradient and implicit vertical viscosity.
48
49 C !USES: ===============================================================
50 C == Global variables ==
51 IMPLICIT NONE
52 #include "SIZE.h"
53 #include "EEPARAMS.h"
54 #include "PARAMS.h"
55 #include "GRID.h"
56 #include "DYNVARS.h"
57 #include "FFIELDS.h"
58 #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: ===================================================
69 C bi,bj :: current tile indices
70 C k :: current vertical level
71 C iMin,iMax,jMin,jMax :: loop ranges
72 C KappaRU :: vertical viscosity
73 C KappaRV :: vertical viscosity
74 C fVerUkm :: vertical advective flux of U, interface above (k-1/2)
75 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
79 C gvDiss :: dissipation tendency (all explicit terms), v component
80 C myTime :: current time
81 C myIter :: current time-step number
82 C myThid :: my Thread Id number
83 INTEGER bi,bj,k
84 INTEGER iMin,iMax,jMin,jMax
85 _RL KappaRU(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
86 _RL KappaRV(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
87 _RL fVerUkm(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
88 _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)
92 _RL gvDiss(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
93 _RL myTime
94 INTEGER myIter
95 INTEGER myThid
96
97 C !OUTPUT PARAMETERS: ==================================================
98 C None - updates gU() and gV() in common blocks
99
100 C !LOCAL VARIABLES: ====================================================
101 C i,j :: loop indices
102 C vF :: viscous flux
103 C v4F :: bi-harmonic viscous flux
104 C cF :: Coriolis acceleration
105 C mT :: Metric terms
106 C fZon :: zonal fluxes
107 C fMer :: meridional fluxes
108 C fVrUp,fVrDw :: vertical viscous fluxes at interface k & k+1
109 INTEGER i,j
110 #ifdef ALLOW_AUTODIFF_TAMC
111 INTEGER imomkey
112 #endif
113 _RL vF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
114 _RL v4F(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
115 _RL cF(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
116 _RL mT(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
117 _RL fZon(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
118 _RL fMer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
119 _RL fVrUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
120 _RL fVrDw(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
121 C afFacMom :: Tracer parameters for turning terms on and off.
122 C vfFacMom
123 C pfFacMom afFacMom - Advective terms
124 C cfFacMom vfFacMom - Eddy viscosity terms
125 C mtFacMom pfFacMom - Pressure terms
126 C cfFacMom - Coriolis terms
127 C foFacMom - Forcing
128 C mtFacMom - Metric term
129 C uDudxFac, AhDudxFac, etc ... individual term parameters for switching terms off
130 _RS hFacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
131 _RS r_hFacZ(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
132 _RS xA(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
133 _RS yA(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
134 _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
135 _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
136 _RL uFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
137 _RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
138 _RL rTransU(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
139 _RL rTransV(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
140 _RL KE(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
141 _RL viscAh_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
142 _RL viscAh_Z(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
143 _RL viscA4_D(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
144 _RL viscA4_Z(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
145 _RL vort3(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
146 _RL hDiv(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
147 _RL strain(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
148 _RL tension(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
149 _RL uDudxFac
150 _RL AhDudxFac
151 _RL vDudyFac
152 _RL AhDudyFac
153 _RL rVelDudrFac
154 _RL ArDudrFac
155 _RL fuFac
156 _RL mtFacU
157 _RL mtNHFacU
158 _RL uDvdxFac
159 _RL AhDvdxFac
160 _RL vDvdyFac
161 _RL AhDvdyFac
162 _RL rVelDvdrFac
163 _RL ArDvdrFac
164 _RL fvFac
165 _RL mtFacV
166 _RL mtNHFacV
167 _RL sideMaskFac
168 LOGICAL bottomDragTerms
169 CEOP
170 #ifdef MOM_BOUNDARY_CONSERVE
171 COMMON / MOM_FLUXFORM_LOCAL / uBnd, vBnd
172 _RL uBnd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
173 _RL vBnd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
174 #endif /* MOM_BOUNDARY_CONSERVE */
175
176 #ifdef ALLOW_AUTODIFF_TAMC
177 act0 = k - 1
178 max0 = Nr
179 act1 = bi - myBxLo(myThid)
180 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
181 act2 = bj - myByLo(myThid)
182 max2 = myByHi(myThid) - myByLo(myThid) + 1
183 act3 = myThid - 1
184 max3 = nTx*nTy
185 act4 = ikey_dynamics - 1
186 imomkey = (act0 + 1)
187 & + act1*max0
188 & + act2*max0*max1
189 & + act3*max0*max1*max2
190 & + act4*max0*max1*max2*max3
191 #endif /* ALLOW_AUTODIFF_TAMC */
192
193 C Initialise intermediate terms
194 DO j=1-OLy,sNy+OLy
195 DO i=1-OLx,sNx+OLx
196 vF(i,j) = 0.
197 v4F(i,j) = 0.
198 cF(i,j) = 0.
199 mT(i,j) = 0.
200 fZon(i,j) = 0.
201 fMer(i,j) = 0.
202 fVrUp(i,j)= 0.
203 fVrDw(i,j)= 0.
204 rTransU(i,j)= 0.
205 rTransV(i,j)= 0.
206 c KE(i,j) = 0.
207 hDiv(i,j) = 0.
208 vort3(i,j) = 0.
209 strain(i,j) = 0.
210 tension(i,j)= 0.
211 guDiss(i,j) = 0.
212 gvDiss(i,j) = 0.
213 ENDDO
214 ENDDO
215
216 C-- Term by term tracer parmeters
217 C o U momentum equation
218 uDudxFac = afFacMom*1.
219 AhDudxFac = vfFacMom*1.
220 vDudyFac = afFacMom*1.
221 AhDudyFac = vfFacMom*1.
222 rVelDudrFac = afFacMom*1.
223 ArDudrFac = vfFacMom*1.
224 mtFacU = mtFacMom*1.
225 mtNHFacU = 1.
226 fuFac = cfFacMom*1.
227 C o V momentum equation
228 uDvdxFac = afFacMom*1.
229 AhDvdxFac = vfFacMom*1.
230 vDvdyFac = afFacMom*1.
231 AhDvdyFac = vfFacMom*1.
232 rVelDvdrFac = afFacMom*1.
233 ArDvdrFac = vfFacMom*1.
234 mtFacV = mtFacMom*1.
235 mtNHFacV = 1.
236 fvFac = cfFacMom*1.
237
238 IF (implicitViscosity) THEN
239 ArDudrFac = 0.
240 ArDvdrFac = 0.
241 ENDIF
242
243 C note: using standard stencil (no mask) results in under-estimating
244 C vorticity at a no-slip boundary by a factor of 2 = sideDragFactor
245 IF ( no_slip_sides ) THEN
246 sideMaskFac = sideDragFactor
247 ELSE
248 sideMaskFac = 0. _d 0
249 ENDIF
250
251 IF ( no_slip_bottom
252 & .OR. bottomDragQuadratic.NE.0.
253 & .OR. bottomDragLinear.NE.0.) THEN
254 bottomDragTerms=.TRUE.
255 ELSE
256 bottomDragTerms=.FALSE.
257 ENDIF
258
259 C-- Calculate open water fraction at vorticity points
260 CALL MOM_CALC_HFACZ(bi,bj,k,hFacZ,r_hFacZ,myThid)
261
262 C---- Calculate common quantities used in both U and V equations
263 C Calculate tracer cell face open areas
264 DO j=1-OLy,sNy+OLy
265 DO i=1-OLx,sNx+OLx
266 xA(i,j) = _dyG(i,j,bi,bj)*deepFacC(k)
267 & *drF(k)*_hFacW(i,j,k,bi,bj)
268 yA(i,j) = _dxG(i,j,bi,bj)*deepFacC(k)
269 & *drF(k)*_hFacS(i,j,k,bi,bj)
270 ENDDO
271 ENDDO
272
273 C Make local copies of horizontal flow field
274 DO j=1-OLy,sNy+OLy
275 DO i=1-OLx,sNx+OLx
276 uFld(i,j) = uVel(i,j,k,bi,bj)
277 vFld(i,j) = vVel(i,j,k,bi,bj)
278 ENDDO
279 ENDDO
280
281 C Calculate velocity field "volume transports" through tracer cell faces.
282 C anelastic: transports are scaled by rhoFacC (~ mass transport)
283 DO j=1-OLy,sNy+OLy
284 DO i=1-OLx,sNx+OLx
285 uTrans(i,j) = uFld(i,j)*xA(i,j)*rhoFacC(k)
286 vTrans(i,j) = vFld(i,j)*yA(i,j)*rhoFacC(k)
287 ENDDO
288 ENDDO
289
290 CALL MOM_CALC_KE(bi,bj,k,2,uFld,vFld,KE,myThid)
291 IF ( momViscosity) THEN
292 CALL MOM_CALC_HDIV(bi,bj,k,2,uFld,vFld,hDiv,myThid)
293 CALL MOM_CALC_RELVORT3(bi,bj,k,uFld,vFld,hFacZ,vort3,myThid)
294 CALL MOM_CALC_TENSION(bi,bj,k,uFld,vFld,tension,myThid)
295 CALL MOM_CALC_STRAIN(bi,bj,k,uFld,vFld,hFacZ,strain,myThid)
296 DO j=1-OLy,sNy+OLy
297 DO i=1-OLx,sNx+OLx
298 IF ( hFacZ(i,j).EQ.0. ) THEN
299 vort3(i,j) = sideMaskFac*vort3(i,j)
300 strain(i,j) = sideMaskFac*strain(i,j)
301 ENDIF
302 ENDDO
303 ENDDO
304 #ifdef ALLOW_DIAGNOSTICS
305 IF ( useDiagnostics ) THEN
306 CALL DIAGNOSTICS_FILL(hDiv, 'momHDiv ',k,1,2,bi,bj,myThid)
307 CALL DIAGNOSTICS_FILL(vort3, 'momVort3',k,1,2,bi,bj,myThid)
308 CALL DIAGNOSTICS_FILL(tension,'Tension ',k,1,2,bi,bj,myThid)
309 CALL DIAGNOSTICS_FILL(strain, 'Strain ',k,1,2,bi,bj,myThid)
310 ENDIF
311 #endif
312 ENDIF
313
314 C--- First call (k=1): compute vertical adv. flux fVerUkm & fVerVkm
315 IF (momAdvection.AND.k.EQ.1) THEN
316
317 #ifdef MOM_BOUNDARY_CONSERVE
318 CALL MOM_UV_BOUNDARY( bi, bj, k,
319 I uVel, vVel,
320 O uBnd(1-OLx,1-OLy,k,bi,bj),
321 O vBnd(1-OLx,1-OLy,k,bi,bj),
322 I myTime, myIter, myThid )
323 #endif /* MOM_BOUNDARY_CONSERVE */
324
325 C- Calculate vertical transports above U & V points (West & South face):
326
327 #ifdef ALLOW_AUTODIFF_TAMC
328 # ifdef NONLIN_FRSURF
329 # ifndef DISABLE_RSTAR_CODE
330 CADJ STORE dwtransc(:,:,bi,bj) =
331 CADJ & comlev1_bibj_k, key = imomkey, byte = isbyte
332 CADJ STORE dwtransu(:,:,bi,bj) =
333 CADJ & comlev1_bibj_k, key = imomkey, byte = isbyte
334 CADJ STORE dwtransv(:,:,bi,bj) =
335 CADJ & comlev1_bibj_k, key = imomkey, byte = isbyte
336 # endif
337 # endif /* NONLIN_FRSURF */
338 #endif /* ALLOW_AUTODIFF_TAMC */
339 CALL MOM_CALC_RTRANS( k, bi, bj,
340 O rTransU, rTransV,
341 I myTime, myIter, myThid)
342
343 C- Free surface correction term (flux at k=1)
344 CALL MOM_U_ADV_WU( bi,bj,k,uVel,wVel,rTransU,
345 O fVerUkm, myThid )
346
347 CALL MOM_V_ADV_WV( bi,bj,k,vVel,wVel,rTransV,
348 O fVerVkm, myThid )
349
350 C--- endif momAdvection & k=1
351 ENDIF
352
353 C--- Calculate vertical transports (at k+1) below U & V points :
354 IF (momAdvection) THEN
355 CALL MOM_CALC_RTRANS( k+1, bi, bj,
356 O rTransU, rTransV,
357 I myTime, myIter, myThid)
358 ENDIF
359
360 #ifdef MOM_BOUNDARY_CONSERVE
361 IF ( momAdvection .AND. k.LT.Nr ) THEN
362 CALL MOM_UV_BOUNDARY( bi, bj, k+1,
363 I uVel, vVel,
364 O uBnd(1-OLx,1-OLy,k+1,bi,bj),
365 O vBnd(1-OLx,1-OLy,k+1,bi,bj),
366 I myTime, myIter, myThid )
367 ENDIF
368 #endif /* MOM_BOUNDARY_CONSERVE */
369
370 IF (momViscosity) THEN
371 DO j=1-OLy,sNy+OLy
372 DO i=1-OLx,sNx+OLx
373 viscAh_D(i,j) = viscAhD
374 viscAh_Z(i,j) = viscAhZ
375 viscA4_D(i,j) = viscA4D
376 viscA4_Z(i,j) = viscA4Z
377 ENDDO
378 ENDDO
379 IF ( useVariableVisc ) THEN
380 CALL MOM_CALC_VISC( bi, bj, k,
381 O viscAh_Z, viscAh_D, viscA4_Z, viscA4_D,
382 I hDiv, vort3, tension, strain, KE, hFacZ,
383 I myThid )
384 ENDIF
385 ENDIF
386
387 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
388
389 C---- Zonal momentum equation starts here
390
391 IF (momAdvection) THEN
392 C--- Calculate mean fluxes (advection) between cells for zonal flow.
393
394 #ifdef MOM_BOUNDARY_CONSERVE
395 CALL MOM_U_ADV_UU( bi,bj,k,uTrans,uBnd(1-OLx,1-OLy,k,bi,bj),
396 O fZon,myThid )
397 CALL MOM_U_ADV_VU( bi,bj,k,vTrans,uBnd(1-OLx,1-OLy,k,bi,bj),
398 O fMer,myThid )
399 CALL MOM_U_ADV_WU(
400 I bi,bj,k+1,uBnd,wVel,rTransU,
401 O fVerUkp, myThid )
402 #else /* MOM_BOUNDARY_CONSERVE */
403 C-- Zonal flux (fZon is at east face of "u" cell)
404 C Mean flow component of zonal flux -> fZon
405 CALL MOM_U_ADV_UU(bi,bj,k,uTrans,uFld,fZon,myThid)
406
407 C-- Meridional flux (fMer is at south face of "u" cell)
408 C Mean flow component of meridional flux -> fMer
409 CALL MOM_U_ADV_VU(bi,bj,k,vTrans,uFld,fMer,myThid)
410
411 C-- Vertical flux (fVer is at upper face of "u" cell)
412 C Mean flow component of vertical flux (at k+1) -> fVer
413 CALL MOM_U_ADV_WU(
414 I bi,bj,k+1,uVel,wVel,rTransU,
415 O fVerUkp, myThid )
416 #endif /* MOM_BOUNDARY_CONSERVE */
417
418 C-- Tendency is minus divergence of the fluxes + coriolis + pressure term
419 DO j=jMin,jMax
420 DO i=iMin,iMax
421 gU(i,j,k,bi,bj) =
422 #ifdef OLD_UV_GEOM
423 & -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)/
424 & ( 0.5 _d 0*(rA(i,j,bi,bj)+rA(i-1,j,bi,bj)) )
425 #else
426 & -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)
427 & *recip_rAw(i,j,bi,bj)*recip_deepFac2C(k)*recip_rhoFacC(k)
428 #endif
429 & *( ( fZon(i,j ) - fZon(i-1,j) )*uDudxFac
430 & +( fMer(i,j+1) - fMer(i, j) )*vDudyFac
431 & +( fVerUkp(i,j) - fVerUkm(i,j) )*rkSign*rVelDudrFac
432 & )
433 ENDDO
434 ENDDO
435
436 #ifdef ALLOW_DIAGNOSTICS
437 IF ( useDiagnostics ) THEN
438 CALL DIAGNOSTICS_FILL( fZon, 'ADVx_Um ',k,1,2,bi,bj,myThid)
439 CALL DIAGNOSTICS_FILL( fMer, 'ADVy_Um ',k,1,2,bi,bj,myThid)
440 CALL DIAGNOSTICS_FILL(fVerUkm,'ADVrE_Um',k,1,2,bi,bj,myThid)
441 ENDIF
442 #endif
443
444 #ifdef NONLIN_FRSURF
445 C-- account for 3.D divergence of the flow in rStar coordinate:
446 # ifndef DISABLE_RSTAR_CODE
447 IF ( select_rStar.GT.0 ) THEN
448 DO j=jMin,jMax
449 DO i=iMin,iMax
450 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)
451 & - (rStarExpW(i,j,bi,bj) - 1. _d 0)/deltaTfreesurf
452 & *uVel(i,j,k,bi,bj)
453 ENDDO
454 ENDDO
455 ENDIF
456 IF ( select_rStar.LT.0 ) THEN
457 DO j=jMin,jMax
458 DO i=iMin,iMax
459 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)
460 & - rStarDhWDt(i,j,bi,bj)*uVel(i,j,k,bi,bj)
461 ENDDO
462 ENDDO
463 ENDIF
464 # endif /* DISABLE_RSTAR_CODE */
465 #endif /* NONLIN_FRSURF */
466
467 #ifdef ALLOW_ADDFLUID
468 IF ( selectAddFluid.GE.1 ) THEN
469 DO j=jMin,jMax
470 DO i=iMin,iMax
471 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)
472 & + uVel(i,j,k,bi,bj)*mass2rUnit*0.5 _d 0
473 & *( addMass(i-1,j,k,bi,bj) + addMass(i,j,k,bi,bj) )
474 & *_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)*recip_rhoFacC(k)
475 & * recip_rAw(i,j,bi,bj)*recip_deepFac2C(k)
476 ENDDO
477 ENDDO
478 ENDIF
479 #endif /* ALLOW_ADDFLUID */
480
481 ELSE
482 C- if momAdvection / else
483 DO j=1-OLy,sNy+OLy
484 DO i=1-OLx,sNx+OLx
485 gU(i,j,k,bi,bj) = 0. _d 0
486 ENDDO
487 ENDDO
488
489 C- endif momAdvection.
490 ENDIF
491
492 IF (momViscosity) THEN
493 C--- Calculate eddy fluxes (dissipation) between cells for zonal flow.
494
495 C Bi-harmonic term del^2 U -> v4F
496 IF ( useBiharmonicVisc )
497 & CALL MOM_U_DEL2U(bi,bj,k,uFld,hFacZ,v4f,myThid)
498
499 C Laplacian and bi-harmonic terms, Zonal Fluxes -> fZon
500 CALL MOM_U_XVISCFLUX(bi,bj,k,uFld,v4F,fZon,
501 I viscAh_D,viscA4_D,myThid)
502
503 C Laplacian and bi-harmonic termis, Merid Fluxes -> fMer
504 CALL MOM_U_YVISCFLUX(bi,bj,k,uFld,v4F,hFacZ,fMer,
505 I viscAh_Z,viscA4_Z,myThid)
506
507 C Eddy component of vertical flux (interior component only) -> fVrUp & fVrDw
508 IF (.NOT.implicitViscosity) THEN
509 CALL MOM_U_RVISCFLUX(bi,bj, k, uVel,KappaRU,fVrUp,myThid)
510 CALL MOM_U_RVISCFLUX(bi,bj,k+1,uVel,KappaRU,fVrDw,myThid)
511 ENDIF
512
513 C-- Tendency is minus divergence of the fluxes
514 C anelastic: hor.visc.fluxes are not scaled by rhoFac (by vert.visc.flx is)
515 DO j=jMin,jMax
516 DO i=iMin,iMax
517 guDiss(i,j) =
518 #ifdef OLD_UV_GEOM
519 & -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)/
520 & ( 0.5 _d 0*(rA(i,j,bi,bj)+rA(i-1,j,bi,bj)) )
521 #else
522 & -_recip_hFacW(i,j,k,bi,bj)*recip_drF(k)
523 & *recip_rAw(i,j,bi,bj)*recip_deepFac2C(k)
524 #endif
525 & *( ( fZon(i,j ) - fZon(i-1,j) )*AhDudxFac
526 & +( fMer(i,j+1) - fMer(i, j) )*AhDudyFac
527 & +( fVrDw(i,j) - fVrUp(i,j) )*rkSign*ArDudrFac
528 & *recip_rhoFacC(k)
529 & )
530 ENDDO
531 ENDDO
532
533 #ifdef ALLOW_DIAGNOSTICS
534 IF ( useDiagnostics ) THEN
535 CALL DIAGNOSTICS_FILL(fZon, 'VISCx_Um',k,1,2,bi,bj,myThid)
536 CALL DIAGNOSTICS_FILL(fMer, 'VISCy_Um',k,1,2,bi,bj,myThid)
537 IF (.NOT.implicitViscosity)
538 & CALL DIAGNOSTICS_FILL(fVrUp,'VISrE_Um',k,1,2,bi,bj,myThid)
539 ENDIF
540 #endif
541
542 C-- No-slip and drag BCs appear as body forces in cell abutting topography
543 IF (no_slip_sides) THEN
544 C- No-slip BCs impose a drag at walls...
545 CALL MOM_U_SIDEDRAG( bi, bj, k,
546 I uFld, v4f, hFacZ,
547 I viscAh_Z, viscA4_Z,
548 I useHarmonicVisc, useBiharmonicVisc, useVariableVisc,
549 O vF,
550 I myThid )
551 DO j=jMin,jMax
552 DO i=iMin,iMax
553 gUdiss(i,j) = gUdiss(i,j) + vF(i,j)
554 ENDDO
555 ENDDO
556 ENDIF
557 C- No-slip BCs impose a drag at bottom
558 IF (bottomDragTerms) THEN
559 CALL MOM_U_BOTTOMDRAG(bi,bj,k,uFld,KE,KappaRU,vF,myThid)
560 DO j=jMin,jMax
561 DO i=iMin,iMax
562 gUdiss(i,j) = gUdiss(i,j) + vF(i,j)
563 ENDDO
564 ENDDO
565 ENDIF
566
567 #ifdef ALLOW_SHELFICE
568 IF (useShelfIce) THEN
569 CALL SHELFICE_U_DRAG(bi,bj,k,uFld,KE,KappaRU,vF,myThid)
570 DO j=jMin,jMax
571 DO i=iMin,iMax
572 gUdiss(i,j) = gUdiss(i,j) + vF(i,j)
573 ENDDO
574 ENDDO
575 ENDIF
576 #endif /* ALLOW_SHELFICE */
577
578 C- endif momViscosity
579 ENDIF
580
581 C-- Forcing term (moved to timestep.F)
582 c IF (momForcing)
583 c & CALL EXTERNAL_FORCING_U(
584 c I iMin,iMax,jMin,jMax,bi,bj,k,
585 c I myTime,myThid)
586
587 C-- Metric terms for curvilinear grid systems
588 IF (useNHMTerms) THEN
589 C o Non-Hydrostatic (spherical) metric terms
590 CALL MOM_U_METRIC_NH(bi,bj,k,uFld,wVel,mT,myThid)
591 DO j=jMin,jMax
592 DO i=iMin,iMax
593 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mtNHFacU*mT(i,j)
594 ENDDO
595 ENDDO
596 ENDIF
597 IF ( usingSphericalPolarGrid .AND. metricTerms ) THEN
598 C o Spherical polar grid metric terms
599 CALL MOM_U_METRIC_SPHERE(bi,bj,k,uFld,vFld,mT,myThid)
600 DO j=jMin,jMax
601 DO i=iMin,iMax
602 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mtFacU*mT(i,j)
603 ENDDO
604 ENDDO
605 ENDIF
606 IF ( usingCylindricalGrid .AND. metricTerms ) THEN
607 C o Cylindrical grid metric terms
608 CALL MOM_U_METRIC_CYLINDER(bi,bj,k,uFld,vFld,mT,myThid)
609 DO j=jMin,jMax
610 DO i=iMin,iMax
611 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+mtFacU*mT(i,j)
612 ENDDO
613 ENDDO
614 ENDIF
615
616 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
617
618 C---- Meridional momentum equation starts here
619
620 IF (momAdvection) THEN
621
622 #ifdef MOM_BOUNDARY_CONSERVE
623 CALL MOM_V_ADV_UV( bi,bj,k,uTrans,vBnd(1-OLx,1-OLy,k,bi,bj),
624 O fZon,myThid )
625 CALL MOM_V_ADV_VV( bi,bj,k,vTrans,vBnd(1-OLx,1-OLy,k,bi,bj),
626 O fMer,myThid )
627 CALL MOM_V_ADV_WV( bi,bj,k+1,vBnd,wVel,rTransV,
628 O fVerVkp, myThid )
629 #else /* MOM_BOUNDARY_CONSERVE */
630 C--- Calculate mean fluxes (advection) between cells for meridional flow.
631 C Mean flow component of zonal flux -> fZon
632 CALL MOM_V_ADV_UV( bi,bj,k,uTrans,vFld,fZon,myThid )
633
634 C-- Meridional flux (fMer is at north face of "v" cell)
635 C Mean flow component of meridional flux -> fMer
636 CALL MOM_V_ADV_VV( bi,bj,k,vTrans,vFld,fMer,myThid )
637
638 C-- Vertical flux (fVer is at upper face of "v" cell)
639 C Mean flow component of vertical flux (at k+1) -> fVerV
640 CALL MOM_V_ADV_WV( bi,bj,k+1,vVel,wVel,rTransV,
641 O fVerVkp, myThid )
642 #endif /* MOM_BOUNDARY_CONSERVE */
643
644 C-- Tendency is minus divergence of the fluxes + coriolis + pressure term
645 DO j=jMin,jMax
646 DO i=iMin,iMax
647 gV(i,j,k,bi,bj) =
648 #ifdef OLD_UV_GEOM
649 & -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)/
650 & ( 0.5 _d 0*(_rA(i,j,bi,bj)+_rA(i,j-1,bi,bj)) )
651 #else
652 & -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)
653 & *recip_rAs(i,j,bi,bj)*recip_deepFac2C(k)*recip_rhoFacC(k)
654 #endif
655 & *( ( fZon(i+1,j) - fZon(i,j ) )*uDvdxFac
656 & +( fMer(i, j) - fMer(i,j-1) )*vDvdyFac
657 & +( fVerVkp(i,j) - fVerVkm(i,j) )*rkSign*rVelDvdrFac
658 & )
659 ENDDO
660 ENDDO
661
662 #ifdef ALLOW_DIAGNOSTICS
663 IF ( useDiagnostics ) THEN
664 CALL DIAGNOSTICS_FILL( fZon, 'ADVx_Vm ',k,1,2,bi,bj,myThid)
665 CALL DIAGNOSTICS_FILL( fMer, 'ADVy_Vm ',k,1,2,bi,bj,myThid)
666 CALL DIAGNOSTICS_FILL(fVerVkm,'ADVrE_Vm',k,1,2,bi,bj,myThid)
667 ENDIF
668 #endif
669
670 #ifdef NONLIN_FRSURF
671 C-- account for 3.D divergence of the flow in rStar coordinate:
672 # ifndef DISABLE_RSTAR_CODE
673 IF ( select_rStar.GT.0 ) THEN
674 DO j=jMin,jMax
675 DO i=iMin,iMax
676 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)
677 & - (rStarExpS(i,j,bi,bj) - 1. _d 0)/deltaTfreesurf
678 & *vVel(i,j,k,bi,bj)
679 ENDDO
680 ENDDO
681 ENDIF
682 IF ( select_rStar.LT.0 ) THEN
683 DO j=jMin,jMax
684 DO i=iMin,iMax
685 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)
686 & - rStarDhSDt(i,j,bi,bj)*vVel(i,j,k,bi,bj)
687 ENDDO
688 ENDDO
689 ENDIF
690 # endif /* DISABLE_RSTAR_CODE */
691 #endif /* NONLIN_FRSURF */
692
693 #ifdef ALLOW_ADDFLUID
694 IF ( selectAddFluid.GE.1 ) THEN
695 DO j=jMin,jMax
696 DO i=iMin,iMax
697 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)
698 & + vVel(i,j,k,bi,bj)*mass2rUnit*0.5 _d 0
699 & *( addMass(i,j-1,k,bi,bj) + addMass(i,j,k,bi,bj) )
700 & *_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)*recip_rhoFacC(k)
701 & * recip_rAs(i,j,bi,bj)*recip_deepFac2C(k)
702 ENDDO
703 ENDDO
704 ENDIF
705 #endif /* ALLOW_ADDFLUID */
706
707 ELSE
708 C- if momAdvection / else
709 DO j=1-OLy,sNy+OLy
710 DO i=1-OLx,sNx+OLx
711 gV(i,j,k,bi,bj) = 0. _d 0
712 ENDDO
713 ENDDO
714
715 C- endif momAdvection.
716 ENDIF
717
718 IF (momViscosity) THEN
719 C--- Calculate eddy fluxes (dissipation) between cells for meridional flow.
720 C Bi-harmonic term del^2 V -> v4F
721 IF ( useBiharmonicVisc )
722 & CALL MOM_V_DEL2V(bi,bj,k,vFld,hFacZ,v4f,myThid)
723
724 C Laplacian and bi-harmonic terms, Zonal Fluxes -> fZon
725 CALL MOM_V_XVISCFLUX(bi,bj,k,vFld,v4f,hFacZ,fZon,
726 I viscAh_Z,viscA4_Z,myThid)
727
728 C Laplacian and bi-harmonic termis, Merid Fluxes -> fMer
729 CALL MOM_V_YVISCFLUX(bi,bj,k,vFld,v4f,fMer,
730 I viscAh_D,viscA4_D,myThid)
731
732 C Eddy component of vertical flux (interior component only) -> fVrUp & fVrDw
733 IF (.NOT.implicitViscosity) THEN
734 CALL MOM_V_RVISCFLUX(bi,bj, k, vVel,KappaRV,fVrUp,myThid)
735 CALL MOM_V_RVISCFLUX(bi,bj,k+1,vVel,KappaRV,fVrDw,myThid)
736 ENDIF
737
738 C-- Tendency is minus divergence of the fluxes + coriolis + pressure term
739 C anelastic: hor.visc.fluxes are not scaled by rhoFac (by vert.visc.flx is)
740 DO j=jMin,jMax
741 DO i=iMin,iMax
742 gvDiss(i,j) =
743 #ifdef OLD_UV_GEOM
744 & -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)/
745 & ( 0.5 _d 0*(_rA(i,j,bi,bj)+_rA(i,j-1,bi,bj)) )
746 #else
747 & -_recip_hFacS(i,j,k,bi,bj)*recip_drF(k)
748 & *recip_rAs(i,j,bi,bj)*recip_deepFac2C(k)
749 #endif
750 & *( ( fZon(i+1,j) - fZon(i,j ) )*AhDvdxFac
751 & +( fMer(i, j) - fMer(i,j-1) )*AhDvdyFac
752 & +( fVrDw(i,j) - fVrUp(i,j) )*rkSign*ArDvdrFac
753 & *recip_rhoFacC(k)
754 & )
755 ENDDO
756 ENDDO
757
758 #ifdef ALLOW_DIAGNOSTICS
759 IF ( useDiagnostics ) THEN
760 CALL DIAGNOSTICS_FILL(fZon, 'VISCx_Vm',k,1,2,bi,bj,myThid)
761 CALL DIAGNOSTICS_FILL(fMer, 'VISCy_Vm',k,1,2,bi,bj,myThid)
762 IF (.NOT.implicitViscosity)
763 & CALL DIAGNOSTICS_FILL(fVrUp,'VISrE_Vm',k,1,2,bi,bj,myThid)
764 ENDIF
765 #endif
766
767 C-- No-slip and drag BCs appear as body forces in cell abutting topography
768 IF (no_slip_sides) THEN
769 C- No-slip BCs impose a drag at walls...
770 CALL MOM_V_SIDEDRAG( bi, bj, k,
771 I vFld, v4f, hFacZ,
772 I viscAh_Z,viscA4_Z,
773 I useHarmonicVisc, useBiharmonicVisc, useVariableVisc,
774 O vF,
775 I myThid )
776 DO j=jMin,jMax
777 DO i=iMin,iMax
778 gvDiss(i,j) = gvDiss(i,j) + vF(i,j)
779 ENDDO
780 ENDDO
781 ENDIF
782 C- No-slip BCs impose a drag at bottom
783 IF (bottomDragTerms) THEN
784 CALL MOM_V_BOTTOMDRAG(bi,bj,k,vFld,KE,KappaRV,vF,myThid)
785 DO j=jMin,jMax
786 DO i=iMin,iMax
787 gvDiss(i,j) = gvDiss(i,j) + vF(i,j)
788 ENDDO
789 ENDDO
790 ENDIF
791
792 #ifdef ALLOW_SHELFICE
793 IF (useShelfIce) THEN
794 CALL SHELFICE_V_DRAG(bi,bj,k,vFld,KE,KappaRV,vF,myThid)
795 DO j=jMin,jMax
796 DO i=iMin,iMax
797 gvDiss(i,j) = gvDiss(i,j) + vF(i,j)
798 ENDDO
799 ENDDO
800 ENDIF
801 #endif /* ALLOW_SHELFICE */
802
803 C- endif momViscosity
804 ENDIF
805
806 C-- Forcing term (moved to timestep.F)
807 c IF (momForcing)
808 c & CALL EXTERNAL_FORCING_V(
809 c I iMin,iMax,jMin,jMax,bi,bj,k,
810 c I myTime,myThid)
811
812 C-- Metric terms for curvilinear grid systems
813 IF (useNHMTerms) THEN
814 C o Non-Hydrostatic (spherical) metric terms
815 CALL MOM_V_METRIC_NH(bi,bj,k,vFld,wVel,mT,myThid)
816 DO j=jMin,jMax
817 DO i=iMin,iMax
818 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mtNHFacV*mT(i,j)
819 ENDDO
820 ENDDO
821 ENDIF
822 IF ( usingSphericalPolarGrid .AND. metricTerms ) THEN
823 C o Spherical polar grid metric terms
824 CALL MOM_V_METRIC_SPHERE(bi,bj,k,uFld,mT,myThid)
825 DO j=jMin,jMax
826 DO i=iMin,iMax
827 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mtFacV*mT(i,j)
828 ENDDO
829 ENDDO
830 ENDIF
831 IF ( usingCylindricalGrid .AND. metricTerms ) THEN
832 C o Cylindrical grid metric terms
833 CALL MOM_V_METRIC_CYLINDER(bi,bj,k,uFld,vFld,mT,myThid)
834 DO j=jMin,jMax
835 DO i=iMin,iMax
836 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+mtFacV*mT(i,j)
837 ENDDO
838 ENDDO
839 ENDIF
840
841 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
842
843 C-- Coriolis term (call to CD_CODE_SCHEME has been moved to timestep.F)
844 IF (.NOT.useCDscheme) THEN
845 CALL MOM_U_CORIOLIS(bi,bj,k,vFld,cf,myThid)
846 DO j=jMin,jMax
847 DO i=iMin,iMax
848 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j)
849 ENDDO
850 ENDDO
851 #ifdef ALLOW_DIAGNOSTICS
852 IF ( useDiagnostics )
853 & CALL DIAGNOSTICS_FILL(cf,'Um_Cori ',k,1,2,bi,bj,myThid)
854 #endif
855 CALL MOM_V_CORIOLIS(bi,bj,k,uFld,cf,myThid)
856 DO j=jMin,jMax
857 DO i=iMin,iMax
858 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j)
859 ENDDO
860 ENDDO
861 #ifdef ALLOW_DIAGNOSTICS
862 IF ( useDiagnostics )
863 & CALL DIAGNOSTICS_FILL(cf,'Vm_Cori ',k,1,2,bi,bj,myThid)
864 #endif
865 ENDIF
866
867 C-- 3.D Coriolis term (horizontal momentum, Eastward component: -fprime*w)
868 IF ( use3dCoriolis ) THEN
869 CALL MOM_U_CORIOLIS_NH(bi,bj,k,wVel,cf,myThid)
870 DO j=jMin,jMax
871 DO i=iMin,iMax
872 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)+fuFac*cf(i,j)
873 ENDDO
874 ENDDO
875 IF ( usingCurvilinearGrid ) THEN
876 C- presently, non zero angleSinC array only supported with Curvilinear-Grid
877 CALL MOM_V_CORIOLIS_NH(bi,bj,k,wVel,cf,myThid)
878 DO j=jMin,jMax
879 DO i=iMin,iMax
880 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)+fvFac*cf(i,j)
881 ENDDO
882 ENDDO
883 ENDIF
884 ENDIF
885
886 C-- Set du/dt & dv/dt on boundaries to zero
887 DO j=jMin,jMax
888 DO i=iMin,iMax
889 gU(i,j,k,bi,bj) = gU(i,j,k,bi,bj)*_maskW(i,j,k,bi,bj)
890 guDiss(i,j) = guDiss(i,j) *_maskW(i,j,k,bi,bj)
891 gV(i,j,k,bi,bj) = gV(i,j,k,bi,bj)*_maskS(i,j,k,bi,bj)
892 gvDiss(i,j) = gvDiss(i,j) *_maskS(i,j,k,bi,bj)
893 ENDDO
894 ENDDO
895
896 #ifdef ALLOW_DIAGNOSTICS
897 IF ( useDiagnostics ) THEN
898 CALL DIAGNOSTICS_FILL(KE, 'momKE ',k,1,2,bi,bj,myThid)
899 CALL DIAGNOSTICS_FILL(gU(1-OLx,1-OLy,k,bi,bj),
900 & 'Um_Advec',k,1,2,bi,bj,myThid)
901 CALL DIAGNOSTICS_FILL(gV(1-OLx,1-OLy,k,bi,bj),
902 & 'Vm_Advec',k,1,2,bi,bj,myThid)
903 IF (momViscosity) THEN
904 CALL DIAGNOSTICS_FILL(guDiss,'Um_Diss ',k,1,2,bi,bj,myThid)
905 CALL DIAGNOSTICS_FILL(gvDiss,'Vm_Diss ',k,1,2,bi,bj,myThid)
906 ENDIF
907 ENDIF
908 #endif /* ALLOW_DIAGNOSTICS */
909
910 RETURN
911 END

  ViewVC Help
Powered by ViewVC 1.1.22