diff --git a/payu/models/roms.py b/payu/models/roms.py index 3e46ee7f..e5b4eda4 100644 --- a/payu/models/roms.py +++ b/payu/models/roms.py @@ -12,9 +12,6 @@ from payu.models.model import Model from payu.fsops import mkdir_p -config_files = ['varinfo_seacofs.yaml'] -optional_config_files = [] - class Roms(Model): def __init__(self, expt, name, config): @@ -24,12 +21,12 @@ def __init__(self, expt, name, config): # Model-specific configuration self.model_type = 'roms' - - self.config_files = config_files - self.optional_config_files = optional_config_files + + self.config_files = [] + self.optional_config_files = [] def setup(self): - # Add the model config file to the list of config files + ## handle mandatory config files if 'model_config' not in self.config: raise ValueError( "'model_config' field must be specified in config.yaml for " @@ -46,6 +43,20 @@ def setup(self): self.config_files.append(model_config) + ## handle optional config files + optional_config_files = self.expt.config['optional_config_files'] + if optional_config_files and isinstance(optional_config_files, str): + optional_config_files = [optional_config_files] + + for optional_file in optional_config_files: + if not (Path(self.control_path) / optional_file).is_file(): + raise FileNotFoundError( + f"Optional configuration file '{optional_file}' not found in the " + f"control directory: {self.control_path}" + ) + + self.optional_config_files.extend(optional_config_files) + super(Roms, self).setup() # Set the model config file to be added after the executable