1111import  os 
1212import  shutil 
1313import  itertools 
14+ import  glob 
1415
1516# Extensions 
1617import  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