From 4ec144380f10c67c5852742cb35db47a692bec83 Mon Sep 17 00:00:00 2001 From: Sean Bryan Date: Fri, 22 Sep 2023 13:13:01 +1000 Subject: [PATCH] Set `ncciy` year explicitly in namelist 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. --- payu/models/__init__.py | 2 +- payu/models/cable.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/payu/models/__init__.py b/payu/models/__init__.py index e7f0d0a9..c3b4e971 100644 --- a/payu/models/__init__.py +++ b/payu/models/__init__.py @@ -20,7 +20,7 @@ from payu.models.model import Model index = { - 'access': Access, + 'access': Access, 'access-om2': AccessOm2, 'access-om3': AccessOm3, 'cice': Cice, diff --git a/payu/models/cable.py b/payu/models/cable.py index a908d622..86192d95 100644 --- a/payu/models/cable.py +++ b/payu/models/cable.py @@ -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()) @@ -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(