Skip to content

Commit

Permalink
Move magic constants into internal
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBryan51 committed Apr 4, 2024
1 parent cdd5e5b commit ca5e691
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/benchcab/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

CONFIG_REQUIRED_KEYS = ["realisations", "modules"]

# CMake module used for compilation:
CMAKE_MODULE = "cmake/3.24.2"

# Number of parallel jobs used when compiling with CMake:
CMAKE_BUILD_PARALLEL_LEVEL = 4

# Parameters for job script:
QSUB_FNAME = "benchmark_cable_qsub.sh"
FLUXSITE_DEFAULT_PBS: PBSConfig = {
Expand Down
7 changes: 4 additions & 3 deletions src/benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ def custom_build(self, modules: list[str]):
def build(self, modules: list[str], mpi=False):
"""Build CABLE with CMake."""
path_to_repo = internal.SRC_DIR / self.name
nproc_default = 4
cmake_args = ["-DCMAKE_BUILD_TYPE=Release"]
if mpi:
cmake_args.append('-DCABLE_MPI="ON"')

Check warning on line 126 in src/benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

src/benchcab/model.py#L124-L126

Added lines #L124 - L126 were not covered by tests

with chdir(path_to_repo), self.modules_handler.load(["cmake/3.24.2", *modules]):
with chdir(path_to_repo), self.modules_handler.load(

Check warning on line 128 in src/benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

src/benchcab/model.py#L128

Added line #L128 was not covered by tests
[internal.CMAKE_MODULE, *modules]
):
env = os.environ.copy()
# This is required so that the netcdf-fortran library is discoverable by
# pkg-config:
Expand All @@ -141,7 +142,7 @@ def build(self, modules: list[str], mpi=False):
"CMAKE_PREFIX_PATH", f"{env['OPENMPI_BASE']}/include/Intel", env=env
)

env["CMAKE_BUILD_PARALLEL_LEVEL"] = str(nproc_default)
env["CMAKE_BUILD_PARALLEL_LEVEL"] = str(internal.CMAKE_BUILD_PARALLEL_LEVEL)

Check warning on line 145 in src/benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

src/benchcab/model.py#L145

Added line #L145 was not covered by tests

self.subprocess_handler.run_cmd(

Check warning on line 147 in src/benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

src/benchcab/model.py#L147

Added line #L147 was not covered by tests
"cmake -S . -B build " + " ".join(cmake_args), env=env
Expand Down

0 comments on commit ca5e691

Please sign in to comment.