Skip to content

Commit

Permalink
+Added 9 ..._ANSWER_DATE runtime parameters
Browse files Browse the repository at this point in the history
  Added 9 ..._ANSWER_DATE runtime parameters controlling the expressions and
order of arithmetic in the parameterizations modules, which take precedence over
their older ..._ANSWERS_2018 counterparts.  The new runtime parameters are
HOR_VISC_ANSWER_DATE, MEKE_GEOMETRIC_ANSWER_DATE, EPBL_ANSWER_DATE,
OPTICS_ANSWER_DATE, REGULARIZE_LAYERS_ANSWER_DATE, SET_DIFF_ANSWER_DATE,
SET_VISC_ANSWER_DATE, TIDAL_MIXING_ANSWER_DATE and VERT_FRICTION_ANSWER_DATE.
All answers are bitwise identical, but there are numerous new entries in the
MOM_parameter_doc.all files.
  • Loading branch information
Hallberg-NOAA committed Jul 31, 2022
1 parent ab1e514 commit a32b840
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 80 deletions.
32 changes: 25 additions & 7 deletions src/parameterizations/lateral/MOM_hor_visc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ module MOM_hor_visc
logical :: res_scale_MEKE !< If true, the viscosity contribution from MEKE is scaled by
!! the resolution function.
logical :: use_GME !< If true, use GME backscatter scheme.
logical :: answers_2018 !< If true, use the order of arithmetic and expressions that recover the
!! answers from the end of 2018. Otherwise, use updated and more robust
!! forms of the same expressions.
integer :: answer_date !< The vintage of the order of arithmetic and expressions in the
!! horizontal viscosity calculations. Values below 20190101 recover
!! the answers from the end of 2018, while higher values use updated
!! and more robust forms of the same expressions.
real :: GME_h0 !< The strength of GME tapers quadratically to zero when the bathymetric
!! depth is shallower than GME_H0 [Z ~> m]
real :: GME_efficiency !< The nondimensional prefactor multiplying the GME coefficient [nondim]
Expand Down Expand Up @@ -1549,7 +1550,7 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,
Shear_mag_bc = sqrt(sh_xx(i,j) * sh_xx(i,j) + &
0.25*((sh_xy(I-1,J-1)*sh_xy(I-1,J-1) + sh_xy(I,J)*sh_xy(I,J)) + &
(sh_xy(I-1,J)*sh_xy(I-1,J) + sh_xy(I,J-1)*sh_xy(I,J-1))))
if (CS%answers_2018) then
if (CS%answer_date > 20190101) then
FatH = (US%s_to_T*FatH)**MEKE%backscatter_Ro_pow ! f^n
! Note the hard-coded dimensional constant in the following line that can not
! be rescaled for dimensional consistency.
Expand Down Expand Up @@ -1724,7 +1725,11 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
logical :: split ! If true, use the split time stepping scheme.
! If false and USE_GME = True, issue a FATAL error.
logical :: use_MEKE ! If true, the MEKE parameterization is in use.
logical :: default_2018_answers
logical :: answers_2018 ! If true, use the order of arithmetic and expressions that recover the
! answers from the end of 2018. Otherwise, use updated and more robust
! forms of the same expressions.
integer :: default_answer_date ! The default setting for the various ANSWER_DATE flags
logical :: default_2018_answers ! The default setting for the various 2018_ANSWERS flags
character(len=64) :: inputdir, filename
real :: deg2rad ! Converts degrees to radians
real :: slat_fn ! sin(lat)**Kh_pwr_of_sine
Expand All @@ -1748,13 +1753,26 @@ subroutine hor_visc_init(Time, G, GV, US, param_file, diag, CS, ADp)
call log_version(param_file, mdl, version, "")

! All parameters are read in all cases to enable parameter spelling checks.
call get_param(param_file, mdl, "DEFAULT_ANSWER_DATE", default_answer_date, &
"This sets the default value for the various _ANSWER_DATE parameters.", &
default=99991231)
call get_param(param_file, mdl, "DEFAULT_2018_ANSWERS", default_2018_answers, &
"This sets the default value for the various _2018_ANSWERS parameters.", &
default=.false.)
call get_param(param_file, mdl, "HOR_VISC_2018_ANSWERS", CS%answers_2018, &
default=(default_answer_date<20190101))
call get_param(param_file, mdl, "HOR_VISC_2018_ANSWERS", answers_2018, &
"If true, use the order of arithmetic and expressions that recover the "//&
"answers from the end of 2018. Otherwise, use updated and more robust "//&
"forms of the same expressions.", default=default_2018_answers)
! Revise inconsistent default answer dates for horizontal viscosity.
if (answers_2018 .and. (default_answer_date >= 20190101)) default_answer_date = 20181231
if (.not.answers_2018 .and. (default_answer_date < 20190101)) default_answer_date = 20190101
call get_param(param_file, mdl, "HOR_VISC_ANSWER_DATE", CS%answer_date, &
"The vintage of the order of arithmetic and expressions in the horizontal "//&
"viscosity calculations. Values below 20190101 recover the answers from the "//&
"end of 2018, while higher values use updated and more robust forms of the "//&
"same expressions. If both HOR_VISC_2018_ANSWERS and HOR_VISC_ANSWER_DATE are "//&
"specified, the latter takes precedence.", default=default_answer_date)

call get_param(param_file, mdl, "DEBUG", CS%debug, default=.false.)
call get_param(param_file, mdl, "LAPLACIAN", CS%Laplacian, &
"If true, use a Laplacian horizontal viscosity.", &
Expand Down
29 changes: 23 additions & 6 deletions src/parameterizations/lateral/MOM_thickness_diffuse.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ module MOM_thickness_diffuse
!! the GEOMETRIC thickness diffusion [nondim]
real :: MEKE_GEOMETRIC_epsilon !< Minimum Eady growth rate for the GEOMETRIC thickness
!! diffusivity [T-1 ~> s-1].
logical :: MEKE_GEOM_answers_2018 !< If true, use expressions in the MEKE_GEOMETRIC calculation
!! that recover the answers from the original implementation.
!! Otherwise, use expressions that satisfy rotational symmetry.
integer :: MEKE_GEOM_answer_date !< The vintage of the expressions in the MEKE_GEOMETRIC
!! calculation. Values below 20190101 recover the answers from the
!! original implementation, while higher values use expressions that
!! satisfy rotational symmetry.
logical :: Use_KH_in_MEKE !< If true, uses the thickness diffusivity calculated here to diffuse MEKE.
logical :: GM_src_alt !< If true, use the GM energy conversion form S^2*N^2*kappa rather
!! than the streamfunction for the GM source term.
Expand Down Expand Up @@ -392,7 +393,7 @@ subroutine thickness_diffuse(h, uhtr, vhtr, tv, dt, G, GV, US, MEKE, VarMix, CDp

if (allocated(MEKE%Kh)) then
if (CS%MEKE_GEOMETRIC) then
if (CS%MEKE_GEOM_answers_2018) then
if (CS%MEKE_GEOM_answer_date < 20190101) then
!$OMP do
do j=js,je ; do I=is,ie
! This does not give bitwise rotational symmetry.
Expand Down Expand Up @@ -1950,7 +1951,11 @@ subroutine thickness_diffuse_init(Time, G, GV, US, param_file, diag, CDp, CS)
real :: strat_floor ! A floor for buoyancy frequency in the Ferrari et al. 2010,
! streamfunction formulation, expressed as a fraction of planetary
! rotation [nondim].
integer :: default_answer_date ! The default setting for the various ANSWER_DATE flags.
logical :: default_2018_answers ! The default setting for the various 2018_ANSWERS flags.
logical :: MEKE_GEOM_answers_2018 ! If true, use expressions in the MEKE_GEOMETRIC calculation
! that recover the answers from the original implementation.
! Otherwise, use expressions that satisfy rotational symmetry.
integer :: i, j

CS%initialized = .true.
Expand Down Expand Up @@ -2068,13 +2073,25 @@ subroutine thickness_diffuse_init(Time, G, GV, US, param_file, diag, CDp, CS)
"The nondimensional coefficient governing the efficiency of the GEOMETRIC "//&
"thickness diffusion.", units="nondim", default=0.05)

call get_param(param_file, mdl, "DEFAULT_ANSWER_DATE", default_answer_date, &
"This sets the default value for the various _ANSWER_DATE parameters.", &
default=99991231)
call get_param(param_file, mdl, "DEFAULT_2018_ANSWERS", default_2018_answers, &
"This sets the default value for the various _2018_ANSWERS parameters.", &
default=.false.)
call get_param(param_file, mdl, "MEKE_GEOMETRIC_2018_ANSWERS", CS%MEKE_GEOM_answers_2018, &
default=(default_answer_date<20190101))
call get_param(param_file, mdl, "MEKE_GEOMETRIC_2018_ANSWERS", MEKE_GEOM_answers_2018, &
"If true, use expressions in the MEKE_GEOMETRIC calculation that recover the "//&
"answers from the original implementation. Otherwise, use expressions that "//&
"satisfy rotational symmetry.", default=default_2018_answers)
! Revise inconsistent default answer dates for MEKE_geometric.
if (MEKE_GEOM_answers_2018 .and. (default_answer_date >= 20190101)) default_answer_date = 20181231
if (.not.MEKE_GEOM_answers_2018 .and. (default_answer_date < 20190101)) default_answer_date = 20190101
call get_param(param_file, mdl, "MEKE_GEOMETRIC_ANSWER_DATE", CS%MEKE_GEOM_answer_date, &
"The vintage of the expressions in the MEKE_GEOMETRIC calculation. "//&
"Values below 20190101 recover the answers from the original implementation, "//&
"while higher values use expressions that satisfy rotational symmetry. "//&
"If both MEKE_GEOMETRIC_2018_ANSWERS and MEKE_GEOMETRIC_ANSWER_DATE are "//&
"specified, the latter takes precedence.", default=default_answer_date)
endif

call get_param(param_file, mdl, "USE_KH_IN_MEKE", CS%Use_KH_in_MEKE, &
Expand Down
39 changes: 28 additions & 11 deletions src/parameterizations/vertical/MOM_energetic_PBL.F90
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ module MOM_energetic_PBL
type(time_type), pointer :: Time=>NULL() !< A pointer to the ocean model's clock.

logical :: TKE_diagnostics = .false. !< If true, diagnostics of the TKE budget are being calculated.
logical :: answers_2018 !< If true, use the order of arithmetic and expressions that recover the
!! answers from the end of 2018. Otherwise, use updated and more robust
!! forms of the same expressions.
integer :: answer_date !< The vintage of the order of arithmetic and expressions in the ePBL
!! calculations. Values below 20190101 recover the answers from the
!! end of 2018, while higher values use updated and more robust forms
!! of the same expressions.
logical :: orig_PE_calc !< If true, the ePBL code uses the original form of the
!! potential energy change code. Otherwise, it uses a newer version
!! that can work with successive increments to the diffusivity in
Expand Down Expand Up @@ -828,7 +829,7 @@ subroutine ePBL_column(h, u, v, T0, S0, dSV_dT, dSV_dS, TKE_forcing, B_flux, abs
endif

!/ Apply MStar to get mech_TKE
if ((CS%answers_2018) .and. (CS%mstar_scheme==Use_Fixed_MStar)) then
if ((CS%answer_date < 20190101) .and. (CS%mstar_scheme==Use_Fixed_MStar)) then
mech_TKE = (dt*MSTAR_total*GV%Rho0) * u_star**3
else
mech_TKE = MSTAR_total * (dt*GV%Rho0* u_star**3)
Expand Down Expand Up @@ -1760,7 +1761,7 @@ subroutine find_mstar(CS, US, Buoyancy_Flux, UStar, UStar_Mean,&
!/ 1. Get mstar
elseif (CS%mstar_scheme == MStar_from_Ekman) then

if (CS%answers_2018) then
if (CS%answer_date < 20190101) then
! The limit for the balance of rotation and stabilizing is f(L_Ekman,L_Obukhov)
MStar_S = CS%MStar_coef*sqrt(max(0.0,Buoyancy_Flux) / UStar**2 / &
(Abs_Coriolis + 1.e-10*US%T_to_s) )
Expand All @@ -1778,7 +1779,7 @@ subroutine find_mstar(CS, US, Buoyancy_Flux, UStar, UStar_Mean,&
MStar = max(MStar_S, min(1.25, MStar_N))
if (CS%MStar_Cap > 0.0) MStar = min( CS%MStar_Cap,MStar )
elseif ( CS%mstar_scheme == MStar_from_RH18 ) then
if (CS%answers_2018) then
if (CS%answer_date < 20190101) then
MStar_N = CS%RH18_MStar_cn1 * ( 1.0 - 1.0 / ( 1. + CS%RH18_MStar_cn2 * &
exp( CS%RH18_mstar_CN3 * BLD * Abs_Coriolis / UStar) ) )
else
Expand All @@ -1791,7 +1792,7 @@ subroutine find_mstar(CS, US, Buoyancy_Flux, UStar, UStar_Mean,&
endif

!/ 2. Adjust mstar to account for convective turbulence
if (CS%answers_2018) then
if (CS%answer_date < 20190101) then
MStar_Conv_Red = 1. - CS%MStar_Convect_coef * (-min(0.0,Buoyancy_Flux) + 1.e-10*US%T_to_s**3*US%m_to_Z**2) / &
( (-min(0.0,Buoyancy_Flux) + 1.e-10*US%T_to_s**3*US%m_to_Z**2) + &
2.0 *MStar * UStar**3 / BLD )
Expand Down Expand Up @@ -1851,7 +1852,7 @@ subroutine Mstar_Langmuir(CS, US, Abs_Coriolis, Buoyancy_Flux, UStar, BLD, Langm

if (CS%LT_Enhance_Form /= No_Langmuir) then
! a. Get parameters for modified LA
if (CS%answers_2018) then
if (CS%answer_date < 20190101) then
iL_Ekman = Abs_Coriolis / Ustar
iL_Obukhov = Buoyancy_Flux*CS%vonkar / Ustar**3
Ekman_Obukhov_stab = abs(max(0., iL_Obukhov / (iL_Ekman + 1.e-10*US%Z_to_m)))
Expand Down Expand Up @@ -1942,7 +1943,11 @@ subroutine energetic_PBL_init(Time, G, GV, US, param_file, diag, CS)
real :: omega_frac_dflt
integer :: isd, ied, jsd, jed
integer :: mstar_mode, LT_enhance, wT_mode
logical :: default_2018_answers
integer :: default_answer_date ! The default setting for the various ANSWER_DATE flags.
logical :: default_2018_answers ! The default setting for the various 2018_ANSWERS flags.
logical :: answers_2018 ! If true, use the order of arithmetic and expressions that recover the
! answers from the end of 2018. Otherwise, use updated and more robust
! forms of the same expressions.
logical :: use_temperature, use_omega
logical :: use_la_windsea
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
Expand Down Expand Up @@ -1977,13 +1982,25 @@ subroutine energetic_PBL_init(Time, G, GV, US, param_file, diag, CS)
"A nondimensional scaling factor controlling the inhibition "//&
"of the diffusive length scale by rotation. Making this larger "//&
"decreases the PBL diffusivity.", units="nondim", default=1.0)
call get_param(param_file, mdl, "DEFAULT_ANSWER_DATE", default_answer_date, &
"This sets the default value for the various _ANSWER_DATE parameters.", &
default=99991231)
call get_param(param_file, mdl, "DEFAULT_2018_ANSWERS", default_2018_answers, &
"This sets the default value for the various _2018_ANSWERS parameters.", &
default=.false.)
call get_param(param_file, mdl, "EPBL_2018_ANSWERS", CS%answers_2018, &
default=(default_answer_date<20190101))
call get_param(param_file, mdl, "EPBL_2018_ANSWERS", answers_2018, &
"If true, use the order of arithmetic and expressions that recover the "//&
"answers from the end of 2018. Otherwise, use updated and more robust "//&
"forms of the same expressions.", default=default_2018_answers)
! Revise inconsistent default answer dates for horizontal viscosity.
if (answers_2018 .and. (default_answer_date >= 20190101)) default_answer_date = 20181231
if (.not.answers_2018 .and. (default_answer_date < 20190101)) default_answer_date = 20190101
call get_param(param_file, mdl, "EPBL_ANSWER_DATE", CS%answer_date, &
"The vintage of the order of arithmetic and expressions in the energetic "//&
"PBL calculations. Values below 20190101 recover the answers from the "//&
"end of 2018, while higher values use updated and more robust forms of the "//&
"same expressions. If both EPBL_2018_ANSWERS and EPBL_ANSWER_DATE are "//&
"specified, the latter takes precedence.", default=default_answer_date)


call get_param(param_file, mdl, "EPBL_ORIGINAL_PE_CALC", CS%orig_PE_calc, &
Expand Down
Loading

0 comments on commit a32b840

Please sign in to comment.