Skip to content

Commit 2b72682

Browse files
Hallberg-NOAAmarshallward
authored andcommitted
*+HOR_VISC_ANSWER_DATE logic fix
When HOR_VISC_ANSWER_DATE was introduced to replace HOR_VISC_2018_ANSWERS on August 4, 2022 as a part of github.com/NOAA-GFDL/pull/179, the logic was incorrectly specified, using the older form with the newer answer date and vice versa, because `(CS%answer_date > 20190101)` was used instead of `(CS%answer_date < 20190101)`. (Curiously, using exactly 20190101 actually gives the intended result.) This commit modifies this logic so that the older (mildly dimensionally inconsistent) version is now being used for answer dates between 20190102 and 20241201, but a very late answer date uses the corrected form. The offending block of code is only used when USE_MEKE is true and the Rossby number scaling of the biharmonic energy source is enabled by setting MEKE_BACKSCAT_RO_C > 0, which does not appear to be very common. To avoid logging the description of this ugly new logic in MOM_parameter_doc files where it does not impact the solutions, new logic was added to limit the logging of HOR_VISC_ANSWER_DATE. Also, as there are no known non-Boussinesq cases with this combination of MEKE parameters, the minimum value of HOR_VISC_ANSWER_DATE was changed to 20241201 when the model is in non-Boussinesq mode. Because this bug went undetected when it was first introduced, it probably is not widely used, and it might make sense to obsolete HOR_VISC_ANSWER_DATE and eliminate the older, inconsistent block of code. This commit could change answers for answer dates that are above 20241201 with the MEKE Rossby number scaling enabled via MEKE_BACKSCAT_RO_C > 0.
1 parent 7a9adbc commit 2b72682

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/parameterizations/lateral/MOM_hor_visc.F90

+17-8
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ subroutine horizontal_viscosity(u, v, h, uh, vh, diffu, diffv, MEKE, VarMix, G,
21412141
Shear_mag_bc = sqrt(sh_xx(i,j) * sh_xx(i,j) + &
21422142
0.25*(((sh_xy(I-1,J-1)*sh_xy(I-1,J-1)) + (sh_xy(I,J)*sh_xy(I,J))) + &
21432143
((sh_xy(I-1,J)*sh_xy(I-1,J)) + (sh_xy(I,J-1)*sh_xy(I,J-1)))))
2144-
if (CS%answer_date > 20190101) then
2144+
if ((CS%answer_date > 20190101) .and. (CS%answer_date < 20241201)) then
21452145
FatH = (US%s_to_T*FatH)**MEKE%backscatter_Ro_pow ! f^n
21462146
! Note the hard-coded dimensional constant in the following line that can not
21472147
! be rescaled for dimensional consistency.
@@ -2332,6 +2332,7 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
23322332
logical :: split ! If true, use the split time stepping scheme.
23332333
! If false and USE_GME = True, issue a FATAL error.
23342334
logical :: use_MEKE ! If true, the MEKE parameterization is in use.
2335+
real :: backscatter_Ro_c ! Coefficient in Rossby number function for backscatter [nondim]
23352336
integer :: default_answer_date ! The default setting for the various ANSWER_DATE flags
23362337
character(len=200) :: inputdir, filename ! Input file names and paths
23372338
character(len=80) :: Kh_var ! Input variable names
@@ -2363,13 +2364,23 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
23632364
call get_param(param_file, mdl, "DEFAULT_ANSWER_DATE", default_answer_date, &
23642365
"This sets the default value for the various _ANSWER_DATE parameters.", &
23652366
default=99991231)
2367+
2368+
! Determine whether HOR_VISC_ANSWER_DATE is used, and avoid logging it if it is not used.
2369+
call get_param(param_file, mdl, "USE_MEKE", use_MEKE, &
2370+
default=.false., do_not_log=.true.)
2371+
backscatter_Ro_c = 0.0
2372+
if (use_MEKE) call get_param(param_file, mdl, "MEKE_BACKSCAT_RO_C", backscatter_Ro_c, &
2373+
"The coefficient in the Rossby number function for scaling the biharmonic "//&
2374+
"frictional energy source. Setting to non-zero enables the Rossby number function.", &
2375+
units="nondim", default=0.0, do_not_log=.true.)
2376+
23662377
call get_param(param_file, mdl, "HOR_VISC_ANSWER_DATE", CS%answer_date, &
23672378
"The vintage of the order of arithmetic and expressions in the horizontal "//&
2368-
"viscosity calculations. Values below 20190101 recover the answers from the "//&
2369-
"end of 2018, while higher values use updated and more robust forms of the "//&
2370-
"same expressions.", &
2371-
default=default_answer_date, do_not_log=.not.GV%Boussinesq)
2372-
if (.not.GV%Boussinesq) CS%answer_date = max(CS%answer_date, 20230701)
2379+
"viscosity calculations. Values between 20190102 and 20241201 recover the "//&
2380+
"answers from the end of 2018, while higher values use updated and more robust "//&
2381+
"forms of the same expressions.", &
2382+
default=default_answer_date, do_not_log=(.not.GV%Boussinesq).or.(backscatter_Ro_c==0.0))
2383+
if (.not.GV%Boussinesq) CS%answer_date = max(CS%answer_date, 20241201)
23732384

23742385
call get_param(param_file, mdl, "DEBUG", CS%debug, default=.false.)
23752386
call get_param(param_file, mdl, "USE_CONT_THICKNESS", CS%use_cont_thick, &
@@ -2425,8 +2436,6 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
24252436
"The nondimensional Laplacian Leith constant, "//&
24262437
"often set to 1.0", units="nondim", default=0.0, &
24272438
fail_if_missing=CS%Leith_Kh, do_not_log=.not.CS%Leith_Kh)
2428-
call get_param(param_file, mdl, "USE_MEKE", use_MEKE, &
2429-
default=.false., do_not_log=.true.)
24302439
call get_param(param_file, mdl, "RES_SCALE_MEKE_VISC", CS%res_scale_MEKE, &
24312440
"If true, the viscosity contribution from MEKE is scaled by "//&
24322441
"the resolution function.", default=.false., &

0 commit comments

Comments
 (0)