Skip to content

Commit 7a399f5

Browse files
committed
Add all namelists to optional_config_files and improved clarity
1 parent b69b26d commit 7a399f5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

payu/models/staged_cable.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
import shutil
1313
import itertools
14+
import glob
1415

1516
# Extensions
1617
import f90nml
@@ -30,15 +31,11 @@ def __init__(self, expt, name, config):
3031
self.model_type = 'staged_cable'
3132
self.default_exec = 'cable'
3233

33-
# We want people to be able to use payu during testing, which
34-
# often means additions of new namelists due to new science
35-
# modules. I would like to set
36-
# optional_config_files = glob.glob("*.nml")
37-
# but this feels like a bit of an abuse of feature.
3834
self.config_files = ['stage_config.yaml']
39-
self.optional_config_files = ['cable.nml', 'cru.nml',
40-
'luc.nml', 'met_names.nml',
41-
'bios.nml']
35+
36+
# To support different branches of cable, which may have different
37+
# namelists, add all found namelists to the optional_config_files
38+
self.optional_config_files = glob.glob('*.nml')
4239

4340
def setup(self):
4441
super(StagedCable, self).setup()
@@ -178,13 +175,13 @@ def _apply_stage_namelists(self, stage_name):
178175
for namelist in namelists:
179176
write_target = os.path.join(self.work_input_path, namelist)
180177
stage_nml = os.path.join(self.control_path, stage_name, namelist)
178+
master_nml = os.path.join(self.control_path, namelist)
181179

182-
if os.path.isfile(os.path.join(self.control_path, namelist)):
180+
if os.path.isfile(master_nml):
183181
# Instance where there is a master and stage namelist
184182
with open(stage_nml) as stage_nml_f:
185183
stage_namelist = f90nml.read(stage_nml_f)
186184

187-
master_nml = os.path.join(self.control_path, namelist)
188185
f90nml.patch(master_nml, stage_namelist, write_target)
189186
else:
190187
# Instance where there is only a stage namelist

0 commit comments

Comments
 (0)