Repository: ESMCI/cime

Issue:
ERIO test gives false positive in PIO1
The netcdf4p and netcdf4c pio types silently fail to open that format and fail over to netcdf and
so this test falsely indicates those tests as passing.  


Discussion:

Resolving patch:
diff --git a/scripts/lib/CIME/SystemTests/seq.py b/scripts/lib/CIME/SystemTests/seq.py
--- a/scripts/lib/CIME/SystemTests/seq.py
+++ b/scripts/lib/CIME/SystemTests/seq.py
@@ -3,7 +3,7 @@
 """
 from CIME.XML.standard_module_setup import *
 from CIME.SystemTests.system_tests_common import SystemTestsCommon
-from CIME.case_setup import case_setup
+from CIME.case_setup import case_setup, adjust_pio_layout
 from CIME.check_lockedfiles import *
 import shutil
 
@@ -45,18 +45,19 @@ def build_phase(self, sharedlib_only=False, model_only=False):
             for comp in comp_classes:
                 self._case.set_value("ROOTPE_%s"%comp, 0)
         else:
-            rootpe = 2
+            totalpes = self._case.get_value("TOTALPES")
+            newntasks = max(1, totalpes/len(comp_classes))
+            rootpe = newntasks
+
             for comp in comp_classes:
                 # here we set the cpl to have the first 2 tasks
                 # and each component to have a different ROOTPE
                 if comp == "CPL":
-                    self._case.set_value("NTASKS_CPL", 2)
+                    self._case.set_value("NTASKS_CPL", newntasks)
                 else:
-                    ntasks = self._case.get_value("NTASKS_%s"%comp)
-                    if ntasks > 1:
-                        self._case.set_value("NTASKS_%s"%comp, max(1,ntasks-rootpe))
-                        self._case.set_value("ROOTPE_%s"%comp, rootpe)
-                        rootpe += 1
+                    self._case.set_value("NTASKS_%s"%comp, newntasks)
+                    self._case.set_value("ROOTPE_%s"%comp, rootpe)
+                    rootpe += newntasks
         self._case.flush()
         case_setup(self._case, test_mode=True, reset=True)
         self.clean_build()
@@ -86,6 +87,11 @@ def run_phase(self):
         shutil.copy("%s/%s.exe.SEQ1"%(exeroot,cime_model),
                     "%s/%s.exe"%(exeroot,cime_model))
         restore("env_mach_pes.SEQ1.xml", newname="env_mach_pes.xml")
+
+        # update the pelayout settings for this run
+        self._case.read_xml()
+        adjust_pio_layout(self._case, self._case.get_value("PES_PER_NODE"))
+
         self.run_indv()
 
         restore("env_mach_pes.SEQ2.xml", newname="env_mach_pes.xml")
@@ -95,5 +101,9 @@ def run_phase(self):
                     "%s/%s.exe"%(exeroot,cime_model))
 
         logger.info("doing a second %d %s test with rootpes set to zero" % (stop_n, stop_option))
+        # update the pelayout settings for this run
+        self._case.read_xml()
+        adjust_pio_layout(self._case, self._case.get_value("PES_PER_NODE"))
+
         self.run_indv(suffix="seq")
         self._component_compare_test("base", "seq")
diff --git a/scripts/lib/CIME/case_setup.py b/scripts/lib/CIME/case_setup.py
--- a/scripts/lib/CIME/case_setup.py
+++ b/scripts/lib/CIME/case_setup.py
@@ -179,18 +179,7 @@ def _case_setup_impl(case, caseroot, clean=False, test_mode=False, reset=False,
 
             # Make sure pio settings are consistant
             if adjust_pio:
-                for comp in models:
-                    pio_stride = case.get_value("PIO_STRIDE_%s"%comp)
-                    pio_numtasks = case.get_value("PIO_NUMTASKS_%s"%comp)
-                    ntasks = case.get_value("NTASKS_%s"%comp)
-                    new_stride = min(ntasks, tasks_per_node)
-                    new_numtasks = max(1, ntasks//new_stride)
-                    if pio_stride != new_stride:
-                        logger.info("Resetting  PIO_STRIDE_%s to %s"%(comp, new_stride))
-                        case.set_value("PIO_STRIDE_%s"%comp, new_stride)
-                    if pio_numtasks != new_numtasks:
-                        logger.info("Resetting  PIO_NUMTASKS_%s to %s"%(comp, new_numtasks))
-                        case.set_value("PIO_NUMTASKS_%s"%comp, new_numtasks)
+                adjust_pio_layout(case, tasks_per_node)
 
             # Make a copy of env_mach_pes.xml in order to be able
             # to check that it does not change once case.setup is invoked
@@ -239,6 +228,24 @@ def _case_setup_impl(case, caseroot, clean=False, test_mode=False, reset=False,
         env_module.make_env_mach_specific_file(compiler, debug, mpilib, "csh")
         env_module.save_all_env_info("software_environment.txt")
 
+
+def adjust_pio_layout(case, new_pio_stride):
+
+    models = case.get_values("COMP_CLASSES")
+    for comp in models:
+        pio_stride = case.get_value("PIO_STRIDE_%s"%comp)
+        pio_numtasks = case.get_value("PIO_NUMTASKS_%s"%comp)
+        ntasks = case.get_value("NTASKS_%s"%comp)
+        new_stride = min(ntasks, new_pio_stride)
+        new_numtasks = max(1, ntasks//new_stride)
+        if pio_stride != new_stride:
+            logger.info("Resetting  PIO_STRIDE_%s to %s"%(comp, new_stride))
+            case.set_value("PIO_STRIDE_%s"%comp, new_stride)
+            if pio_numtasks != new_numtasks:
+                logger.info("Resetting  PIO_NUMTASKS_%s to %s"%(comp, new_numtasks))
+                case.set_value("PIO_NUMTASKS_%s"%comp, new_numtasks)
+
+
 ###############################################################################
 def case_setup(case, clean=False, test_mode=False, reset=False, no_status=False, adjust_pio=True):
 ###############################################################################


Test patch: