Skip to content

Refactor config_archive.xml/case_st_archive.py #4792

@jasonb5

Description

@jasonb5

The regex patterns for matching history/restart files for archiving are partial hard-coded. Updates require PRs like #4788 to be made when the naming changes. We should update these patterns to be fully definable in config_archive.xml.

This would also be a good opportunity to refactor case_st_archive.py, some of this code belongs in CIME/XML/archive_base.py and CIME/XML/archive.py. There's also a bit of component specific code that should be moved out into config_archive.xml.

  • if compname == "nemo":
    archive_rblddir = os.path.join(dout_s_root, compclass, "rebuild")
    if not os.path.exists(archive_rblddir):
    os.makedirs(archive_rblddir)
    logger.debug("created directory {}".format(archive_rblddir))
    sfxrbld = r"mesh_mask_" + r"[0-9]*"
  • if compname.find("mpas") == 0 or compname == "mali":
    pattern = (
    casename
    + r"\."
    + compname
    + r"\."
    + suffix
    + r"\."
    + "_".join(datename_str.rsplit("-", 1))
    )
    pfile = re.compile(pattern)
    restfiles = [f for f in os.listdir(rundir) if pfile.search(f)]
    elif compname == "nemo":
    pattern = r"_*_" + suffix + r"[0-9]*"
    pfile = re.compile(pattern)
    restfiles = [f for f in os.listdir(rundir) if pfile.search(f)]
  • if compname == "nemo":
    flist = glob.glob(rundir + "/" + casename + "_*_restart*.nc")
    logger.debug("nemo restart file {}".format(flist))
    if len(flist) > 2:
    flist0 = glob.glob(
    rundir + "/" + casename + "_*_restart_0000.nc"
    )
    if len(flist0) > 1:
    rstfl01 = flist0[0]
    rstfl01spl = rstfl01.split("/")
    logger.debug("splitted name {}".format(rstfl01spl))
    rstfl01nm = rstfl01spl[-1]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions