11"""
22CIME HOMME test. This class inherits from SystemTestsCommon
33"""
4+
45from CIME .XML .standard_module_setup import *
56from CIME .SystemTests .system_tests_common import SystemTestsCommon
67from CIME .build import post_build
78from CIME .status import append_testlog
8- from CIME .utils import SharedArea
9+ from CIME .utils import SharedArea , new_lid , gzip_existing_file
910from CIME .test_status import *
1011
1112import shutil
@@ -19,6 +20,8 @@ def __init__(self, case, **kwargs):
1920 initialize an object interface to the SMS system test
2021 """
2122 SystemTestsCommon .__init__ (self , case , ** kwargs )
23+ compiler = case .get_value ("COMPILER" )
24+ logger .info (f"[DEBUG] Detected compiler: { compiler } " )
2225 case .load_env ()
2326 self .csnd = "not defined"
2427 self .cmakesuffix = self .csnd
@@ -36,6 +39,11 @@ def build_phase(self, sharedlib_only=False, model_only=False):
3639 gmake = self ._case .get_value ("GMAKE" )
3740 gmake_j = self ._case .get_value ("GMAKE_J" )
3841 cprnc = self ._case .get_value ("CCSM_CPRNC" )
42+ is_debug = self ._case .get_value ("DEBUG" )
43+
44+ # Assign LID at start
45+ lid = new_lid (case = self ._case )
46+ log_path = os .path .join (exeroot , f"homme.bldlog.{ lid } " )
3947
4048 if compare :
4149 basename = basecmp
@@ -49,29 +57,45 @@ def build_phase(self, sharedlib_only=False, model_only=False):
4957 "ERROR in hommebaseclass: Must have cmakesuffix set up" ,
5058 )
5159
60+ logger .info (
61+ f"[DEBUG] Machine: { mach } , Source root: { srcroot } , Total Procs: { procs } , Is Debug: { is_debug } "
62+ )
63+ logger .info ("[DEBUG] Preparing to invoke CMake with constructed command:" )
5264 cmake_cmd = "cmake -C {0}/components/homme/cmake/machineFiles/{1}{6}.cmake -DUSE_NUM_PROCS={2} {0}/components/homme -DHOMME_BASELINE_DIR={3}/{4} -DCPRNC_DIR={5}/.." .format (
5365 srcroot , mach , procs , baselinedir , basename , cprnc , self .cmakesuffix
5466 )
5567
68+ if is_debug :
69+ cmake_cmd += " -DCMAKE_BUILD_TYPE=Debug"
70+
5671 run_cmd_no_fail (
5772 cmake_cmd ,
58- arg_stdout = "homme.bldlog" ,
73+ arg_stdout = log_path ,
5974 combine_output = True ,
6075 from_dir = exeroot ,
6176 )
6277 run_cmd_no_fail (
6378 "{} -j{} VERBOSE=1 test-execs" .format (gmake , gmake_j ),
64- arg_stdout = "homme.bldlog" ,
79+ arg_stdout = log_path ,
6580 combine_output = True ,
6681 from_dir = exeroot ,
6782 )
6883
69- post_build (
70- self ._case , [os .path .join (exeroot , "homme.bldlog" )], build_complete = True
71- )
84+ post_build (self ._case , [log_path ], build_complete = True )
7285
73- def run_phase (self ):
86+ # Prepend the LID as first line if log file exists
87+ if os .path .exists (log_path ):
88+ with open (log_path , "r" ) as original :
89+ original_content = original .read ()
90+ with open (log_path , "w" ) as modified :
91+ modified .write (f"LID: { lid } \n " + original_content )
92+ gzip_existing_file (log_path )
93+ else :
94+ logger .warning (
95+ f"[WARN] Build log does not exist: { log_path } . Skipping LID prepend and gzip step."
96+ )
7497
98+ def run_phase (self ):
7599 rundir = self ._case .get_value ("RUNDIR" )
76100 exeroot = self ._case .get_value ("EXEROOT" )
77101 baseline = self ._case .get_value ("BASELINE_ROOT" )
@@ -80,9 +104,8 @@ def run_phase(self):
80104 basegen = self ._case .get_value ("BASEGEN_CASE" )
81105 gmake = self ._case .get_value ("GMAKE" )
82106
83- log = os .path .join (rundir , "homme.log" )
84- if os .path .exists (log ):
85- os .remove (log )
107+ lid = new_lid (case = self ._case )
108+ log = os .path .join (rundir , "homme.log." + lid )
86109
87110 if generate :
88111 full_baseline_dir = os .path .join (baseline , basegen , "tests" , "baseline" )
@@ -130,6 +153,10 @@ def run_phase(self):
130153 # is pretty useless for this test.
131154 append_testlog (open (log , "r" ).read ())
132155
156+ if stat == 0 :
157+ # Gzip the log file to be consistent with other CIME cases (bldglogs)
158+ gzip_existing_file (log )
159+
133160 expect (stat == 0 , "RUN FAIL for HOMME" )
134161
135162 # Homme is a bit of an oddball test since it's not really running the E3SM model
0 commit comments