Skip to content

Commit

Permalink
Set ncciy year explicitly in namelist
Browse files Browse the repository at this point in the history
This is a bit of hack so that we don't have to specify non-quoted
special characters for the the ncciy parameter such as the '$' character
for templating. This allows the CABLE driver to be compatible with
namelist files generated by standard Fortran namelist parsing tools such
as f90nml.

Temporarily disable spinup until correctly implemented.
  • Loading branch information
SeanBryan51 committed Oct 27, 2023
1 parent abfa27a commit 4ec1443
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion payu/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from payu.models.model import Model

index = {
'access': Access,
'access': Access,
'access-om2': AccessOm2,
'access-om3': AccessOm3,
'cice': Cice,
Expand Down
17 changes: 10 additions & 7 deletions payu/models/cable.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ def set_model_pathnames(self):
def setup(self):
super(Cable, self).setup()

if os.path.exists(self.restart_calendar_path):
with open(self.restart_calendar_path, 'r') as restart_file:
self.restart_info = yaml.safe_load(restart_file)
if not self.prior_restart_path:
msg = (
"Spinup is not yet supported for the CABLE model driver. Please "
"specify the `restart` key in config.yaml."
)
raise RuntimeError(msg)

with open(self.restart_calendar_path, 'r') as restart_file:
self.restart_info = yaml.safe_load(restart_file)

with open(self.cable_nml_path, 'r') as f:
nml_template = Template(f.read())
Expand All @@ -67,10 +73,7 @@ def setup(self):
nml_template.substitute(self.restart_info)
)

if self.prior_restart_path:
self.cable_nml['cable']['spinup'] = False
else:
self.cable_nml['cable']['spinup'] = True
self.cable_nml['cable']['ncciy'] = self.restart_info['year']

# Write modified namelist file to work dir
self.cable_nml.write(
Expand Down

0 comments on commit 4ec1443

Please sign in to comment.