Repository: ESMCI/cime

Issue:
Allow HOMME tests to work in CIME
Jim, please make a separate PR to ESMCI for all the changes needed to get HOMME tests to work.



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/SystemTests/homme.py b/utils/python/CIME/SystemTests/homme.py
new file mode 100644
--- /dev/null
+++ b/utils/python/CIME/SystemTests/homme.py
@@ -0,0 +1,62 @@
+"""
+CIME HOMME test. This class inherits from SystemTestsCommon
+"""
+from CIME.XML.standard_module_setup import *
+from CIME.SystemTests.system_tests_common import SystemTestsCommon
+from CIME.build import post_build
+
+import shutil
+
+logger = logging.getLogger(__name__)
+
+class HOMME(SystemTestsCommon):
+
+    def __init__(self, case):
+        """
+        initialize an object interface to the SMS system test
+        """
+        SystemTestsCommon.__init__(self, case)
+
+    def build_phase(self, sharedlib_only=False, model_only=False):
+        if not sharedlib_only:
+            # Build HOMME
+            srcroot  = self._case.get_value("SRCROOT")
+            mach     = self._case.get_value("MACH")
+            procs    = self._case.get_value("TOTALPES")
+            exeroot  = self._case.get_value("EXEROOT")
+            baseline = self._case.get_value("CCSM_BASELINE")
+            basegen  = self._case.get_value("BASEGEN_CASE")
+            basecmp  = self._case.get_value("BASECMP_CASE")
+            generate = self._case.get_value("GENERATE_BASELINE")
+
+            basename = basegen if generate else basecmp
+            cmake_cmd = "cmake -C %s/components/homme/cmake/machineFiles/%s.cmake -DUSE_NUM_PROCS=%s %s/components/homme -DHOMME_BASELINE_DIR=%s/%s >& homme.bldlog" % (srcroot, mach, procs, srcroot, baseline, basename)
+
+            run_cmd_no_fail(cmake_cmd, from_dir=exeroot)
+            run_cmd_no_fail("make -j8 >> homme.bldlog 2>&1", from_dir=exeroot)
+
+            post_build(self._case, [os.path.join(exeroot, "homme.bldlog")])
+
+    def run_phase(self):
+
+        rundir   = self._case.get_value("RUNDIR")
+        exeroot  = self._case.get_value("EXEROOT")
+        baseline = self._case.get_value("CCSM_BASELINE")
+        compare  = self._case.get_value("COMPARE_BASELINE")
+        generate = self._case.get_value("GENERATE_BASELINE")
+        basegen  = self._case.get_value("BASEGEN_CASE")
+
+        log = os.path.join(rundir, "homme.log")
+        if os.path.exists(log):
+            os.remove(log)
+
+        if generate:
+            full_baseline_dir = os.path.join(baseline, basegen, "tests", "baseline")
+            run_cmd_no_fail("make -j 4 baseline >& %s" % log, from_dir=exeroot)
+            if os.path.isdir(full_baseline_dir):
+                shutil.rmtree(full_baseline_dir)
+            shutil.copytree(os.path.join(exeroot, "tests", "baseline"), full_baseline_dir)
+        elif compare:
+            run_cmd_no_fail("make -j 4 check >& %s" % log, from_dir=exeroot)
+        else:
+            run_cmd_no_fail("make -j 4 baseline >& %s" % log, from_dir=exeroot)
diff --git a/utils/python/CIME/build.py b/utils/python/CIME/build.py
--- a/utils/python/CIME/build.py
+++ b/utils/python/CIME/build.py
@@ -10,7 +10,8 @@
 logger = logging.getLogger(__name__)
 
 def stringify_bool(val):
-    expect(type(val) is bool, "Wrong type")
+    val = False if val is None else val
+    expect(type(val) is bool, "Wrong type for val '%s'" % repr(val))
     return "TRUE" if val else "FALSE"
 
 ###############################################################################
@@ -130,7 +131,8 @@ def post_build(case, logs):
     # Set XML to indicate build complete
     case.set_value("BUILD_COMPLETE", True)
     case.set_value("BUILD_STATUS", 0)
-    case.set_value("SMP_BUILD", os.environ["SMP_VALUE"])
+    if "SMP_VALUE" in os.environ:
+        case.set_value("SMP_BUILD", os.environ["SMP_VALUE"])
     case.flush()
 
     if os.path.exists("LockedFiles/env_build.xml"):
@@ -231,10 +233,10 @@ def case_build(caseroot, case, sharedlib_only=False, model_only=False):
     os.environ["CAM_CONFIG_OPTS"]      = cam_config_opts     if cam_config_opts     is not None else ""
     os.environ["PIO_CONFIG_OPTS"]      = pio_config_opts     if pio_config_opts     is not None else ""
     os.environ["OCN_SUBMODEL"]         = ocn_submodel        if ocn_submodel        is not None else ""
-    os.environ["PROFILE_PAPI_ENABLE"]  = stringify_bool(profile_papi_enable) if profile_papi_enable is not None else ""
-    os.environ["CLM_USE_PETSC"]        = stringify_bool(clm_use_petsc)       if clm_use_petsc       is not None else ""
-    os.environ["CISM_USE_TRILINOS"]    = stringify_bool(cism_use_trilinos)   if cism_use_trilinos   is not None else ""
-    os.environ["MPASLI_USE_ALBANY"]    = stringify_bool(mpasli_use_albany)   if mpasli_use_albany   is not None else ""
+    os.environ["PROFILE_PAPI_ENABLE"]  = stringify_bool(profile_papi_enable)
+    os.environ["CLM_USE_PETSC"]        = stringify_bool(clm_use_petsc)
+    os.environ["CISM_USE_TRILINOS"]    = stringify_bool(cism_use_trilinos)
+    os.environ["MPASLI_USE_ALBANY"]    = stringify_bool(mpasli_use_albany)
 
     # This is a timestamp for the build , not the same as the testid,
     # and this case may not be a test anyway. For a production
@@ -268,9 +270,9 @@ def case_build(caseroot, case, sharedlib_only=False, model_only=False):
     # the future there may be others -- so USE_ALBANY will be true if
     # ANY of those are true.
 
-    use_albany = mpasli_use_albany
+    use_albany = stringify_bool(mpasli_use_albany)
     case.set_value("USE_ALBANY", use_albany)
-    os.environ["USE_ALBANY"] = stringify_bool(use_albany)
+    os.environ["USE_ALBANY"] = use_albany
 
     # Load modules
     env_module = case.get_env("mach_specific")


Test patch:
diff --git a/scripts/Testing/Testcases/HOMME_script b/scripts/Testing/Testcases/HOMME_script
deleted file mode 100755
--- a/scripts/Testing/Testcases/HOMME_script
+++ /dev/null
@@ -1,26 +0,0 @@
-
-set EXEROOT  = `./xmlquery EXEROOT -value`
-set GEN      = `./xmlquery GENERATE_BASELINE -value`
-set COMP     = `./xmlquery COMPARE_BASELINE -value`
-set TESTID   = `./xmlquery TEST_TESTID -value`
-set BASELINE = `./xmlquery CCSM_BASELINE -value`
-set BASEGEN  = `./xmlquery BASEGEN_CASE -value`
-
-set LOG      = $RUNDIR/cpl.log.$TESTID
-set FULL_BASELINE_DIR = $BASELINE/$BASEGEN
-
-cd $EXEROOT
-
-if ($GEN == "TRUE") then
-   make -j 4 baseline >& $LOG || exit -1
-   mkdir -p $FULL_BASELINE_DIR/tests
-   cp -f -r tests/baseline $FULL_BASELINE_DIR/tests
-else if ($COMP == "TRUE") then
-   make -j 4 check  >& $LOG || exit -1
-else
-   make -j 4 baseline >& $LOG || exit -1
-endif
-
-cd -
-
-set CplLogFile = `ls -1t $RUNDIR/cpl.log* | head -1`
diff --git a/utils/python/CIME/SystemTests/system_tests_common.py b/utils/python/CIME/SystemTests/system_tests_common.py
--- a/utils/python/CIME/SystemTests/system_tests_common.py
+++ b/utils/python/CIME/SystemTests/system_tests_common.py
@@ -431,8 +431,8 @@ def build_phase(self, sharedlib_only=False, model_only=False):
                 f.write(self._script)
 
             os.chmod(modelexe, 0755)
-            self._case.set_value("BUILD_COMPLETE", True)
-            self._case.flush()
+
+            build.post_build(self._case, [])
 
     def run_phase(self):
         self.run_indv(suffix=None)
diff --git a/utils/python/update_acme_tests.py b/utils/python/update_acme_tests.py
--- a/utils/python/update_acme_tests.py
+++ b/utils/python/update_acme_tests.py
@@ -88,7 +88,7 @@
                          "HOMME_P24.f19_g16_rx1.A",
                          "NCK.f19_g16_rx1.A",
                          "SMS.ne30_f19_g16_rx1.A",
-                         "ERS_Ld5.T62_oQU120.C_MPAS_NORMAL_YEAR",
+                         "ERS_Ld5.T62_oQU120.CMPASO-NYF",
                          "ERS.f09_g16_g.MPASLI_ONLY",
                          "ERS_Ld5.ne16_ne16.FC5ATMMODCOSP",
                          "SMS.T62_oQU120_ais20.MPAS_LISIO_TEST",