Skip to content

Commit 5851a69

Browse files
committed
+Separate OBC_for_remap and OBC_for_bug arguments
Add separate OBC_for_remap and OBC_for_bug arguments to MOM_initialize_state() to clarify the distinct roles of the two arguments, to make it clear that one can not be used without rotation, and to prepare for the eventual obsoleting of OBC_RESERVOIR_INIT_BUG. This commit also simplifies the logic setting ntstep when do_thermo is false. All answers are bitwise identical, but there is a new optional argument to MOM_initialize_state and another argument has been renamed.
1 parent 4d5bcea commit 5851a69

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/core/MOM.F90

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
673673
if (do_dyn) then
674674
n_max = 1
675675
if (time_interval > CS%dt) n_max = ceiling(time_interval/CS%dt - 0.001)
676-
ntstep = 1 ! initialization
676+
677677
dt = time_interval / real(n_max)
678678
thermo_does_span_coupling = (CS%thermo_spans_coupling .and. &
679679
(CS%dt_therm > 1.5*cycle_time))
@@ -686,7 +686,8 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
686686
elseif (.not.do_thermo) then
687687
dt_therm = CS%dt_therm
688688
if (present(cycle_length)) dt_therm = min(CS%dt_therm, cycle_length)
689-
! ntstep is not used.
689+
ntstep = 1 ! ntstep is initialized to avoid an error in a secondary logical test,
690+
! but the nonzero value of ntstep does not matter when do_thermo is false.
690691
else
691692
ntstep = MAX(1, MIN(n_max, floor(CS%dt_therm/dt + 0.001)))
692693
dt_therm = dt*ntstep
@@ -698,7 +699,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
698699
elseif (.not.do_thermo) then
699700
dt_tr_adv = CS%dt_tr_adv
700701
if (present(cycle_length)) dt_tr_adv = min(CS%dt_tr_adv, cycle_length)
701-
! ntstep is not used.
702+
! ntastep is not used.
702703
else
703704
ntastep = MAX(1, MIN(n_max, floor(CS%dt_tr_adv/dt + 0.001)))
704705
dt_tr_adv = dt*ntastep
@@ -3179,7 +3180,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, &
31793180
CS%tv%T => T_in
31803181
CS%tv%S => S_in
31813182

3182-
if (associated(OBC_in)) then
3183+
if (associated(CS%OBC)) then
31833184
! Log this parameter in MOM_initialize_state
31843185
call get_param(param_file, "MOM", "OBC_RESERVOIR_INIT_BUG", OBC_reservoir_init_bug, &
31853186
"If true, set the OBC tracer reservoirs at the startup of a new run from the "//&
@@ -3260,12 +3261,12 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, &
32603261
call ice_shelf_query(ice_shelf_CSp,G,CS%frac_shelf_h, CS%mass_shelf)
32613262
call MOM_initialize_state(CS%u, CS%v, CS%h, CS%tv, Time, G, GV, US, &
32623263
param_file, dirs, restart_CSp, CS%ALE_CSp, CS%tracer_Reg, &
3263-
CS%sponge_CSp, CS%ALE_sponge_CSp,CS%oda_incupd_CSp, CS%OBC, Time_in, &
3264-
frac_shelf_h=CS%frac_shelf_h, mass_shelf=CS%mass_shelf)
3264+
CS%sponge_CSp, CS%ALE_sponge_CSp, CS%oda_incupd_CSp, CS%OBC, Time_in, &
3265+
frac_shelf_h=CS%frac_shelf_h, mass_shelf=CS%mass_shelf, OBC_for_bug=CS%OBC)
32653266
else
32663267
call MOM_initialize_state(CS%u, CS%v, CS%h, CS%tv, Time, G, GV, US, &
32673268
param_file, dirs, restart_CSp, CS%ALE_CSp, CS%tracer_Reg, &
3268-
CS%sponge_CSp, CS%ALE_sponge_CSp, CS%oda_incupd_CSp, CS%OBC, Time_in)
3269+
CS%sponge_CSp, CS%ALE_sponge_CSp, CS%oda_incupd_CSp, CS%OBC, Time_in, OBC_for_bug=CS%OBC)
32693270
endif
32703271

32713272
! Reset the first direction if it was found in a restart file.

src/initialization/MOM_state_initialization.F90

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ module MOM_state_initialization
113113
!! conditions or by reading them from a restart (or saves) file.
114114
subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
115115
restart_CS, ALE_CSp, tracer_Reg, sponge_CSp, &
116-
ALE_sponge_CSp, oda_incupd_CSp, OBC, Time_in, frac_shelf_h, mass_shelf)
116+
ALE_sponge_CSp, oda_incupd_CSp, OBC_for_remap, &
117+
Time_in, frac_shelf_h, mass_shelf, OBC_for_bug)
117118
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure.
118119
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
119120
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
@@ -137,8 +138,10 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
137138
type(tracer_registry_type), pointer :: tracer_Reg !< A pointer to the tracer registry
138139
type(sponge_CS), pointer :: sponge_CSp !< The layerwise sponge control structure.
139140
type(ALE_sponge_CS), pointer :: ALE_sponge_CSp !< The ALE sponge control structure.
140-
type(ocean_OBC_type), pointer :: OBC !< The open boundary condition control structure.
141-
! OBC is only used in MOM_initialize_state if OBC_RESERVOIR_INIT_BUG is true.
141+
type(ocean_OBC_type), pointer :: OBC_for_remap !< The open boundary condition control
142+
!! structure that may be used for remapping velocities.
143+
!! This must be on the unrotated grid, but only the
144+
!! position and directions of the OBC faces are used.
142145
type(oda_incupd_CS), pointer :: oda_incupd_CSp !< The oda_incupd control structure.
143146
type(time_type), optional, intent(in) :: Time_in !< Time at the start of the run segment.
144147
real, dimension(SZI_(G),SZJ_(G)), &
@@ -147,6 +150,9 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
147150
real, dimension(SZI_(G),SZJ_(G)), &
148151
optional, intent(in) :: mass_shelf !< The mass per unit area of the overlying
149152
!! ice shelf [ R Z ~> kg m-2 ]
153+
type(ocean_OBC_type), optional, pointer :: OBC_for_bug !< An open boundary condition control structure
154+
!! that might be used to store OBC temperatures and
155+
!! salinities if OBC_RESERVOIR_INIT_BUG is true.
150156
! Local variables
151157
real :: depth_tot(SZI_(G),SZJ_(G)) ! The nominal total depth of the ocean [Z ~> m]
152158
real :: dz(SZI_(G),SZJ_(G),SZK_(GV)) ! The layer thicknesses in geopotential (z) units [Z ~> m]
@@ -432,7 +438,7 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
432438
endif
433439
endif ! not from_Z_file.
434440

435-
if (use_temperature .and. associated(OBC)) then
441+
if (present(OBC_for_bug)) then ; if (use_temperature .and. associated(OBC_for_bug)) then
436442
call get_param(PF, mdl, "ENABLE_BUGS_BY_DEFAULT", enable_bugs, &
437443
default=.true., do_not_log=.true.) ! This is logged from MOM.F90.
438444
! Log this parameter later with the other OBC parameters.
@@ -445,9 +451,9 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
445451
! the temperatures and salinities can change due to the remapping and reading from the restarts.
446452
call pass_var(tv%T, G%Domain, complete=.false.)
447453
call pass_var(tv%S, G%Domain, complete=.true.)
448-
call fill_temp_salt_segments(G, GV, US, OBC, tv)
454+
call fill_temp_salt_segments(G, GV, US, OBC_for_bug, tv)
449455
endif
450-
endif
456+
endif ; endif
451457

452458
! Convert thicknesses from geometric distances in depth units to thickness units or mass-per-unit-area.
453459
if (new_sim .and. convert) call dz_to_thickness(dz, tv, h, G, GV, US)
@@ -496,10 +502,10 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &
496502

497503
if (new_sim .and. debug) &
498504
call hchksum(h, "Pre-ALE_regrid: h ", G%HI, haloshift=1, unscale=GV%H_to_MKS)
499-
! In this call, OBC is only used for the directions of OBCs when setting thicknesses at
505+
! In this call, OBC_for_remap is only used for the directions of OBCs when setting thicknesses at
500506
! velocity points.
501-
call ALE_regrid_accelerated(ALE_CSp, G, GV, US, h, tv, regrid_iterations, u, v, OBC, tracer_Reg, &
502-
dt=dt, initial=.true.)
507+
call ALE_regrid_accelerated(ALE_CSp, G, GV, US, h, tv, regrid_iterations, u, v, OBC_for_remap, &
508+
tracer_Reg, dt=dt, initial=.true.)
503509
endif
504510
endif
505511

0 commit comments

Comments
 (0)