From 9fa1fbc19e2cb6c1fc595c542b97c0d5bb6d1de2 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 9 May 2024 15:49:47 -0600 Subject: [PATCH 1/4] Add option to avoid negative MEKE --- src/parameterizations/lateral/MOM_MEKE.F90 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/parameterizations/lateral/MOM_MEKE.F90 b/src/parameterizations/lateral/MOM_MEKE.F90 index a44eec7727..4b5e390666 100644 --- a/src/parameterizations/lateral/MOM_MEKE.F90 +++ b/src/parameterizations/lateral/MOM_MEKE.F90 @@ -82,6 +82,7 @@ module MOM_MEKE !! first baroclinic deformation radius. logical :: use_old_lscale !< Use the old formula for mixing length scale. logical :: use_min_lscale !< Use simple minimum for mixing length scale. + logical :: MEKE_positive !< If true, it guarantees that MEKE will always be greater than zero. real :: lscale_maxval !< The ceiling on the MEKE mixing length scale when use_min_lscale is true [L ~> m]. real :: cdrag !< The bottom drag coefficient for MEKE, times rescaling factors [H L-1 ~> nondim or kg m-3] real :: MEKE_BGsrc !< Background energy source for MEKE [L2 T-3 ~> W kg-1] (= m2 s-3). @@ -648,6 +649,13 @@ subroutine step_forward_MEKE(MEKE, h, SN_u, SN_v, visc, dt, G, GV, US, CS, hu, h call MOM_error(FATAL,"Invalid method specified for calculating EKE") end select + if (CS%MEKE_positive) then + !$OMP parallel do default(shared) + do j=js,je ; do i=is,ie + MEKE%MEKE(i,j) = MAX(0., MEKE%MEKE(i,j)) + enddo ; enddo + endif + call cpu_clock_begin(CS%id_clock_pass) call do_group_pass(CS%pass_MEKE, G%Domain) call cpu_clock_end(CS%id_clock_pass) @@ -1228,6 +1236,9 @@ logical function MEKE_init(Time, G, GV, US, param_file, diag, dbcomms_CS, CS, ME call get_param(param_file, mdl, "MEKE_DTSCALE", CS%MEKE_dtScale, & "A scaling factor to accelerate the time evolution of MEKE.", & units="nondim", default=1.0) + call get_param(param_file, mdl, "MEKE_POSITIVE", CS%MEKE_positive, & + "If true, it guarantees that MEKE will always be greater than zero.", & + default=.false.) case("dbclient") CS%eke_src = EKE_DBCLIENT call ML_MEKE_init(diag, G, US, Time, param_file, dbcomms_CS, CS) From 5189b19988ed7cad5f6fb4316bb8250b0d3eb764 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 9 May 2024 15:57:53 -0600 Subject: [PATCH 2/4] Improve description --- src/parameterizations/lateral/MOM_MEKE.F90 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/parameterizations/lateral/MOM_MEKE.F90 b/src/parameterizations/lateral/MOM_MEKE.F90 index 4b5e390666..298ae76c05 100644 --- a/src/parameterizations/lateral/MOM_MEKE.F90 +++ b/src/parameterizations/lateral/MOM_MEKE.F90 @@ -81,8 +81,7 @@ module MOM_MEKE logical :: Rd_as_max_scale !< If true the length scale can not exceed the !! first baroclinic deformation radius. logical :: use_old_lscale !< Use the old formula for mixing length scale. - logical :: use_min_lscale !< Use simple minimum for mixing length scale. - logical :: MEKE_positive !< If true, it guarantees that MEKE will always be greater than zero. + logical :: use_min_lscale !< Use simple minimum for mixing l >= 0. real :: lscale_maxval !< The ceiling on the MEKE mixing length scale when use_min_lscale is true [L ~> m]. real :: cdrag !< The bottom drag coefficient for MEKE, times rescaling factors [H L-1 ~> nondim or kg m-3] real :: MEKE_BGsrc !< Background energy source for MEKE [L2 T-3 ~> W kg-1] (= m2 s-3). @@ -1237,7 +1236,7 @@ logical function MEKE_init(Time, G, GV, US, param_file, diag, dbcomms_CS, CS, ME "A scaling factor to accelerate the time evolution of MEKE.", & units="nondim", default=1.0) call get_param(param_file, mdl, "MEKE_POSITIVE", CS%MEKE_positive, & - "If true, it guarantees that MEKE will always be greater than zero.", & + "If true, it guarantees that MEKE will always be >= 0.", & default=.false.) case("dbclient") CS%eke_src = EKE_DBCLIENT From b6a84f48acb57435f9c9137e2894f3d46044cc2a Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 9 May 2024 16:04:12 -0600 Subject: [PATCH 3/4] Add MEKE_positive to the control structure --- src/parameterizations/lateral/MOM_MEKE.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parameterizations/lateral/MOM_MEKE.F90 b/src/parameterizations/lateral/MOM_MEKE.F90 index 298ae76c05..96edd94b76 100644 --- a/src/parameterizations/lateral/MOM_MEKE.F90 +++ b/src/parameterizations/lateral/MOM_MEKE.F90 @@ -82,6 +82,7 @@ module MOM_MEKE !! first baroclinic deformation radius. logical :: use_old_lscale !< Use the old formula for mixing length scale. logical :: use_min_lscale !< Use simple minimum for mixing l >= 0. + logical :: MEKE_positive !< If true, it guarantees that MEKE will always be >= 0. real :: lscale_maxval !< The ceiling on the MEKE mixing length scale when use_min_lscale is true [L ~> m]. real :: cdrag !< The bottom drag coefficient for MEKE, times rescaling factors [H L-1 ~> nondim or kg m-3] real :: MEKE_BGsrc !< Background energy source for MEKE [L2 T-3 ~> W kg-1] (= m2 s-3). From 0e1e29bb183f5886c0f9354ad93245662d47220a Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 9 May 2024 16:56:06 -0600 Subject: [PATCH 4/4] Revert a comment that was changed unintentionally. --- src/parameterizations/lateral/MOM_MEKE.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parameterizations/lateral/MOM_MEKE.F90 b/src/parameterizations/lateral/MOM_MEKE.F90 index 96edd94b76..d269171da9 100644 --- a/src/parameterizations/lateral/MOM_MEKE.F90 +++ b/src/parameterizations/lateral/MOM_MEKE.F90 @@ -81,7 +81,7 @@ module MOM_MEKE logical :: Rd_as_max_scale !< If true the length scale can not exceed the !! first baroclinic deformation radius. logical :: use_old_lscale !< Use the old formula for mixing length scale. - logical :: use_min_lscale !< Use simple minimum for mixing l >= 0. + logical :: use_min_lscale !< Use simple minimum for mixing length scale. logical :: MEKE_positive !< If true, it guarantees that MEKE will always be >= 0. real :: lscale_maxval !< The ceiling on the MEKE mixing length scale when use_min_lscale is true [L ~> m]. real :: cdrag !< The bottom drag coefficient for MEKE, times rescaling factors [H L-1 ~> nondim or kg m-3]