Skip to content

Commit

Permalink
Updating scripts/lib/CIME/case_st_archive.py
Browse files Browse the repository at this point in the history
> _get_ninst_info; comment out else: ninst_strings.append('')
   Appends 2 single quotes, instead of nothing as intended.
> _get_component_archive_entries: add log info about components that are skipped.
> _archive_rpointer_files: debugging statements in can eventually be removed.
> _archive_history_files, _archive_restart_date_comps:
  changed handling of 'dart' compname to 'esp'
  and use fact that DART output, which st_archive should archive,
  now all uses standard CESM naming conventions.
  Updated logger information.
  • Loading branch information
kdraeder committed Sep 22, 2017
1 parent 5597f64 commit 8c77f31
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions scripts/lib/CIME/case_st_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ def _get_ninst_info(case, compclass):
for i in range(1,ninst+1):
if ninst > 1:
ninst_strings.append('_' + '{:04d}'.format(i))
else:
ninst_strings.append('')
# KDR This doesn't do what's intended. The result is ninst_strings is not empty.
# It has "''" in it.
## else:
## ninst_strings.append('')

logger.debug("ninst and ninst_strings are: {} and {} for {}".format(ninst, ninst_strings, compclass))
return ninst, ninst_strings
Expand All @@ -77,7 +79,7 @@ def _get_ninst_info(case, compclass):
def _get_component_archive_entries(case, archive):
###############################################################################
"""
Each time this is generator function is called, it yields a tuple
Each time this generator function is called, it yields a tuple
(archive_entry, compname, compclass) for one component in this
case's compset components.
"""
Expand All @@ -90,6 +92,10 @@ def _get_component_archive_entries(case, archive):
if archive_entry is not None:
yield(archive_entry, compname, archive_entry.get("compclass"))

if compname not in compset_comps:
# KDR Say if something is being skipped
logger.info('Skipping compname %s' %(compname))

###############################################################################
def _archive_rpointer_files(case, archive, archive_entry, archive_restdir,
datename, datename_is_last):
Expand Down Expand Up @@ -129,7 +135,7 @@ def _archive_rpointer_files(case, archive, archive_entry, archive_restdir,
logger.info("rpointer_content not unset? {}".format(rpointer_content))
if not ninst_strings:
ninst_strings = ["empty"]
# KDR indenting all the rest 4 spaces to put under control of 'if ... unset'
# KDR indented 4 spaces, up to 'else:' to put under control of 'if ... unset'
for ninst_string in ninst_strings:
rpointer_file = temp_rpointer_file
rpointer_content = temp_rpointer_content
Expand Down Expand Up @@ -201,10 +207,13 @@ def _archive_history_files(case, archive, archive_entry,
rundir = case.get_value("RUNDIR")
for suffix in archive.get_hist_file_extensions(archive_entry):
for i in range(ninst):
if compname == 'dart':
newsuffix = casename + suffix
elif compname.find('mpas') == 0:
newsuffix = compname + '.*' + suffix
if compname.find('mpas') == 0:
newsuffix = compname + '.*' + suffix
# KDR I've chosen to use compname 'cam' for DART output from CAM assims,
# inside compclass 'esp', to distinguish it from other components in multi-component assims.
# All CAM+DART output conforms to CESM naming conventions (2017-9-1).
elif ninst_string:
newsuffix = casename + '.' + compname + ".*" + ninst_string[i] + suffix
else:
if ninst_string:
newsuffix = casename + '.' + compname + ".*" + ninst_string[i] + suffix
Expand Down Expand Up @@ -336,6 +345,11 @@ def _archive_restarts_date_comp(case, archive, archive_entry,
pattern = compname + suffix + '_'.join(datename.rsplit('-', 1))
pfile = re.compile(pattern)
restfiles = [f for f in os.listdir(rundir) if pfile.search(f)]
# KDR CAM+DART doesn't need special treatment as of 2017-9-1, so this is commented out.
# if compclass == 'esp' and 'cam' in pattern:
# pattern = suffix + datename
# pfile = re.compile(pattern)
# restfiles = [f for f in os.listdir(rundir) if pfile.search(f)]
else:
pattern = r"{}\.{}\d*.*".format(casename, compname)
if "dart" not in pattern:
Expand Down Expand Up @@ -373,21 +387,21 @@ def _archive_restarts_date_comp(case, archive, archive_entry,
srcfile = os.path.join(rundir, restfile)
destfile = os.path.join(archive_restdir, restfile)
last_restart_file_fn(srcfile, destfile)
logger.info("{} \n{} to \n{}".format(
last_restart_file_fn_msg, srcfile, destfile))
logger.info("{} {} \n{} to \n{}".format(
"datename_is_last", last_restart_file_fn_msg, srcfile, destfile))
for histfile in histfiles_for_restart:
srcfile = os.path.join(rundir, histfile)
destfile = os.path.join(archive_restdir, histfile)
expect(os.path.isfile(srcfile),
"restart file {} does not exist ".format(srcfile))
shutil.copy(srcfile, destfile)
logger.info("copying \n{} to \n{}".format(srcfile, destfile))
logger.info("datename_is_last + histfiles_for_restart copying \n{} to \n{}".format(srcfile, destfile))
else:
# Only archive intermediate restarts if requested - otherwise remove them
if case.get_value('DOUT_S_SAVE_INTERIM_RESTART_FILES'):
srcfile = os.path.join(rundir, restfile)
destfile = os.path.join(archive_restdir, restfile)
logger.info("moving \n{} to \n{}".format(srcfile, destfile))
# KDR redundant? logger.info("moving \n{} to \n{}".format(srcfile, destfile))
expect(os.path.isfile(srcfile),
"restart file {} does not exist ".format(srcfile))
archive_file_fn(srcfile, destfile)
Expand Down

0 comments on commit 8c77f31

Please sign in to comment.