/[escript]/trunk/run-escript.in
ViewVC logotype

Annotation of /trunk/run-escript.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4369 - (hide annotations)
Fri Apr 19 02:32:34 2013 UTC (6 years, 4 months ago) by jfenwick
Original Path: trunk/bin/run-escript
File size: 16101 byte(s)
fix problems revealed on freebsd
1 jfenwick 4369 #!/usr/bin/env bash
2 jfenwick 2409
3     # Escript/Finley wrapper for python
4     # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
5    
6     #Extra paths can be configured about a page further down
7     #Search for EXTRA_PATH=""
8    
9 jfenwick 2568 #set to 1 if performing this is a standalone build and ../../pkg contains the relevant tools
10 caltinay 4362 STANDALONE=0
11 jfenwick 2409
12     #set to 1 if this is part of a packaged build (.deb) and files will be installed in standard locations
13     #rather than everything in a single directory
14     #Do not use this together with $STANDALONE
15     STDLOCATION=0
16    
17     #Now we find the location of this script
18     #Note that this location should be absolute but does not need to be unique
19     scriptdir=""
20     CURDIR=`pwd`
21    
22     #Environment vars which control operations:
23     # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROCS, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES
24    
25 jfenwick 3047 HOSTFILE=/tmp/escript.$USER.$$
26     HOSTFILE2=/tmp/escript2.$USER.$$
27 jfenwick 2409
28     #Begin finding ESCRIPT_ROOT
29 caltinay 2806 if [ $STDLOCATION -ne 0 ]
30 jfenwick 2409 then
31     ESCRIPT_ROOT=/usr/lib/escript
32     else
33 caltinay 4031 # We don't know the escript root so we need to work it out from the invocation
34     # Need to match if the name contains /
35 jfenwick 2409 if [[ $0 =~ / ]]
36     then
37     # We are not using the PATH to find the script
38 caltinay 3388 cd "`dirname $0`"
39 jfenwick 2409 scriptdir=`pwd`
40 caltinay 3388 cd "$CURDIR"
41 jfenwick 2409 else
42     # name does not contain / therefore we are using
43     tscriptdir=`which $0`
44 caltinay 3096 if [ $? -ne 0 ]
45 jfenwick 2409 then
46 caltinay 2806 echo "Error! Unable to determine script directory. Exiting."
47     exit 1
48 jfenwick 2409 fi
49     scriptdir=`dirname $tscriptdir`
50     fi
51    
52 caltinay 3388 cd "$scriptdir/.."
53 jfenwick 2409 ESCRIPT_ROOT=`pwd`
54     cd ..
55     ESCRIPT_PARENT=`pwd`
56 caltinay 3388 cd "$CURDIR"
57 jfenwick 2409
58     fi
59 caltinay 4031 ##### End finding ESCRIPT_ROOT ########
60 jfenwick 2409
61     PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"
62     PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"
63     PYTHON_CMD=python
64    
65     # if possible please express paths relative to $ESCRIPT_ROOT unless
66     # they are in an unrelated location
67    
68     EXTRA_DYLD_LIBRARY_PATH=""
69     EXTRA_PATH=$ESCRIPT_ROOT/bin
70     EXTRA_PYTHONPATH=$ESCRIPT_ROOT
71    
72 jfenwick 4078 if [ $STDLOCATION -eq 1 ]
73     then
74     EXTRA_LD_LIBRARY_PATH=/usr/lib/escript
75     else
76     EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
77     fi
78    
79    
80 caltinay 2806 if [ $STANDALONE -eq 1 ]
81 jfenwick 2409 then
82 jfenwick 3335 EXTRA_PATH=$ESCRIPT_PARENT/pkg/python/bin:$ESCRIPT_PARENT/pkg/scons/bin:$EXTRA_PATH
83 jfenwick 2530 EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/boost/lib:$ESCRIPT_PARENT/pkg/netcdf/lib/:$EXTRA_LD_LIBRARY_PATH
84 jfenwick 2541 EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH
85 jfenwick 2530 EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/python/lib:$EXTRA_LD_LIBRARY_PATH
86 jfenwick 2541 EXTRA_PYTHONPATH=$ESCRIPT_PARENT/pkg/numpy/lib/python2.6/site-packages:$ESCRIPT_PARENT/pkg/matplotlib/lib/python2.6/site-packages:$EXTRA_PYTHONPATH
87 jfenwick 2409 fi
88    
89 jfenwick 3335
90 jfenwick 4342 BUILDINFO_FILE="$ESCRIPT_ROOT/lib/buildvars"
91 jfenwick 4078 if [ "$STDLOCATION" = "1" ]
92     then
93     BUILDINFO_FILE=/usr/lib/escript/buildvars
94     fi
95 jfenwick 4342 if [ ! -r "$BUILDINFO_FILE" ]; then
96 caltinay 4031 if [ "$1" = "-e" ]; then
97     echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
98     echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
99     echo "export PATH=$EXTRA_PATH:\$PATH"
100     if [ "`uname`" = "Darwin" ]
101     then
102     echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
103     fi
104 jfenwick 3335 exit 0
105     fi
106     echo "Error! Unable to read escript build information. Exiting."
107     exit 1
108     fi
109    
110 caltinay 4031 get_buildvar () {
111 jfenwick 4342 echo `grep "^$1=" "$BUILDINFO_FILE" |cut -d= -f2`
112 jfenwick 3335 }
113    
114 caltinay 3096 #
115     # Add VisIt paths if required
116     #
117 jfenwick 3259 WITH_VISIT=`get_buildvar visit`
118     if [ "$WITH_VISIT" = "1" ]; then
119 caltinay 4030 VISIT_BIN=`which visit 2>/dev/null`
120 caltinay 3096 if [ $? -eq 0 ]; then
121     VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`
122     EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH
123     EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$VISIT_PY_PATH
124     elif [ ! -z $ESCRIPT_VERBOSE ]; then
125     echo "VisIt module enabled but VisIt not in path!"
126     fi
127     fi
128 jfenwick 2409
129     HELP_TEXT="
130 caltinay 4031 Usage: run-escript [options] script.py [arguments...]
131 jfenwick 2409 -n nn number of nodes to use
132 gross 3193 -p np number of MPI processes to spawn per node
133 jfenwick 2409 -t nt number of OpenMP threads to use
134     -f file name of MPI hostfile
135 caltinay 4031 -c print compile information for escript and exit
136 jfenwick 2409 -V print escript version and exit
137     -i interactive mode
138     -b do not invoke python (run non-python programs)
139     -e print export statements for environment and exit
140     -o redirect output from MPI to files
141     -v print diagnostics
142 caltinay 4031 -x run in new xterm instance
143 jfenwick 2409 script.py Your python script
144     arguments... The optional command-line arguments to your script
145     "
146    
147     if [ "$1" = "--help" ]; then
148     echo "$HELP_TEXT"
149     exit 0
150     fi
151 caltinay 4031 #==============================================================================
152 jfenwick 2409
153     # Parse the command-line options
154     # option e should not be followed by a :
155 caltinay 4031 while getopts 'bn:p:t:f:hecVviox' option
156 jfenwick 2409 do
157 caltinay 4031 case "$option" in
158     "b") DO_BINARY=y
159     ;;
160     "n") ESCRIPT_NUM_NODES=$OPTARG
161     ;;
162     "p") ESCRIPT_NUM_PROCS=$OPTARG
163     ;;
164     "t") ESCRIPT_NUM_THREADS=$OPTARG
165     ;;
166     "f") ESCRIPT_HOSTFILE=$OPTARG
167     ;;
168 jfenwick 4342 "c") cat "$BUILDINFO_FILE"
169 caltinay 4031 exit 0
170     ;;
171     "V") echo "escript-development(build "`get_buildvar svn_revision`")"
172     exit 0
173     ;;
174     "h") echo "$HELP_TEXT"
175     exit 0
176     ;;
177     "i") DO_INTERACTIVE=y
178     ;;
179     "e") echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
180     echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
181     echo "export PATH=$EXTRA_PATH:\$PATH"
182     if [ "`uname`" = "Darwin" ]
183     then
184     echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
185     fi
186     exit 0
187     ;;
188     "o") ESCRIPT_CREATESTDFILES=y
189     ;;
190     "v") ESCRIPT_VERBOSE=y
191     ;;
192     "x") DO_XTERM=y
193     ;;
194     ?) echo "$HELP_TEXT"
195     exit 1
196     ;;
197     esac
198 jfenwick 2409 done
199     shift `expr $OPTIND - 1`
200     #==============================================
201     #
202 caltinay 3178 # Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
203 jfenwick 2409 #
204 jfenwick 3259 MPI_FLAVOUR=`get_buildvar mpi`
205     WITH_OPENMP=`get_buildvar openmp`
206 jfenwick 2409
207 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]; then
208     echo "MPI flavour is $MPI_FLAVOUR."
209 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]; then echo "OpenMP enabled."; fi
210 caltinay 2806 fi
211    
212 jfenwick 2409 #
213     # extend path variables
214     #
215     export PATH=$EXTRA_PATH:$PATH
216     export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
217     export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
218     EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"
219 caltinay 2806 if [ "`uname`" = "Darwin" ]
220 jfenwick 2409 then
221     export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH
222     EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"
223     fi
224 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]
225 jfenwick 2409 then
226     echo "PATH = $PATH "
227     echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "
228     echo "PYTHONPATH = $PYTHONPATH "
229     if [ ! -z $DYLD_LIBRARY_PATH ]; then echo "DYLD_LIBRARY_PATH = $DYLD_LIBRARY_PATH "; fi
230     fi
231     #==============================================
232     #
233     # Ensure the variables have sensible values
234     #
235 caltinay 2806 if [ "$MPI_FLAVOUR" = "none" ]
236 jfenwick 2409 then
237     if [ ! -z $ESCRIPT_NUM_NODES ]
238     then
239     echo "Warning: MPI disabled but number of nodes set. Option ignored."
240     fi
241     if [ ! -z $ESCRIPT_NUM_PROCS ]
242     then
243     echo "Warning: MPI disabled but number of processors per node set. Option ignored."
244     fi
245 jfenwick 4342 if [ ! -z "$ESCRIPT_HOSTFILE" ]
246 jfenwick 2409 then
247     echo "Warning: MPI disabled but host file is given. Option ignored."
248     fi
249     ESCRIPT_NUM_NODES=1
250     ESCRIPT_NUM_PROCS=1
251     else
252 jfenwick 3056 # use the PBS_NODEFILE if not otherwise specified
253 jfenwick 4342 if [ ! -z "$PBS_NODEFILE" ] && [ -z "$ESCRIPT_HOSTFILE" ]
254 jfenwick 3056 then
255 caltinay 3178 ESCRIPT_HOSTFILE=$PBS_NODEFILE
256 jfenwick 3056 fi
257    
258 jfenwick 4342 if [ ! -z "$ESCRIPT_HOSTFILE" ]
259 jfenwick 2409 then
260 jfenwick 4342 if [ -f "$ESCRIPT_HOSTFILE" ]
261 jfenwick 2409 then
262 jfenwick 4342 cat "$ESCRIPT_HOSTFILE" | sort -u > $HOSTFILE
263     NUM_HOSTS=`cat "$HOSTFILE" | wc -l`
264 jfenwick 2409 if [ ! -z $ESCRIPT_NUM_NODES ]
265     then
266     if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]
267     then
268     echo "number of hosts selected in the host file $ESCRIPT_HOSTFILE needs to match the requested number of nodes $ESCRIPT_NUM_NODES."
269     exit 1
270     fi
271     else
272     ESCRIPT_NUM_NODES=$NUM_HOSTS
273     fi
274     else
275     echo "cannot find hostfile $ESCRIPT_HOSTFILE."
276     exit 1
277     fi
278     else
279     HOSTFILE=''
280     fi
281    
282     if [ -z $ESCRIPT_NUM_NODES ]
283     then
284 caltinay 3178 ESCRIPT_NUM_NODES=1
285 jfenwick 2409 fi
286    
287     if [ -z $ESCRIPT_NUM_PROCS ]
288     then
289 caltinay 3178 ESCRIPT_NUM_PROCS=1
290 jfenwick 2409 fi
291    
292 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]
293 jfenwick 2409 then
294 caltinay 3178 echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
295     echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
296 jfenwick 2409 fi
297     fi
298    
299 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
300 jfenwick 2409 then
301     if [ -z $ESCRIPT_NUM_THREADS ]
302     then
303     ESCRIPT_NUM_THREADS=$OMP_NUM_THREADS
304     if [ -z $ESCRIPT_NUM_THREADS ]
305     then
306     ESCRIPT_NUM_THREADS=1
307     fi
308     fi
309     if [ ! -z $ESCRIPT_VERBOSE ]
310     then
311     echo "ESCRIPT_NUM_THREADS is $ESCRIPT_NUM_THREADS."
312     fi
313     else
314 caltinay 4031 if [ ! -z $ESCRIPT_NUM_THREADS ] && [ $ESCRIPT_NUM_THREADS != 1 ]
315 jfenwick 2409 then
316     echo "Warning: OpenMP is disabled but number of threads requested is $ESCRIPT_NUM_THREADS!=1. Running without threads."
317     fi
318     ESCRIPT_NUM_THREADS=1
319     fi
320     #
321     # Now we compute total number of Processes
322     #
323 caltinay 4031 TOTPROC=$((ESCRIPT_NUM_NODES * ESCRIPT_NUM_PROCS))
324     if [ $? -ne 0 ] #Some compute error
325     then #This could happen if the args were not a number
326 caltinay 3178 echo "expression of total number of processors = $ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS is not numerical."
327     exit 1
328 jfenwick 2409 fi
329    
330     #
331     # Test to ensure people aren't trying to combine interactive and multi-process
332     #
333 caltinay 4058 if ([ ! -z $DO_INTERACTIVE ] || [ $# -eq 0 ]) && ([ $TOTPROC -gt 1 ])
334 jfenwick 2409 then
335 caltinay 3178 echo "Interactive mode cannot be used with more than one process"
336     exit 1
337 jfenwick 2409 fi
338    
339     if [ $TOTPROC -gt 1 ]
340     then
341 caltinay 4322 if [ "$ESCRIPT_CREATESTDFILES" = "y" ]
342 caltinay 3178 then
343     PYTHON_MPI=$PYTHON_MPI_REDIRECT
344     else
345     PYTHON_MPI=$PYTHON_MPI_NULL
346     fi
347 jfenwick 2409 else
348     PYTHON_MPI=$PYTHON_MPI_NULL
349     fi
350 caltinay 4031 #==============================================================================
351 jfenwick 2409 # Must have at least one command-line arg: the python script
352     if [ $# -eq 0 ]
353     then
354 caltinay 4031 if [ ! -z $DO_BINARY ]
355 caltinay 3178 then
356     echo "No program to run was specified. Exiting."
357     exit 1
358     else
359 caltinay 4031 DO_INTERACTIVE=y
360 caltinay 3178 fi
361 jfenwick 2409 fi
362    
363 caltinay 4031 #==============================================================================
364     if [ ! -z $DO_XTERM ]
365 jfenwick 2409 then
366 caltinay 4031 EXEC_CMD="xterm -e"
367 jfenwick 2409 else
368 caltinay 4031 EXEC_CMD=""
369     fi
370    
371     if [ ! -z $DO_BINARY ]
372     then
373     EXEC_CMD="$EXEC_CMD $@"
374     else
375 caltinay 3178 # Check to see if the python version we were compiled with matches the
376     # one of PYTHON_CMD.
377 jfenwick 3892 compfull=`get_buildvar python_version`
378     compversion=`echo $compfull | cut -d. -f1,2`
379     compmajor=`echo $compfull | cut -d. -f1`
380 caltinay 4031 if [ "$PYTHON_CMD" = "python" ] # if people have customised the command they
381 jfenwick 3892 then # might not want us changing it
382     if [ "$compmajor" = "3" ]
383     then
384     PYTHON_CMD=python3
385     fi
386     fi
387     intversion=`$PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))'`
388 caltinay 3178 if [ "$compversion" != "$intversion" ]
389     then
390     echo "Python versions do not match. Escript was compiled for "$compversion"."
391     echo "Current version of Python appears to be "$intversion"."
392     exit 1
393     fi
394 caltinay 2806 if [ "$MPI_FLAVOUR" = "none" ]
395 jfenwick 2409 then
396 caltinay 4031 if [ ! -z $DO_INTERACTIVE ]
397 jfenwick 2409 then
398 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_CMD -i $@"
399 jfenwick 2409 else
400 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_CMD $@"
401 jfenwick 2409 fi
402     else
403 caltinay 4031 if [ ! -z $DO_INTERACTIVE ]
404 gross 2865 then
405 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_MPI -i $@"
406 gross 2865 else
407 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_MPI $@"
408 gross 2865 fi
409 jfenwick 2409 fi
410     fi
411     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi
412 caltinay 4031 #==============================================================================
413 jfenwick 2409 #
414 caltinay 4031 # now we start to spawn things:
415 jfenwick 2409 #
416 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
417 jfenwick 2409 then
418     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
419     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
420     fi
421     EXIT_CODE=1
422     #=============== no MPI ===================================
423 caltinay 2806 if [ "$MPI_FLAVOUR" = "none" ]
424 jfenwick 2409 then
425     $EXEC_CMD
426     EXIT_CODE=$?
427     #=============== OpenMPI ===================================
428 caltinay 2806 elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
429 jfenwick 2409 then
430 jfenwick 4342 if [ ! -z "$HOSTFILE" ]
431 jfenwick 2409 then
432 jfenwick 4342 HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE"`
433 caltinay 4029 CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } --bynode -np $TOTPROC --bind-to-socket --cpus-per-rank $ESCRIPT_NUM_THREADS --host $HOST_LIST $EXEC_CMD"
434 jfenwick 2409 else
435 caltinay 4029 CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } --cpus-per-rank $ESCRIPT_NUM_THREADS -np $TOTPROC $EXEC_CMD"
436 jfenwick 2409 fi
437     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
438     $CMD
439     EXIT_CODE=$?
440    
441     #=============== Intel MPI ===================================
442 caltinay 2806 elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
443 jfenwick 2409 then
444 gross 2510
445 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
446 gross 2510 then
447     export I_MPI_PIN_DOMAIN=omp
448     EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"
449     fi
450    
451 jfenwick 4342 if [ ! -z "$HOSTFILE" ]
452 jfenwick 2409 then
453 jfenwick 4342 mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
454 jfenwick 2409 if [ $? -ne 0 ]
455     then
456     echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
457     exit 1
458     else
459     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
460     fi
461 gross 2866 else
462     mpdboot -n 1 -r ssh
463     if [ $? -ne 0 ]
464     then
465     echo "mpdboot failed."
466     exit 1
467     else
468     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
469     fi
470 jfenwick 2409 fi
471     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"
472     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
473     $CMD
474     EXIT_CODE=$?
475 gross 2866 mpdallexit
476     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
477 jfenwick 2409 #=============== SGI's MPIMPT ===================================
478 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPT" ]
479 jfenwick 2409 then
480     export MPI_NUM_MEMORY_REGIONS=0
481     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
482 jfenwick 4342 if [ ! -z "$HOSTFILE" ]
483 jfenwick 2409 then
484 jfenwick 4342 HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE"`
485 gross 2866 CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
486 jfenwick 2409 else
487     CMD="mpirun -np $TOTPROC $EXEC_CMD"
488     fi
489     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
490     $CMD
491     EXIT_CODE=$?
492     #=============== MPICH ===================================
493 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPICH" ]
494 jfenwick 2409 then
495 jfenwick 4342 if [ ! -z "$HOSTFILE" ]
496 jfenwick 2409 then
497 jfenwick 4342 touch "$HOSTFILE2"
498     for (( i=1;i<=$ESCRIPT_NUM_PROCS;i+=1 )) ; do cat "$HOSTFILE" >> "$HOSTFILE2" ; done
499     CMD="mpirun -machinefile \"$HOSTFILE2\" -np $TOTPROC $EXEC_CMD"
500 jfenwick 2409 else
501     CMD="mpirun -np $TOTPROC $EXEC_CMD"
502     fi
503     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
504     $CMD
505     EXIT_CODE=$?
506     #=============== MPICH2 ===================================
507 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPICH2" ]
508 jfenwick 2409 then
509 jfenwick 4342 if [ ! -z "$HOSTFILE" ]
510 jfenwick 2409 then
511 jfenwick 4342 mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
512 jfenwick 2409 if [ $? -ne 0 ]
513     then
514     echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
515     exit 1
516     else
517     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
518     fi
519 gross 2866 else
520     mpdboot -n 1 -r ssh
521     if [ $? -ne 0 ]
522     then
523     echo "mpdboot failed."
524     exit 1
525     else
526     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
527     fi
528 jfenwick 2409 fi
529     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"
530     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
531     $CMD
532     EXIT_CODE=$?
533 gross 2866 mpdallexit
534     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
535 jfenwick 2409 else
536 caltinay 2806 echo "unknown MPI flavour '$MPI_FLAVOUR'."
537 jfenwick 2409 fi
538     exit $EXIT_CODE
539 caltinay 4031

Properties

Name Value
svn:executable *
svn:mergeinfo /branches/lapack2681/bin/escript:2682-2741 /branches/pasowrap/bin/run-escript:3661-3674 /branches/py3_attempt2/bin/run-escript:3871-3891 /branches/restext/bin/escript:2610-2624 /branches/ripleygmg_from_3668/bin/run-escript:3669-3791 /branches/stage3.0/bin/escript:2569-2590 /branches/symbolic_from_3470/bin/run-escript:3471-3974 /branches/symbolic_from_3470/ripley/test/python/bin/run-escript:3517-3974 /release/3.0/bin/escript:2591-2601 /trunk/ripley/test/python/bin/run-escript:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26