Skip to content

Commit

Permalink
Fix logic for setting KV_ML_INVZ2 from KVML
Browse files Browse the repository at this point in the history
- We were reading KV_ML_INVZ2 without logging, then checking for KVML
  and finally logging based on a combination of the two. This had the side
  affect that we get warnings about not using KVML even if KVML was not
  present.
- The fix checks for KVML first, and then changes the default so that
  when KVML=1e-4 is replaced by KV_ML_INVZ2=1e-4 we end up with no
  warnings and KVML can be obsoleted safely.
  Note: this commit alone does not remove all warnings from the MOM6-examples
  suite because we still need to fix the MOM_input that still use KVML
- KVML needs to be unscaled since it is the default for KV_ML_INVZ2
- tc3 used KVML and has been corrected.
  • Loading branch information
adcroft authored and marshallward committed Jul 20, 2023
1 parent df0eaf0 commit 25feaf2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .testing/tc3/MOM_input
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ HMIX_FIXED = 20.0 ! [m]
KV = 1.0E-04 ! [m2 s-1]
! The background kinematic viscosity in the interior.
! The molecular value, ~1e-6 m2 s-1, may be used.
KVML = 0.01 ! [m2 s-1] default = 1.0E-04
! The kinematic viscosity in the mixed layer. A typical
! value is ~1e-2 m2 s-1. KVML is not used if
! BULKMIXEDLAYER is true. The default is set by KV.
KV_ML_INVZ2 = 0.01 ! [m2 s-1] default = 0.0
! An extra kinematic viscosity in a mixed layer of thickness HMIX_FIXED, with
! the actual viscosity scaling as 1/(z*HMIX_FIXED)^2, where z is the distance
! from the surface, to allow for finite wind stresses to be transmitted through.
HBBL = 10.0 ! [m]
! The thickness of a bottom boundary layer with a
! viscosity of KVBBL if BOTTOMDRAGLAW is not defined, or
Expand Down
25 changes: 9 additions & 16 deletions src/parameterizations/vertical/MOM_vert_friction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,7 @@ subroutine vertvisc_init(MIS, Time, G, GV, US, param_file, diag, ADp, dirs, &
# include "version_variable.h"
character(len=40) :: mdl = "MOM_vert_friction" ! This module's name.
character(len=40) :: thickness_units
real :: Kv_mks ! KVML in MKS

if (associated(CS)) then
call MOM_error(WARNING, "vertvisc_init called with an associated "// &
Expand Down Expand Up @@ -2339,30 +2340,22 @@ subroutine vertvisc_init(MIS, Time, G, GV, US, param_file, diag, ADp, dirs, &

CS%Kvml_invZ2 = 0.0
if (GV%nkml < 1) then
call get_param(param_file, mdl, "KV_ML_INVZ2", CS%Kvml_invZ2, &
"An extra kinematic viscosity in a mixed layer of thickness HMIX_FIXED, "//&
"with the actual viscosity scaling as 1/(z*HMIX_FIXED)^2, where z is the "//&
"distance from the surface, to allow for finite wind stresses to be "//&
"transmitted through infinitesimally thin surface layers. This is an "//&
"older option for numerical convenience without a strong physical basis, "//&
"and its use is now discouraged.", &
units="m2 s-1", default=-1.0, scale=US%m2_s_to_Z2_T, do_not_log=.true.)
if (CS%Kvml_invZ2 < 0.0) then
call get_param(param_file, mdl, "KVML", CS%Kvml_invZ2, &
call get_param(param_file, mdl, "KVML", Kv_mks, &
"The scale for an extra kinematic viscosity in the mixed layer", &
units="m2 s-1", default=0.0, scale=US%m2_s_to_Z2_T, do_not_log=.true.)
if (CS%Kvml_invZ2 >= 0.0) &
call MOM_error(WARNING, "KVML is a deprecated parameter. Use KV_ML_INVZ2 instead.")
units="m2 s-1", default=-1.0, do_not_log=.true.)
if (Kv_mks >= 0.0) then
call MOM_error(WARNING, "KVML is a deprecated parameter. Use KV_ML_INVZ2 instead.")
else
Kv_mks = 0.0
endif
if (CS%Kvml_invZ2 < 0.0) CS%Kvml_invZ2 = 0.0
call log_param(param_file, mdl, "KV_ML_INVZ2", CS%Kvml_invZ2, &
call get_param(param_file, mdl, "KV_ML_INVZ2", CS%Kvml_invZ2, &
"An extra kinematic viscosity in a mixed layer of thickness HMIX_FIXED, "//&
"with the actual viscosity scaling as 1/(z*HMIX_FIXED)^2, where z is the "//&
"distance from the surface, to allow for finite wind stresses to be "//&
"transmitted through infinitesimally thin surface layers. This is an "//&
"older option for numerical convenience without a strong physical basis, "//&
"and its use is now discouraged.", &
units="m2 s-1", default=0.0, unscale=US%Z2_T_to_m2_s)
units="m2 s-1", default=Kv_mks, scale=US%m2_s_to_Z2_T)
endif

if (.not.CS%bottomdraglaw) then
Expand Down

0 comments on commit 25feaf2

Please sign in to comment.