Skip to content

Commit 6d64f4a

Browse files
committed
Give Nice Error MSG if No Conda ENV is activated or if MPI implementation is not installed
1 parent 95eaccb commit 6d64f4a

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

tests/pot3d/validate.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,26 @@ set -ex
22

33
POT3D_HOME=$PWD
44
TEST="validation"
5-
MPIEXEC=${CONDA_PREFIX}/bin/mpiexec
65

76
cp ${POT3D_HOME}/testsuite/${TEST}/input/* ${POT3D_HOME}/testsuite/${TEST}/run/
87
cd ${POT3D_HOME}/testsuite/${TEST}/run
98

9+
# Check if conda is active
10+
if [[ -z "$CONDA_PREFIX" ]]; then
11+
echo -e "${RED}Error: No Conda environment is active. Please activate a conda env with MPI installed.${NC}"
12+
exit 1
13+
fi
14+
15+
# Try locating mpiexec
16+
if [[ -x "${CONDA_PREFIX}/bin/mpiexec" ]]; then
17+
MPIEXEC="${CONDA_PREFIX}/bin/mpiexec"
18+
elif command -v mpiexec &> /dev/null; then
19+
MPIEXEC=$(command -v mpiexec)
20+
else
21+
echo -e "${RED}Error: mpiexec not found. Please install MPI (OpenMPI or MPICH) via Conda or system package manager.${NC}"
22+
exit 1
23+
fi
24+
1025
# detect MPI implementation
1126
MPI_VERSION=$($MPIEXEC --version 2>&1)
1227
if echo "$MPI_VERSION" | grep -q "Open MPI"; then

tests/run_tests.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ while [[ $# -gt 0 ]]; do
2222
esac
2323
done
2424

25-
MPIEXEC=${CONDA_PREFIX}/bin/mpiexec
25+
# Check if conda is active
26+
if [[ -z "$CONDA_PREFIX" ]]; then
27+
echo -e "${RED}Error: No Conda environment is active. Please activate a conda env with MPI installed.${NC}"
28+
exit 1
29+
fi
30+
31+
# Try locating mpiexec
32+
if [[ -x "${CONDA_PREFIX}/bin/mpiexec" ]]; then
33+
MPIEXEC="${CONDA_PREFIX}/bin/mpiexec"
34+
elif command -v mpiexec &> /dev/null; then
35+
MPIEXEC=$(command -v mpiexec)
36+
else
37+
echo -e "${RED}Error: mpiexec not found. Please install MPI (OpenMPI or MPICH) via Conda or system package manager.${NC}"
38+
exit 1
39+
fi
2640

2741
# detect MPI implementation
2842
MPI_VERSION=$($MPIEXEC --version 2>&1)

0 commit comments

Comments
 (0)