Skip to content

Commit

Permalink
Add a check for MOM6 parameter filenames defined in input.nml
Browse files Browse the repository at this point in the history
  • Loading branch information
Jo Basevi committed Sep 18, 2023
1 parent 2d16f18 commit 631a372
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions payu/models/mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Standard library
import os
import shutil

# Extensions
import f90nml
Expand Down Expand Up @@ -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)

0 comments on commit 631a372

Please sign in to comment.