Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into particle-API
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Oct 11, 2021
2 parents 725d3ff + 7d808b5 commit 93aa4ca
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
26 changes: 24 additions & 2 deletions src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ module MOM_barotropic
!! pressure [nondim]. Stable values are < ~1.0.
!! The default is 0.9.
logical :: tides !< If true, apply tidal momentum forcing.
logical :: tidal_sal_bug !< If true, the tidal self-attraction and loading anomaly in the
!! barotropic solver has the wrong sign, replicating a long-standing
!! bug.
real :: G_extra !< A nondimensional factor by which gtot is enhanced.
integer :: hvel_scheme !< An integer indicating how the thicknesses at
!! velocity points are calculated. Valid values are
Expand Down Expand Up @@ -1048,7 +1051,11 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,

if (CS%tides) then
call tidal_forcing_sensitivity(G, CS%tides_CSp, det_de)
dgeo_de = 1.0 + det_de + CS%G_extra
if (CS%tidal_sal_bug) then
dgeo_de = 1.0 + det_de + CS%G_extra
else
dgeo_de = (1.0 - det_de) + CS%G_extra
endif
else
dgeo_de = 1.0 + CS%G_extra
endif
Expand Down Expand Up @@ -2792,7 +2799,11 @@ subroutine set_dtbt(G, GV, US, CS, eta, pbce, BT_cont, gtot_est, SSH_add)

det_de = 0.0
if (CS%tides) call tidal_forcing_sensitivity(G, CS%tides_CSp, det_de)
dgeo_de = 1.0 + max(0.0, det_de + CS%G_extra)
if (CS%tidal_sal_bug) then
dgeo_de = 1.0 + max(0.0, det_de + CS%G_extra)
else
dgeo_de = 1.0 + max(0.0, CS%G_extra - det_de)
endif
if (present(pbce)) then
do j=js,je ; do i=is,ie
gtot_E(i,j) = 0.0 ; gtot_W(i,j) = 0.0
Expand Down Expand Up @@ -4329,6 +4340,9 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
! a restart file to the internal representation in this run.
real :: mean_SL ! The mean sea level that is used along with the bathymetry to estimate the
! geometry when LINEARIZED_BT_CORIOLIS is true or BT_NONLIN_STRESS is false [Z ~> m].
real :: det_de ! The partial derivative due to self-attraction and loading of the reference
! geopotential with the sea surface height when tides are enabled.
! This is typically ~0.09 or less.
real, allocatable, dimension(:,:) :: lin_drag_h
type(memory_size_type) :: MS
type(group_pass_type) :: pass_static_data, pass_q_D_Cor
Expand Down Expand Up @@ -4483,6 +4497,14 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,

call get_param(param_file, mdl, "TIDES", CS%tides, &
"If true, apply tidal momentum forcing.", default=.false.)
det_de = 0.0
if (CS%tides .and. associated(CS%tides_CSp)) &
call tidal_forcing_sensitivity(G, CS%tides_CSp, det_de)
call get_param(param_file, mdl, "BAROTROPIC_TIDAL_SAL_BUG", CS%tidal_sal_bug, &
"If true, the tidal self-attraction and loading anomaly in the barotropic "//&
"solver has the wrong sign, replicating a long-standing bug with a scalar "//&
"self-attraction and loading term or the SAL term from a previous simulation.", &
default=.true., do_not_log=(det_de==0.0))
call get_param(param_file, mdl, "SADOURNY", CS%Sadourny, &
"If true, the Coriolis terms are discretized with the "//&
"Sadourny (1975) energy conserving scheme, otherwise "//&
Expand Down
21 changes: 19 additions & 2 deletions src/parameterizations/lateral/MOM_MEKE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ module MOM_MEKE
real :: MEKE_topographic_beta !< Weight for how much topographic beta is considered
!! when computing beta in Rhines scale [nondim]
real :: MEKE_restoring_rate !< Inverse of the timescale used to nudge MEKE toward its equilibrium value [s-1].
logical :: MEKE_advection_bug !< If true, recover a bug in the calculation of the barotropic
!! transport for the advection of MEKE, wherein only the transports in the
!! deepest layer are used.
logical :: fixed_total_depth !< If true, use the nominal bathymetric depth as the estimate of
!! the time-varying ocean depth. Otherwise base the depth on the total
!! ocean mass per unit area.
Expand Down Expand Up @@ -220,17 +223,27 @@ subroutine step_forward_MEKE(MEKE, h, SN_u, SN_v, visc, dt, G, GV, US, CS, hu, h
enddo ; enddo
do k=1,nz
do j=js,je ; do I=is-1,ie
baroHu(I,j) = hu(I,j,k) * GV%H_to_RZ
baroHu(I,j) = baroHu(I,j) + hu(I,j,k) * GV%H_to_RZ
enddo ; enddo
enddo
do J=js-1,je ; do i=is,ie
baroHv(i,J) = 0.
enddo ; enddo
do k=1,nz
do J=js-1,je ; do i=is,ie
baroHv(i,J) = hv(i,J,k) * GV%H_to_RZ
baroHv(i,J) = baroHv(i,J) + hv(i,J,k) * GV%H_to_RZ
enddo ; enddo
enddo
if (CS%MEKE_advection_bug) then
! This code obviously incorrect code reproduces a bug in the original implementation of
! the MEKE advection.
do j=js,je ; do I=is-1,ie
baroHu(I,j) = hu(I,j,nz) * GV%H_to_RZ
enddo ; enddo
do J=js-1,je ; do i=is,ie
baroHv(i,J) = hv(i,J,nz) * GV%H_to_RZ
enddo ; enddo
endif
endif


Expand Down Expand Up @@ -1212,6 +1225,10 @@ logical function MEKE_init(Time, G, US, param_file, diag, CS, MEKE, restart_CS)
"Using unity would be normal but other values could accommodate a mismatch "//&
"between the advecting barotropic flow and the vertical structure of MEKE.", &
units="nondim", default=0.0)
call get_param(param_file, mdl, "MEKE_ADVECTION_BUG", CS%MEKE_advection_bug, &
"If true, recover a bug in the calculation of the barotropic transport for "//&
"the advection of MEKE. With the bug, only the transports in the deepest "//&
"layer are used.", default=.false., do_not_log=(CS%MEKE_advection_factor<=0.))
call get_param(param_file, mdl, "MEKE_TOPOGRAPHIC_BETA", CS%MEKE_topographic_beta, &
"A scale factor to determine how much topographic beta is weighed in " //&
"computing beta in the expression of Rhines scale. Use 1 if full "//&
Expand Down

0 comments on commit 93aa4ca

Please sign in to comment.