Repository: ESMCI/cime

Issue:
ERI test creates more sym links than it needs to
The ERI test creates a bunch of unnecessary sym links in the main case (i.e., the case without a 'ref' extension), pointing to history files in the ref2 archive space. As far as I can tell, this doesn't cause problems with the test, but it makes it hard to understand what's going on when you're trying to debug a failed test: It means that the history files created by the main case are actually put in the ref2 archive space! I could also imagine this causing problems in some edge cases, e.g., involving rerunning a test, but I'm not sure about that.

Specifically, I ran `ERI_Lm36.T31_g37_gl4.IGCLM45.yellowstone_intel.clm-glcMEC_long`, but this should show up in many ERI tests.

It looks like these come from this code in eri.py:

```python
        # the following lines creates the initial component history files for the restart test
        for item in glob.glob("%s/*/hist/*nc" % dout_sr2):
            newfile = "%s" % item.replace(".ref2", "")
            newfile = os.path.basename(newfile)
            dst = os.path.join(rundir, newfile)
            if os.path.exists(dst):
                os.remove(dst)
            os.symlink(item, dst)
```

This block follows immediately after:

```python
        _helper(dout_sr2, refdate_3, refsec_3, rundir)
```

and I would think that that `_helper` is enough to create the necessary sym links to run the main case.

@jgfouca @mvertens @jedwards4b - it looks like you're the ones who wrote the python version of this test. Can any of you comment on this?


Discussion:

Resolving patch:
diff --git a/scripts/lib/CIME/SystemTests/eri.py b/scripts/lib/CIME/SystemTests/eri.py
--- a/scripts/lib/CIME/SystemTests/eri.py
+++ b/scripts/lib/CIME/SystemTests/eri.py
@@ -140,13 +140,13 @@ def run_phase(self):
         clone2.set_value("HIST_N",        hist_n)
         clone2.flush()
 
-        rundir = clone2.get_value("RUNDIR")
+        rundir2 = clone2.get_value("RUNDIR")
         dout_sr2 = clone2.get_value("DOUT_S_ROOT")
 
-        if not os.path.exists(rundir):
-            os.makedirs(rundir)
+        if not os.path.exists(rundir2):
+            os.makedirs(rundir2)
 
-        _helper(dout_sr1, refdate_2, refsec_2, rundir)
+        _helper(dout_sr1, refdate_2, refsec_2, rundir2)
 
         # run ref2 case (all component history files will go to short term archiving)
 
@@ -188,8 +188,8 @@ def run_phase(self):
 
         _helper(dout_sr2, refdate_3, refsec_3, rundir)
 
-        # the following lines creates the initial component history files for the restart test
-        for item in glob.glob("%s/*/hist/*nc" % dout_sr2):
+        # link the hybrid history files from ref2 to the run dir for comparison
+        for item in glob.iglob("%s/*.hybrid"%rundir2):
             newfile = "%s" % item.replace(".ref2", "")
             newfile = os.path.basename(newfile)
             dst = os.path.join(rundir, newfile)
@@ -197,8 +197,6 @@ def run_phase(self):
                 os.remove(dst)
             os.symlink(item, dst)
 
-        self._component_compare_copy("hybrid")
-
         # run branch case (short term archiving is off)
         self.run_indv()
 


Test patch: