Skip to content

Commit

Permalink
Merge pull request #4659 from ESMCI/reformat/config_batch
Browse files Browse the repository at this point in the history
Reformat/config batch
  • Loading branch information
jedwards4b authored Aug 9, 2024
2 parents dc8196e + a1736a3 commit f89e7a2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CIME/BuildTools/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from CIME.XML.files import Files
from CIME.build import CmakeTmpBuildDir

import shutil
import shutil, glob

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -72,6 +72,12 @@ def configure(
output_cmake_macros_dir = os.path.join(output_dir, "cmake_macros")
if not os.path.exists(output_cmake_macros_dir):
shutil.copytree(new_cmake_macros_dir, output_cmake_macros_dir)
ccs_mach_dir = os.path.join(
new_cmake_macros_dir, "..", machobj.get_machine_name()
)
for f in glob.iglob(os.path.join(ccs_mach_dir, "*.cmake")):
print(f"copying {f} to {output_dir}")
safe_copy(f, output_dir)

copy_local_macros_to_dir(
output_cmake_macros_dir, extra_machdir=extra_machines_dir
Expand Down
10 changes: 10 additions & 0 deletions CIME/XML/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __init__(
if infile is None:
infile = files.get_value("BATCH_SPEC_FILE")

config_dir = os.path.dirname(infile)

schema = files.get_schema("BATCH_SPEC_FILE")

GenericXML.__init__(self, infile, schema=schema)
Expand All @@ -50,12 +52,20 @@ def __init__(
#
# This could cause problems if node matches are repeated when only one is expected.
infile = os.path.join(os.environ.get("HOME"), ".cime", "config_batch.xml")
usehome = False
if os.path.exists(infile):
GenericXML.read(self, infile)
usehome = True
useextra = False
if extra_machines_dir:
infile = os.path.join(extra_machines_dir, "config_batch.xml")
if os.path.exists(infile):
GenericXML.read(self, infile)
useextra = True
if not usehome and not useextra:
batchfile = os.path.join(config_dir, self.machine, "config_batch.xml")
if os.path.exists(batchfile):
GenericXML.read(self, batchfile)

if self.batch_system is not None:
self.set_batch_system(self.batch_system, machine=machine)
Expand Down
8 changes: 6 additions & 2 deletions CIME/case/case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def _create_macros_cmake(
]
for macro in macros:
repo_macro = os.path.join(cmake_macros_dir, macro)
mach_repo_macro = os.path.join(cmake_macros_dir, "..", mach, macro)
case_macro = os.path.join(case_cmake_path, macro)
if not os.path.exists(case_macro) and os.path.exists(repo_macro):
safe_copy(repo_macro, case_cmake_path)
if not os.path.exists(case_macro):
if os.path.exists(mach_repo_macro):
safe_copy(mach_repo_macro, case_cmake_path)
elif os.path.exists(repo_macro):
safe_copy(repo_macro, case_cmake_path)

copy_depends_files(mach, mach_obj.machines_dir, caseroot, compiler)

Expand Down
6 changes: 6 additions & 0 deletions CIME/tests/test_sys_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def setUp(self):

def _has_unit_test_support(self):
cmake_macros_dir = Files().get_value("CMAKE_MACROS_DIR")
cmake_machine_macros_dir = os.path.join(cmake_macros_dir, "..", self._machine)

macros_to_check = [
os.path.join(
Expand All @@ -39,6 +40,11 @@ def _has_unit_test_support(self):
os.path.join(
os.environ.get("HOME"), ".cime", "{}.cmake".format(self._machine)
),
os.path.join(
cmake_machine_macros_dir,
"{}_{}.cmake".format(self._compiler, self._machine),
),
os.path.join(cmake_machine_macros_dir, "{}.cmake".format(self._machine)),
]

for macro_to_check in macros_to_check:
Expand Down

0 comments on commit f89e7a2

Please sign in to comment.