#
# script to run MPI programs
#
#!/bin/sh
if [ -z "$3" ]
then
	echo usage is `basename $0` hostfile nprocs pgm args
	exit 1
fi
if [ -z "$MPI_HOME" ]
then
    echo "no MPI_HOME (do you need a module load?)"
	exit 1
fi
hostfile="$1"
np="$2"
pgm="$3"
shift 3

if [ ! -r "$hostfile" ]
then
    echo "file $hostfile not found"
    exit 2
fi
if [ ! -x "$pgm" ]
then
    echo "program $pgm not found"
    exit 2
fi

mpirun -v \
    -prefix $MPI_HOME \
    -hostfile "$hostfile" -map-by node \
    -np $np $hostparam "$pgm" $*
