Skip to content

Commit 88a5baa

Browse files
authored
Merge branch 'bartgol/eamxx/atm-proc-time-stamp-fixes' (PR #7114)
- Update timestamp inside subcycle loop - Update timestamp before calling run_impl [non-BFB for eamxx-standalone testing and mam4xx cases only] Fixes #7074
2 parents a7a020f + 6982b02 commit 88a5baa

21 files changed

+70
-76
lines changed

components/eamxx/docs/_presentations_srcs/eamxx-tutorial-2025-part2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void POMPEI::run_impl(const double dt) {
487487
using PC = scream::physics::Constants<Real>;
488488
auto g = PC::gravit;
489489

490-
auto t = timestamp() + dt;
490+
auto t = end_of_step_ts();
491491
auto rate = pompei::ash_emission_rate(t.days_from(m_eruption_start));
492492
auto mass = dt * rate;
493493

components/eamxx/docs/developer/dev_testing/testing_for_development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ be the `eamxx_inject_ash_process_interface.<x>pp` files, located at
7676
[...] // set source_mask=1 only on area of interest, using lat/lon field
7777
}
7878
void MAM_AshInjection::run_impl(const double dt) {
79-
auto t = this->timestamp() + dt; // timestamp() is the START of step time
79+
auto t = end_of_step_ts();
8080
auto ash = get_field_out("ash");
8181
auto rate = compute_ash_injection_rate(
8282
t); // defined in ash_source_calculation.hpp header

components/eamxx/src/control/atmosphere_surface_coupling_exporter.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void SurfaceCouplingExporter::do_export(const double dt, const bool called_durin
322322
}
323323

324324
if (m_num_from_file_exports>0) {
325-
set_from_file_exports(dt);
325+
set_from_file_exports();
326326
}
327327

328328
if (m_num_from_model_exports>0) {
@@ -350,15 +350,10 @@ void SurfaceCouplingExporter::set_constant_exports()
350350

351351
}
352352
// =========================================================================================
353-
void SurfaceCouplingExporter::set_from_file_exports(const int dt)
353+
void SurfaceCouplingExporter::set_from_file_exports()
354354
{
355355
// Perform interpolation on the data with the latest timestamp
356-
auto ts = timestamp();
357-
if (dt > 0) {
358-
ts += dt;
359-
}
360-
m_time_interp.perform_time_interpolation(ts);
361-
356+
m_time_interp.perform_time_interpolation(end_of_step_ts());
362357
}
363358
// =========================================================================================
364359
// This compute_eamxx_exports routine handles all export variables that are derived from the EAMxx state.

components/eamxx/src/control/atmosphere_surface_coupling_exporter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class SurfaceCouplingExporter : public AtmosphereProcess
8181
void do_export(const double dt, const bool called_during_initialization=false); // Main export routine
8282
void compute_eamxx_exports(const double dt, const bool called_during_initialization=false); // Export vars are derived from eamxx state
8383
void set_constant_exports(); // Export vars are set to a constant
84-
void set_from_file_exports(const int dt); // Export vars are set by interpolation of data from files
84+
void set_from_file_exports(); // Export vars are set by interpolation of data from files
8585
void do_export_to_cpl(const bool called_during_initialization=false); // Finish export by copying data to cpl structures.
8686

8787
// Take and store data from SCDataManager

components/eamxx/src/control/atmosphere_surface_coupling_importer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ void SurfaceCouplingImporter::overwrite_iop_imports (const bool called_during_in
226226
const auto has_Tg = m_iop_data_manager->has_iop_field("Tg");
227227

228228
// Read IOP file for current time step, if necessary
229-
m_iop_data_manager->read_iop_file_data(timestamp());
229+
// TODO: this is using the TS from the beg of the step. Should it use end_of_step_ts() instead?
230+
m_iop_data_manager->read_iop_file_data(start_of_step_ts());
230231

231232
static constexpr Real latvap = C::LatVap;
232233
static constexpr Real stebol = C::stebol;

components/eamxx/src/dynamics/homme/eamxx_homme_fv_phys.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void copy_prev (const int ncols, const int npacks,
9393
Kokkos::fence();
9494
}
9595

96-
void HommeDynamics::fv_phys_dyn_to_fv_phys (const bool restart) {
96+
void HommeDynamics::fv_phys_dyn_to_fv_phys (const util::TimeStamp& ts, const bool restart) {
9797
if (not fv_phys_active()) return;
9898
constexpr int N = HOMMEXX_PACK_SIZE;
9999
using Pack = ekat::Pack<Real,N>;
@@ -136,10 +136,10 @@ void HommeDynamics::fv_phys_dyn_to_fv_phys (const bool restart) {
136136
// IC for FV fields, this step remains safe (we're setting the same t0)
137137
for (auto n : {"T_mid","horiz_winds","ps","phis","omega","pseudo_density"}) {
138138
auto f = get_field_out(n,pgn);
139-
f.get_header().get_tracking().update_time_stamp(timestamp());
139+
f.get_header().get_tracking().update_time_stamp(ts);
140140
}
141141
auto Q = get_group_out("tracers",pgn).m_monolithic_field;
142-
Q->get_header().get_tracking().update_time_stamp(timestamp());
142+
Q->get_header().get_tracking().update_time_stamp(ts);
143143
}
144144
update_pressure(m_phys_grid);
145145
}
@@ -156,7 +156,7 @@ void HommeDynamics::fv_phys_pre_process () {
156156
// update_pressure to update p_mid,int.
157157
void HommeDynamics::fv_phys_post_process () {
158158
if (not fv_phys_active()) return;
159-
fv_phys_dyn_to_fv_phys();
159+
fv_phys_dyn_to_fv_phys(end_of_step_ts());
160160
}
161161

162162
void HommeDynamics::remap_dyn_to_fv_phys (GllFvRemapTmp* t) const {
@@ -304,7 +304,7 @@ void HommeDynamics::fv_phys_rrtmgp_active_gases_remap (const RunType run_type) {
304304
gfr.remap_tracer_dyn_to_fv_phys(time_idx, 1, in_dgll, out_phys);
305305
Kokkos::fence();
306306

307-
f_phys.get_header().get_tracking().update_time_stamp(timestamp());
307+
f_phys.get_header().get_tracking().update_time_stamp(start_of_step_ts());
308308
}
309309
}
310310
}

components/eamxx/src/dynamics/homme/eamxx_homme_process_interface.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,16 +430,16 @@ void HommeDynamics::initialize_impl (const RunType run_type)
430430
}
431431

432432
// Since we just inited them, ensure p_mid/p_int (dry and wet) timestamps are valid
433-
get_field_out("p_int") .get_header().get_tracking().update_time_stamp(timestamp());
434-
get_field_out("p_mid") .get_header().get_tracking().update_time_stamp(timestamp());
435-
get_field_out("p_dry_int").get_header().get_tracking().update_time_stamp(timestamp());
436-
get_field_out("p_dry_mid").get_header().get_tracking().update_time_stamp(timestamp());
433+
get_field_out("p_int") .get_header().get_tracking().update_time_stamp(start_of_step_ts());
434+
get_field_out("p_mid") .get_header().get_tracking().update_time_stamp(start_of_step_ts());
435+
get_field_out("p_dry_int").get_header().get_tracking().update_time_stamp(start_of_step_ts());
436+
get_field_out("p_dry_mid").get_header().get_tracking().update_time_stamp(start_of_step_ts());
437437

438438
// Complete homme model initialization
439439
prim_init_model_f90 ();
440440

441441
if (fv_phys_active()) {
442-
fv_phys_dyn_to_fv_phys(run_type == RunType::Restart);
442+
fv_phys_dyn_to_fv_phys(start_of_step_ts(),run_type == RunType::Restart);
443443
// [CGLL ICs in pg2] Remove the CGLL fields from the process. The AD has a
444444
// separate fvphyshack-based line to remove the whole CGLL FM. The intention
445445
// is to clear the view memory on the device, but I don't know if these two
@@ -489,8 +489,8 @@ void HommeDynamics::run_impl (const double dt)
489489
" - input dt : " << dt << "\n"
490490
" - tolerance: " << std::numeric_limits<double>::epsilon()*10 << "\n");
491491

492-
if (m_bfb_hash_nstep > 0 && timestamp().get_num_steps() % m_bfb_hash_nstep == 0)
493-
print_fast_global_state_hash("Hommexx");
492+
if (m_bfb_hash_nstep > 0 && start_of_step_ts().get_num_steps() % m_bfb_hash_nstep == 0)
493+
print_fast_global_state_hash("Hommexx",start_of_step_ts());
494494

495495
const int dt_int = static_cast<int>(std::round(dt));
496496

@@ -1177,7 +1177,7 @@ void HommeDynamics::initialize_homme_state () {
11771177
const auto& name = it.get_header().get_identifier().name();
11781178
const auto& grid = it.get_header().get_identifier().get_grid_name();
11791179
auto& f = get_internal_field(name,grid);
1180-
f.get_header().get_tracking().update_time_stamp(timestamp());
1180+
f.get_header().get_tracking().update_time_stamp(start_of_step_ts());
11811181
}
11821182

11831183
if (not fv_phys_active()) {

components/eamxx/src/dynamics/homme/eamxx_homme_process_interface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class HommeDynamics : public AtmosphereProcess
9898
void fv_phys_set_grids();
9999
void fv_phys_requested_buffer_size_in_bytes() const;
100100
void fv_phys_initialize_impl();
101-
void fv_phys_dyn_to_fv_phys(const bool restart = false);
101+
void fv_phys_dyn_to_fv_phys(const util::TimeStamp& t, const bool restart = false);
102102
void fv_phys_pre_process();
103103
void fv_phys_post_process();
104104
// See [rrtmgp active gases] in eamxx_homme_fv_phys.cpp.

components/eamxx/src/physics/cosp/eamxx_cosp.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ void Cosp::run_impl (const double dt)
138138
// Make sure cosp frequency is multiple of rad frequency?
139139

140140
// Compare frequency in steps with current timestep
141-
// NOTE: timestamp() returns the time RIGHT BEFORE the call to run
142-
auto end_of_step = timestamp()+dt;
143-
auto update_cosp = cosp_do(cosp_freq_in_steps, end_of_step.get_num_steps());
141+
auto update_cosp = cosp_do(cosp_freq_in_steps, end_of_step_ts().get_num_steps());
144142

145143
// Call COSP wrapper routines
146144
if (update_cosp) {

components/eamxx/src/physics/iop_forcing/eamxx_iop_forcing_process_interface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ void IOPForcing::run_impl (const double dt)
346346
const auto Q = get_group_out("tracers").m_monolithic_field->get_view<Pack***>();
347347

348348
// Load data from IOP files, if necessary
349-
m_iop_data_manager->read_iop_file_data(timestamp());
349+
// TODO: this is using the TS from the beg of the step. Should it use end_of_step_ts() instead?
350+
m_iop_data_manager->read_iop_file_data(start_of_step_ts());
350351

351352
// Define local IOP param values
352353
const auto iop_dosubsidence = m_iop_data_manager->get_params().get<bool>("iop_dosubsidence");

0 commit comments

Comments
 (0)