Skip to content

Commit

Permalink
Merge pull request #3086 from E3SM-Project/aarondonahue/IO/add_more_f…
Browse files Browse the repository at this point in the history
…req_units_options

Add alias options for frequency units of output.
  • Loading branch information
AaronDonahue authored Nov 4, 2024
2 parents 97bf293 + eedfdcc commit a1d4b50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions components/eamxx/src/share/io/scream_io_control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ struct IOControl {
ts.get_time()==next_write_ts.get_time());
}

void set_frequency_units (const std::string& freq_unit) {
if (freq_unit=="none" or freq_unit=="never") {
frequency_units = freq_unit;
} else if (freq_unit=="nstep" or freq_unit=="nsteps") {
frequency_units = "nsteps";
} else if (freq_unit=="nsecond" or freq_unit=="nseconds" or freq_unit=="nsecs") {
frequency_units = "nsecs";
} else if (freq_unit=="nminute" or freq_unit=="nminutes" or freq_unit=="nmins") {
frequency_units = "nmins";
} else if (freq_unit=="nhour" or freq_unit=="nhours") {
frequency_units = "nhours";
} else if (freq_unit=="nday" or freq_unit=="ndays") {
frequency_units = "ndays";
} else if (freq_unit=="nmonth" or freq_unit=="nmonths") {
frequency_units = "nmonths";
} else if (freq_unit=="nyear" or freq_unit=="nyears") {
frequency_units = "nyears";
} else {
// TODO - add support for "end" as an option
EKAT_ERROR_MSG("Error! Unsupported frequency units of " + freq_unit + " provided.");
}

}

void set_dt (const double dt_in) {
EKAT_REQUIRE_MSG (dt==0 or dt==dt_in,
"[IOControl::set_dt] Error! Cannot reset dt once it is set.\n");
Expand Down
4 changes: 2 additions & 2 deletions components/eamxx/src/share/io/scream_output_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ setup_internals (const std::map<std::string,std::shared_ptr<fm_type>>& field_mgr
EKAT_REQUIRE_MSG(m_params.isSublist("output_control"),
"Error! The output control YAML file for " + m_filename_prefix + " is missing the sublist 'output_control'");
auto& out_control_pl = m_params.sublist("output_control");
m_output_control.frequency_units = out_control_pl.get<std::string>("frequency_units");
m_output_control.set_frequency_units(out_control_pl.get<std::string>("frequency_units"));

// In case output is disabled, no point in doing anything else
if (m_output_control.frequency_units=="none" || m_output_control.frequency_units=="never") {
Expand All @@ -747,7 +747,7 @@ setup_internals (const std::map<std::string,std::shared_ptr<fm_type>>& field_mgr

if (m_params.isSublist("Checkpoint Control")) {
auto& pl = m_params.sublist("Checkpoint Control");
m_checkpoint_control.frequency_units = pl.get<std::string>("frequency_units");
m_checkpoint_control.set_frequency_units(pl.get<std::string>("frequency_units"));

if (m_checkpoint_control.output_enabled()) {
m_checkpoint_control.frequency = pl.get<int>("Frequency");
Expand Down

0 comments on commit a1d4b50

Please sign in to comment.