From dbaeea26beec89d0a7a72187fc813766cabd2b5d Mon Sep 17 00:00:00 2001 From: Luca Bertagna Date: Thu, 25 Jul 2024 08:40:52 -0600 Subject: [PATCH 1/3] EAMxx: add runtime and buildnml-time checks on output frequency Ensures dt_output is not smaller than dt_atm --- components/eamxx/cime_config/eamxx_buildnml.py | 17 +++++++++++++++++ .../src/share/io/scream_output_manager.cpp | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/components/eamxx/cime_config/eamxx_buildnml.py b/components/eamxx/cime_config/eamxx_buildnml.py index 0c7ed8e52aa..121506f7eff 100644 --- a/components/eamxx/cime_config/eamxx_buildnml.py +++ b/components/eamxx/cime_config/eamxx_buildnml.py @@ -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) diff --git a/components/eamxx/src/share/io/scream_output_manager.cpp b/components/eamxx/src/share/io/scream_output_manager.cpp index 35b1c753b03..539204c66a1 100644 --- a/components/eamxx/src/share/io/scream_output_manager.cpp +++ b/components/eamxx/src/share/io/scream_output_manager.cpp @@ -328,6 +328,13 @@ void OutputManager::run(const util::TimeStamp& timestamp) return; } + EKAT_REQUIRE_MSG (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_stirng() + "\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; From 2ed55ace931870c0e12adfb7c50c94cfdcffd28c Mon Sep 17 00:00:00 2001 From: Luca Bertagna Date: Fri, 26 Jul 2024 12:11:20 -0600 Subject: [PATCH 2/3] EAMxx: fix typo --- components/eamxx/src/share/io/scream_output_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/eamxx/src/share/io/scream_output_manager.cpp b/components/eamxx/src/share/io/scream_output_manager.cpp index 539204c66a1..ccec5f516fd 100644 --- a/components/eamxx/src/share/io/scream_output_manager.cpp +++ b/components/eamxx/src/share/io/scream_output_manager.cpp @@ -331,7 +331,7 @@ void OutputManager::run(const util::TimeStamp& timestamp) EKAT_REQUIRE_MSG (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_stirng() + "\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"); From 846e5044429caf921a74c9b49e194e004b76115a Mon Sep 17 00:00:00 2001 From: Luca Bertagna Date: Mon, 29 Jul 2024 15:00:28 -0600 Subject: [PATCH 3/3] EAMxx: fix check for io --- components/eamxx/src/share/io/scream_output_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/eamxx/src/share/io/scream_output_manager.cpp b/components/eamxx/src/share/io/scream_output_manager.cpp index ccec5f516fd..13e2e97101b 100644 --- a/components/eamxx/src/share/io/scream_output_manager.cpp +++ b/components/eamxx/src/share/io/scream_output_manager.cpp @@ -328,7 +328,11 @@ void OutputManager::run(const util::TimeStamp& timestamp) return; } - EKAT_REQUIRE_MSG (timestamp<=m_output_control.next_write_ts, + // 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"