From cd63ec877d31d5598be19002f4752894c60a54a5 Mon Sep 17 00:00:00 2001 From: Yutaka Ishikawa Date: Tue, 12 Jun 2018 17:05:54 +0900 Subject: [PATCH] mpimcexec: Error handling is added Change-Id: Id4e94adad2afff324b154d0c8be270ecc7568bab --- arch/x86_64/tools/mpimcexec.in | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/x86_64/tools/mpimcexec.in b/arch/x86_64/tools/mpimcexec.in index d242bab9..8da288f4 100755 --- a/arch/x86_64/tools/mpimcexec.in +++ b/arch/x86_64/tools/mpimcexec.in @@ -44,28 +44,52 @@ help_exit() { while true; do case $1 in -ppn | --ppn | --ranks-per-node ) + if [ $# -lt 2 ]; then + echo "error: needs an interger value for -ppn, --ppn, or --ranks-per-node option" + help_exit + fi PPN=$2 shift 2 ;; -n | --n | --ranks ) + if [ $# -lt 2 ]; then + echo "error: needs an interger value for -n, --n, or --ranks option" + help_exit + fi RANKS=$2 shift 2 ;; -m | --numa ) + if [ $# -lt 2 ]; then + echo "error: needs an interger value for -m or --numa option" + help_exit + fi NUMA="-m $2" shift 2 ;; --nodes ) + if [ $# -lt 2 ]; then + echo "error: needs an interger value for --nodes option" + help_exit + fi NODES=$2 shift 2 ;; --env | -env ) + if [ $# -lt 2 ]; then + echo "error: needs an environment variable name for -env or --env option" + help_exit + fi if [ -z "`echo $2 | grep I_MPI_PIN`" ]; then MPI_ENV=`echo "${MPI_ENV} -env $2" | xargs` fi shift 2 ;; -h | --hostfile ) + if [ $# -lt 2 ]; then + echo "error: needs a file name for -h or --hostfile option" + help_exit + fi HOSTFILE="-hostfile $2" shift 2 ;; @@ -94,6 +118,11 @@ if [ -z ${RANKS} ] && [ -z ${NODES} ]; then help_exit fi +if [ x${COMMAND} = x ]; then + echo "error: please specify command" + help_exit +fi + # Calculate total job size if not specified if [ -z ${RANKS} ]; then let RANKS=(${PPN}*${NODES})