Skip to content

Commit

Permalink
EAMxx: only init timestep in IO if this will be an output step
Browse files Browse the repository at this point in the history
  • Loading branch information
bartgol committed May 10, 2024
1 parent 5759664 commit 869910c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/eamxx/src/control/atmosphere_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ void AtmosphereDriver::run (const int dt) {
// the timestamp at the beginning of the timestep, so that we can compute
// dt at the end.
for (auto it : m_output_managers) {
it.init_timestep(m_current_ts);
it.init_timestep(m_current_ts,dt);
}

// The class AtmosphereProcessGroup will take care of dispatching arguments to
Expand Down
19 changes: 13 additions & 6 deletions components/eamxx/src/share/io/scream_output_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ setup (const ekat::Comm& io_comm, const ekat::ParameterList& params,
m_output_control.next_write_ts = m_run_t0;
// This is in case some diags need to init the timestep. Most likely, their output
// is meaningless at t0, but they may still require the start-of-step timestamp to be valid
init_timestep(m_run_t0);
init_timestep(m_run_t0,0);
this->run(m_run_t0);
}

Expand All @@ -285,13 +285,24 @@ add_global (const std::string& name, const ekat::any& global) {
}

/*===============================================================================================*/
void OutputManager::init_timestep (const util::TimeStamp& start_of_step)
void OutputManager::init_timestep (const util::TimeStamp& start_of_step, const Real dt)
{
// In case output is disabled, no point in doing anything else
if (not m_output_control.output_enabled()) {
return;
}

// Update counters
++m_output_control.nsamples_since_last_write;
++m_checkpoint_control.nsamples_since_last_write;

// Check if the end of this timestep will correspond to an output step. If not, there's nothing to do
const auto& end_of_step = start_of_step+dt;
const bool will_be_output_step = m_output_control.is_write_step(end_of_step) || end_of_step==m_case_t0;
if (not will_be_output_step) {
return;
}

if (m_atm_logger) {
m_atm_logger->debug("[OutputManager::init_timestep] filename_prefix: " + m_filename_prefix + "\n");
}
Expand All @@ -317,10 +328,6 @@ void OutputManager::run(const util::TimeStamp& timestamp)
std::string timer_root = m_is_model_restart_output ? "EAMxx::IO::restart" : "EAMxx::IO::standard";
start_timer(timer_root);

// Check if we need to open a new file
++m_output_control.nsamples_since_last_write;
++m_checkpoint_control.nsamples_since_last_write;

// Check if this is a write step (and what kind)
// Note: a full checkpoint not only writes globals in the restart file, but also all the history variables.
// Since we *always* write a history restart file, we can have a non-full checkpoint, if the average
Expand Down
2 changes: 1 addition & 1 deletion components/eamxx/src/share/io/scream_output_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class OutputManager
}
void add_global (const std::string& name, const ekat::any& global);

void init_timestep (const util::TimeStamp& start_of_step);
void init_timestep (const util::TimeStamp& start_of_step, const Real dt);
void run (const util::TimeStamp& current_ts);
void finalize();

Expand Down
2 changes: 1 addition & 1 deletion components/eamxx/src/share/io/tests/io_diags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void write (const int seed, const ekat::Comm& comm)
f.get_header().get_tracking().update_time_stamp(t0+dt);
f.update(one,1.0,1.0);
}
om.init_timestep(t0);
om.init_timestep(t0,dt);
om.run (t0+dt);

// Close file and cleanup
Expand Down

0 comments on commit 869910c

Please sign in to comment.