@@ -31,7 +31,7 @@ module MOM_hor_visc
31
31
32
32
#include < MOM_memory.h>
33
33
34
- public horizontal_viscosity, hor_visc_init, hor_visc_end
34
+ public horizontal_viscosity, hor_visc_init, hor_visc_end, hor_visc_vel_stencil
35
35
36
36
! > Control structure for horizontal viscosity
37
37
type, public :: hor_visc_CS ; private
@@ -1198,10 +1198,9 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
1198
1198
if ((CS% Smagorinsky_Ah) .or. (CS% Leith_Ah) .or. (CS% use_Leithy)) then
1199
1199
if (CS% Smagorinsky_Ah) then
1200
1200
if (CS% bound_Coriolis) then
1201
- do j= js_Kh,je_Kh ; do i= is_Kh,ie_Kh
1201
+ do j= js_Kh,je_Kh ; do i= is_Kh,ie_Kh
1202
1202
AhSm = Shear_mag(i,j) * (CS% Biharm_const_xx(i,j) &
1203
- + CS% Biharm_const2_xx(i,j) * Shear_mag(i,j) &
1204
- )
1203
+ + CS% Biharm_const2_xx(i,j) * Shear_mag(i,j))
1205
1204
Ah(i,j) = max (Ah(i,j), AhSm)
1206
1205
enddo ; enddo
1207
1206
else
@@ -1432,10 +1431,7 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
1432
1431
1433
1432
! Pass the velocity gradients and thickness to ZB2020
1434
1433
if (CS% use_ZB2020) then
1435
- call ZB2020_copy_gradient_and_thickness( &
1436
- sh_xx, sh_xy, vort_xy, &
1437
- hq, &
1438
- G, GV, CS% ZB2020, k)
1434
+ call ZB2020_copy_gradient_and_thickness(sh_xx, sh_xy, vort_xy, hq, G, GV, CS% ZB2020, k)
1439
1435
endif
1440
1436
1441
1437
if (CS% Laplacian) then
@@ -1575,8 +1571,7 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
1575
1571
if (CS% bound_Coriolis) then
1576
1572
do J= js-1 ,Jeq ; do I= is-1 ,Ieq
1577
1573
AhSm = Shear_mag(I,J) * (CS% Biharm_const_xy(I,J) &
1578
- + CS% Biharm_const2_xy(I,J) * Shear_mag(I,J) &
1579
- )
1574
+ + CS% Biharm_const2_xy(I,J) * Shear_mag(I,J))
1580
1575
Ah(I,J) = max (Ah(I,J), AhSm)
1581
1576
enddo ; enddo
1582
1577
else
@@ -1605,8 +1600,7 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
1605
1600
! *Add* the MEKE contribution
1606
1601
do J= js-1 ,Jeq ; do I= is-1 ,Ieq
1607
1602
Ah(I,J) = Ah(I,J) + 0.25 * ( &
1608
- (MEKE% Au(i,j) + MEKE% Au(i+1 ,j+1 )) + (MEKE% Au(i+1 ,j) + MEKE% Au(i,j+1 )) &
1609
- )
1603
+ (MEKE% Au(i,j) + MEKE% Au(i+1 ,j+1 )) + (MEKE% Au(i+1 ,j) + MEKE% Au(i,j+1 )) )
1610
1604
enddo ; enddo
1611
1605
endif
1612
1606
@@ -1897,11 +1891,15 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
1897
1891
1898
1892
if (CS% debug) then
1899
1893
if (CS% Laplacian) then
1894
+ ! In symmetric memory mode, Kh_h should also be valid with a haloshift of 1.
1900
1895
call hchksum(Kh_h, " Kh_h" , G% HI, haloshift= 0 , scale= US% L_to_m** 2 * US% s_to_T)
1901
- call Bchksum(Kh_q, " Kh_q" , G% HI, haloshift= 0 , scale= US% L_to_m** 2 * US% s_to_T)
1896
+ call Bchksum(Kh_q, " Kh_q" , G% HI, haloshift= 0 , symmetric= .true. , scale= US% L_to_m** 2 * US% s_to_T)
1897
+ endif
1898
+ if (CS% biharmonic) then
1899
+ ! In symmetric memory mode, Ah_h should also be valid with a haloshift of 1.
1900
+ call hchksum(Ah_h, " Ah_h" , G% HI, haloshift= 0 , scale= US% L_to_m** 4 * US% s_to_T)
1901
+ call Bchksum(Ah_q, " Ah_q" , G% HI, haloshift= 0 , symmetric= .true. , scale= US% L_to_m** 4 * US% s_to_T)
1902
1902
endif
1903
- if (CS% biharmonic) call hchksum(Ah_h, " Ah_h" , G% HI, haloshift= 0 , scale= US% L_to_m** 4 * US% s_to_T)
1904
- if (CS% biharmonic) call Bchksum(Ah_q, " Ah_q" , G% HI, haloshift= 0 , scale= US% L_to_m** 4 * US% s_to_T)
1905
1903
endif
1906
1904
1907
1905
if (CS% id_FrictWorkIntz > 0 ) then
@@ -2403,14 +2401,31 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
2403
2401
ALLOC_(CS% m_leithy_max(isd:ied,jsd:jed)) ; CS% m_leithy_max(:,:) = 0.0
2404
2402
endif
2405
2403
if (CS% Re_Ah > 0.0 ) then
2406
- ALLOC_(CS% Re_Ah_const_xx(isd:ied,jsd:jed)); CS% Re_Ah_const_xx(:,:) = 0.0
2407
- ALLOC_(CS% Re_Ah_const_xy(IsdB:IedB,JsdB:JedB)); CS% Re_Ah_const_xy(:,:) = 0.0
2404
+ ALLOC_(CS% Re_Ah_const_xx(isd:ied,jsd:jed)) ; CS% Re_Ah_const_xx(:,:) = 0.0
2405
+ ALLOC_(CS% Re_Ah_const_xy(IsdB:IedB,JsdB:JedB)) ; CS% Re_Ah_const_xy(:,:) = 0.0
2408
2406
endif
2409
2407
endif
2410
2408
do J= js-2 ,Jeq+1 ; do I= is-2 ,Ieq+1
2411
2409
CS% dx2q(I,J) = G% dxBu(I,J)* G% dxBu(I,J) ; CS% dy2q(I,J) = G% dyBu(I,J)* G% dyBu(I,J)
2412
- CS% DX_dyBu(I,J) = G% dxBu(I,J)* G% IdyBu(I,J) ; CS% DY_dxBu(I,J) = G% dyBu(I,J)* G% IdxBu(I,J)
2413
2410
enddo ; enddo
2411
+
2412
+ if (((CS% Leith_Kh) .or. (CS% Leith_Ah) .or. (CS% use_Leithy)) .and. &
2413
+ ((G% isc- G% isd < 3 ) .or. (G% isc- G% isd < 3 ))) call MOM_error(FATAL, &
2414
+ " The minimum halo size is 3 when a Leith viscosity is being used." )
2415
+ if (CS% use_Leithy) then
2416
+ do J= js-3 ,Jeq+2 ; do I= is-3 ,Ieq+2
2417
+ CS% DX_dyBu(I,J) = G% dxBu(I,J)* G% IdyBu(I,J) ; CS% DY_dxBu(I,J) = G% dyBu(I,J)* G% IdxBu(I,J)
2418
+ enddo ; enddo
2419
+ elseif ((CS% Leith_Kh) .or. (CS% Leith_Ah)) then
2420
+ do J= Jsq-2 ,Jeq+2 ; do I= Isq-2 ,Ieq+2
2421
+ CS% DX_dyBu(I,J) = G% dxBu(I,J)* G% IdyBu(I,J) ; CS% DY_dxBu(I,J) = G% dyBu(I,J)* G% IdxBu(I,J)
2422
+ enddo ; enddo
2423
+ else
2424
+ do J= js-2 ,Jeq+1 ; do I= is-2 ,Ieq+1
2425
+ CS% DX_dyBu(I,J) = G% dxBu(I,J)* G% IdyBu(I,J) ; CS% DY_dxBu(I,J) = G% dyBu(I,J)* G% IdxBu(I,J)
2426
+ enddo ; enddo
2427
+ endif
2428
+
2414
2429
do j= js-2 ,Jeq+2 ; do i= is-2 ,Ieq+2
2415
2430
CS% dx2h(i,j) = G% dxT(i,j)* G% dxT(i,j) ; CS% dy2h(i,j) = G% dyT(i,j)* G% dyT(i,j)
2416
2431
CS% DX_dyT(i,j) = G% dxT(i,j)* G% IdyT(i,j) ; CS% DY_dxT(i,j) = G% dyT(i,j)* G% IdxT(i,j)
@@ -2541,12 +2556,12 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
2541
2556
endif
2542
2557
endif
2543
2558
if (CS% Leith_Ah) then
2544
- CS% biharm6_const_xx(i,j) = Leith_bi_const * (grid_sp_h3 * grid_sp_h3)
2559
+ CS% biharm6_const_xx(i,j) = Leith_bi_const * (grid_sp_h3 * grid_sp_h3)
2545
2560
endif
2546
2561
if (CS% use_Leithy) then
2547
- CS% biharm6_const_xx(i,j) = Leith_bi_const * max (G% dxT(i,j),G% dyT(i,j))** 6
2548
- CS% m_const_leithy(i,j) = 0.5 * sqrt (CS% c_K) * max (G% dxT(i,j),G% dyT(i,j))
2549
- CS% m_leithy_max(i,j) = 4 . / max (G% dxT(i,j),G% dyT(i,j))** 2
2562
+ CS% biharm6_const_xx(i,j) = Leith_bi_const * max (G% dxT(i,j),G% dyT(i,j))** 6
2563
+ CS% m_const_leithy(i,j) = 0.5 * sqrt (CS% c_K) * max (G% dxT(i,j),G% dyT(i,j))
2564
+ CS% m_leithy_max(i,j) = 4 . / max (G% dxT(i,j),G% dyT(i,j))** 2
2550
2565
endif
2551
2566
CS% Ah_bg_xx(i,j) = MAX (Ah, Ah_vel_scale * grid_sp_h2 * sqrt (grid_sp_h2))
2552
2567
if (CS% Re_Ah > 0.0 ) CS% Re_Ah_const_xx(i,j) = grid_sp_h3 / CS% Re_Ah
@@ -2571,12 +2586,12 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
2571
2586
endif
2572
2587
endif
2573
2588
if ((CS% Leith_Ah) .or. (CS% use_Leithy))then
2574
- CS% biharm6_const_xy(I,J) = Leith_bi_const * (grid_sp_q3 * grid_sp_q3)
2589
+ CS% biharm6_const_xy(I,J) = Leith_bi_const * (grid_sp_q3 * grid_sp_q3)
2575
2590
endif
2576
2591
CS% Ah_bg_xy(I,J) = MAX (Ah, Ah_vel_scale * grid_sp_q2 * sqrt (grid_sp_q2))
2577
2592
if (CS% Re_Ah > 0.0 ) CS% Re_Ah_const_xy(i,j) = grid_sp_q3 / CS% Re_Ah
2578
2593
if (Ah_time_scale > 0 .) CS% Ah_bg_xy(i,j) = &
2579
- MAX (CS% Ah_bg_xy(i,j), (grid_sp_q2 * grid_sp_q2) / Ah_time_scale)
2594
+ MAX (CS% Ah_bg_xy(i,j), (grid_sp_q2 * grid_sp_q2) / Ah_time_scale)
2580
2595
if (CS% bound_Ah .and. .not. CS% better_bound_Ah) then
2581
2596
CS% Ah_Max_xy(I,J) = Ah_Limit * (grid_sp_q2 * grid_sp_q2)
2582
2597
CS% Ah_bg_xy(I,J) = MIN (CS% Ah_bg_xy(I,J), CS% Ah_Max_xy(I,J))
@@ -2822,6 +2837,18 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
2822
2837
2823
2838
end subroutine hor_visc_init
2824
2839
2840
+ ! > hor_visc_vel_stencil returns the horizontal viscosity input velocity stencil size
2841
+ function hor_visc_vel_stencil (CS ) result(stencil)
2842
+ type (hor_visc_CS), intent (in ) :: CS ! < Control structure for horizontal viscosity
2843
+ integer :: stencil ! < The horizontal viscosity velocity stencil size with the current settings.
2844
+
2845
+ stencil = 2
2846
+
2847
+ if ((CS% Leith_Kh) .or. (CS% Leith_Ah) .or. (CS% use_Leithy)) then
2848
+ stencil = 3
2849
+ endif
2850
+ end function hor_visc_vel_stencil
2851
+
2825
2852
! > Calculates factors in the anisotropic orientation tensor to be align with the grid.
2826
2853
! ! With n1=1 and n2=0, this recovers the approach of Large et al, 2001.
2827
2854
subroutine align_aniso_tensor_to_grid (CS , n1 , n2 )
0 commit comments