Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions payu/models/cesm_cmeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
"GREGORIAN" : "proleptic_gregorian"
}

restart_error_msg = f"""
Possible cause: model runtime is shorter than the restart write frequency.
Fix:
1. Remove the incomplete restart subdirectory in the archive path
2. Adjust the restart write frequency to write a restart at the end of the model run."""

# Add as needed
component_info = {
"mom": {
Expand Down Expand Up @@ -328,7 +334,8 @@ def _collect_restart_files(self, pointer_files):
# rpointer file not exist
if not os.path.exists(pointer):
raise FileNotFoundError(
f"payu: rpointer file {pointer} does not exist!"
f"\nPayu Error: Restart pointer file not found at the end of payu run: {pointer}"
f"{restart_error_msg}"
)

with open(pointer, "r") as f:
Expand All @@ -348,7 +355,8 @@ def _collect_restart_files(self, pointer_files):
continue

raise FileNotFoundError(
f"payu: restart file {target_restart_path} listed in the rpointer file {pointer} does not exist!"
f"\nPayu Error: Restart file {target_restart_path} listed in the rpointer file {pointer} not found."
f"{restart_error_msg}"
)

return sorted(restart_files)
Expand Down
29 changes: 29 additions & 0 deletions test/models/access-om3/test_access_om3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import payu
import cftime
from payu.models.cesm_cmeps import restart_error_msg

from test.common import cd, tmpdir, ctrldir, labdir, workdir, write_config, config_path
from test.common import config as config_orig
Expand Down Expand Up @@ -580,5 +581,33 @@ def test_collect_restart_files_incorrect_parallel():

# Check a representative missing file appears in the message
assert "access-om3.cice.r.1900-01-01-00000.nc" in str(e.value)
assert "rpointer.ice not found." in str(e.value)
assert restart_error_msg in str(e.value)

teardown_cmeps_config()
os.remove(os.path.join(model.work_path, expected_present[0]))

def test_collect_restart_files_nonexist_rpointer():
""" Test if error is raised when rpointer file does not exist. """
cmeps_config(1)

with cd(ctrldir):
lab = payu.laboratory.Laboratory(lab_path=str(labdir))
expt = payu.experiment.Experiment(lab, reproduce=False)
model = expt.models[0]

pointer_files = [
os.path.join(model.work_path, "test_rpointer.cpl"),
os.path.join(model.work_path, "test_rpointer.ice"),
]
for file in pointer_files:
assert not os.path.exists(file)

with pytest.raises(FileNotFoundError) as e:
model._collect_restart_files(pointer_files)

# Check a representative missing file appears in the message
assert restart_error_msg in str(e.value)
assert "Restart pointer file not found at the end of payu run" in str(e.value)

teardown_cmeps_config()
Loading