Skip to content

Commit

Permalink
Merge pull request mom-ocean#1296 from adcroft/options-to-recover-spear
Browse files Browse the repository at this point in the history
Options enabling old bugs to recover SPEAR
  • Loading branch information
Hallberg-NOAA authored Jan 26, 2021
2 parents 68a6b91 + 4e73370 commit b3e33d4
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 74 deletions.
35 changes: 28 additions & 7 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ module MOM
logical :: useWaves !< If true, update Stokes drift
logical :: use_p_surf_in_EOS !< If true, always include the surface pressure contributions
!! in equation of state calculations.
logical :: use_diabatic_time_bug !< If true, uses the wrong calendar time for diabatic processes,
!! as was done in MOM6 versions prior to February 2018.
real :: dtbt_reset_period !< The time interval between dynamic recalculation of the
!! barotropic time step [s]. If this is negative dtbt is never
!! calculated, and if it is 0, dtbt is calculated every step.
Expand Down Expand Up @@ -663,9 +665,15 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS

rel_time = 0.0
do n=1,n_max
rel_time = rel_time + dt ! The relative time at the end of the step.
! Set the universally visible time to the middle of the time step.
CS%Time = Time_start + real_to_time(US%T_to_s*(rel_time - 0.5*dt))
if (CS%use_diabatic_time_bug) then
! This wrong form of update was used until Feb 2018, recovered with CS%use_diabatic_time_bug=T.
CS%Time = Time_start + real_to_time(US%T_to_s*int(floor(rel_time+0.5*dt+0.5)))
rel_time = rel_time + dt
else
rel_time = rel_time + dt ! The relative time at the end of the step.
! Set the universally visible time to the middle of the time step.
CS%Time = Time_start + real_to_time(US%T_to_s*(rel_time - 0.5*dt))
endif
! Set the local time to the end of the time step.
Time_local = Time_start + real_to_time(US%T_to_s*rel_time)

Expand Down Expand Up @@ -695,12 +703,16 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
endif

end_time_thermo = Time_local
if (dtdia > dt) then
if (dtdia > dt .and. .not. CS%use_diabatic_time_bug) then
! If necessary, temporarily reset CS%Time to the center of the period covered
! by the call to step_MOM_thermo, noting that they begin at the same time.
! This step was missing prior to Feb 2018, and is skipped with CS%use_diabatic_time_bug=T.
CS%Time = CS%Time + real_to_time(0.5*US%T_to_s*(dtdia-dt))
endif
if (dtdia > dt .or. CS%use_diabatic_time_bug) then
! The end-time of the diagnostic interval needs to be set ahead if there
! are multiple dynamic time steps worth of thermodynamics applied here.
! This line was not conditional prior to Feb 2018, recovered with CS%use_diabatic_time_bug=T.
end_time_thermo = Time_local + real_to_time(US%T_to_s*(dtdia-dt))
endif

Expand All @@ -713,7 +725,8 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
CS%t_dyn_rel_thermo = -dtdia
if (showCallTree) call callTree_waypoint("finished diabatic_first (step_MOM)")

if (dtdia > dt) & ! Reset CS%Time to its previous value.
if (dtdia > dt .and. .not. CS%use_diabatic_time_bug) & ! Reset CS%Time to its previous value.
! This step was missing prior to Feb 2018, recovered with CS%use_diabatic_time_bug=T.
CS%Time = Time_start + real_to_time(US%T_to_s*(rel_time - 0.5*dt))
endif ! end of block "(CS%diabatic_first .and. (CS%t_dyn_rel_adv==0.0))"

Expand Down Expand Up @@ -800,7 +813,9 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS

! If necessary, temporarily reset CS%Time to the center of the period covered
! by the call to step_MOM_thermo, noting that they end at the same time.
if (dtdia > dt) CS%Time = CS%Time - real_to_time(0.5*US%T_to_s*(dtdia-dt))
! This step was missing prior to Feb 2018, and is skipped with CS%use_diabatic_time_bug=T.
if (dtdia > dt .and. .not. CS%use_diabatic_time_bug) &
CS%Time = CS%Time - real_to_time(0.5*US%T_to_s*(dtdia-dt))

! Apply diabatic forcing, do mixing, and regrid.
call step_MOM_thermo(CS, G, GV, US, u, v, h, CS%tv, fluxes, dtdia, &
Expand All @@ -814,7 +829,9 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
CS%t_dyn_rel_thermo = 0.0
endif

if (dtdia > dt) & ! Reset CS%Time to its previous value.
! Reset CS%Time to its previous value.
! This step was missing prior to Feb 2018, and is skipped with CS%use_diabatic_time_bug=T.
if (dtdia > dt .and. .not. CS%use_diabatic_time_bug) &
CS%Time = Time_start + real_to_time(US%T_to_s*(rel_time - 0.5*dt))
endif

Expand Down Expand Up @@ -2000,6 +2017,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
"If true, use expressions for the surface properties that recover the answers "//&
"from the end of 2018. Otherwise, use more appropriate expressions that differ "//&
"at roundoff for non-Boussinesq cases.", default=default_2018_answers)
call get_param(param_file, "MOM", "USE_DIABATIC_TIME_BUG", CS%use_diabatic_time_bug, &
"If true, uses the wrong calendar time for diabatic processes, as was "//&
"done in MOM6 versions prior to February 2018. This is not recommended.", &
default=.false.)

call get_param(param_file, "MOM", "SAVE_INITIAL_CONDS", save_IC, &
"If true, write the initial conditions to a file given "//&
Expand Down
9 changes: 8 additions & 1 deletion src/core/MOM_PressureForce_FV.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ module MOM_PressureForce_FV
type(diag_ctrl), pointer :: diag !< A structure that is used to regulate the
!! timing of diagnostic output.
logical :: useMassWghtInterp !< Use mass weighting in T/S interpolation
logical :: use_inaccurate_pgf_rho_anom !< If true, uses the older and less accurate
!! method to calculate density anomalies, as used prior to
!! March 2018.
logical :: boundary_extrap !< Indicate whether high-order boundary
!! extrapolation should be used within boundary cells

Expand Down Expand Up @@ -696,7 +699,8 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
call int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, &
rho_ref, CS%Rho0, GV%g_Earth, dz_neglect, G%bathyT, &
G%HI, GV, tv%eqn_of_state, US, dpa, intz_dpa, intx_dpa, inty_dpa, &
useMassWghtInterp=CS%useMassWghtInterp)
useMassWghtInterp=CS%useMassWghtInterp, &
use_inaccurate_form=CS%use_inaccurate_pgf_rho_anom)
elseif ( CS%Recon_Scheme == 2 ) then
call int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
rho_ref, CS%Rho0, GV%g_Earth, dz_neglect, G%bathyT, &
Expand Down Expand Up @@ -838,6 +842,9 @@ subroutine PressureForce_FV_init(Time, G, GV, US, param_file, diag, CS, tides_CS
"If true, use mass weighting when interpolating T/S for "//&
"integrals near the bathymetry in FV pressure gradient "//&
"calculations.", default=.false.)
call get_param(param_file, mdl, "USE_INACCURATE_PGF_RHO_ANOM", CS%use_inaccurate_pgf_rho_anom, &
"If true, use a form of the PGF that uses the reference density "//&
"in an inaccurate way. This is not recommended.", default=.false.)
call get_param(param_file, mdl, "RECONSTRUCT_FOR_PRESSURE", CS%reconstruct, &
"If True, use vertical reconstruction of T & S within "//&
"the integrals of the FV pressure gradient calculation. "//&
Expand Down
Loading

0 comments on commit b3e33d4

Please sign in to comment.