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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
#! /bin/sh
#
# Based largely on the mpirun.ch_p4.in file.
#
#
# The following makes a statement that is true of ALL versions of MPIRUN,
# and hence is redundent.
#
#echo "Notice: This is not the using the full features of the Nexus" 2>&1
#echo "Notice: runtime. To do so, you should try to run the program" 2>&1
#echo "Notice: directly instead." 2>&1
#
# If this program was started up without the arguments being passed, we
# must first set up the arguments
#
if [ -z "$MPIR_HOME" ] ; then
MPIR_HOME=#MPIR_HOME#
fi
if [ "$MPIR_HOME" = "#""MPIR_HOME""#" ] ; then
MPIR_HOME=`pwd`/..
fi
if [ "#MPIRUN_BIN#" = "#""MPIRUN_BIN""#" ] ; then
MPIRUN_HOME=$MPIR_HOME/bin
else
MPIRUN_HOME=$MPIR_HOME/#MPIRUN_BIN#
fi
if [ -z "$argsset" ] ; then
. $MPIRUN_HOME/mpirun.args
argsset=1
fi
#
# This section is mostly snarfed from mpirun.anlspx
#
if [ -d /etc/FRAMES -a -d /mcs ] ; then
on_anlsp=1
else
on_anlsp=0
fi
#
# Make sure that the application is in the .server_apps file.
# This is really only necessary if the secure server is running, but
# it doesn't hurt too badly.
#
if [ -z "$HOME" ] ; then
echo "Cannot determine location of home directory (in HOME)"
exit 1
fi
if [ -r $HOME/.server_apps ] ; then
grep $progname $HOME/.server_apps > /dev/null 2>&1
if [ $? != 0 ] ; then
echo "$progname" >> $HOME/.server_apps
chmod 600 $HOME/.server_apps
fi
else # $HOME/.server_apps
echo "$progname" >> $HOME/.server_apps
chmod 600 $HOME/.server_apps
fi
#
# Construct a startup file. If one is not used, use the same file that
# p4 uses to create one. This only applies to non-ANL SP usages, since
# we expect the SP to use MPL instead of TCP, so a startup file is not
# needed.
#
if [ "$on_anlsp" != "1" ] ; then
if [ "x$nexuspgfile" = "x" ] ; then
. $MPIRUN_HOME/mpirun.pg
prognamemain=$progname
nexuspgfile="$PWD_TRIAL/startup.$$"
archval=$archlocal
proginstance=`echo $progname | sed "s/%a/$archval/g"`
prognamemain=$proginstance
if [ $just_testing = 1 ] ; then
echo "Startup file:"
echo "$MPI_HOST startup_exe=$proginstance"
else
echo "$MPI_HOST startup_exe=$proginstance" > $nexuspgfile
fi
cnt=1
for machine in $machinelist ; do
archval=`echo $archuselist | cut -d' ' -f$cnt`
cnt=`expr $cnt + 1`
proginstance=`echo $progname | sed "s/%a/$archval/g"`
if [ $just_testing = 1 ] ; then
echo "$machine#$cnt startup_exe=$proginstance"
else
echo "$machine#$cnt startup_exe=$proginstance" >> $nexuspgfile
fi
done
#
# Make sure the startup file was written
#
if [ $just_testing = 0 -a \! -r "$nexuspgfile" ] ; then
echo "Failed to write $nexuspgfile. Exiting."
exit 1
fi
fi
NexusArgs="-s $nexuspgfile $NexusArgs"
fi
#
# Use a rdb file (if necessary)
#
if [ "x$nexusdbfile" != "x" ] ; then
NexusArgs="-dbfile $nexusdbfile $NexusArgs"
fi
if [ "$debugger" = "dbx" ] ; then
NexusArgs="-debug_command $MPIRUN_HOME/rundbx -debug_display $DISPLAY $NexusArgs"
fi
if [ "$debugger" = "gdb" ] ; then
NexusArgs="-debug_command $MPIRUN_HOME/rungdb -debug_display $DISPLAY $NexusArgs"
fi
#
# Somehow get the right options to Nexus without munching the options to
# the program. If the user typed something like
#
# mpirun -np 2 a.out foo -mpi -stack 50000
#
# the $cmdLineArgs becomes "foo -mpi -stack 50000", so the easiest way
# to add arguments is at the beginning surrounded by a -mpi/-mpi_end
# pair. This makes the current $cmdLineArgs equal to
# "foo -mpi -s startupfile -mpi_end -mpi -stack 5000", because we always
# use a startup file.
#
cmdLineArgs="-mpi $NexusArgs -mpi_end $cmdLineArgs"
if [ $on_anlsp = 1 ] ; then
. $MPIRUN_HOME/mpirun.anlspx
else
#
# Check for non-supported options:
# nolocal
# e
# nopoll
# maxtime
# cac
#
#
# Set up the debugger (if necessary)
#
if [ "x$debugger" != "x" ] ; then
debuggerfile="$PWD_TRIAL/debugger.$$"
# If gdb has an equivalent, the documentation is well hidden.
if [ "$debugger" = "dbx" -a -r $HOME/.dbxinit ] ; then
cat $HOME/.dbxinit > $debuggerfile
fi
cat >> $debuggerfile <<EOF
# ignore USR1
# Use this command to start your program:
run $cmdLineArgs
EOF
startpgm="$debugger $progname $commandfile $debuggerfile"
else # debugger
startpgm="$progname $cmdLineArgs"
fi # debugger
#
# Start program (if necessary)
#
if [ $just_testing = 1 ] ; then
echo ""
echo $startpgm
else # just_testing
$startpgm
if [ $leavePGFile = 1 ] ; then
echo "Startup file is $nexuspgfile."
else
/bin/rm "$nexuspgfile"
fi
fi # just_testing
fi # on_anlsp
|