Skip to content

Commit

Permalink
Merge Pull Request #2919 from E3SM-Project/scream/bartgol/eamxx-add-i…
Browse files Browse the repository at this point in the history
…o-time-check

Automatically Merged using E3SM Pull Request AutoTester
PR Title: Add runtime and buildnml-time checks on output frequency
PR Author: bartgol
PR LABELS: BFB, I/O, AT: AUTOMERGE, code usability
  • Loading branch information
E3SM-Bot authored Jul 30, 2024
2 parents 5e7b019 + 846e504 commit 9d845ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions components/eamxx/cime_config/eamxx_buildnml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,23 @@ def do_cime_vars_on_yaml_output_files(case, caseroot):
print (" - setting skip_t0_output=true\n")
print (" - setting freq and freq_units to HIST_N and HIST_OPTION respectively\n")

# If frequency_units is not nsteps, verify that we don't request
# a frequency faster than the model timestep
if content['output_control']['frequency_units'] in ['nsecs','nmins','nhours']:
freq = content['output_control']['Frequency']
units = content['output_control']['frequency_units']
dt_out = 1 if units=="nsecs" else 60 if units=="nmins" else 3600
dt_out = dt_out*int(freq)

dt_atm = 86400 / case.get_value("ATM_NCPL")
expect (dt_atm<=dt_out,
"Cannot have output frequency faster than atm timestep.\n"
f" yaml file: {fn.strip()}\n"
f" Frequency: {freq}\n"
f" frequency_units: {units}\n"
f" ATM_NCPL: {case.get_value('ATM_NCPL')}\n"
f" This yields dt_atm={dt_atm} > dt_output={dt_out}. Please, adjust 'Frequency' and/or 'frequency_units'\n")

ordered_dump(content, open(dst_yaml, "w"))

output_yaml_files.append(dst_yaml)
Expand Down
11 changes: 11 additions & 0 deletions components/eamxx/src/share/io/scream_output_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ void OutputManager::run(const util::TimeStamp& timestamp)
return;
}

// Ensure we did not go past the scheduled write time without hitting it
EKAT_REQUIRE_MSG (
(m_output_control.frequency_units=="nsteps"
? timestamp.get_num_steps()<=m_output_control.next_write_ts.get_num_steps()
: timestamp<=m_output_control.next_write_ts),
"Error! The input timestamp is past the next scheduled write timestamp.\n"
" - current time stamp : " + timestamp.to_string() + "\n"
" - next write time stamp: " + m_output_control.next_write_ts.to_string() + "\n"
"The most likely cause is an output frequency that is faster than the atm timestep.\n"
"Try to increase 'Frequency' and/or 'frequency_units' in your output yaml file.\n");

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

0 comments on commit 9d845ad

Please sign in to comment.