-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvalidate.sh
More file actions
executable file
·68 lines (56 loc) · 1.83 KB
/
Copy pathvalidate.sh
File metadata and controls
executable file
·68 lines (56 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
set -ex
POT3D_HOME=$PWD
TEST="validation"
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
MPI_TYPE="openmpi"
elif echo "$MPI_VERSION" | grep -q "MPICH"; then
MPI_TYPE="mpich"
else
# we don't yet support other MPI implementations
# like intel MPI etc.0
echo -e "${RED}Unknown MPI implementation!${NC}"
exit 1
fi
for np in 1 2 4; do
rm -rf pot3d.log pot3d.out timing.out
# set MPIEXEC_ARGS based on MPI type and number of ranks
# `--oversubscribe` isn't needed with Open MPI when running
# with 1 or 2 ranks
if [[ "$MPI_TYPE" == "openmpi" && $np -gt 2 ]]; then
MPIEXEC_ARGS="--oversubscribe"
else
MPIEXEC_ARGS=""
fi
echo "Running POT3D with $np MPI rank..."
${MPIEXEC} -np ${np} ${MPIEXEC_ARGS} ${POT3D_HOME}/bin/pot3d 1> pot3d.log 2>pot3d.err
echo "Done!"
runtime=($(tail -n 5 timing.out | head -n 1))
echo "Wall clock time: ${runtime[6]} seconds"
echo " "
#Validate run:
${POT3D_HOME}/scripts/pot3d_validation.sh pot3d.out ${POT3D_HOME}/testsuite/${TEST}/validation/pot3d.out
if [ $? -ne 0 ]; then
echo "Validation failed for $np MPI rank. Exiting..."
exit 1
fi
echo ""
done
echo "Done!"