@@ -15,7 +15,7 @@ import logging
1515CIMEROOT = os .environ .get ("CIMEROOT" )
1616if CIMEROOT is None :
1717 raise SystemExit ("ERROR: must set CIMEROOT environment variable" )
18- sys .path .append (os .path .join (CIMEROOT , "scripts " , "Tools" ))
18+ sys .path .append (os .path .join (CIMEROOT , "CIME " , "Tools" ))
1919
2020# The scope of the following path expansion is limited to this script only,
2121# and is needed to import MOM6 input file classes:
@@ -399,10 +399,13 @@ def prechecks(case, inst_suffixes):
399399 f"Missing rpointer files in rundir. Expected files with pattern { rpointer_pattern } ." ,
400400 )
401401
402- # check if the restart file is present in rundir
402+ # check if the restart file is present in rundir for fresh branch or hybrid runs
403403 if run_type in ["branch" , "hybrid" ] and not continue_run and not get_refcase :
404- restart_file = os .path .join (rundir , f'./{ run_refcase } .mom6.r.{ run_refdate } -{ run_reftod } .nc' )
405- assert os .path .exists (restart_file ), f"Missing restart file { run_refcase } .mom6.r.{ run_refdate } -{ run_reftod } .nc in rundir."
404+ restart_file_pattern = run_refcase + r".mom6.*.r." + run_refdate + "-" + run_reftod + r".*nc$"
405+ restart_files = [
406+ f for f in os .listdir (rundir ) if re .match (restart_file_pattern , f )
407+ ]
408+ assert len (restart_files ) > 0 , f"Missing restart file in rundir. Expected file matching pattern { restart_file_pattern } ."
406409
407410def postchecks (case , MOM_input_final ):
408411 """Performs checks after input files are generated. To be called within prep_input() as a final step."""
@@ -433,7 +436,15 @@ def buildnml(case, caseroot, compname):
433436 # Build the component namelist
434437 if compname != "mom" :
435438 raise AttributeError
436-
439+ # add the FMS library to the list of cesm support libraries for the case
440+ # designed to be backward compatible in case cmeps does not define CASE_SUPPORT_LIBRARIES
441+ try :
442+ libs = case .get_values ("CASE_SUPPORT_LIBRARIES" )
443+ if libs is not None and "FMS" not in libs :
444+ libs .extend (["gptl" ,"pio" ,"csm_share" ,"FMS" ])
445+ case .set_value ("CASE_SUPPORT_LIBRARIES" , "," .join (libs ))
446+ except :
447+ pass
437448 ninst = case .get_value ("NINST_OCN" )
438449 inst_suffixes = (
439450 ["_{:04d}" .format (i + 1 ) for i in range (ninst )] if ninst > 1 else ["" ]
@@ -460,7 +471,7 @@ def buildnml(case, caseroot, compname):
460471def _main_func ():
461472
462473 caseroot = parse_input (sys .argv )
463- with Case (caseroot ) as case :
474+ with Case (caseroot , read_only = False ) as case :
464475 buildnml (case , caseroot , "mom" )
465476
466477
0 commit comments