2010-05-12 13:27:55 +00:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
|
|
|
# Giuseppe Ciaccio 15 November 2000
|
|
|
|
# This script is derived from the mpirun.args original script of MPICH .
|
|
|
|
#
|
|
|
|
hasprinthelp=1
|
|
|
|
progname=
|
|
|
|
cmdLineArgs=
|
|
|
|
machineFile=
|
|
|
|
machineFileArg=
|
|
|
|
fake_progname=
|
|
|
|
np=1
|
|
|
|
mpirun_verbose=0
|
|
|
|
just_testing=0
|
|
|
|
machineFileArg=
|
|
|
|
machineFile=
|
|
|
|
Show=eval
|
|
|
|
#
|
|
|
|
PrintHelp() {
|
|
|
|
#
|
|
|
|
# If you change this, make the corresponding changes in README so that
|
|
|
|
# the man pages are updated.
|
|
|
|
#
|
|
|
|
cat <<EOF
|
|
|
|
mpirun [mpirun_options...] <progname> [options...]
|
|
|
|
|
|
|
|
mpirun_options:
|
|
|
|
-h This help
|
|
|
|
-machinefile <machine-file name>
|
2013-07-18 01:43:15 +00:00
|
|
|
The file is a list of machines to be involved in the job run.
|
|
|
|
Local machine is always involved (and hosts instance #0).
|
2010-05-12 13:27:55 +00:00
|
|
|
Default machine file is /etc/gamma.conf
|
|
|
|
-np <np>
|
|
|
|
specify the number of process instances to be generated.
|
|
|
|
-t Testing - do not actually run, just print what would be
|
|
|
|
executed
|
|
|
|
-v Verbose - throw in some comments
|
|
|
|
|
|
|
|
Multiple architectures as well as multiple pathnames for the executables
|
|
|
|
cannot be handled yet.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ 1 -le $# ] ; do
|
|
|
|
arg=$1
|
|
|
|
#echo $arg
|
|
|
|
#echo $#
|
|
|
|
shift
|
2013-07-18 01:02:34 +00:00
|
|
|
case $arg in
|
|
|
|
-arch)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-np)
|
2013-07-18 01:43:15 +00:00
|
|
|
np="$1"
|
2010-05-12 13:27:55 +00:00
|
|
|
nodigits=`echo $np | sed 's/^[0-9]*$//'`
|
|
|
|
if [ "$nodigits" != "" -o $np -lt 1 ] ; then
|
|
|
|
echo np: $np is an invalid number of processors. Exiting.
|
|
|
|
exit 1
|
2013-07-18 01:43:15 +00:00
|
|
|
fi
|
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-machine)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-machinefile)
|
|
|
|
machineFileArg="-machinefile"
|
|
|
|
machineFile="$1"
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-device)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-stdin)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-stdout)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-stderr)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-nolocal)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-h)
|
2013-07-18 01:43:15 +00:00
|
|
|
if [ "$hasprinthelp" = 1 ] ; then
|
|
|
|
PrintHelp
|
2010-05-12 13:27:55 +00:00
|
|
|
fi
|
2013-07-18 01:43:15 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-e)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-pg)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-leave_pg|-keep_pg)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-batch)
|
|
|
|
;;
|
|
|
|
-jid)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-globusrsl)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-globusdb)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-globusargs)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-p4pg)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-p4wd)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-tcppg)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-p4ssport)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-paragontype)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-paragonname)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-paragonpn)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-v)
|
2013-07-18 01:43:15 +00:00
|
|
|
mpirun_verbose=1
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-t)
|
2013-07-18 01:43:15 +00:00
|
|
|
just_testing=1
|
|
|
|
Show=echo
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-tv|-totalview)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-ksq)
|
|
|
|
;;
|
|
|
|
-dbx)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-gdb)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-xxgdb)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-ddd)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-pedb)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-nopoll)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-maxtime|-cpu)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-mem)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-mvhome)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-mvback)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-cac)
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-echo)
|
2013-07-18 01:43:15 +00:00
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
-usage|-help|-\?)
|
2013-07-18 01:43:15 +00:00
|
|
|
# Accept these for help until the program name is provided.
|
|
|
|
if [ "$progname" = "" ] ; then
|
|
|
|
if [ "$hasprinthelp" = "1" ] ; then
|
|
|
|
PrintHelp
|
2010-05-12 13:27:55 +00:00
|
|
|
fi
|
2013-07-18 01:43:15 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
*)
|
2013-07-18 01:43:15 +00:00
|
|
|
# The first unrecognized argument is assumed to be the name of
|
|
|
|
# the program, but only if it is executable
|
|
|
|
proginstance=`echo $arg | sed "s/%a/$arch/g"`
|
|
|
|
if [ "$progname" = "" -a "$fake_progname" = "" -a \
|
|
|
|
! -x "$proginstance" ] ; then
|
|
|
|
fake_progname="$arg"
|
|
|
|
elif [ "$progname" = "" -a -x "$proginstance" ] ; then
|
|
|
|
progname="$arg"
|
2010-05-12 13:27:55 +00:00
|
|
|
# any following unrecognized arguments are assumed to be arguments
|
|
|
|
# to be passed to the program, as well as all future args
|
2013-07-18 01:43:15 +00:00
|
|
|
while [ 1 -le $# ] ; do
|
2010-05-12 13:27:55 +00:00
|
|
|
cmdLineArgs="$cmdLineArgs $1"
|
2013-07-18 01:43:15 +00:00
|
|
|
shift
|
2010-05-12 13:27:55 +00:00
|
|
|
done
|
|
|
|
else
|
2013-07-18 01:43:15 +00:00
|
|
|
echo "Warning: Command line arguments for program should be given"
|
2010-05-12 13:27:55 +00:00
|
|
|
echo "after the program name. Assuming that $arg is a"
|
|
|
|
echo "command line argument for the program."
|
|
|
|
cmdLineArgsExecer="$cmdLineArgsExecer -arg=$arg"
|
|
|
|
cmdLineArgs="$cmdLineArgs $arg"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# We need at least the program name
|
|
|
|
|
|
|
|
if [ "$progname" = "" ] ; then
|
|
|
|
echo "Missing: program name"
|
|
|
|
if [ "$fake_progname" != "" ] ; then
|
|
|
|
echo "Program $fake_progname either does not exist, is not "
|
|
|
|
echo "executable, or is an erroneous argument to mpirun."
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Fill out relative program pathnames
|
|
|
|
#
|
|
|
|
# Get the current directory
|
|
|
|
# Note that PWD may NOT be `pwd` if an explicit "cd", outside of the csh
|
|
|
|
# shell, is used. A downside of this is that PWD may have a more reasonable
|
|
|
|
# version of the path. To try and fix this, we create a test file and see
|
|
|
|
# if it is accessible from PWD and pwd; if so, we take the PWD value
|
2013-07-18 01:02:34 +00:00
|
|
|
#
|
2010-05-12 13:27:55 +00:00
|
|
|
# Why can't automounters work!???!!
|
|
|
|
#
|
|
|
|
# For those unfamiliar with the problem, the automounter creates
|
2013-07-18 01:02:34 +00:00
|
|
|
# paths like /tmp_mnt/.... . But if you try to open a file with that path,
|
2010-05-12 13:27:55 +00:00
|
|
|
# and the ACTUAL path has not been accessed before, the automounter fails
|
|
|
|
# to mount the partition. In otherwords, the automounter is so mind-bogglingly
|
|
|
|
# stupid as to not recognize its OWN MOUNTS. Network computing indeed.
|
|
|
|
#
|
|
|
|
# Note that PWD may ALSO be damaged, so we need to sed PWD as well...
|
|
|
|
#
|
|
|
|
# We should move this to the point in the code where it needs to know a
|
|
|
|
# particular filename, since this will fail if the directory is not
|
|
|
|
# writable by the user.
|
2013-07-18 01:02:34 +00:00
|
|
|
#
|
2010-05-12 13:27:55 +00:00
|
|
|
if [ -n "sed -e s@/tmp_mnt/@/@g" ] ; then
|
|
|
|
PWDtest=`pwd | sed -e s@/tmp_mnt/@/@g`
|
|
|
|
if [ ! -d $PWDtest ] ; then
|
|
|
|
PWDtest=`pwd`
|
|
|
|
fi
|
|
|
|
if [ -n "$PWD" ] ; then
|
2013-07-18 01:43:15 +00:00
|
|
|
# Use a process-specific filename
|
|
|
|
PWDtest2=`echo $PWD | sed -e s@/tmp_mnt/@/@g`
|
2010-05-12 13:27:55 +00:00
|
|
|
/bin/rm -f $PWDtest/.mpirtmp$$ $PWDtest2/.mpirtmp$$
|
|
|
|
if `eval "echo test > $PWDtest2/.mpirtmp$$" 2>/dev/null` ; then
|
|
|
|
if [ ! -s $PWDtest/.mpirtmp$$ ] ; then
|
2013-07-18 01:43:15 +00:00
|
|
|
/bin/rm -f $PWDtest2/.mpirtmp$$
|
2010-05-12 13:27:55 +00:00
|
|
|
PWD=$PWDtest
|
2013-07-18 01:43:15 +00:00
|
|
|
else
|
|
|
|
PWD=$PWDtest2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Current directory is not writable. Hope for the best
|
2013-07-18 01:02:34 +00:00
|
|
|
PWD=$PWDtest
|
2010-05-12 13:27:55 +00:00
|
|
|
fi
|
|
|
|
/bin/rm -f $PWDtest/.mpirtmp$$ $PWDtest2/.mpirtmp$$
|
2013-07-18 01:02:34 +00:00
|
|
|
else
|
2010-05-12 13:27:55 +00:00
|
|
|
PWD=$PWDtest
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
PWD=`pwd`
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
if [ -n "$PWD" ] ; then
|
|
|
|
PWD_TRIAL=$PWD
|
|
|
|
else
|
|
|
|
PWD_TRIAL=$PWDtest
|
|
|
|
fi
|
|
|
|
# The test for PWD_TRIAL usable is within the p4/execer/tcp test (since that
|
|
|
|
# is where it matters)
|
|
|
|
#
|
2013-07-18 01:02:34 +00:00
|
|
|
tail=`echo $progname | sed 's/\/.*//'`
|
2010-05-12 13:27:55 +00:00
|
|
|
if [ "$tail" = "" ] ; then
|
|
|
|
#echo Absolute path, don't need to change anything
|
|
|
|
true
|
|
|
|
else
|
|
|
|
#echo Relative path
|
|
|
|
progname="$PWD_TRIAL/$progname"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $mpirun_verbose = 1 ] ; then
|
|
|
|
echo "running $progname on $np $arch $machine processors"
|
|
|
|
fi
|
|
|
|
|
|
|
|
$Show $progname $cmdLineArgs $machineFileArg $machineFile -GAMMANP $np
|