ThirdParty packages: Add comment in README file. Contributed by Darrin Stephens
[OpenFOAM-1.6-ext.git] / bin / mpigammarun
blobfa789ddf5537701225c22312256195c633b9e4fc
1 #! /bin/sh
3 # Giuseppe Ciaccio 15 November 2000
4 # This script is derived from the mpirun.args original script of MPICH .
6 hasprinthelp=1
7 progname=
8 cmdLineArgs=
9 machineFile=
10 machineFileArg=
11 fake_progname=
12 np=1
13 mpirun_verbose=0
14 just_testing=0
15 machineFileArg=
16 machineFile=
17 Show=eval
19 PrintHelp() {
21 # If you change this, make the corresponding changes in README so that
22 # the man pages are updated.
24 cat <<EOF
25 mpirun [mpirun_options...] <progname> [options...]
27 mpirun_options:
28 -h This help
29 -machinefile <machine-file name>
30 The file is a list of machines to be involved in the job run.
31 Local machine is always involved (and hosts instance #0).
32 Default machine file is /etc/gamma.conf
33 -np <np>
34 specify the number of process instances to be generated.
35 -t Testing - do not actually run, just print what would be
36 executed
37 -v Verbose - throw in some comments
39 Multiple architectures as well as multiple pathnames for the executables
40 cannot be handled yet.
42 EOF
45 while [ 1 -le $# ] ; do
46 arg=$1
47 #echo $arg
48 #echo $#
49 shift
50 case $arg in
51 -arch)
52 shift
54 -np)
55 np="$1"
56 nodigits=`echo $np | sed 's/^[0-9]*$//'`
57 if [ "$nodigits" != "" -o $np -lt 1 ] ; then
58 echo np: $np is an invalid number of processors. Exiting.
59 exit 1
61 shift
63 -machine)
64 shift
66 -machinefile)
67 machineFileArg="-machinefile"
68 machineFile="$1"
69 shift
71 -device)
72 shift
74 -stdin)
75 shift
77 -stdout)
78 shift
80 -stderr)
81 shift
83 -nolocal)
84 ;;
85 -h)
86 if [ "$hasprinthelp" = 1 ] ; then
87 PrintHelp
89 exit 1
90 ;;
91 -e)
93 -pg)
95 -leave_pg|-keep_pg)
97 -batch)
99 -jid)
100 shift
102 -globusrsl)
103 shift
105 -globusdb)
106 shift
108 -globusargs)
109 shift
111 -p4pg)
112 shift
114 -p4wd)
115 shift
117 -tcppg)
118 shift
120 -p4ssport)
121 shift
123 -paragontype)
124 shift
126 -paragonname)
127 shift
129 -paragonpn)
130 shift
133 mpirun_verbose=1
136 just_testing=1
137 Show=echo
139 -tv|-totalview)
141 -ksq)
143 -dbx)
145 -gdb)
147 -xxgdb)
149 -ddd)
151 -pedb)
153 -nopoll)
155 -maxtime|-cpu)
156 shift
158 -mem)
159 shift
161 -mvhome)
163 -mvback)
164 shift
166 -cac)
167 shift
169 -echo)
171 -usage|-help|-\?)
172 # Accept these for help until the program name is provided.
173 if [ "$progname" = "" ] ; then
174 if [ "$hasprinthelp" = "1" ] ; then
175 PrintHelp
177 exit 1
181 # The first unrecognized argument is assumed to be the name of
182 # the program, but only if it is executable
183 proginstance=`echo $arg | sed "s/%a/$arch/g"`
184 if [ "$progname" = "" -a "$fake_progname" = "" -a \
185 ! -x "$proginstance" ] ; then
186 fake_progname="$arg"
187 elif [ "$progname" = "" -a -x "$proginstance" ] ; then
188 progname="$arg"
189 # any following unrecognized arguments are assumed to be arguments
190 # to be passed to the program, as well as all future args
191 while [ 1 -le $# ] ; do
192 cmdLineArgs="$cmdLineArgs $1"
193 shift
194 done
195 else
196 echo "Warning: Command line arguments for program should be given"
197 echo "after the program name. Assuming that $arg is a"
198 echo "command line argument for the program."
199 cmdLineArgsExecer="$cmdLineArgsExecer -arg=$arg"
200 cmdLineArgs="$cmdLineArgs $arg"
203 esac
204 done
206 # We need at least the program name
208 if [ "$progname" = "" ] ; then
209 echo "Missing: program name"
210 if [ "$fake_progname" != "" ] ; then
211 echo "Program $fake_progname either does not exist, is not "
212 echo "executable, or is an erroneous argument to mpirun."
214 exit 1
217 # Fill out relative program pathnames
219 # Get the current directory
220 # Note that PWD may NOT be `pwd` if an explicit "cd", outside of the csh
221 # shell, is used. A downside of this is that PWD may have a more reasonable
222 # version of the path. To try and fix this, we create a test file and see
223 # if it is accessible from PWD and pwd; if so, we take the PWD value
225 # Why can't automounters work!???!!
227 # For those unfamiliar with the problem, the automounter creates
228 # paths like /tmp_mnt/.... . But if you try to open a file with that path,
229 # and the ACTUAL path has not been accessed before, the automounter fails
230 # to mount the partition. In otherwords, the automounter is so mind-bogglingly
231 # stupid as to not recognize its OWN MOUNTS. Network computing indeed.
233 # Note that PWD may ALSO be damaged, so we need to sed PWD as well...
235 # We should move this to the point in the code where it needs to know a
236 # particular filename, since this will fail if the directory is not
237 # writable by the user.
239 if [ -n "sed -e s@/tmp_mnt/@/@g" ] ; then
240 PWDtest=`pwd | sed -e s@/tmp_mnt/@/@g`
241 if [ ! -d $PWDtest ] ; then
242 PWDtest=`pwd`
244 if [ -n "$PWD" ] ; then
245 # Use a process-specific filename
246 PWDtest2=`echo $PWD | sed -e s@/tmp_mnt/@/@g`
247 /bin/rm -f $PWDtest/.mpirtmp$$ $PWDtest2/.mpirtmp$$
248 if `eval "echo test > $PWDtest2/.mpirtmp$$" 2>/dev/null` ; then
249 if [ ! -s $PWDtest/.mpirtmp$$ ] ; then
250 /bin/rm -f $PWDtest2/.mpirtmp$$
251 PWD=$PWDtest
252 else
253 PWD=$PWDtest2
255 else
256 # Current directory is not writable. Hope for the best
257 PWD=$PWDtest
259 /bin/rm -f $PWDtest/.mpirtmp$$ $PWDtest2/.mpirtmp$$
260 else
261 PWD=$PWDtest
263 else
264 PWD=`pwd`
267 if [ -n "$PWD" ] ; then
268 PWD_TRIAL=$PWD
269 else
270 PWD_TRIAL=$PWDtest
272 # The test for PWD_TRIAL usable is within the p4/execer/tcp test (since that
273 # is where it matters)
275 tail=`echo $progname | sed 's/\/.*//'`
276 if [ "$tail" = "" ] ; then
277 #echo Absolute path, don't need to change anything
278 true
279 else
280 #echo Relative path
281 progname="$PWD_TRIAL/$progname"
284 if [ $mpirun_verbose = 1 ] ; then
285 echo "running $progname on $np $arch $machine processors"
288 $Show $progname $cmdLineArgs $machineFileArg $machineFile -GAMMANP $np