-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2786: adds metoffice specific env files
- Loading branch information
Katherine Tomkins
committed
Sep 7, 2022
1 parent
1b1cc76
commit 1c92f66
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
esmvaltool/utils/recipe_run_workflow/recipe_run_workflow/site/metoffice-env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash -l | ||
# | ||
# Usage metoffice-env COMMAND | ||
# | ||
# ENVIRONMENT | ||
# MODULE_NAME The name of the module to load | ||
# PYTHONPATH_PREPEND The path to prepend to PYTHONPATH after loading the | ||
# module | ||
# QUIET_MODE Don't print confirmation messages | ||
# | ||
# OPTIONS | ||
# COMMAND The command to execute with options | ||
set -eu | ||
|
||
module_count(){ | ||
module list -t 2>&1 | wc -l | ||
} | ||
|
||
safe_load(){ | ||
PRE_LOAD_COUNT=$(module_count) | ||
|
||
module load "${1}" | ||
# Check module count to determine whether module load was successful. | ||
if (( PRE_LOAD_COUNT == $(module_count) )); then | ||
echo "[ERROR] Failed to load: ${1}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Must be run before importing numpy, see | ||
# https://www-avd/sci/dask_best_practice/numpy-threads.html. | ||
export OMP_NUM_THREADS=1 | ||
export OPENBLAS_NUM_THREADS=1 | ||
export MKL_NUM_THREADS=1 | ||
export VECLIB_MAXIMUM_THREADS=1 | ||
export NUMEXPR_NUM_THREADS=1 | ||
|
||
# Ensure '~/.local' isn't added to 'sys.path'. | ||
export PYTHONNOUSERSITE=True | ||
|
||
safe_load "${MODULE_NAME}" | ||
|
||
# If PYTHONPATH_PREPEND has been set, prepend it to PYTHONPATH to extend the | ||
# Python environment. | ||
if [[ ! -z ${PYTHONPATH_PREPEND:-} ]]; then | ||
echo "[INFO] Prepending the following to PYTHONPATH: ${PYTHONPATH_PREPEND}" | ||
export PYTHONPATH=${PYTHONPATH_PREPEND}:${PYTHONPATH:-} | ||
fi | ||
|
||
if [[ -z ${QUIET_MODE:-} ]]; then | ||
echo "[OK] Modules loaded." | ||
fi | ||
|
||
command="/usr/bin/time -v -o ${CYLC_TASK_LOG_ROOT}.time $@" | ||
exec ${command} |
Empty file.