Skip to content

Commit

Permalink
(*)Test for inconsistent USE_STANLEY flags
Browse files Browse the repository at this point in the history
  Also added tests for cases when USE_STANLEY_ISO or USE_STANLEY_ML are set to
true but STANLEY_COEF is negative to reset the internal versions of these flags
to false with a sensible warning message rather than encountering segmentation
faults.  All solutions are bitwise identical in cases that worked before.
  • Loading branch information
Hallberg-NOAA committed Dec 8, 2022
1 parent 194077c commit 2ebb731
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/parameterizations/lateral/MOM_lateral_mixing_coeffs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,8 @@ subroutine VarMix_init(Time, G, GV, US, param_file, diag, CS)
! scaled by the resolution function.
logical :: better_speed_est ! If true, use a more robust estimate of the first
! mode wave speed as the starting point for iterations.
real :: Stanley_coeff ! Coefficient relating the temperature gradient and sub-gridscale
! temperature variance [nondim]
! This include declares and sets the variable "version".
# include "version_variable.h"
character(len=40) :: mdl = "MOM_lateral_mixing_coeffs" ! This module's name.
Expand Down Expand Up @@ -1198,6 +1200,15 @@ subroutine VarMix_init(Time, G, GV, US, param_file, diag, CS)
call get_param(param_file, mdl, "USE_STANLEY_ISO", CS%use_stanley_iso, &
"If true, turn on Stanley SGS T variance parameterization "// &
"in isopycnal slope code.", default=.false.)
if (CS%use_stanley_iso) then
call get_param(param_file, mdl, "STANLEY_COEFF", Stanley_coeff, &
"Coefficient correlating the temperature gradient and SGS T variance.", &
units="nondim", default=-1.0, do_not_log=.true.)
if (Stanley_coeff < 0.0) then
call MOM_error(WARNING, "STANLEY_COEFF must be set >= 0 if USE_STANLEY_ISO is true.")
CS%use_stanley_iso = .false.
endif
endif

if (CS%Resoln_use_ebt .or. CS%khth_use_ebt_struct) then
in_use = .true.
Expand Down
15 changes: 13 additions & 2 deletions src/parameterizations/lateral/MOM_mixed_layer_restrat.F90
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,10 @@ logical function mixedlayer_restrat_init(Time, G, GV, US, param_file, diag, CS,

! Local variables
real :: H_rescale ! A rescaling factor for thicknesses from the representation in
! a restart file to the internal representation in this run.
real :: flux_to_kg_per_s ! A unit conversion factor for fluxes.
! a restart file to the internal representation in this run, [nondim]?
real :: flux_to_kg_per_s ! A unit conversion factor for fluxes. [kg T s-1 H-1 L-2 ~> kg m-3 or 1]
real :: Stanley_coeff ! Coefficient relating the temperature gradient and sub-gridscale
! temperature variance [nondim]
! This include declares and sets the variable "version".
# include "version_variable.h"
integer :: i, j
Expand Down Expand Up @@ -886,6 +888,15 @@ logical function mixedlayer_restrat_init(Time, G, GV, US, param_file, diag, CS,
call get_param(param_file, mdl, "USE_STANLEY_ML", CS%use_stanley_ml, &
"If true, turn on Stanley SGS T variance parameterization "// &
"in ML restrat code.", default=.false.)
if (CS%use_stanley_ml) then
call get_param(param_file, mdl, "STANLEY_COEFF", Stanley_coeff, &
"Coefficient correlating the temperature gradient and SGS T variance.", &
units="nondim", default=-1.0, do_not_log=.true.)
if (Stanley_coeff < 0.0) then
call MOM_error(WARNING, "STANLEY_COEFF must be set >= 0 if USE_STANLEY_ML is true.")
CS%use_stanley_ml = .false.
endif
endif
call get_param(param_file, mdl, 'VON_KARMAN_CONST', CS%vonKar, &
'The value the von Karman constant as used for mixed layer viscosity.', &
units='nondim', default=0.41)
Expand Down

0 comments on commit 2ebb731

Please sign in to comment.