From 6d64f4a47beed278419fc2d1880378b1e8885695 Mon Sep 17 00:00:00 2001 From: Aditya Trivedi Date: Sat, 17 May 2025 11:31:54 +0530 Subject: [PATCH] Give Nice Error MSG if No Conda ENV is activated or if MPI implementation is not installed --- tests/pot3d/validate.sh | 17 ++++++++++++++++- tests/run_tests.sh | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/pot3d/validate.sh b/tests/pot3d/validate.sh index 7dfe013..4037bba 100755 --- a/tests/pot3d/validate.sh +++ b/tests/pot3d/validate.sh @@ -2,11 +2,26 @@ set -ex POT3D_HOME=$PWD TEST="validation" -MPIEXEC=${CONDA_PREFIX}/bin/mpiexec cp ${POT3D_HOME}/testsuite/${TEST}/input/* ${POT3D_HOME}/testsuite/${TEST}/run/ cd ${POT3D_HOME}/testsuite/${TEST}/run +# Check if conda is active +if [[ -z "$CONDA_PREFIX" ]]; then + echo -e "${RED}Error: No Conda environment is active. Please activate a conda env with MPI installed.${NC}" + exit 1 +fi + +# Try locating mpiexec +if [[ -x "${CONDA_PREFIX}/bin/mpiexec" ]]; then + MPIEXEC="${CONDA_PREFIX}/bin/mpiexec" +elif command -v mpiexec &> /dev/null; then + MPIEXEC=$(command -v mpiexec) +else + echo -e "${RED}Error: mpiexec not found. Please install MPI (OpenMPI or MPICH) via Conda or system package manager.${NC}" + exit 1 +fi + # detect MPI implementation MPI_VERSION=$($MPIEXEC --version 2>&1) if echo "$MPI_VERSION" | grep -q "Open MPI"; then diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 1e8f4ea..f80f63d 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -22,7 +22,21 @@ while [[ $# -gt 0 ]]; do esac done -MPIEXEC=${CONDA_PREFIX}/bin/mpiexec +# Check if conda is active +if [[ -z "$CONDA_PREFIX" ]]; then + echo -e "${RED}Error: No Conda environment is active. Please activate a conda env with MPI installed.${NC}" + exit 1 +fi + +# Try locating mpiexec +if [[ -x "${CONDA_PREFIX}/bin/mpiexec" ]]; then + MPIEXEC="${CONDA_PREFIX}/bin/mpiexec" +elif command -v mpiexec &> /dev/null; then + MPIEXEC=$(command -v mpiexec) +else + echo -e "${RED}Error: mpiexec not found. Please install MPI (OpenMPI or MPICH) via Conda or system package manager.${NC}" + exit 1 +fi # detect MPI implementation MPI_VERSION=$($MPIEXEC --version 2>&1)