Repository: ESMCI/cime

Issue:
GENERATE and BASELINE phases fail for PFS test
Running a PFS test without any testmods, I get failures in both the GENERATE and BASELINE phases.

The BASELINE failure looks like this:

```
Did not compare any hist files! Missing baselines?
FAIL
```

The GENERATE failure is less graceful, involving an uncaught exception:

```
2018-11-21 15:48:24: Exception during GENERATE:
ERROR: Could not generate any hist files for case '/glade/scratch/sacks/PFS.f09_g17.I2000Clm50BgcCrop.cheyenne_intel.G.20181121_151920_nwxojv/run/PFS.f09_g17.I2000Clm50BgcCrop.cheyenne_intel.G.20181121_151920_nwxojv', something is seriously wrong
Traceback (most recent call last):
  File "/gpfs/fs1/scratch/sacks/cesm_code/ctsm/cime/scripts/Tools/../../scripts/lib/CIME/SystemTests/system_tests_common.py", line 340, in _phase_modifying_call
    function()
  File "/gpfs/fs1/scratch/sacks/cesm_code/ctsm/cime/scripts/Tools/../../scripts/lib/CIME/SystemTests/system_tests_common.py", line 499, in _generate_baseline
    success, comments = generate_baseline(self._case)
  File "/gpfs/fs1/scratch/sacks/cesm_code/ctsm/cime/scripts/Tools/../../scripts/lib/CIME/hist_utils.py", line 525, in generate_baseline
    expect(num_gen > 0, "Could not generate any hist files for case '{}', something is seriously wrong".format(os.path.join(rundir, testcase)))
  File "/gpfs/fs1/scratch/sacks/cesm_code/ctsm/cime/scripts/Tools/../../scripts/lib/CIME/utils.py", line 130, in expect
    raise exc_type(msg)
SystemExit: ERROR: Could not generate any hist files for case '/glade/scratch/sacks/PFS.f09_g17.I2000Clm50BgcCrop.cheyenne_intel.G.20181121_151920_nwxojv/run/PFS.f09_g17.I2000Clm50BgcCrop.cheyenne_intel.G.20181121_151920_nwxojv', something is seriously wrong
```

The problem is that, unlike most tests, the PFS test deliberately does not generate any history files. Should there be some mechanism for a given test to be able to say: skip the generation and comparison of history files – or at least, don't fail if there are no history files to generate / compare. I don't want to skip generation and comparison entirely, because TPUTCOMP is of interest for these PFS tests.


Discussion:
I have a fix for this on the nuopc branch.

Resolving patch:
diff --git a/scripts/lib/CIME/hist_utils.py b/scripts/lib/CIME/hist_utils.py
--- a/scripts/lib/CIME/hist_utils.py
+++ b/scripts/lib/CIME/hist_utils.py
@@ -522,8 +522,8 @@ def generate_baseline(case, baseline_dir=None, allow_baseline_overwrite=False):
         logger.warning("No {}.log file found in directory {}".format(cplname,case.get_value("RUNDIR")))
     else:
         safe_copy(newestcpllogfile, os.path.join(basegen_dir, "{}.log.gz".format(cplname)))
-
-    expect(num_gen > 0, "Could not generate any hist files for case '{}', something is seriously wrong".format(os.path.join(rundir, testcase)))
+    testname = case.get_value("TESTCASE")
+    expect(num_gen > 0 or testname == "PFS", "Could not generate any hist files for case '{}', something is seriously wrong".format(os.path.join(rundir, testcase)))
     #make sure permissions are open in baseline directory
     for root, _, files in os.walk(basegen_dir):
         for name in files:


Test patch: