2020-04-03 03:15:49 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-07-03 02:05:45 -05:00
|
|
|
# This runs a simulator and optionally a post command in result directory.
|
2020-04-03 03:15:49 -05:00
|
|
|
|
2021-10-13 03:47:23 -05:00
|
|
|
if test $# -eq 0
|
|
|
|
then
|
|
|
|
echo -e "Usage:\t$0 <options> -- [additional simulator options]"
|
|
|
|
echo -e "\tMandatory options:"
|
|
|
|
echo -e "\t\t -i <path> Path to read deck from"
|
|
|
|
echo -e "\t\t -r <path> Path to store results in"
|
|
|
|
echo -e "\t\t -b <path> Path to simulator binary"
|
|
|
|
echo -e "\t\t -f <filename> Deck file name"
|
|
|
|
echo -e "\t\t -e <filename> Simulator binary to use"
|
2023-07-03 02:05:45 -05:00
|
|
|
echo -e "\tOptional options:"
|
2021-10-13 03:47:23 -05:00
|
|
|
echo -e "\t\t -n <procs > Number of MPI processes to use"
|
2023-07-03 02:05:45 -05:00
|
|
|
echo -e "\t\t -p <cmd> Post-command to execute"
|
2021-10-13 03:47:23 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
OPTIND=1
|
2023-07-03 02:05:45 -05:00
|
|
|
MPI_PROCS=1
|
|
|
|
while getopts "i:r:b:f:e:n:p:" OPT
|
2021-10-13 03:47:23 -05:00
|
|
|
do
|
|
|
|
case "${OPT}" in
|
|
|
|
i) INPUT_DATA_PATH=${OPTARG} ;;
|
|
|
|
r) RESULT_PATH=${OPTARG} ;;
|
|
|
|
b) BINPATH=${OPTARG} ;;
|
|
|
|
f) FILENAME=${OPTARG} ;;
|
|
|
|
e) EXE_NAME=${OPTARG} ;;
|
|
|
|
n) MPI_PROCS=${OPTARG} ;;
|
2023-07-03 02:05:45 -05:00
|
|
|
p) POST_COMMAND=${OPTARG} ;;
|
2021-10-13 03:47:23 -05:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND-1))
|
2020-04-03 03:15:49 -05:00
|
|
|
TEST_ARGS="$@"
|
|
|
|
|
|
|
|
mkdir -p ${RESULT_PATH}
|
|
|
|
if (( ${MPI_PROCS} > 1))
|
|
|
|
then
|
2023-06-29 08:20:38 -05:00
|
|
|
mpirun -np ${MPI_PROCS} ${BINPATH}/${EXE_NAME} ${TEST_ARGS} --output-dir=${RESULT_PATH} "${INPUT_DATA_PATH}/${FILENAME}.DATA"
|
2020-04-03 03:15:49 -05:00
|
|
|
else
|
2023-06-29 08:20:38 -05:00
|
|
|
${BINPATH}/${EXE_NAME} ${TEST_ARGS} --output-dir=${RESULT_PATH} "${INPUT_DATA_PATH}/${FILENAME}.DATA"
|
2020-04-03 03:15:49 -05:00
|
|
|
fi
|
|
|
|
test $? -eq 0 || exit 1
|
2023-07-03 02:05:45 -05:00
|
|
|
|
|
|
|
if test -n "${POST_COMMAND}"
|
|
|
|
then
|
|
|
|
cd $RESULT_PATH
|
|
|
|
${POST_COMMAND}
|
|
|
|
fi
|