/[MITgcm]/MITgcm/verification/tutorial_deep_convection/code/dynamics.F
ViewVC logotype

Contents of /MITgcm/verification/tutorial_deep_convection/code/dynamics.F

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


Revision 1.1 - (show annotations) (download)
Mon Sep 30 18:19:41 2013 UTC (10 years, 8 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64p
add 1rst version of isotropic 3-D Smagorinsky code (from Louis-Philippe),
  for now all in this exp. code dir.

1 C $Header: /u/gcmpack/MITgcm/model/src/dynamics.F,v 1.164 2013/03/21 18:15:44 jahn Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6 #ifdef ALLOW_MOM_COMMON
7 # include "MOM_COMMON_OPTIONS.h"
8 #endif
9 #ifdef ALLOW_OBCS
10 # include "OBCS_OPTIONS.h"
11 #endif
12
13 #undef DYNAMICS_GUGV_EXCH_CHECK
14
15 CBOP
16 C !ROUTINE: DYNAMICS
17 C !INTERFACE:
18 SUBROUTINE DYNAMICS(myTime, myIter, myThid)
19 C !DESCRIPTION: \bv
20 C *==========================================================*
21 C | SUBROUTINE DYNAMICS
22 C | o Controlling routine for the explicit part of the model
23 C | dynamics.
24 C *==========================================================*
25 C | This routine evaluates the "dynamics" terms for each
26 C | block of ocean in turn. Because the blocks of ocean have
27 C | overlap regions they are independent of one another.
28 C | If terms involving lateral integrals are needed in this
29 C | routine care will be needed. Similarly finite-difference
30 C | operations with stencils wider than the overlap region
31 C | require special consideration.
32 C | The algorithm...
33 C |
34 C | "Correction Step"
35 C | =================
36 C | Here we update the horizontal velocities with the surface
37 C | pressure such that the resulting flow is either consistent
38 C | with the free-surface evolution or the rigid-lid:
39 C | U[n] = U* + dt x d/dx P
40 C | V[n] = V* + dt x d/dy P
41 C | W[n] = W* + dt x d/dz P (NH mode)
42 C |
43 C | "Calculation of Gs"
44 C | ===================
45 C | This is where all the accelerations and tendencies (ie.
46 C | physics, parameterizations etc...) are calculated
47 C | rho = rho ( theta[n], salt[n] )
48 C | b = b(rho, theta)
49 C | K31 = K31 ( rho )
50 C | Gu[n] = Gu( u[n], v[n], wVel, b, ... )
51 C | Gv[n] = Gv( u[n], v[n], wVel, b, ... )
52 C | Gt[n] = Gt( theta[n], u[n], v[n], wVel, K31, ... )
53 C | Gs[n] = Gs( salt[n], u[n], v[n], wVel, K31, ... )
54 C |
55 C | "Time-stepping" or "Prediction"
56 C | ================================
57 C | The models variables are stepped forward with the appropriate
58 C | time-stepping scheme (currently we use Adams-Bashforth II)
59 C | - For momentum, the result is always *only* a "prediction"
60 C | in that the flow may be divergent and will be "corrected"
61 C | later with a surface pressure gradient.
62 C | - Normally for tracers the result is the new field at time
63 C | level [n+1} *BUT* in the case of implicit diffusion the result
64 C | is also *only* a prediction.
65 C | - We denote "predictors" with an asterisk (*).
66 C | U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] )
67 C | V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] )
68 C | theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
69 C | salt[n+1] = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
70 C | With implicit diffusion:
71 C | theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
72 C | salt* = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
73 C | (1 + dt * K * d_zz) theta[n] = theta*
74 C | (1 + dt * K * d_zz) salt[n] = salt*
75 C |
76 C *==========================================================*
77 C \ev
78 C !USES:
79 IMPLICIT NONE
80 C == Global variables ===
81 #include "SIZE.h"
82 #include "EEPARAMS.h"
83 #include "PARAMS.h"
84 #include "GRID.h"
85 #include "DYNVARS.h"
86 #ifdef ALLOW_MOM_COMMON
87 # include "MOM_VISC.h"
88 #endif
89 #ifdef ALLOW_CD_CODE
90 # include "CD_CODE_VARS.h"
91 #endif
92 #ifdef ALLOW_AUTODIFF_TAMC
93 # include "tamc.h"
94 # include "tamc_keys.h"
95 # include "FFIELDS.h"
96 # include "EOS.h"
97 # ifdef ALLOW_KPP
98 # include "KPP.h"
99 # endif
100 # ifdef ALLOW_PTRACERS
101 # include "PTRACERS_SIZE.h"
102 # include "PTRACERS_FIELDS.h"
103 # endif
104 # ifdef ALLOW_OBCS
105 # include "OBCS_PARAMS.h"
106 # include "OBCS_FIELDS.h"
107 # ifdef ALLOW_PTRACERS
108 # include "OBCS_PTRACERS.h"
109 # endif
110 # endif
111 # ifdef ALLOW_MOM_FLUXFORM
112 # include "MOM_FLUXFORM.h"
113 # endif
114 #endif /* ALLOW_AUTODIFF_TAMC */
115
116 C !CALLING SEQUENCE:
117 C DYNAMICS()
118 C |
119 C |-- CALC_EP_FORCING
120 C |
121 C |-- CALC_GRAD_PHI_SURF
122 C |
123 C |-- CALC_VISCOSITY
124 C |
125 C |-- MOM_CALC_3D_STRAIN
126 C |
127 C |-- CALC_EDDY_STRESS
128 C |
129 C |-- CALC_PHI_HYD
130 C |
131 C |-- MOM_FLUXFORM
132 C |
133 C |-- MOM_VECINV
134 C |
135 C |-- MOM_CALC_SMAG_3D
136 C |-- MOM_UV_SMAG_3D
137 C |
138 C |-- TIMESTEP
139 C |
140 C |-- MOM_U_IMPLICIT_R
141 C |-- MOM_V_IMPLICIT_R
142 C |
143 C |-- IMPLDIFF
144 C |
145 C |-- OBCS_APPLY_UV
146 C |
147 C |-- CALC_GW
148 C |
149 C |-- DIAGNOSTICS_FILL
150 C |-- DEBUG_STATS_RL
151
152 C !INPUT/OUTPUT PARAMETERS:
153 C == Routine arguments ==
154 C myTime :: Current time in simulation
155 C myIter :: Current iteration number in simulation
156 C myThid :: Thread number for this instance of the routine.
157 _RL myTime
158 INTEGER myIter
159 INTEGER myThid
160
161 C !FUNCTIONS:
162 #ifdef ALLOW_DIAGNOSTICS
163 LOGICAL DIAGNOSTICS_IS_ON
164 EXTERNAL DIAGNOSTICS_IS_ON
165 #endif
166
167 C !LOCAL VARIABLES:
168 C == Local variables
169 C fVer[UV] o fVer: Vertical flux term - note fVer
170 C is "pipelined" in the vertical
171 C so we need an fVer for each
172 C variable.
173 C phiHydC :: hydrostatic potential anomaly at cell center
174 C In z coords phiHyd is the hydrostatic potential
175 C (=pressure/rho0) anomaly
176 C In p coords phiHyd is the geopotential height anomaly.
177 C phiHydF :: hydrostatic potential anomaly at middle between 2 centers
178 C dPhiHydX,Y :: Gradient (X & Y directions) of hydrostatic potential anom.
179 C phiSurfX, :: gradient of Surface potential (Pressure/rho, ocean)
180 C phiSurfY or geopotential (atmos) in X and Y direction
181 C guDissip :: dissipation tendency (all explicit terms), u component
182 C gvDissip :: dissipation tendency (all explicit terms), v component
183 C KappaRU :: vertical viscosity for velocity U-component
184 C KappaRV :: vertical viscosity for velocity V-component
185 C iMin, iMax :: Ranges and sub-block indices on which calculations
186 C jMin, jMax are applied.
187 C bi, bj :: tile indices
188 C k :: current level index
189 C km1, kp1 :: index of level above (k-1) and below (k+1)
190 C kUp, kDown :: Index for interface above and below. kUp and kDown are
191 C are switched with k to be the appropriate index into fVerU,V
192 _RL fVerU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
193 _RL fVerV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
194 _RL phiHydF (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
195 _RL phiHydC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
196 _RL dPhiHydX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
197 _RL dPhiHydY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
198 _RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
199 _RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
200 _RL guDissip(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
201 _RL gvDissip(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
202 _RL KappaRU (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
203 _RL KappaRV (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
204 #ifdef ALLOW_SMAG_3D
205 _RL addDissU(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
206 _RL addDissV(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
207 #endif
208
209 INTEGER iMin, iMax
210 INTEGER jMin, jMax
211 INTEGER bi, bj
212 INTEGER i, j
213 INTEGER k, km1, kp1, kUp, kDown
214
215 #ifdef ALLOW_DIAGNOSTICS
216 LOGICAL dPhiHydDiagIsOn
217 _RL tmpFac
218 #endif /* ALLOW_DIAGNOSTICS */
219
220 C--- The algorithm...
221 C
222 C "Correction Step"
223 C =================
224 C Here we update the horizontal velocities with the surface
225 C pressure such that the resulting flow is either consistent
226 C with the free-surface evolution or the rigid-lid:
227 C U[n] = U* + dt x d/dx P
228 C V[n] = V* + dt x d/dy P
229 C
230 C "Calculation of Gs"
231 C ===================
232 C This is where all the accelerations and tendencies (ie.
233 C physics, parameterizations etc...) are calculated
234 C rho = rho ( theta[n], salt[n] )
235 C b = b(rho, theta)
236 C K31 = K31 ( rho )
237 C Gu[n] = Gu( u[n], v[n], wVel, b, ... )
238 C Gv[n] = Gv( u[n], v[n], wVel, b, ... )
239 C Gt[n] = Gt( theta[n], u[n], v[n], wVel, K31, ... )
240 C Gs[n] = Gs( salt[n], u[n], v[n], wVel, K31, ... )
241 C
242 C "Time-stepping" or "Prediction"
243 C ================================
244 C The models variables are stepped forward with the appropriate
245 C time-stepping scheme (currently we use Adams-Bashforth II)
246 C - For momentum, the result is always *only* a "prediction"
247 C in that the flow may be divergent and will be "corrected"
248 C later with a surface pressure gradient.
249 C - Normally for tracers the result is the new field at time
250 C level [n+1} *BUT* in the case of implicit diffusion the result
251 C is also *only* a prediction.
252 C - We denote "predictors" with an asterisk (*).
253 C U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] )
254 C V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] )
255 C theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
256 C salt[n+1] = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
257 C With implicit diffusion:
258 C theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
259 C salt* = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
260 C (1 + dt * K * d_zz) theta[n] = theta*
261 C (1 + dt * K * d_zz) salt[n] = salt*
262 C---
263 CEOP
264
265 #ifdef ALLOW_DEBUG
266 IF (debugMode) CALL DEBUG_ENTER( 'DYNAMICS', myThid )
267 #endif
268
269 #ifdef ALLOW_DIAGNOSTICS
270 dPhiHydDiagIsOn = .FALSE.
271 IF ( useDiagnostics )
272 & dPhiHydDiagIsOn = DIAGNOSTICS_IS_ON( 'Um_dPHdx', myThid )
273 & .OR. DIAGNOSTICS_IS_ON( 'Vm_dPHdy', myThid )
274 #endif
275
276 C-- Call to routine for calculation of Eliassen-Palm-flux-forced
277 C U-tendency, if desired:
278 #ifdef INCLUDE_EP_FORCING_CODE
279 CALL CALC_EP_FORCING(myThid)
280 #endif
281
282 #ifdef ALLOW_AUTODIFF_MONITOR_DIAG
283 CALL DUMMY_IN_DYNAMICS( myTime, myIter, myThid )
284 #endif
285
286 #ifdef ALLOW_AUTODIFF_TAMC
287 C-- HPF directive to help TAMC
288 CHPF$ INDEPENDENT
289 #endif /* ALLOW_AUTODIFF_TAMC */
290
291 DO bj=myByLo(myThid),myByHi(myThid)
292
293 #ifdef ALLOW_AUTODIFF_TAMC
294 C-- HPF directive to help TAMC
295 CHPF$ INDEPENDENT, NEW (fVerU,fVerV
296 CHPF$& ,phiHydF
297 CHPF$& ,KappaRU,KappaRV
298 CHPF$& )
299 #endif /* ALLOW_AUTODIFF_TAMC */
300
301 DO bi=myBxLo(myThid),myBxHi(myThid)
302
303 #ifdef ALLOW_AUTODIFF_TAMC
304 act1 = bi - myBxLo(myThid)
305 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
306 act2 = bj - myByLo(myThid)
307 max2 = myByHi(myThid) - myByLo(myThid) + 1
308 act3 = myThid - 1
309 max3 = nTx*nTy
310 act4 = ikey_dynamics - 1
311 idynkey = (act1 + 1) + act2*max1
312 & + act3*max1*max2
313 & + act4*max1*max2*max3
314 #endif /* ALLOW_AUTODIFF_TAMC */
315
316 C-- Set up work arrays with valid (i.e. not NaN) values
317 C These initial values do not alter the numerical results. They
318 C just ensure that all memory references are to valid floating
319 C point numbers. This prevents spurious hardware signals due to
320 C uninitialised but inert locations.
321
322 #ifdef ALLOW_AUTODIFF_TAMC
323 DO k=1,Nr
324 DO j=1-OLy,sNy+OLy
325 DO i=1-OLx,sNx+OLx
326 cph(
327 c-- need some re-initialisation here to break dependencies
328 cph)
329 gU(i,j,k,bi,bj) = 0. _d 0
330 gV(i,j,k,bi,bj) = 0. _d 0
331 ENDDO
332 ENDDO
333 ENDDO
334 #endif /* ALLOW_AUTODIFF_TAMC */
335 DO j=1-OLy,sNy+OLy
336 DO i=1-OLx,sNx+OLx
337 fVerU (i,j,1) = 0. _d 0
338 fVerU (i,j,2) = 0. _d 0
339 fVerV (i,j,1) = 0. _d 0
340 fVerV (i,j,2) = 0. _d 0
341 phiHydF (i,j) = 0. _d 0
342 phiHydC (i,j) = 0. _d 0
343 #ifndef INCLUDE_PHIHYD_CALCULATION_CODE
344 dPhiHydX(i,j) = 0. _d 0
345 dPhiHydY(i,j) = 0. _d 0
346 #endif
347 phiSurfX(i,j) = 0. _d 0
348 phiSurfY(i,j) = 0. _d 0
349 guDissip(i,j) = 0. _d 0
350 gvDissip(i,j) = 0. _d 0
351 #ifdef ALLOW_AUTODIFF_TAMC
352 phiHydLow(i,j,bi,bj) = 0. _d 0
353 # if (defined NONLIN_FRSURF) && (defined ALLOW_MOM_FLUXFORM)
354 # ifndef DISABLE_RSTAR_CODE
355 # ifndef ALLOW_AUTODIFF_OPENAD
356 dWtransC(i,j,bi,bj) = 0. _d 0
357 dWtransU(i,j,bi,bj) = 0. _d 0
358 dWtransV(i,j,bi,bj) = 0. _d 0
359 # endif
360 # endif
361 # endif
362 #endif
363 ENDDO
364 ENDDO
365
366 C-- Start computation of dynamics
367 iMin = 0
368 iMax = sNx+1
369 jMin = 0
370 jMax = sNy+1
371
372 #ifdef ALLOW_AUTODIFF_TAMC
373 CADJ STORE wVel (:,:,:,bi,bj) =
374 CADJ & comlev1_bibj, key=idynkey, byte=isbyte
375 #endif /* ALLOW_AUTODIFF_TAMC */
376
377 C-- Explicit part of the Surface Potential Gradient (add in TIMESTEP)
378 C (note: this loop will be replaced by CALL CALC_GRAD_ETA)
379 IF (implicSurfPress.NE.1.) THEN
380 CALL CALC_GRAD_PHI_SURF(
381 I bi,bj,iMin,iMax,jMin,jMax,
382 I etaN,
383 O phiSurfX,phiSurfY,
384 I myThid )
385 ENDIF
386
387 #ifdef ALLOW_AUTODIFF_TAMC
388 CADJ STORE uVel (:,:,:,bi,bj) = comlev1_bibj, key=idynkey, byte=isbyte
389 CADJ STORE vVel (:,:,:,bi,bj) = comlev1_bibj, key=idynkey, byte=isbyte
390 #ifdef ALLOW_KPP
391 CADJ STORE KPPviscAz (:,:,:,bi,bj)
392 CADJ & = comlev1_bibj, key=idynkey, byte=isbyte
393 #endif /* ALLOW_KPP */
394 #endif /* ALLOW_AUTODIFF_TAMC */
395
396 #if (defined INCLUDE_CALC_DIFFUSIVITY_CALL) && !(defined ALLOW_AUTODIFF)
397 IF ( .NOT.momViscosity ) THEN
398 #endif /* INCLUDE_CALC_DIFFUSIVITY_CALL and not ALLOW_AUTODIFF */
399 DO k=1,Nr
400 DO j=1-OLy,sNy+OLy
401 DO i=1-OLx,sNx+OLx
402 KappaRU(i,j,k) = 0. _d 0
403 KappaRV(i,j,k) = 0. _d 0
404 ENDDO
405 ENDDO
406 ENDDO
407 #ifdef INCLUDE_CALC_DIFFUSIVITY_CALL
408 C-- Calculate the total vertical viscosity
409 #ifdef ALLOW_AUTODIFF
410 IF ( momViscosity ) THEN
411 #else
412 ELSE
413 #endif
414 CALL CALC_VISCOSITY(
415 I bi,bj, iMin,iMax,jMin,jMax,
416 O KappaRU, KappaRV,
417 I myThid )
418 ENDIF
419 #endif /* INCLUDE_CALC_DIFFUSIVITY_CALL */
420
421 #ifdef ALLOW_SMAG_3D
422 IF ( useSmag3D ) THEN
423 CALL MOM_CALC_3D_STRAIN(
424 O str11(1-OLx,1-OLy,1,bi,bj), str22(1-OLx,1-OLy,1,bi,bj),
425 O str33(1-OLx,1-OLy,1,bi,bj), str12(1-OLx,1-OLy,1,bi,bj),
426 O str13(1-OLx,1-OLy,1,bi,bj), str23(1-OLx,1-OLy,1,bi,bj),
427 I bi, bj, myThid )
428 ENDIF
429 #endif /* ALLOW_SMAG_3D */
430
431 #ifdef ALLOW_AUTODIFF_TAMC
432 CADJ STORE KappaRU(:,:,:)
433 CADJ & = comlev1_bibj, key=idynkey, byte=isbyte
434 CADJ STORE KappaRV(:,:,:)
435 CADJ & = comlev1_bibj, key=idynkey, byte=isbyte
436 #endif /* ALLOW_AUTODIFF_TAMC */
437
438 #ifdef ALLOW_OBCS
439 C-- For Stevens boundary conditions velocities need to be extrapolated
440 C (copied) to a narrow strip outside the domain
441 IF ( useOBCS ) THEN
442 CALL OBCS_COPY_UV_N(
443 U uVel(1-OLx,1-OLy,1,bi,bj),
444 U vVel(1-OLx,1-OLy,1,bi,bj),
445 I Nr, bi, bj, myThid )
446 ENDIF
447 #endif /* ALLOW_OBCS */
448
449 #ifdef ALLOW_EDDYPSI
450 CALL CALC_EDDY_STRESS(bi,bj,myThid)
451 #endif
452
453 C-- Start of dynamics loop
454 DO k=1,Nr
455
456 C-- km1 Points to level above k (=k-1)
457 C-- kup Cycles through 1,2 to point to layer above
458 C-- kDown Cycles through 2,1 to point to current layer
459
460 km1 = MAX(1,k-1)
461 kp1 = MIN(k+1,Nr)
462 kup = 1+MOD(k+1,2)
463 kDown= 1+MOD(k,2)
464
465 #ifdef ALLOW_AUTODIFF_TAMC
466 kkey = (idynkey-1)*Nr + k
467 c
468 CADJ STORE totPhiHyd (:,:,k,bi,bj)
469 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
470 CADJ STORE phiHydLow (:,:,bi,bj)
471 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
472 CADJ STORE theta (:,:,k,bi,bj)
473 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
474 CADJ STORE salt (:,:,k,bi,bj)
475 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
476 CADJ STORE gT(:,:,k,bi,bj)
477 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
478 CADJ STORE gS(:,:,k,bi,bj)
479 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
480 # ifdef NONLIN_FRSURF
481 cph-test
482 CADJ STORE phiHydC (:,:)
483 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
484 CADJ STORE phiHydF (:,:)
485 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
486 CADJ STORE guDissip (:,:)
487 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
488 CADJ STORE gvDissip (:,:)
489 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
490 CADJ STORE fVerU (:,:,:)
491 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
492 CADJ STORE fVerV (:,:,:)
493 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
494 CADJ STORE gU(:,:,k,bi,bj)
495 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
496 CADJ STORE gV(:,:,k,bi,bj)
497 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
498 # ifndef ALLOW_ADAMSBASHFORTH_3
499 CADJ STORE guNm1(:,:,k,bi,bj)
500 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
501 CADJ STORE gvNm1(:,:,k,bi,bj)
502 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
503 # else
504 CADJ STORE guNm(:,:,k,bi,bj,1)
505 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
506 CADJ STORE guNm(:,:,k,bi,bj,2)
507 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
508 CADJ STORE gvNm(:,:,k,bi,bj,1)
509 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
510 CADJ STORE gvNm(:,:,k,bi,bj,2)
511 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
512 # endif
513 # ifdef ALLOW_CD_CODE
514 CADJ STORE uNM1(:,:,k,bi,bj)
515 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
516 CADJ STORE vNM1(:,:,k,bi,bj)
517 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
518 CADJ STORE uVelD(:,:,k,bi,bj)
519 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
520 CADJ STORE vVelD(:,:,k,bi,bj)
521 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
522 # endif
523 # endif
524 # ifdef ALLOW_DEPTH_CONTROL
525 CADJ STORE fVerU (:,:,:)
526 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
527 CADJ STORE fVerV (:,:,:)
528 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
529 # endif
530 #endif /* ALLOW_AUTODIFF_TAMC */
531
532 C-- Integrate hydrostatic balance for phiHyd with BC of phiHyd(z=0)=0
533 IF ( implicitIntGravWave ) THEN
534 CALL CALC_PHI_HYD(
535 I bi,bj,iMin,iMax,jMin,jMax,k,
536 I gT, gS,
537 U phiHydF,
538 O phiHydC, dPhiHydX, dPhiHydY,
539 I myTime, myIter, myThid )
540 ELSE
541 CALL CALC_PHI_HYD(
542 I bi,bj,iMin,iMax,jMin,jMax,k,
543 I theta, salt,
544 U phiHydF,
545 O phiHydC, dPhiHydX, dPhiHydY,
546 I myTime, myIter, myThid )
547 ENDIF
548 #ifdef ALLOW_DIAGNOSTICS
549 IF ( dPhiHydDiagIsOn ) THEN
550 tmpFac = -1. _d 0
551 CALL DIAGNOSTICS_SCALE_FILL( dPhiHydX, tmpFac, 1,
552 & 'Um_dPHdx', k, 1, 2, bi, bj, myThid )
553 CALL DIAGNOSTICS_SCALE_FILL( dPhiHydY, tmpFac, 1,
554 & 'Vm_dPHdy', k, 1, 2, bi, bj, myThid )
555 ENDIF
556 #endif /* ALLOW_DIAGNOSTICS */
557
558 C-- Calculate accelerations in the momentum equations (gU, gV, ...)
559 C and step forward storing the result in gU, gV, etc...
560 IF ( momStepping ) THEN
561 #ifdef ALLOW_AUTODIFF_TAMC
562 # ifdef NONLIN_FRSURF
563 # if (defined ALLOW_MOM_FLUXFORM) && !(defined DISABLE_RSTAR_CODE)
564 CADJ STORE dWtransC(:,:,bi,bj)
565 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
566 CADJ STORE dWtransU(:,:,bi,bj)
567 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
568 CADJ STORE dWtransV(:,:,bi,bj)
569 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
570 # endif
571 CADJ STORE fVerU(:,:,:)
572 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
573 CADJ STORE fVerV(:,:,:)
574 CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte
575 # endif /* NONLIN_FRSURF */
576 #endif /* ALLOW_AUTODIFF_TAMC */
577 IF (.NOT. vectorInvariantMomentum) THEN
578 #ifdef ALLOW_MOM_FLUXFORM
579 CALL MOM_FLUXFORM(
580 I bi,bj,k,iMin,iMax,jMin,jMax,
581 I KappaRU, KappaRV,
582 U fVerU(1-OLx,1-OLy,kUp), fVerV(1-OLx,1-OLy,kUp),
583 O fVerU(1-OLx,1-OLy,kDown), fVerV(1-OLx,1-OLy,kDown),
584 O guDissip, gvDissip,
585 I myTime, myIter, myThid)
586 #endif
587 ELSE
588 #ifdef ALLOW_MOM_VECINV
589 CALL MOM_VECINV(
590 I bi,bj,k,iMin,iMax,jMin,jMax,
591 I KappaRU, KappaRV,
592 I fVerU(1-OLx,1-OLy,kUp), fVerV(1-OLx,1-OLy,kUp),
593 O fVerU(1-OLx,1-OLy,kDown), fVerV(1-OLx,1-OLy,kDown),
594 O guDissip, gvDissip,
595 I myTime, myIter, myThid)
596 #endif
597 ENDIF
598
599 #ifdef ALLOW_SMAG_3D
600 IF ( useSmag3D ) THEN
601 CALL MOM_CALC_SMAG_3D(
602 I str11(1-OLx,1-OLy,1,bi,bj), str22(1-OLx,1-OLy,1,bi,bj),
603 I str33(1-OLx,1-OLy,1,bi,bj), str12(1-OLx,1-OLy,1,bi,bj),
604 I str13(1-OLx,1-OLy,1,bi,bj), str23(1-OLx,1-OLy,1,bi,bj),
605 O viscAh3d_00(1-OLx,1-OLy,1,bi,bj),
606 O viscAh3d_12(1-OLx,1-OLy,1,bi,bj),
607 O viscAh3d_13(1-OLx,1-OLy,1,bi,bj),
608 O viscAh3d_23(1-OLx,1-OLy,1,bi,bj),
609 I smag3D_hLsC, smag3D_hLsW, smag3D_hLsS, smag3D_hLsZ,
610 I k, bi, bj, myThid )
611 CALL MOM_UV_SMAG_3D(
612 I str11(1-OLx,1-OLy,1,bi,bj), str22(1-OLx,1-OLy,1,bi,bj),
613 I str12(1-OLx,1-OLy,1,bi,bj),
614 I str13(1-OLx,1-OLy,1,bi,bj), str23(1-OLx,1-OLy,1,bi,bj),
615 I viscAh3d_00(1-OLx,1-OLy,1,bi,bj),
616 I viscAh3d_12(1-OLx,1-OLy,1,bi,bj),
617 I viscAh3d_13(1-OLx,1-OLy,1,bi,bj),
618 I viscAh3d_23(1-OLx,1-OLy,1,bi,bj),
619 O addDissU, addDissV,
620 I k, bi, bj, myThid )
621 DO j=1-OLy,sNy+OLy
622 DO i=1-OLx,sNx+OLx
623 guDissip(i,j) = guDissip(i,j) + addDissU(i,j)
624 gvDissip(i,j) = gvDissip(i,j) + addDissV(i,j)
625 ENDDO
626 ENDDO
627 ENDIF
628 #endif /* ALLOW_SMAG_3D */
629
630 CALL TIMESTEP(
631 I bi,bj,iMin,iMax,jMin,jMax,k,
632 I dPhiHydX,dPhiHydY, phiSurfX, phiSurfY,
633 I guDissip, gvDissip,
634 I myTime, myIter, myThid)
635
636 ENDIF
637
638 C-- end of dynamics k loop (1:Nr)
639 ENDDO
640
641 C-- Implicit Vertical advection & viscosity
642 #if (defined (INCLUDE_IMPLVERTADV_CODE) && \
643 defined (ALLOW_MOM_COMMON) && !(defined ALLOW_AUTODIFF_TAMC))
644 IF ( momImplVertAdv ) THEN
645 CALL MOM_U_IMPLICIT_R( kappaRU,
646 I bi, bj, myTime, myIter, myThid )
647 CALL MOM_V_IMPLICIT_R( kappaRV,
648 I bi, bj, myTime, myIter, myThid )
649 ELSEIF ( implicitViscosity ) THEN
650 #else /* INCLUDE_IMPLVERTADV_CODE */
651 IF ( implicitViscosity ) THEN
652 #endif /* INCLUDE_IMPLVERTADV_CODE */
653 #ifdef ALLOW_AUTODIFF_TAMC
654 CADJ STORE KappaRU(:,:,:) = comlev1_bibj , key=idynkey, byte=isbyte
655 CADJ STORE gU(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
656 #endif /* ALLOW_AUTODIFF_TAMC */
657 CALL IMPLDIFF(
658 I bi, bj, iMin, iMax, jMin, jMax,
659 I -1, KappaRU, recip_hFacW(1-OLx,1-OLy,1,bi,bj),
660 U gU,
661 I myThid )
662 #ifdef ALLOW_AUTODIFF_TAMC
663 CADJ STORE KappaRV(:,:,:) = comlev1_bibj , key=idynkey, byte=isbyte
664 CADJ STORE gV(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
665 #endif /* ALLOW_AUTODIFF_TAMC */
666 CALL IMPLDIFF(
667 I bi, bj, iMin, iMax, jMin, jMax,
668 I -2, KappaRV, recip_hFacS(1-OLx,1-OLy,1,bi,bj),
669 U gV,
670 I myThid )
671 ENDIF
672
673 #ifdef ALLOW_OBCS
674 C-- Apply open boundary conditions
675 IF ( useOBCS ) THEN
676 C-- but first save intermediate velocities to be used in the
677 C next time step for the Stevens boundary conditions
678 CALL OBCS_SAVE_UV_N(
679 I bi, bj, iMin, iMax, jMin, jMax, 0,
680 I gU, gV, myThid )
681 CALL OBCS_APPLY_UV( bi, bj, 0, gU, gV, myThid )
682 ENDIF
683 #endif /* ALLOW_OBCS */
684
685 #ifdef ALLOW_CD_CODE
686 IF (implicitViscosity.AND.useCDscheme) THEN
687 #ifdef ALLOW_AUTODIFF_TAMC
688 CADJ STORE vVelD(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
689 #endif /* ALLOW_AUTODIFF_TAMC */
690 CALL IMPLDIFF(
691 I bi, bj, iMin, iMax, jMin, jMax,
692 I 0, KappaRU, recip_hFacW(1-OLx,1-OLy,1,bi,bj),
693 U vVelD,
694 I myThid )
695 #ifdef ALLOW_AUTODIFF_TAMC
696 CADJ STORE uVelD(:,:,:,bi,bj) = comlev1_bibj , key=idynkey, byte=isbyte
697 #endif /* ALLOW_AUTODIFF_TAMC */
698 CALL IMPLDIFF(
699 I bi, bj, iMin, iMax, jMin, jMax,
700 I 0, KappaRV, recip_hFacS(1-OLx,1-OLy,1,bi,bj),
701 U uVelD,
702 I myThid )
703 ENDIF
704 #endif /* ALLOW_CD_CODE */
705 C-- End implicit Vertical advection & viscosity
706
707 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
708
709 #ifdef ALLOW_NONHYDROSTATIC
710 C-- Step forward W field in N-H algorithm
711 IF ( nonHydrostatic ) THEN
712 #ifdef ALLOW_DEBUG
713 IF (debugMode) CALL DEBUG_CALL('CALC_GW', myThid )
714 #endif
715 CALL TIMER_START('CALC_GW [DYNAMICS]',myThid)
716 CALL CALC_GW(
717 I bi,bj, KappaRU, KappaRV,
718 I myTime, myIter, myThid )
719 ENDIF
720 IF ( nonHydrostatic.OR.implicitIntGravWave )
721 & CALL TIMESTEP_WVEL( bi,bj, myTime, myIter, myThid )
722 IF ( nonHydrostatic )
723 & CALL TIMER_STOP ('CALC_GW [DYNAMICS]',myThid)
724 #endif
725
726 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
727
728 C- end of bi,bj loops
729 ENDDO
730 ENDDO
731
732 #ifdef ALLOW_OBCS
733 IF (useOBCS) THEN
734 CALL OBCS_EXCHANGES( myThid )
735 ENDIF
736 #endif
737
738 Cml(
739 C In order to compare the variance of phiHydLow of a p/z-coordinate
740 C run with etaH of a z/p-coordinate run the drift of phiHydLow
741 C has to be removed by something like the following subroutine:
742 C CALL REMOVE_MEAN_RL( 1, phiHydLow, maskInC, maskInC, rA, drF,
743 C & 'phiHydLow', myTime, myThid )
744 Cml)
745
746 #ifdef ALLOW_DIAGNOSTICS
747 IF ( useDiagnostics ) THEN
748
749 CALL DIAGNOSTICS_FILL(totPhihyd,'PHIHYD ',0,Nr,0,1,1,myThid)
750 CALL DIAGNOSTICS_FILL(phiHydLow,'PHIBOT ',0, 1,0,1,1,myThid)
751
752 tmpFac = 1. _d 0
753 CALL DIAGNOSTICS_SCALE_FILL(totPhihyd,tmpFac,2,
754 & 'PHIHYDSQ',0,Nr,0,1,1,myThid)
755
756 CALL DIAGNOSTICS_SCALE_FILL(phiHydLow,tmpFac,2,
757 & 'PHIBOTSQ',0, 1,0,1,1,myThid)
758
759 ENDIF
760 #endif /* ALLOW_DIAGNOSTICS */
761
762 #ifdef ALLOW_DEBUG
763 IF ( debugLevel .GE. debLevD ) THEN
764 CALL DEBUG_STATS_RL(1,EtaN,'EtaN (DYNAMICS)',myThid)
765 CALL DEBUG_STATS_RL(Nr,uVel,'Uvel (DYNAMICS)',myThid)
766 CALL DEBUG_STATS_RL(Nr,vVel,'Vvel (DYNAMICS)',myThid)
767 CALL DEBUG_STATS_RL(Nr,wVel,'Wvel (DYNAMICS)',myThid)
768 CALL DEBUG_STATS_RL(Nr,theta,'Theta (DYNAMICS)',myThid)
769 CALL DEBUG_STATS_RL(Nr,salt,'Salt (DYNAMICS)',myThid)
770 CALL DEBUG_STATS_RL(Nr,gU,'Gu (DYNAMICS)',myThid)
771 CALL DEBUG_STATS_RL(Nr,gV,'Gv (DYNAMICS)',myThid)
772 CALL DEBUG_STATS_RL(Nr,gT,'Gt (DYNAMICS)',myThid)
773 CALL DEBUG_STATS_RL(Nr,gS,'Gs (DYNAMICS)',myThid)
774 #ifndef ALLOW_ADAMSBASHFORTH_3
775 CALL DEBUG_STATS_RL(Nr,guNm1,'GuNm1 (DYNAMICS)',myThid)
776 CALL DEBUG_STATS_RL(Nr,gvNm1,'GvNm1 (DYNAMICS)',myThid)
777 CALL DEBUG_STATS_RL(Nr,gtNm1,'GtNm1 (DYNAMICS)',myThid)
778 CALL DEBUG_STATS_RL(Nr,gsNm1,'GsNm1 (DYNAMICS)',myThid)
779 #endif
780 ENDIF
781 #endif
782
783 #ifdef DYNAMICS_GUGV_EXCH_CHECK
784 C- jmc: For safety checking only: This Exchange here should not change
785 C the solution. If solution changes, it means something is wrong,
786 C but it does not mean that it is less wrong with this exchange.
787 IF ( debugLevel .GE. debLevE ) THEN
788 CALL EXCH_UV_XYZ_RL(gU,gV,.TRUE.,myThid)
789 ENDIF
790 #endif
791
792 #ifdef ALLOW_DEBUG
793 IF (debugMode) CALL DEBUG_LEAVE( 'DYNAMICS', myThid )
794 #endif
795
796 RETURN
797 END

  ViewVC Help
Powered by ViewVC 1.1.22