Repository: ESMCI/cime

Issue:
short term archiver updates to support DART1
The DART v1 code base outputs a specific set of files that
need to be archived. The case_st_archive.py _archive_history_files function
is looking to match filenames with the 'dart' sting included as the component 
identifier but DART v1 does not output any such files with that string in the filename. 
Consequently, most of the DART files are not being archived correctly. 

We now have an updated list of filename pattern strings for DART so we can
update the XML and _archive_history_files function accordingly. 


Discussion:

Resolving patch:
diff --git a/utils/python/CIME/SystemTests/err.py b/utils/python/CIME/SystemTests/err.py
--- a/utils/python/CIME/SystemTests/err.py
+++ b/utils/python/CIME/SystemTests/err.py
@@ -29,6 +29,13 @@ def run_phase(self):
             rundir = self._case.get_value("RUNDIR")
             logger.info("staging files from archive %s" % dout_s_root)
             for item in glob.glob(os.path.join(dout_s_root, "*", "hist", "*base")):
+                # NOTE - this loop doesn't do anything because the
+                # _ers_first_phase has already copied the history files in the
+                # rundir adding the .base suffix before the short term archiver runs.
+                # The pattern matching in the env_archive.xml looks for history 
+                # files that match ".nc$" in the rundir in order to copy them
+                # to the DOUT_S_ROOT location so the files with the .base
+                # suffix are never copied. 
                 shutil.copy(item, rundir)
 
             self._ers_second_phase()
diff --git a/utils/python/CIME/case_st_archive.py b/utils/python/CIME/case_st_archive.py
--- a/utils/python/CIME/case_st_archive.py
+++ b/utils/python/CIME/case_st_archive.py
@@ -147,10 +147,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 ninst_string:
-                newsuffix = casename + '.' + compname + ".*" + ninst_string[i] + suffix
+            if compname == 'dart':
+                newsuffix = casename + suffix
             else:
-                newsuffix = casename + '.' + compname + ".*" + suffix
+                if ninst_string:
+                    newsuffix = casename + '.' + compname + ".*" + ninst_string[i] + suffix
+                else:
+                    newsuffix = casename + '.' + compname + ".*" + suffix
             logger.debug("short term archiving suffix is %s " %newsuffix)
             pfile = re.compile(newsuffix)
             histfiles = [f for f in os.listdir(rundir) if pfile.search(f)]
@@ -194,7 +197,7 @@ def get_histfiles_for_restarts(case, archive, archive_entry, restfile):
                 if matchobj:
                     histfile = matchobj.group(1).strip()
                     histfile = os.path.basename(histfile)
-                    # append histfile to the list ONLY if it exists in rundir before the archviving
+                    # append histfile to the list ONLY if it exists in rundir before the archiving
                     if os.path.isfile(os.path.join(rundir,histfile)): 
                         histfiles.append(histfile)
     return histfiles


Test patch: