Repository: ESMCI/cime

Issue:
CIME error in wave watch archiving
While running an SMS test on a case with WaveWatch3 in E3SM, it ended with this error:
```
2023-06-20 02:49:05: Exception during SHORT_TERM_ARCHIVER:
ERROR: env_archive defines component ww not defined in case
Traceback (most recent call last):
  File "/home/jason_sarich/E3SM/cime/CIME/SystemTests/system_tests_common.py", line 572, in _phase_modifying_call
    function()
  File "/home/jason_sarich/E3SM/cime/CIME/SystemTests/system_tests_common.py", line 522, in _st_archive_case_test
    result = self._case.test_env_archive()
  File "/home/jason_sarich/E3SM/cime/CIME/case/case_st_archive.py", line 1202, in test_env_archive
    comp_expected
  File "/home/jason_sarich/E3SM/cime/CIME/utils.py", line 166, in expect
    raise exc_type(msg)
CIME.utils.CIMEError: ERROR: env_archive defines component ww not defined in case
```
env_archive in the case dir does NOT define a "ww" component:
`<comp_archive_spec compclass="wav" compname="ww3">`

While looking at the stack trace, I found this code in case_st_archive.py:
```
1186         comp_expected = archive.get(comp_archive_spec, "compname")
1187         if comp_expected == "ww3":
1188             comp_expected = "ww"
```
what is that doing?


Discussion:
@jgfouca your name is on those lines.
@rljacob , strange code that I don't remember writing. Git blame does show me as the last person who touched these lines. The associated commit is:

```
Update CIME to ESMCI cime5.7.0 (PR #2414)
    
    Squash merge of jgfouca/branch-for-to-acme-2018-06-28
    
    Features:
    
    * Allow users to go up through the setup phase on non-local machines
    * Documentation updates
    
    Bug fixes:
    
    * fix issue with e3sm mali file archiving
    * Use ConfigParser rather than SafeConfigParser
    * Fix for passing run arguments in LSF
    
    Fixes #2393
    Fixes #2390
    
    [BFB]

```

So this commit was just a bulk of changes being synced, not stuff really authored by me.

It's possible @jedwards4b knows the reason for this.
Oh I forgot we can't trust gitblame during the subtree era.
Yeah, the subtree era mucked-up the git histories of both E3SM and CIME.
Thinking about it some more, it seems like this bullet must be the reason:

`   * fix issue with e3sm mali file archiving `


This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.
@jedwards4b , any recollection of the "ww" stuff?
We have ww3 and wwdev and this is intended to match either.  I don't think that there is an archiving issue with ww3 in cesm.
Thanks, @jedwards4b . So this is likely an issue with an E3SM XML file. I've assigned @jasonb5 

```python
1173    for comp in list(components):
1174        compname = self.get_value("COMP_{}".format(comp))
...
1186         comp_expected = archive.get(comp_archive_spec, "compname")
1187         if comp_expected == "ww3":
1188             comp_expected = "ww"
...
1201            expect(
1202                comp_expected in comps_in_case,
1203               "env_archive defines component {} not defined in case".format(
```
After some investigating I found a CESM test (`PET.f19_g17_rx1.2000_DATM%NYF_SLND_CICE5_POP2_DROF%NYF_SGLC_WW3`) that I could trace to understand what's happening. When this code runs for CESM the case's `compname` is `ww` and the archive `compname` is `ww3` so the code in question handles that difference. For E3SM we don't need this between the compnames match.

I'll add a comment for the future and bypass this for E3SM.

Resolving patch:
diff --git a/CIME/case/case_st_archive.py b/CIME/case/case_st_archive.py
--- a/CIME/case/case_st_archive.py
+++ b/CIME/case/case_st_archive.py
@@ -1186,7 +1186,9 @@ def test_env_archive(self, testdir="env_archive_test"):
 
     for comp_archive_spec in comp_archive_specs:
         comp_expected = archive.get(comp_archive_spec, "compname")
-        if comp_expected == "ww3":
+        # Rename ww3 component when case and archive names don't match,
+        # specific to CESM.
+        if comp_expected == "ww3" and "ww" in comps_in_case:
             comp_expected = "ww"
         comp_class = archive.get(comp_archive_spec, "compclass").upper()
         if comp_class in components:


Test patch: