Repository: ESMCI/cime

Issue:
SystemTestsCompareTwo multisubmit tries to do too much in phase 1
In comparing #1830 with what made it to master, I noticed that the indentation of this block is wrong:

```python
        # Compare results
        # Case1 is the "main" case, and we need to do the comparisons from there
        self._activate_case1()
        self._link_to_case2_output()

        self._component_compare_test(self._run_one_suffix, self._run_two_suffix, success_change=success_change)
```

-- this should be indented under the "Second run" conditional.

The current indentation leads the ERR test (and any other multi-submit test) to try to do component_compare_test after the first phase, leading to a FAIL result. This doesn't cause a test failure, because the FAIL is later overwritten with a PASS, but it is still incorrect.

I have a fix for this in an incoming PR.


Discussion:

Resolving patch:
diff --git a/scripts/lib/CIME/SystemTests/erp.py b/scripts/lib/CIME/SystemTests/erp.py
--- a/scripts/lib/CIME/SystemTests/erp.py
+++ b/scripts/lib/CIME/SystemTests/erp.py
@@ -1,5 +1,5 @@
 """
-CIME ERP test.  This class inherits from SystemTestsCompareTwo
+CIME ERP test.  This class inherits from RestartTest
 
 This is a pes counts hybrid (open-MP/MPI) restart bfb test from
 startup.  This is just like an ERS test but the pe-counts/threading
@@ -10,31 +10,26 @@
 
 from CIME.XML.standard_module_setup import *
 from CIME.case_setup import case_setup
-from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo
+from CIME.SystemTests.restart_tests import RestartTest
 from CIME.check_lockedfiles import *
 
 logger = logging.getLogger(__name__)
 
-class ERP(SystemTestsCompareTwo):
+class ERP(RestartTest):
 
     def __init__(self, case):
         """
         initialize a test object
         """
-        SystemTestsCompareTwo.__init__(self, case,
-                                       separate_builds = True,
-                                       run_two_suffix = 'rest',
-                                       run_one_description = 'initial',
-                                       run_two_description = 'restart')
+        RestartTest.__init__(self, case,
+                             separate_builds = True,
+                             run_two_suffix = 'rest',
+                             run_one_description = 'initial',
+                             run_two_description = 'restart')
 
     def _common_setup(self):
         self._case.set_value("BUILD_THREADED",True)
 
-    def _case_one_setup(self):
-        stop_n      = self._case.get_value("STOP_N")
-
-        expect(stop_n > 2, "ERROR: stop_n value {:d} too short".format(stop_n))
-
     def _case_two_setup(self):
         # halve the number of tasks and threads
         for comp in self._case.get_values("COMP_CLASSES"):
@@ -47,15 +42,7 @@ def _case_two_setup(self):
                 self._case.set_value("NTASKS_{}".format(comp), ntasks/2)
                 self._case.set_value("ROOTPE_{}".format(comp), rootpe/2)
 
-        stop_n = self._case1.get_value("STOP_N")
-        rest_n = self._case1.get_value("REST_N")
-        stop_new = stop_n - rest_n
-        expect(stop_new > 0, "ERROR: stop_n value {:d} too short {:d} {:d}".format(stop_new,stop_n,rest_n))
-        self._case.set_value("STOP_N", stop_new)
-        self._case.set_value("HIST_N", stop_n)
-        self._case.set_value("CONTINUE_RUN", True)
-        self._case.set_value("REST_OPTION","never")
-
+        RestartTest._case_two_setup(self)
         # Note, some components, like CESM-CICE, have
         # decomposition information in env_build.xml that
         # needs to be regenerated for the above new tasks and thread counts


Test patch:
diff --git a/scripts/lib/CIME/SystemTests/system_tests_compare_two.py b/scripts/lib/CIME/SystemTests/system_tests_compare_two.py
--- a/scripts/lib/CIME/SystemTests/system_tests_compare_two.py
+++ b/scripts/lib/CIME/SystemTests/system_tests_compare_two.py
@@ -229,12 +229,12 @@ def run_phase(self, success_change=False):  # pylint: disable=arguments-differ
                 self.run_indv(suffix = self._run_two_suffix)
                 self._case_two_custom_postrun_action()
 
-        # Compare results
-        # Case1 is the "main" case, and we need to do the comparisons from there
-        self._activate_case1()
-        self._link_to_case2_output()
+            # Compare results
+            # Case1 is the "main" case, and we need to do the comparisons from there
+            self._activate_case1()
+            self._link_to_case2_output()
 
-        self._component_compare_test(self._run_one_suffix, self._run_two_suffix, success_change=success_change)
+            self._component_compare_test(self._run_one_suffix, self._run_two_suffix, success_change=success_change)
 
     def copy_case1_restarts_to_case2(self):
         """