Repository: ESMCI/cime

Issue:
ERR test is broken 
using cesm2_0_alpha06a I get two log files from the test that say

log1:
doing an 7 ndays initial test with restart file at 4 ndays
doing an 7 ndays startup test, with restarts every 4 ndays

log2:
doing an 7 ndays restart test
doing an 3 ndays startup test, with restarts every 4 never

When I run using my sandbox with a newer cime master with my changes my first log looks ok but 
log2 has an error in the setup, restarts are every 2 instead of 4:
doing an 7 ndays restart test
doing an 3 ndays startup test, with restarts every 2 never



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/SystemTests/ers.py b/utils/python/CIME/SystemTests/ers.py
--- a/utils/python/CIME/SystemTests/ers.py
+++ b/utils/python/CIME/SystemTests/ers.py
@@ -33,12 +33,13 @@ def _ers_second_phase(self):
         stop_new = stop_n - rest_n
         expect(stop_new > 0, "ERROR: stop_n value %d too short %d %d"%(stop_new,stop_n,rest_n))
 
+        self._case.set_value("HIST_N", stop_n)
         self._case.set_value("STOP_N", stop_new)
         self._case.set_value("CONTINUE_RUN", True)
         self._case.set_value("REST_OPTION","never")
         self._case.flush()
         logger.info("doing an %s %s restart test"
-                    %(str(stop_n), stop_option))
+                    %(str(stop_new), stop_option))
         self.run_indv(suffix="rest")
 
         # Compare restart file
diff --git a/utils/python/CIME/case_run.py b/utils/python/CIME/case_run.py
--- a/utils/python/CIME/case_run.py
+++ b/utils/python/CIME/case_run.py
@@ -11,7 +11,7 @@
 logger = logging.getLogger(__name__)
 
 ###############################################################################
-def pre_run_check(case):
+def pre_run_check(case, lid):
 ###############################################################################
 
     # Pre run initialization code..
@@ -22,6 +22,11 @@ def pre_run_check(case):
     rundir = case.get_value("RUNDIR")
     build_complete = case.get_value("BUILD_COMPLETE")
 
+    if case.get_value("TESTCASE") == "PFS":
+        env_mach_pes = os.path.join(caseroot,"env_mach_pes.xml")
+        shutil.copy(env_mach_pes,"%s.%s"%(env_mach_pes,lid))
+
+
     # check for locked files.
     check_lockedfiles(case.get_value("CASEROOT"))
     logger.debug("check_lockedfiles OK")
@@ -210,7 +215,7 @@ def case_run(case):
             case.set_value("CONTINUE_RUN", "TRUE")
             lid = new_lid()
 
-        pre_run_check(case)
+        pre_run_check(case, lid)
         run_model(case)
         post_run_check(case, lid)
         save_logs(case, lid)       # Copy log files back to caseroot
diff --git a/utils/python/CIME/check_lockedfiles.py b/utils/python/CIME/check_lockedfiles.py
--- a/utils/python/CIME/check_lockedfiles.py
+++ b/utils/python/CIME/check_lockedfiles.py
@@ -20,6 +20,7 @@ def lock_file(filename, caseroot=None, newname=None):
     fulllockdir = os.path.join(caseroot, LOCKED_DIR)
     if not os.path.exists(fulllockdir):
         os.mkdir(fulllockdir)
+    logging.debug("Locking file %s to %s"%(filename, newname))
     shutil.copyfile(os.path.join(caseroot, filename), os.path.join(fulllockdir, newname))
 
 def unlock_file(filename, caseroot=None):
@@ -41,7 +42,7 @@ def restore(filename, caseroot=None, newname=None):
     expect("/" not in filename, "Please just provide basename of locked file")
     caseroot = os.getcwd() if caseroot is None else caseroot
     newname = filename if newname is None else newname
-    shutil.copyfile(os.path.join(caseroot, LOCKED_DIR, newname), os.path.join(caseroot, filename))
+    shutil.copyfile(os.path.join(caseroot, LOCKED_DIR, filename), os.path.join(caseroot, newname))
     # relock the restored file if names diffs
     if newname != filename:
         lock_file(newname, caseroot)
@@ -81,7 +82,7 @@ def check_lockedfiles(caseroot=None):
     If caseroot is not specified, it is set to the current working directory
     """
     caseroot = os.getcwd() if caseroot is None else caseroot
-    lockedfiles = glob.glob(os.path.join(caseroot, "LockedFiles", "*.xml"))
+    lockedfiles = glob.glob(os.path.join(caseroot, "LockedFiles", "[^.]*.xml"))
     for lfile in lockedfiles:
         fpart = os.path.basename(lfile)
         cfile = os.path.join(caseroot, fpart)


Test patch:
diff --git a/utils/python/CIME/SystemTests/system_tests_common.py b/utils/python/CIME/SystemTests/system_tests_common.py
--- a/utils/python/CIME/SystemTests/system_tests_common.py
+++ b/utils/python/CIME/SystemTests/system_tests_common.py
@@ -193,7 +193,7 @@ def run_indv(self, suffix="base", st_archive=False):
         rest_n      = self._case.get_value("REST_N")
         infostr     = "doing an %d %s %s test" % (stop_n, stop_option,run_type)
 
-        if rest_option == "none":
+        if rest_option == "none" or rest_option == "never":
             infostr += ", no restarts written"
         else:
             infostr += ", with restarts every %d %s"%(rest_n, rest_option)
diff --git a/utils/python/CIME/test_scheduler.py b/utils/python/CIME/test_scheduler.py
--- a/utils/python/CIME/test_scheduler.py
+++ b/utils/python/CIME/test_scheduler.py
@@ -501,9 +501,11 @@ def _xml_phase(self, test):
         with Case(test_dir, read_only=False) as case:
             if self._output_root is None:
                 self._output_root = case.get_value("CIME_OUTPUT_ROOT")
-            case.set_value("SHAREDLIBROOT",
-                           os.path.join(self._output_root,
-                                        "sharedlibroot.%s"%self._test_id))
+            # if we are running a single test we don't need sharedlibroot
+            if len(self._tests) > 1:
+                case.set_value("SHAREDLIBROOT",
+                               os.path.join(self._output_root,
+                                            "sharedlibroot.%s"%self._test_id))
             envtest.set_initial_values(case)
             case.set_value("TEST", True)
             if self._save_timing:
diff --git a/utils/python/update_acme_tests.py b/utils/python/update_acme_tests.py
--- a/utils/python/update_acme_tests.py
+++ b/utils/python/update_acme_tests.py
@@ -43,9 +43,10 @@
                              "ERI.f45_g37.X",
                              "ERIO.f45_g37.X",
                              "SEQ_Ln9.f19_g16_rx1.A",
-                             "ERS_Ld3.ne30_g16_rx1.A",
-                             "ERS_N2_Ld3.f19_g16_rx1.A",
-                             "ERR_Ld3.f45_g37_rx1.A",
+                             "ERS.ne30_g16_rx1.A",
+                             "ERS_N2.f19_g16_rx1.A",
+                             "ERR.f45_g37_rx1.A",
+                             "ERP.f45_g37_rx1.A",
                              "SMS_D_Ln9.f19_g16_rx1.A")
                             ),