Skip to content

Commit

Permalink
Rename VISC_REM bugfix parameters
Browse files Browse the repository at this point in the history
VISC_REM_TIMESTEP_FIX -> VISC_REM_TIMESTEP_BUG
VISC_REM_BT_WEIGHT_FIX -> VISC_REM_BT_WEIGHT_BUG

The "signs" of the flags are flipped accordingly.
  • Loading branch information
herrwang0 authored and adcroft committed Nov 5, 2024
1 parent f2e927b commit 341caf4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
13 changes: 6 additions & 7 deletions src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ module MOM_barotropic
logical :: tidal_sal_flather !< Apply adjustment to external gravity wave speed
!! consistent with tidal self-attraction and loading
!! used within the barotropic solver
logical :: wt_uv_fix !< If true, use a normalized wt_[uv] for vertical averages.
logical :: wt_uv_bug = .true. !< If true, recover a bug that wt_[uv] that is not normalized.
type(time_type), pointer :: Time => NULL() !< A pointer to the ocean models clock.
type(diag_ctrl), pointer :: diag => NULL() !< A structure that is used to regulate
!! the timing of diagnostic output.
Expand Down Expand Up @@ -1070,7 +1070,7 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,
wt_v(i,J,k) = CS%frhatv(i,J,k) * visc_rem
enddo ; enddo ; enddo

if (CS%wt_uv_fix) then
if (.not. CS%wt_uv_bug) then
do j=js,je ; do I=is-1,ie ; Iwt_u_tot(I,j) = wt_u(I,j,1) ; enddo ; enddo
do k=2,nz ; do j=js,je ; do I=is-1,ie
Iwt_u_tot(I,j) = Iwt_u_tot(I,j) + wt_u(I,j,k)
Expand Down Expand Up @@ -4652,11 +4652,10 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
if (.not.GV%Boussinesq) CS%answer_date = max(CS%answer_date, 20230701)

call get_param(param_file, mdl, "VISC_REM_BUG", visc_rem_bug, default=.true., do_not_log=.true.)
call get_param(param_file, mdl, "VISC_REM_BT_WEIGHT_FIX", CS%wt_uv_fix, &
"If true, use a normalized weight function for vertical averages of "//&
"baroclinic velocity and forcing. Default of this flag is set by "//&
"VISC_REM_BUG. This flag should be used with VISC_REM_TIMESTEP_FIX.", &
default=.not.visc_rem_bug)
call get_param(param_file, mdl, "VISC_REM_BT_WEIGHT_BUG", CS%wt_uv_bug, &
"If true, recover a bug in barotropic solver that uses an unnormalized weight "//&
"function for vertical averages of baroclinic velocity and forcing. Default "//&
"of this flag is set by VISC_REM_BUG.", default=visc_rem_bug)
call get_param(param_file, mdl, "TIDES", use_tides, &
"If true, apply tidal momentum forcing.", default=.false.)
if (use_tides .and. present(HA_CSp)) CS%HA_CSp => HA_CSp
Expand Down
27 changes: 13 additions & 14 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ module MOM_dynamics_split_RK2
logical :: debug_OBC !< If true, do debugging calls for open boundary conditions.
logical :: fpmix = .false. !< If true, applies profiles of momentum flux magnitude and direction.
logical :: module_is_initialized = .false. !< Record whether this module has been initialized.
logical :: visc_rem_dt_fix = .false. !<If true, use dt rather than dt_pred for vertvisc_rem at the end of predictor.
logical :: visc_rem_dt_bug = .true. !< If true, recover a bug that uses dt_pred rather than dt for vertvisc_rem
!! at the end of predictor.

!>@{ Diagnostic IDs
integer :: id_uold = -1, id_vold = -1
Expand Down Expand Up @@ -736,10 +737,10 @@ subroutine step_MOM_dyn_split_RK2(u_inst, v_inst, h, tv, visc, Time_local, dt, f
call start_group_pass(CS%pass_uvp, G%Domain, clock=id_clock_pass)
call cpu_clock_begin(id_clock_vertvisc)
endif
if (CS%visc_rem_dt_fix) then
call vertvisc_remnant(visc, CS%visc_rem_u, CS%visc_rem_v, dt, G, GV, US, CS%vertvisc_CSp)
else
if (CS%visc_rem_dt_bug) then
call vertvisc_remnant(visc, CS%visc_rem_u, CS%visc_rem_v, dt_pred, G, GV, US, CS%vertvisc_CSp)
else
call vertvisc_remnant(visc, CS%visc_rem_u, CS%visc_rem_v, dt, G, GV, US, CS%vertvisc_CSp)
endif
call cpu_clock_end(id_clock_vertvisc)

Expand Down Expand Up @@ -1439,16 +1440,14 @@ subroutine initialize_dyn_split_RK2(u, v, h, tv, uh, vh, eta, Time, G, GV, US, p
default=.false.)
call get_param(param_file, mdl, "VISC_REM_BUG", visc_rem_bug, &
"If true, visc_rem_[uv] in split mode is incorrectly calculated or accounted "//&
"for in three places. This parameter controls the defaults of three individual "//&
"flags, VISC_REM_TIMESTEP_FIX in MOM_dynamics_split_RK2(b), "//&
"VISC_REM_BT_WEIGHT_FIX in MOM_barotropic, and VISC_REM_CONT_HVEL_FIX in "//&
"MOM_continuity_PPM. Eventually, the three individual flags should be removed "//&
"after tests and the default of VISC_REM_BUG should be to False.", default=.true.)
call get_param(param_file, mdl, "VISC_REM_TIMESTEP_FIX", CS%visc_rem_dt_fix, &
"If true, use dt rather than dt_pred in vertvisc_remnant() at the end of "//&
"predictor stage for the following continuity() call and btstep() call "//&
"in the corrector step. This flag should be used with "//&
"VISC_REM_BT_WEIGHT_FIX.", default=.not.visc_rem_bug)
"for in two places. This parameter controls the defaults of two individual "//&
"flags, VISC_REM_TIMESTEP_BUG in MOM_dynamics_split_RK2(b) and "//&
"VISC_REM_BT_WEIGHT_BUG in MOM_barotropic.", default=.true.)
call get_param(param_file, mdl, "VISC_REM_TIMESTEP_BUG", CS%visc_rem_dt_bug, &
"If true, recover a bug that uses dt_pred rather than dt in "//&
"vertvisc_remnant() at the end of predictor stage for the following "//&
"continuity() and btstep() calls in the corrector step. Default of this flag "//&
"is set by VISC_REM_BUG", default=visc_rem_bug)

allocate(CS%taux_bot(IsdB:IedB,jsd:jed), source=0.0)
allocate(CS%tauy_bot(isd:ied,JsdB:JedB), source=0.0)
Expand Down
28 changes: 14 additions & 14 deletions src/core/MOM_dynamics_split_RK2b.F90
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ module MOM_dynamics_split_RK2b
logical :: debug_OBC !< If true, do debugging calls for open boundary conditions.
logical :: fpmix = .false. !< If true, applies profiles of momentum flux magnitude and direction.
logical :: module_is_initialized = .false. !< Record whether this module has been initialized.
logical :: visc_rem_dt_fix = .false. !<If true, use dt rather than dt_pred for vertvisc_rem at the end of predictor.
logical :: visc_rem_dt_bug = .true. !< If true, recover a bug that uses dt_pred rather than dt for vertvisc_rem
!! at the end of predictor.

!>@{ Diagnostic IDs
! integer :: id_uold = -1, id_vold = -1
Expand Down Expand Up @@ -754,10 +755,10 @@ subroutine step_MOM_dyn_split_RK2b(u_av, v_av, h, tv, visc, Time_local, dt, forc
call start_group_pass(CS%pass_uvp, G%Domain, clock=id_clock_pass)
call cpu_clock_begin(id_clock_vertvisc)
endif
if (CS%visc_rem_dt_fix) then
call vertvisc_remnant(visc, CS%visc_rem_u, CS%visc_rem_v, dt, G, GV, US, CS%vertvisc_CSp)
else
if (CS%visc_rem_dt_bug) then
call vertvisc_remnant(visc, CS%visc_rem_u, CS%visc_rem_v, dt_pred, G, GV, US, CS%vertvisc_CSp)
else
call vertvisc_remnant(visc, CS%visc_rem_u, CS%visc_rem_v, dt, G, GV, US, CS%vertvisc_CSp)
endif
call cpu_clock_end(id_clock_vertvisc)

Expand Down Expand Up @@ -1355,16 +1356,15 @@ subroutine initialize_dyn_split_RK2b(u, v, h, tv, uh, vh, eta, Time, G, GV, US,
default=.false.)
call get_param(param_file, mdl, "VISC_REM_BUG", visc_rem_bug, &
"If true, visc_rem_[uv] in split mode is incorrectly calculated or accounted "//&
"for in three places. This parameter controls the defaults of three individual "//&
"flags, VISC_REM_TIMESTEP_FIX in MOM_dynamics_split_RK2(b), "//&
"VISC_REM_BT_WEIGHT_FIX in MOM_barotropic, and VISC_REM_CONT_HVEL_FIX in "//&
"MOM_continuity_PPM. Eventually, the three individual flags should be removed "//&
"after tests and the default of VISC_REM_BUG should be to False.", default=.true.)
call get_param(param_file, mdl, "VISC_REM_TIMESTEP_FIX", CS%visc_rem_dt_fix, &
"If true, use dt rather than dt_pred in vertvisc_remnant() at the end of "//&
"predictor stage for the following continuity() call and btstep() call "//&
"in the corrector step. Default of this flag is set by VISC_REM_BUG. "//&
"This flag should be used with VISC_REM_BT_WEIGHT_FIX.", default=.not.visc_rem_bug)
"for in two places. This parameter controls the defaults of two individual "//&
"flags, VISC_REM_TIMESTEP_BUG in MOM_dynamics_split_RK2(b) and "//&
"VISC_REM_BT_WEIGHT_BUG in MOM_barotropic.", default=.true.)
call get_param(param_file, mdl, "VISC_REM_TIMESTEP_BUG", CS%visc_rem_dt_bug, &
"If true, recover a bug that uses dt_pred rather than dt in "//&
"vertvisc_remnant() at the end of predictor stage for the following "//&
"continuity() and btstep() calls in the corrector step. Default of this flag "//&
"is set by VISC_REM_BUG", default=visc_rem_bug)


allocate(CS%taux_bot(IsdB:IedB,jsd:jed), source=0.0)
allocate(CS%tauy_bot(isd:ied,JsdB:JedB), source=0.0)
Expand Down

0 comments on commit 341caf4

Please sign in to comment.