Skip to content

Commit

Permalink
Deprecate serial_cable and parallel_cable scripts
Browse files Browse the repository at this point in the history
The `serial_cable` and `parallel_cable` scripts were deprecated in
CABLE-LSM/CABLE#193. This change does the same
in the benchcab source code.

For code branches that require the serial_cable and parallel_cable
scripts can use the `build_script` key as a work around.

Fixes #223
  • Loading branch information
SeanBryan51 committed Dec 20, 2023
1 parent e6fed7d commit 274895a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
20 changes: 1 addition & 19 deletions benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,6 @@ def pre_build(self, verbose=False):
verbose=verbose,
)

copy2(
path_to_repo / self.src_dir / "offline" / "parallel_cable",
tmp_dir,
verbose=verbose,
)

copy2(
path_to_repo / self.src_dir / "offline" / "serial_cable",
tmp_dir,
verbose=verbose,
)

def run_build(self, modules: list[str], verbose=False):
"""Runs CABLE build scripts."""
path_to_repo = internal.SRC_DIR / self.name
Expand All @@ -148,13 +136,7 @@ def run_build(self, modules: list[str], verbose=False):
env["FC"] = "mpif90" if internal.MPI else "ifort"

self.subprocess_handler.run_cmd(
"make -f Makefile", env=env, verbose=verbose
)
self.subprocess_handler.run_cmd(
f"./{'parallel_cable' if internal.MPI else 'serial_cable'} \"{env['FC']}\" "
f"\"{env['CFLAGS']}\" \"{env['LDFLAGS']}\" \"{env['LD']}\" \"{env['NCMOD']}\"",
env=env,
verbose=verbose,
"make mpi" if internal.MPI else "make", env=env, verbose=verbose
)

def post_build(self, verbose=False):
Expand Down
19 changes: 4 additions & 15 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,13 @@ def _setup(self, model):
"""Setup precondition for `Model.pre_build()`."""
(internal.SRC_DIR / model.name / "offline").mkdir(parents=True)
(internal.SRC_DIR / model.name / "offline" / "Makefile").touch()
(internal.SRC_DIR / model.name / "offline" / "parallel_cable").touch()
(internal.SRC_DIR / model.name / "offline" / "serial_cable").touch()
(internal.SRC_DIR / model.name / "offline" / "foo.f90").touch()

def test_source_files_and_scripts_are_copied_to_tmp_dir(self, model):
"""Success case: test source files and scripts are copied to .tmp."""
model.pre_build()
tmp_dir = internal.SRC_DIR / model.name / "offline" / ".tmp"
assert (tmp_dir / "Makefile").exists()
assert (tmp_dir / "parallel_cable").exists()
assert (tmp_dir / "serial_cable").exists()
assert (tmp_dir / "foo.f90").exists()


Expand Down Expand Up @@ -184,21 +180,14 @@ def _setup(self, model, netcdf_root):
"""Setup precondition for `Model.run_build()`."""
(internal.SRC_DIR / model.name / "offline" / ".tmp").mkdir(parents=True)

# This is required so that we can use the NETCDF_ROOT environment variable
# when running `make`, and `serial_cable` and `parallel_cable` scripts:
# This is required so that we can use the NETCDF_ROOT environment
# variable when running `make`:
os.environ["NETCDF_ROOT"] = netcdf_root

def test_build_command_execution(
self, model, mock_subprocess_handler, modules, netcdf_root
):
def test_build_command_execution(self, model, mock_subprocess_handler, modules):
"""Success case: test build commands are run."""
model.run_build(modules)
assert mock_subprocess_handler.commands == [
"make -f Makefile",
'./serial_cable "ifort" "-O2 -fp-model precise"'
f' "-L{netcdf_root}/lib/Intel -O0" "-lnetcdf -lnetcdff" '
f'"{netcdf_root}/include/Intel"',
]
assert mock_subprocess_handler.commands == ["make"]

def test_modules_loaded_at_runtime(
self, model, mock_environment_modules_handler, modules
Expand Down

0 comments on commit 274895a

Please sign in to comment.