ROMS
Loading...
Searching...
No Matches
hmixing.F
Go to the documentation of this file.
1#include "cppdefs.h"
2#undef NEW_CODE
3 MODULE hmixing_mod
4
5#if (defined DIFF_3DCOEF || defined VISC_3DCOEF) && defined SOLVE3D
6!
7!git $Id$
8!================================================== Hernan G. Arango ===
9! Copyright (c) 2002-2025 The ROMS Group !
10! Licensed under a MIT/X style license !
11! See License_ROMS.md !
12!=======================================================================
13! !
14! This routine computes time-dependent 3D horizontal mixing !
15! coefficients. !
16! !
17! References: !
18! !
19! Smagorinsky, J, 1963: General circulation experiments with !
20! the primitive equations: I. The basic experiment, Mon. !
21! Wea. Rev., 91, 99-164. !
22! !
23! Holland, W.R., J.C. Chow, and F.O. Bryan, 1998: Application !
24! of a Third-Order Upwind Scheme in the NCAR Ocean Model, J. !
25! Climate, 11, 1487-1493. !
26! !
27! Webb, D.J., B.A. De Cuevas, and C.S. Richmond, 1998: Improved !
28! Advection Schemes for Ocean Models, J. Atmos. Oceanic !
29! Technol., 15, 1171-1187. !
30! !
31! Griffies, S.M. and R.W. Hallberg, 2000: Biharmonic Friction !
32! with a Smagorinsky-like Viscosity for Use in Large-Scale !
33! Eddy-Permitting Ocean Models, Monthly Weather Review, 128, !
34! 2935-2946. !
35! !
36! Marchesiello, P., L. Debreu, and Xavien Couvelard, 2008: !
37! Spurious diapycnal mixing in terrain-following coordinate !
38! models" advection problem and solutions, DRAFT. !
39! !
40! This routine was adapted from a routine provided by Patrick !
41! Marchiesello (April 2008). !
42! !
43!=======================================================================
44!
45 implicit none
46
47 PRIVATE
48 PUBLIC :: hmixing
49
50 CONTAINS
51!
52!***********************************************************************
53 SUBROUTINE hmixing (ng, tile)
54!***********************************************************************
55!
56 USE mod_param
57 USE mod_grid
58 USE mod_mixing
59 USE mod_ocean
60 USE mod_stepping
61!
62! Imported variable declarations.
63!
64 integer, intent(in) :: ng, tile
65!
66! Local variable declarations.
67!
68 character (len=*), parameter :: MyFile = &
69 & __FILE__
70!
71# include "tile.h"
72!
73# ifdef PROFILE
74 CALL wclock_on (ng, inlm, 28, __line__, myfile)
75# endif
76 CALL hmixing_tile (ng, tile, &
77 & lbi, ubi, lbj, ubj, &
78 & imins, imaxs, jmins, jmaxs, &
79 & nrhs(ng), &
80# ifdef MASKING
81 & grid(ng) % rmask, &
82 & grid(ng) % umask, &
83 & grid(ng) % vmask, &
84# endif
85 & grid(ng) % pm, &
86 & grid(ng) % pn, &
87 & grid(ng) % omn, &
88 & grid(ng) % om_u, &
89 & grid(ng) % on_v, &
90 & grid(ng) % Hz, &
91 & grid(ng) % z_r, &
92# ifdef DIFF_3DCOEF
93 & mixing(ng) % Hdiffusion, &
94# ifdef TS_U3ADV_SPLIT
95 & mixing(ng) % diff3d_u, &
96 & mixing(ng) % diff3d_v, &
97# else
98 & mixing(ng) % diff3d_r, &
99# endif
100# endif
101# ifdef VISC_3DCOEF
102 & mixing(ng) % Hviscosity, &
103# ifdef UV_U3ADV_SPLIT
104 & mixing(ng) % Uvis3d_r, &
105 & mixing(ng) % Vvis3d_r, &
106# else
107 & mixing(ng) % visc3d_r, &
108# endif
109# endif
110 & ocean(ng) % u, &
111 & ocean(ng) % v)
112# ifdef PROFILE
113 CALL wclock_off (ng, inlm, 28, __line__, myfile)
114# endif
115!
116 RETURN
117 END SUBROUTINE hmixing
118!
119!***********************************************************************
120 SUBROUTINE hmixing_tile (ng, tile, &
121 & LBi, UBi, LBj, UBj, &
122 & IminS, ImaxS, JminS, JmaxS, &
123 & nrhs, &
124# ifdef MASKING
125 & rmask, umask, vmask, &
126# endif
127 & pm, pn, omn, om_u, on_v, &
128 & Hz, z_r, &
129# ifdef DIFF_3DCOEF
130 & Hdiffusion, &
131# ifdef TS_U3ADV_SPLIT
132 & diff3d_u, diff3d_v, &
133# else
134 & diff3d_r, &
135# endif
136# endif
137# ifdef VISC_3DCOEF
138 & Hviscosity, &
139# ifdef UV_U3ADV_SPLIT
140 & Uvis3d_r, Vvis3d_r, &
141# else
142 & visc3d_r, &
143# endif
144# endif
145 & u, v)
146!***********************************************************************
147!
148 USE mod_param
149 USE mod_ncparam
150 USE mod_scalars
151!
153# ifdef DISTRIBUTE
155# endif
156!
157! Imported variable declarations.
158!
159 integer, intent(in) :: ng, tile
160 integer, intent(in) :: LBi, UBi, LBj, UBj
161 integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
162 integer, intent(in) :: nrhs
163!
164# ifdef ASSUMED_SHAPE
165# ifdef MASKING
166 real(r8), intent(in) :: rmask(LBi:,LBj:)
167 real(r8), intent(in) :: umask(LBi:,LBj:)
168 real(r8), intent(in) :: vmask(LBi:,LBj:)
169# endif
170# ifdef DIFF_3DCOEF
171 real(r8), intent(in) :: Hdiffusion(LBi:,LBj:)
172# endif
173# ifdef VISC_3DCOEF
174 real(r8), intent(in) :: Hviscosity(LBi:,LBj:)
175# endif
176 real(r8), intent(in) :: Hz(LBi:,LBj:,:)
177 real(r8), intent(in) :: pm(LBi:,LBj:)
178 real(r8), intent(in) :: pn(LBi:,LBj:)
179 real(r8), intent(in) :: omn(LBi:,LBj:)
180 real(r8), intent(in) :: om_u(LBi:,LBj:)
181 real(r8), intent(in) :: on_v(LBi:,LBj:)
182 real(r8), intent(in) :: u(LBi:,LBj:,:,:)
183 real(r8), intent(in) :: v(LBi:,LBj:,:,:)
184 real(r8), intent(in) :: z_r(LBi:,LBj:,:)
185# ifdef DIFF_3DCOEF
186# ifdef TS_U3ADV_SPLIT
187 real(r8), intent(out) :: diff3d_u(LBi:,LBj:,:)
188 real(r8), intent(out) :: diff3d_v(LBi:,LBj:,:)
189# else
190 real(r8), intent(out) :: diff3d_r(LBi:,LBj:,:)
191# endif
192# endif
193# ifdef VISC_3DCOEF
194# ifdef UV_U3ADV_SPLIT
195 real(r8), intent(out) :: Uvis3d_r(LBi:,LBj:,:)
196 real(r8), intent(out) :: Vvis3d_r(LBi:,LBj:,:)
197# else
198 real(r8), intent(out) :: visc3d_r(LBi:,LBj:,:)
199# endif
200# endif
201
202# else
203
204# ifdef MASKING
205 real(r8), intent(in) :: rmask(LBi:UBi,LBj:UBj)
206 real(r8), intent(in) :: umask(LBi:UBi,LBj:UBj)
207 real(r8), intent(in) :: vmask(LBi:UBi,LBj:UBj)
208# endif
209# ifdef DIFF_3DCOEF
210 real(r8), intent(in) :: Hdiffusion(LBi:UBi,LBj:UBj)
211# endif
212# ifdef VISC_3DCOEF
213 real(r8), intent(in) :: Hviscosity(LBi:UBi,LBj:UBj)
214# endif
215 real(r8), intent(in) :: Hz(LBi:UBi,LBj:UBj,N(ng))
216 real(r8), intent(in) :: pm(LBi:UBi,LBj:UBj)
217 real(r8), intent(in) :: pn(LBi:UBi,LBj:UBj)
218 real(r8), intent(in) :: omn(LBi:UBi,LBj:UBj)
219 real(r8), intent(in) :: om_u(LBi:UBi,LBj:UBj)
220 real(r8), intent(in) :: on_v(LBi:UBi,LBj:UBj)
221 real(r8), intent(in) :: u(LBi:UBi,LBj:UBj,N(ng),2)
222 real(r8), intent(in) :: v(LBi:UBi,LBj:UBj,N(ng),2)
223 real(r8), intent(in) :: z_r(LBi:UBi,LBj:UBj,N(ng))
224# ifdef DIFF_3DCOEF
225# ifdef TS_U3ADV_SPLIT
226 real(r8), intent(out) :: diff3d_u(LBi:UBi,LBj:UBj,N(ng))
227 real(r8), intent(out) :: diff3d_v(LBi:UBi,LBj:UBj,N(ng))
228# else
229 real(r8), intent(out) :: diff3d_r(LBi:UBi,LBj:UBj,N(ng))
230# endif
231# endif
232# ifdef VISC_3DCOEF
233# ifdef UV_U3ADV_SPLIT
234 real(r8), intent(out) :: Uvis3d_r(LBi:UBi,LBj:UBj,N(ng))
235 real(r8), intent(out) :: Vvis3d_r(LBi:UBi,LBj:UBj,N(ng))
236# else
237 real(r8), intent(out) :: visc3d_r(LBi:UBi,LBj:UBj,N(ng))
238# endif
239# endif
240# endif
241!
242! Local variable declarations.
243!
244 integer :: i, j, k
245
246 real(r8), parameter :: SmagorCoef = 0.1_r8
247 real(r8), parameter :: PecletCoef = 1.0_r8 / 12.0_r8
248
249 real(r8) :: DefRate, cff, clip_diff, clip_scale
250
251# include "set_bounds.h"
252
253# if defined UV_SMAGORINSKY || defined UV_U3ADV_SPLIT || \
254 defined ts_smagorinsky
255!
256!-----------------------------------------------------------------------
257! Compute velocity dependent, Smagorinsky (1963) horizontal
258! viscosity coefficients. This are based on the local deformation
259! rate, DefRate, which has a horizontal tension and horizontal
260! shearing strain terms:
261!
262! DefRate = SQRT [ (du/dx)^2 + (dvdy)^2 + 0.5 * (dvdx + dudy)^2 ]
263! tension shearing strain
264!
265! The harmonic viscosity coefficient is computed as:
266!
267! Asmag = SmagorCoef * dx * dy * DefRate
268!
269! The biharmonic viscosity coefficient follows Griffies and Hallberg
270! (2000) formulation:
271!
272! Bsmag = PecletCoef * (dx * dy)^2 * DefRate
273!
274# ifdef TS_SMAGORINSKY
275! It is not clear physically how to compute the Smagorinsky tracer
276! diffusion from momentum viscosity. The diffusivity is usually
277! computed as a time independent constant which is a function of
278! grid space that it is smaller that the viscosity (Griffies and
279! Hallberg, 2000).
280# endif
281!-----------------------------------------------------------------------
282!
283! Compute viscosity and clipping scale.
284!
285 clip_scale=0.01_r8*grdmax(ng)**3
286
287 DO k=1,n(ng)
288 DO j=jstrv-1,jend
289 DO i=istru-1,iend
290!
291! Compute local deformation rate at RHO-points.
292!
293 defrate=sqrt(((u(i+1,j,k,nrhs)- &
294 u(i ,j,k,nrhs))*pm(i,j))**2+ &
295 & ((v(i,j+1,k,nrhs)- &
296 & v(i,j ,k,nrhs))*pn(i,j))**2+ &
297 & 0.5_r8*(0.25_r8*pn(i,j)* &
298 & (u(i ,j+1,k,nrhs)+ &
299 & u(i+1,j+1,k,nrhs)- &
300 & u(i ,j-1,k,nrhs)- &
301 & u(i+1,j-1,k,nrhs))+ &
302 & 0.25_r8*pm(i,j)* &
303 & (v(i+1,j ,k,nrhs)+ &
304 & v(i+1,j+1,k,nrhs)- &
305 & v(i-1,j ,k,nrhs)- &
306 & v(i-1,j+1,k,nrhs)))**2)
307
308# ifdef UV_SMAGORINSKY
309!
310! Smagorinsky viscosity.
311!
312# if defined UV_VIS2
313 visc3d_r(i,j,k)=hviscosity(i,j)+ &
314 & smagorcoef*omn(i,j)*defrate
315# elif defined UV_VIS4
316 visc3d_r(i,j,k)=hviscosity(i,j)+ &
317 & pecletcoef*(omn(i,j)**2)*defrate
318# ifdef MIX_GEO_UV
319 visc3d_r(i,j,k)=min(clip_scale, visc3d_r(i,j,k))
320# endif
321 visc3d_r(i,j,k)=sqrt(visc3d_r(i,j,k))
322# endif
323# ifdef MASKING
324 visc3d_r(i,j,k)=visc3d_r(i,j,k)*rmask(i,j)
325# endif
326
327# elif defined UV_U3ADV_SPLIT
328!
329! Compute momentum horizontal viscosity coefficient [SQRT(m4/s)]
330! as the sum of the biharmonic viscosity term and a diapycnal
331! hyperdiffusive term resulting from the splitting into advective
332! and diffusive components the 3rd-order upstream bias horizontal
333! advection.
334!
335 cff=0.5_r8*pm(i,j)* &
336 & abs(u(i,j,k,nrhs)+u(i+1,j,k,nrhs))
337 uvis3d_r(i,j,k)=hviscosity(i,j)+ &
338 & pecletcoef*(omn(i,j)**2)* &
339 & max(defrate, cff)
340# ifdef MIX_GEO_UV
341 uvis3d_r(i,j,k)=min(clip_scale, uvis3d_r(i,j,k))
342# endif
343 uvis3d_r(i,j,k)=sqrt(uvis3d_r(i,j,k))
344# ifdef MASKING
345 uvis3d_r(i,j,k)=uvis3d_r(i,j,k)*rmask(i,j)
346# endif
347!
348 cff=0.5_r8*pn(i,j)* &
349 & abs(v(i,j,k,nrhs)+v(i,j+1,k,nrhs))
350 vvis3d_r(i,j,k)=hviscosity(i,j)+ &
351 & pecletcoef*(omn(i,j)**2)* &
352 & max(defrate, cff)
353# ifdef MIX_GEO_UV
354 vvis3d_r(i,j,k)=min(clip_scale, uvis3d_r(i,j,k))
355# endif
356 vvis3d_r(i,j,k)=sqrt(vvis3d_r(i,j,k))
357# ifdef MASKING
358 vvis3d_r(i,j,k)=vvis3d_r(i,j,k)*rmask(i,j)
359# endif
360# endif
361
362# ifdef TS_SMAGORINSKY
363!
364! Smagorinsky diffusion at RHO-points.
365!
366# ifdef TS_DIF2
367 diff3d_r(i,j,k)=hdiffusion(i,j)+ &
368 & smagorcoef*omn(i,j)*defrate
369# elif defined TS_DIF4
370 diff3d_r(i,j,k)=hdiffusion(i,j)+ &
371 & pecletcoef*(omn(i,j)**2)*defrate
372# ifdef MIX_GEO_TS
373 diff3d_r(i,j,k)=min(clip_scale, diff3d_r(i,j,k))
374# endif
375 diff3d_r(i,j,k)=sqrt(diff3d_r(i,j,k))
376# endif
377# ifdef MASKING
378 diff3d_r(i,j,k)=diff3d_r(i,j,k)*rmask(i,j)
379# endif
380# endif
381 END DO
382 END DO
383 END DO
384# endif
385
386# if defined TS_U3ADV_SPLIT
387!
388!-----------------------------------------------------------------------
389! Compute tracer horizontal diffusion coefficient as the sum of the
390! biharmonic diffusion term and a diapycnal hyperdiffusion term
391! resulting from the splitting into advective and diffusive components
392! the 3rd-order upstream bias horizontal advection.
393!-----------------------------------------------------------------------
394!
395! Following Holland et al. (1998) and Webb et al. (1998), the 3rd-order
396! upstream bias horizontal advection can be splitted into advective and
397! diffusive terms. The advective term is just the standard 4th-order
398! cenrtered differences operator. The diffusive term is a 3rd-order
399! diapycnal hyperdiffusive operator which is proportional to the
400! absolute local velocity (Marchiesello et al., 2008):
401!
402! B = 1/12 * ABS(u) * (GridSpace ** 3)
403!
404! The resulting diapycnak diffusion, B, is scaled and clipped to achive
405! better stability. The squared-root of the total (diapycnal and
406! biharmonic) diffusion coefficient taken since the harmonic operator
407! is applied twice to achieve biharmonic mixing.
408!
409! Squared-root biharmonic diffusion coefficients [SQRT(m4/s)] at
410! U-points.
411!
412 DO k=1,n(ng)
413 DO j=jstr-1,jend+1
414 DO i=istru-1,iend+1
415 diff3d_u(i,j,k)=0.5_r8*(hdiffusion(i-1,j)+ &
416 & hdiffusion(i ,j))+ &
417 & pecletcoef*(om_u(i,j)**3)* &
418 & abs(u(i,j,k,nrhs))
419# ifdef MIX_GEO_TS
420# ifdef NEW_CODE
421 clip_scale=0.5_r8*(hz(i-1,j,k)+hz(i,j,k))*om_u(i,j)/ &
422 & (z_r(i,j,k)-z_r(i-1,j,k))
423 clip_diff=0.05_r8*clip_scale**4/dt(ng)
424# else
425 clip_scale=0.5_r8*(hz(i-1,j,k)+hz(i,j,k))/ &
426 & (z_r(i,j,k)-z_r(i-1,j,k))
427 clip_diff=diff3d_u(i,j,k)* &
428 & min(1.0_r8, clip_scale*clip_scale)
429# endif
430 diff3d_u(i,j,k)=min(clip_diff, diff3d_u(i,j,k))
431# endif
432 diff3d_u(i,j,k)=sqrt(diff3d_u(i,j,k))
433# ifdef MASKING
434 diff3d_u(i,j,k)=diff3d_u(i,j,k)*umask(i,j)
435# endif
436 END DO
437 END DO
438!
439! Squared-root biharmonic diffusion coefficients [SQRT(m4/s)] at
440! V-points.
441!
442 DO j=jstrv-1,jend+1
443 DO i=istr-1,iend+1
444 diff3d_v(i,j,k)=0.5_r8*(hdiffusion(i,j-1)+ &
445 & hdiffusion(i,j ))+ &
446 & pecletcoef*(on_v(i,j)**3)* &
447 & abs(v(i,j,k,nrhs))
448# ifdef MIX_GEO_TS
449# ifdef NEW_CODE
450 clip_scale=0.5_r8*(hz(i,j,k)+hz(i,j-1,k))*on_v(i,j)/ &
451 & (z_r(i,j,k)-z_r(i,j-1,k))
452 clip_diff=0.05_r8*clip_scale**4/dt(ng)
453# else
454 clip_scale=0.5_r8*(hz(i,j,k)+hz(i,j-1,k))/ &
455 & (z_r(i,j,k)-z_r(i,j-1,k))
456 clip_diff=diff3d_v(i,j,k)* &
457 & min(1.0_r8, clip_scale*clip_scale)
458# endif
459 diff3d_v(i,j,k)=min(clip_diff, diff3d_v(i,j,k))
460# endif
461 diff3d_v(i,j,k)=sqrt(diff3d_v(i,j,k))
462# ifdef MASKING
463 diff3d_v(i,j,k)=diff3d_v(i,j,k)*vmask(i,j)
464# endif
465 END DO
466 END DO
467 END DO
468# endif
469!
470!-----------------------------------------------------------------------
471! Apply boundary conditions
472!-----------------------------------------------------------------------
473!
474! East-West gradient boundary conditions.
475!
476 IF (.not.ewperiodic(ng)) THEN
477 IF (domain(ng)%Eastern_Edge(tile)) THEN
478 DO k=1,n(ng)
479 DO j=jstrv-1,jend
480# if defined DIFF_3DCOEF
481# ifdef TS_U3ADV_SPLIT
482 diff3d_u(iend+1,j,k)=diff3d_u(iend,j,k)
483 diff3d_v(iend+1,j,k)=diff3d_v(iend,j,k)
484# else
485 diff3d_r(iend+1,j,k)=diff3d_r(iend,j,k)
486# endif
487# endif
488# if defined VISC_3DCOEF
489# ifdef UV_U3ADV_SPLIT
490 uvis3d_r(iend+1,j,k)=uvis3d_r(iend,j,k)
491 vvis3d_r(iend+1,j,k)=vvis3d_r(iend,j,k)
492# else
493 visc3d_r(iend+1,j,k)=visc3d_r(iend,j,k)
494# endif
495# endif
496 END DO
497 END DO
498 END IF
499
500 IF (domain(ng)%Western_Edge(tile)) THEN
501 DO k=1,n(ng)
502 DO j=jstrv-1,jend
503# if defined DIFF_3DCOEF
504# ifdef TS_U3ADV_SPLIT
505 diff3d_u(istr-1,j,k)=diff3d_u(istr,j,k)
506 diff3d_v(istr-1,j,k)=diff3d_v(istr,j,k)
507# else
508 diff3d_r(istr-1,j,k)=diff3d_r(istr,j,k)
509# endif
510# endif
511# if defined VISC_3DCOEF
512# ifdef UV_U3ADV_SPLIT
513 uvis3d_r(istr-1,j,k)=uvis3d_r(istr,j,k)
514 vvis3d_r(istr-1,j,k)=vvis3d_r(istr,j,k)
515# else
516 visc3d_r(istr-1,j,k)=visc3d_r(istr,j,k)
517# endif
518# endif
519 END DO
520 END DO
521 END IF
522 END IF
523!
524! North-South gradient boundary conditions.
525!
526 IF (.not.nsperiodic(ng)) THEN
527 IF (domain(ng)%Northern_Edge(tile)) THEN
528 DO k=1,n(ng)
529 DO i=istru-1,iend
530# ifdef DIFF_3DCOEF
531# ifdef TS_U3ADV_SPLIT
532 diff3d_u(i,jend+1,k)=diff3d_u(i,jend,k)
533 diff3d_v(i,jend+1,k)=diff3d_v(i,jend,k)
534# else
535 diff3d_r(i,jend+1,k)=diff3d_r(i,jend,k)
536# endif
537# endif
538# ifdef VISC_3DCOEF
539# ifdef UV_U3ADV_SPLIT
540 uvis3d_r(i,jend+1,k)=uvis3d_r(i,jend,k)
541 vvis3d_r(i,jend+1,k)=vvis3d_r(i,jend,k)
542# else
543 visc3d_r(i,jend+1,k)=visc3d_r(i,jend,k)
544# endif
545# endif
546 END DO
547 END DO
548 END IF
549
550 IF (domain(ng)%Southern_Edge(tile)) THEN
551 DO k=1,n(ng)
552 DO i=istru-1,iend
553# ifdef DIFF_3DCOEF
554# ifdef TS_U3ADV_SPLIT
555 diff3d_u(i,jstr-1,k)=diff3d_u(i,jstr,k)
556 diff3d_v(i,jstr-1,k)=diff3d_v(i,jstr,k)
557# else
558 diff3d_r(i,jstr-1,k)=diff3d_r(i,jstr,k)
559# endif
560# endif
561# ifdef VISC_3DCOEF
562# ifdef UV_U3ADV_SPLIT
563 uvis3d_r(i,jstr-1,k)=uvis3d_r(i,jstr,k)
564 vvis3d_r(i,jstr-1,k)=vvis3d_r(i,jstr,k)
565# else
566 visc3d_r(i,jstr-1,k)=visc3d_r(i,jstr,k)
567# endif
568# endif
569 END DO
570 END DO
571 END IF
572 END IF
573!
574! Boundary corners.
575!
576 IF (.not.(ewperiodic(ng).or.nsperiodic(ng))) THEN
577 IF (domain(ng)%SouthWest_Corner(tile)) THEN
578 DO k=1,n(ng)
579# ifdef DIFF_3DCOEF
580# ifdef TS_U3ADV_SPLIT
581 diff3d_u(istr-1,jstr-1,k)=0.5_r8* &
582 & (diff3d_u(istr ,jstr-1,k)+ &
583 & diff3d_u(istr-1,jstr ,k))
584 diff3d_v(istr-1,jstr-1,k)=0.5_r8* &
585 & (diff3d_v(istr ,jstr-1,k)+ &
586 & diff3d_v(istr-1,jstr ,k))
587# else
588 diff3d_r(istr-1,jstr-1,k)=0.5_r8* &
589 & (diff3d_r(istr ,jstr-1,k)+ &
590 & diff3d_r(istr-1,jstr ,k))
591# endif
592# endif
593# ifdef VISC_3DCOEF
594# ifdef UV_U3ADV_SPLIT
595 uvis3d_r(istr-1,jstr-1,k)=0.5_r8* &
596 & (uvis3d_r(istr ,jstr-1,k)+ &
597 & uvis3d_r(istr-1,jstr ,k))
598 vvis3d_r(istr-1,jstr-1,k)=0.5_r8* &
599 & (vvis3d_r(istr ,jstr-1,k)+ &
600 & vvis3d_r(istr-1,jstr ,k))
601# else
602 visc3d_r(istr-1,jstr-1,k)=0.5_r8* &
603 & (visc3d_r(istr ,jstr-1,k)+ &
604 & visc3d_r(istr-1,jstr ,k))
605# endif
606# endif
607 END DO
608 END IF
609
610 IF (domain(ng)%SouthEast_Corner(tile)) THEN
611 DO k=1,n(ng)
612# ifdef DIFF_3DCOEF
613# ifdef TS_U3ADV_SPLIT
614 diff3d_u(iend+1,jstr-1,k)=0.5_r8* &
615 & (diff3d_u(iend ,jstr-1,k)+ &
616 & diff3d_u(iend+1,jstr ,k))
617 diff3d_v(iend+1,jstr-1,k)=0.5_r8* &
618 & (diff3d_v(iend ,jstr-1,k)+ &
619 & diff3d_v(iend+1,jstr ,k))
620# else
621 diff3d_r(iend+1,jstr-1,k)=0.5_r8* &
622 & (diff3d_r(iend ,jstr-1,k)+ &
623 & diff3d_r(iend+1,jstr ,k))
624# endif
625# endif
626# ifdef VISC_3DCOEF
627# ifdef UV_U3ADV_SPLIT
628 uvis3d_r(iend+1,jstr-1,k)=0.5_r8* &
629 & (uvis3d_r(iend ,jstr-1,k)+ &
630 & uvis3d_r(iend+1,jstr ,k))
631 vvis3d_r(iend+1,jstr-1,k)=0.5_r8* &
632 & (vvis3d_r(iend ,jstr-1,k)+ &
633 & vvis3d_r(iend+1,jstr ,k))
634# else
635 visc3d_r(iend+1,jstr-1,k)=0.5_r8* &
636 & (visc3d_r(iend ,jstr-1,k)+ &
637 & visc3d_r(iend+1,jstr ,k))
638# endif
639# endif
640 END DO
641 END IF
642
643 IF (domain(ng)%Northern_Edge(tile).and. &
644 & domain(ng)%Western_Edge(tile)) THEN
645 DO k=1,n(ng)
646# ifdef DIFF_3DCOEF
647# ifdef TS_U3ADV_SPLIT
648 diff3d_u(istr-1,jend+1,k)=0.5_r8* &
649 & (diff3d_u(istr ,jend+1,k)+ &
650 & diff3d_u(istr-1,jend ,k))
651 diff3d_v(istr-1,jend+1,k)=0.5_r8* &
652 & (diff3d_v(istr ,jend+1,k)+ &
653 & diff3d_v(istr-1,jend ,k))
654# else
655 diff3d_r(istr-1,jend+1,k)=0.5_r8* &
656 & (diff3d_r(istr ,jend+1,k)+ &
657 & diff3d_r(istr-1,jend ,k))
658# endif
659# endif
660# ifdef VISC_3DCOEF
661# ifdef UV_U3ADV_SPLIT
662 uvis3d_r(istr-1,jend+1,k)=0.5_r8* &
663 & (uvis3d_r(istr ,jend+1,k)+ &
664 & uvis3d_r(istr-1,jend ,k))
665 vvis3d_r(istr-1,jend+1,k)=0.5_r8* &
666 & (vvis3d_r(istr ,jend+1,k)+ &
667 & vvis3d_r(istr-1,jend ,k))
668# else
669 visc3d_r(istr-1,jend+1,k)=0.5_r8* &
670 & (visc3d_r(istr ,jend+1,k)+ &
671 & visc3d_r(istr-1,jend ,k))
672# endif
673# endif
674 END DO
675 END IF
676
677 IF (domain(ng)%Northern_Edge(tile).and. &
678 & domain(ng)%Eastern_Edge(tile)) THEN
679 DO k=1,n(ng)
680# ifdef DIFF_3DCOEF
681# ifdef TS_U3ADV_SPLIT
682 diff3d_u(iend+1,jend+1,k)=0.5_r8* &
683 & (diff3d_u(iend ,jend+1,k)+ &
684 & diff3d_u(iend+1,jend ,k))
685 diff3d_v(iend+1,jend+1,k)=0.5_r8* &
686 & (diff3d_v(iend ,jend+1,k)+ &
687 & diff3d_v(iend+1,jend ,k))
688# else
689 diff3d_r(istr-1,jend+1,k)=0.5_r8* &
690 & (diff3d_r(istr ,jend+1,k)+ &
691 & diff3d_r(istr-1,jend ,k))
692# endif
693# endif
694# ifdef VISC_3DCOEF
695# ifdef UV_U3ADV_SPLIT
696 uvis3d_r(iend+1,jend+1,k)=0.5_r8* &
697 & (uvis3d_r(iend ,jend+1,k)+ &
698 & vvis3d_r(iend+1,jend ,k))
699 vvis3d_r(iend+1,jend+1,k)=0.5_r8* &
700 & (vvis3d_r(iend ,jend+1,k)+ &
701 & vvis3d_r(iend+1,jend ,k))
702# else
703 visc3d_r(iend+1,jend+1,k)=0.5_r8* &
704 & (visc3d_r(iend ,jend+1,k)+ &
705 & visc3d_r(iend+1,jend ,k))
706# endif
707# endif
708 END DO
709 END IF
710 END IF
711!
712! Periodic boundary conditions.
713!
714 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
715# ifdef DIFF_3DCOEF
716# ifdef TS_U3ADV_SPLIT
717 CALL exchange_u3d_tile (ng, tile, &
718 & lbi, ubi, lbj, ubj, 1, n(ng), &
719 & diff3d_u)
720 CALL exchange_v3d_tile (ng, tile, &
721 & lbi, ubi, lbj, ubj, 1, n(ng), &
722 & diff3d_v)
723# else
724 CALL exchange_r3d_tile (ng, tile, &
725 & lbi, ubi, lbj, ubj, 1, n(ng), &
726 & diff3d_r)
727# endif
728# endif
729# ifdef VISC_3DCOEF
730# ifdef UV_U3ADV_SPLIT
731 CALL exchange_r3d_tile (ng, tile, &
732 & lbi, ubi, lbj, ubj, 1, n(ng), &
733 & uvis3d_r)
734 CALL exchange_r3d_tile (ng, tile, &
735 & lbi, ubi, lbj, ubj, 1, n(ng), &
736 & vvis3d_r)
737# else
738 CALL exchange_r3d_tile (ng, tile, &
739 & lbi, ubi, lbj, ubj, 1, n(ng), &
740 & visc3d_r)
741# endif
742# endif
743 END IF
744
745# ifdef DISTRIBUTE
746!
747! Exhange boundary data.
748!
749# ifdef DIFF_3DCOEF
750# ifdef TS_U3ADV_SPLIT
751 CALL mp_exchange3d (ng, tile, inlm, 2, &
752 & lbi, ubi, lbj, ubj, 1, n(ng), &
753 & nghostpoints, &
754 & ewperiodic(ng), nsperiodic(ng), &
755 & diff3d_u, diff3d_v)
756# else
757 CALL mp_exchange3d (ng, tile, inlm, 1, &
758 & lbi, ubi, lbj, ubj, 1, n(ng), &
759 & nghostpoints, &
760 & ewperiodic(ng), nsperiodic(ng), &
761 & diff3d_r)
762# endif
763# endif
764# ifdef VISC_3DCOEF
765# ifdef UV_U3ADV_SPLIT
766 CALL mp_exchange3d (ng, tile, inlm, 2, &
767 & lbi, ubi, lbj, ubj, 1, n(ng), &
768 & nghostpoints, &
769 & ewperiodic(ng), nsperiodic(ng), &
770 & uvis3d_r, vvis3d_r)
771# else
772 CALL mp_exchange3d (ng, tile, inlm, 1, &
773 & lbi, ubi, lbj, ubj, 1, n(ng), &
774 & nghostpoints, &
775 & ewperiodic(ng), nsperiodic(ng), &
776 & visc3d_r)
777# endif
778# endif
779# endif
780!
781 RETURN
782 END SUBROUTINE hmixing_tile
783#endif
784 END MODULE hmixing_mod
subroutine exchange_u3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, a)
subroutine exchange_r3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, a)
subroutine exchange_v3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, a)
type(t_grid), dimension(:), allocatable grid
Definition mod_grid.F:365
type(t_mixing), dimension(:), allocatable mixing
Definition mod_mixing.F:399
type(t_ocean), dimension(:), allocatable ocean
Definition mod_ocean.F:351
integer, parameter inlm
Definition mod_param.F:662
integer nghostpoints
Definition mod_param.F:710
type(t_domain), dimension(:), allocatable domain
Definition mod_param.F:329
real(dp), dimension(:), allocatable dt
logical, dimension(:), allocatable ewperiodic
logical, dimension(:), allocatable nsperiodic
real(dp), dimension(:), allocatable grdmax
integer, dimension(:), allocatable nrhs
subroutine mp_exchange3d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, lbk, ubk, nghost, ew_periodic, ns_periodic, a, b, c, d)
recursive subroutine wclock_off(ng, model, region, line, routine)
Definition timers.F:148
recursive subroutine wclock_on(ng, model, region, line, routine)
Definition timers.F:3