From 631a372da0946109042d42e30a9a59d2de9ddecc Mon Sep 17 00:00:00 2001 From: Jo Basevi Date: Tue, 19 Sep 2023 09:14:54 +1000 Subject: [PATCH] Add a check for MOM6 parameter filenames defined in input.nml --- payu/models/mom6.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/payu/models/mom6.py b/payu/models/mom6.py index 86943975..acbc6eea 100644 --- a/payu/models/mom6.py +++ b/payu/models/mom6.py @@ -10,6 +10,7 @@ # Standard library import os +import shutil # Extensions import f90nml @@ -78,3 +79,20 @@ def init_config(self): input_nml['SIS_input_nml']['input_filename'] = input_type f90nml.write(input_nml, input_fpath, force=True) + + # Check to see if the parameter files were included in configuration files + config_files = set(self.config_files).union(self.optional_config_files) + for input_namelist in ['MOM_input_nml', 'SIS_input_nml']: + parameter_files = input_nml.get(input_namelist , {}).get('parameter_filename', []) + if isinstance(parameter_files, str): + parameter_files = [parameter_files] # Transform to list + + for filename in parameter_files: + if filename not in config_files: + print(f"payu: warning: {filename} in {input_namelist} in input.nml is not in mom6's config_files or optional_config_files") + + self.config_files.append(filename) # Extend config files + + # Copy parameter file from control path to work path + file_path = os.path.join(self.control_path, filename) + shutil.copy(file_path, self.work_path)