/[escript]/branches/inv2jf/run-escript.in
ViewVC logotype

Annotation of /branches/inv2jf/run-escript.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4970 - (hide annotations)
Tue May 27 03:47:04 2014 UTC (4 years, 10 months ago) by caltinay
Original Path: trunk/bin/run-escript
File size: 17485 byte(s)
more bashisms removed (valgrind run) from launcher.

1 caltinay 4927 #!/usr/bin/env sh
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 caltinay 4970 CURDIR=$(pwd)
21 jfenwick 2409
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 caltinay 4491 ESCRIPT_ROOT=/usr/lib/python-escript
32 jfenwick 2409 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 caltinay 4927 if $(echo $0|grep -q /)
36 jfenwick 2409 then
37     # We are not using the PATH to find the script
38 caltinay 4970 cd "$(dirname $0)"
39     scriptdir=$(pwd)
40 caltinay 3388 cd "$CURDIR"
41 jfenwick 2409 else
42 caltinay 4927 # name does not contain / therefore we are using
43 caltinay 4970 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 caltinay 4970 scriptdir=$(dirname $tscriptdir)
50 jfenwick 2409 fi
51    
52 caltinay 3388 cd "$scriptdir/.."
53 caltinay 4970 ESCRIPT_ROOT=$(pwd)
54 jfenwick 2409 cd ..
55 caltinay 4970 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 caltinay 4491 EXTRA_LD_LIBRARY_PATH=/usr/lib/python-escript
75 jfenwick 4078 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 caltinay 4491 BUILDINFO_FILE=/usr/lib/python-escript/buildvars
94 jfenwick 4078 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 caltinay 4970 if [ "$(uname)" = "Darwin" ]
101 caltinay 4031 then
102     echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
103 caltinay 4927 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 caltinay 4970 echo $(grep "^$1=" "$BUILDINFO_FILE" |cut -d= -f2)
112 jfenwick 3335 }
113    
114 caltinay 3096 #
115     # Add VisIt paths if required
116     #
117 caltinay 4970 WITH_VISIT=$(get_buildvar visit)
118 jfenwick 3259 if [ "$WITH_VISIT" = "1" ]; then
119 caltinay 4970 VISIT_BIN=$(which visit 2>/dev/null)
120 caltinay 3096 if [ $? -eq 0 ]; then
121 caltinay 4970 VISIT_PY_PATH=$($VISIT_BIN -env | grep LIBPATH | cut -d= -f2)
122 caltinay 3096 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 caltinay 4927 -i interactive mode
138 jfenwick 2409 -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 caltinay 4506 -m tool run with valgrind {tool=m[emcheck]/c[allgrind]}
144 jfenwick 2409 script.py Your python script
145     arguments... The optional command-line arguments to your script
146     "
147    
148     if [ "$1" = "--help" ]; then
149     echo "$HELP_TEXT"
150     exit 0
151     fi
152 caltinay 4031 #==============================================================================
153 jfenwick 2409
154     # Parse the command-line options
155 caltinay 4506 while getopts 'bn:p:t:f:echim:oVvx' option
156 jfenwick 2409 do
157 caltinay 4031 case "$option" in
158     "b") DO_BINARY=y
159     ;;
160 caltinay 4506 "m") DO_VALGRIND=$OPTARG
161 caltinay 4483 ;;
162 caltinay 4031 "n") ESCRIPT_NUM_NODES=$OPTARG
163     ;;
164     "p") ESCRIPT_NUM_PROCS=$OPTARG
165     ;;
166     "t") ESCRIPT_NUM_THREADS=$OPTARG
167     ;;
168     "f") ESCRIPT_HOSTFILE=$OPTARG
169     ;;
170 jfenwick 4342 "c") cat "$BUILDINFO_FILE"
171 caltinay 4031 exit 0
172     ;;
173 caltinay 4970 "V") echo "escript-development(build "$(get_buildvar svn_revision)")"
174 caltinay 4031 exit 0
175     ;;
176     "h") echo "$HELP_TEXT"
177     exit 0
178     ;;
179     "i") DO_INTERACTIVE=y
180     ;;
181     "e") echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
182     echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
183     echo "export PATH=$EXTRA_PATH:\$PATH"
184 caltinay 4970 if [ "$(uname)" = "Darwin" ]
185 caltinay 4031 then
186     echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
187     fi
188     exit 0
189     ;;
190     "o") ESCRIPT_CREATESTDFILES=y
191     ;;
192     "v") ESCRIPT_VERBOSE=y
193     ;;
194     "x") DO_XTERM=y
195     ;;
196     ?) echo "$HELP_TEXT"
197     exit 1
198     ;;
199     esac
200 jfenwick 2409 done
201 caltinay 4970 shift $(($OPTIND - 1))
202 jfenwick 2409 #==============================================
203     #
204 caltinay 3178 # Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
205 jfenwick 2409 #
206 caltinay 4970 MPI_FLAVOUR=$(get_buildvar mpi)
207     WITH_OPENMP=$(get_buildvar openmp)
208 jfenwick 2409
209 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]; then
210     echo "MPI flavour is $MPI_FLAVOUR."
211 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]; then echo "OpenMP enabled."; fi
212 caltinay 2806 fi
213    
214 jfenwick 2409 #
215     # extend path variables
216     #
217     export PATH=$EXTRA_PATH:$PATH
218     export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
219     export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
220     EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"
221 caltinay 4970 if [ "$(uname)" = "Darwin" ]
222 jfenwick 2409 then
223     export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH
224     EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"
225     fi
226 caltinay 4927 if [ ! -z $ESCRIPT_VERBOSE ]
227     then
228 jfenwick 2409 echo "PATH = $PATH "
229     echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "
230     echo "PYTHONPATH = $PYTHONPATH "
231     if [ ! -z $DYLD_LIBRARY_PATH ]; then echo "DYLD_LIBRARY_PATH = $DYLD_LIBRARY_PATH "; fi
232     fi
233     #==============================================
234     #
235     # Ensure the variables have sensible values
236     #
237 caltinay 4927 if [ "$MPI_FLAVOUR" = "none" ]
238 jfenwick 2409 then
239 caltinay 4664 if [ ! -z "$ESCRIPT_NUM_NODES" ]; then
240     if [ $ESCRIPT_NUM_NODES -gt 1 ]; then
241     echo "Warning: MPI disabled but number of nodes set. Option ignored."
242     fi
243 jfenwick 2409 fi
244 caltinay 4664 if [ ! -z "$ESCRIPT_NUM_PROCS" ]; then
245     if [ $ESCRIPT_NUM_PROCS -gt 1 ]; then
246     echo "Warning: MPI disabled but number of processors per node set. Option ignored."
247     fi
248 jfenwick 2409 fi
249 jfenwick 4342 if [ ! -z "$ESCRIPT_HOSTFILE" ]
250 jfenwick 2409 then
251     echo "Warning: MPI disabled but host file is given. Option ignored."
252     fi
253     ESCRIPT_NUM_NODES=1
254     ESCRIPT_NUM_PROCS=1
255     else
256 jfenwick 3056 # use the PBS_NODEFILE if not otherwise specified
257 jfenwick 4342 if [ ! -z "$PBS_NODEFILE" ] && [ -z "$ESCRIPT_HOSTFILE" ]
258 jfenwick 3056 then
259 caltinay 3178 ESCRIPT_HOSTFILE=$PBS_NODEFILE
260 jfenwick 3056 fi
261    
262 caltinay 4927 if [ ! -z "$ESCRIPT_HOSTFILE" ]
263 jfenwick 2409 then
264 jfenwick 4342 if [ -f "$ESCRIPT_HOSTFILE" ]
265 jfenwick 2409 then
266 jfenwick 4342 cat "$ESCRIPT_HOSTFILE" | sort -u > $HOSTFILE
267 caltinay 4970 NUM_HOSTS=$(cat "$HOSTFILE" | wc -l)
268 caltinay 4927 if [ ! -z $ESCRIPT_NUM_NODES ]
269 jfenwick 2409 then
270     if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]
271     then
272     echo "number of hosts selected in the host file $ESCRIPT_HOSTFILE needs to match the requested number of nodes $ESCRIPT_NUM_NODES."
273     exit 1
274     fi
275     else
276     ESCRIPT_NUM_NODES=$NUM_HOSTS
277     fi
278     else
279     echo "cannot find hostfile $ESCRIPT_HOSTFILE."
280     exit 1
281     fi
282     else
283     HOSTFILE=''
284     fi
285    
286     if [ -z $ESCRIPT_NUM_NODES ]
287     then
288 caltinay 3178 ESCRIPT_NUM_NODES=1
289 jfenwick 2409 fi
290    
291     if [ -z $ESCRIPT_NUM_PROCS ]
292     then
293 caltinay 3178 ESCRIPT_NUM_PROCS=1
294 jfenwick 2409 fi
295    
296 caltinay 2806 if [ ! -z $ESCRIPT_VERBOSE ]
297 caltinay 4927 then
298 caltinay 3178 echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
299     echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
300 jfenwick 2409 fi
301     fi
302    
303 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
304 jfenwick 2409 then
305     if [ -z $ESCRIPT_NUM_THREADS ]
306     then
307     ESCRIPT_NUM_THREADS=$OMP_NUM_THREADS
308     if [ -z $ESCRIPT_NUM_THREADS ]
309     then
310     ESCRIPT_NUM_THREADS=1
311     fi
312     fi
313     if [ ! -z $ESCRIPT_VERBOSE ]
314     then
315     echo "ESCRIPT_NUM_THREADS is $ESCRIPT_NUM_THREADS."
316     fi
317     else
318 caltinay 4031 if [ ! -z $ESCRIPT_NUM_THREADS ] && [ $ESCRIPT_NUM_THREADS != 1 ]
319 jfenwick 2409 then
320     echo "Warning: OpenMP is disabled but number of threads requested is $ESCRIPT_NUM_THREADS!=1. Running without threads."
321     fi
322     ESCRIPT_NUM_THREADS=1
323     fi
324     #
325     # Now we compute total number of Processes
326     #
327 caltinay 4031 TOTPROC=$((ESCRIPT_NUM_NODES * ESCRIPT_NUM_PROCS))
328 caltinay 4927 if [ $? -ne 0 ] #Some compute error
329 caltinay 4031 then #This could happen if the args were not a number
330 caltinay 3178 echo "expression of total number of processors = $ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS is not numerical."
331     exit 1
332 jfenwick 2409 fi
333    
334     #
335     # Test to ensure people aren't trying to combine interactive and multi-process
336     #
337 caltinay 4058 if ([ ! -z $DO_INTERACTIVE ] || [ $# -eq 0 ]) && ([ $TOTPROC -gt 1 ])
338 jfenwick 2409 then
339 caltinay 3178 echo "Interactive mode cannot be used with more than one process"
340     exit 1
341 jfenwick 2409 fi
342    
343 caltinay 4927 if [ $TOTPROC -gt 1 ]
344 jfenwick 2409 then
345 caltinay 4322 if [ "$ESCRIPT_CREATESTDFILES" = "y" ]
346 caltinay 3178 then
347     PYTHON_MPI=$PYTHON_MPI_REDIRECT
348     else
349     PYTHON_MPI=$PYTHON_MPI_NULL
350     fi
351 jfenwick 2409 else
352     PYTHON_MPI=$PYTHON_MPI_NULL
353     fi
354 caltinay 4031 #==============================================================================
355 jfenwick 2409 # Must have at least one command-line arg: the python script
356     if [ $# -eq 0 ]
357     then
358 caltinay 4031 if [ ! -z $DO_BINARY ]
359 caltinay 3178 then
360     echo "No program to run was specified. Exiting."
361     exit 1
362     else
363 caltinay 4031 DO_INTERACTIVE=y
364 caltinay 3178 fi
365 jfenwick 2409 fi
366    
367 caltinay 4031 #==============================================================================
368 caltinay 4483
369 caltinay 4031 if [ ! -z $DO_XTERM ]
370 jfenwick 2409 then
371 caltinay 4031 EXEC_CMD="xterm -e"
372 jfenwick 2409 else
373 caltinay 4031 EXEC_CMD=""
374     fi
375    
376 caltinay 4483 if [ ! -z "$DO_VALGRIND" ]
377     then
378 caltinay 4970 VALGRIND_BIN=$(which valgrind 2>/dev/null)
379 caltinay 4483 if [ $? -eq 0 ]; then
380 caltinay 4506 LOGDIR=$ESCRIPT_ROOT/valgrind_logs
381 caltinay 4483 [ -d $LOGDIR ] || mkdir $LOGDIR
382 caltinay 4970 VG_TOOL=$(echo $DO_VALGRIND | awk '{ s=substr($0,1,1);print s;}')
383     if [ $VG_TOOL = "c" ];
384 caltinay 4506 then
385     # run callgrind
386     LOGFILE=${LOGDIR}/callgrind.%p.xml
387     VALGRIND="valgrind --tool=callgrind --callgrind-out-file=$LOGFILE"
388     EXEC_CMD="$EXEC_CMD $VALGRIND"
389     else
390     # run memcheck by default
391 caltinay 4970 LAST_N=$(ls -1 $LOGDIR|grep "^memcheck"|tail -1|cut -d. -f2)
392     NEW_N=$(printf "%04d" $((LAST_N + 1)))
393 caltinay 4506 LOGFILE=${LOGDIR}/memcheck.${NEW_N}.xml
394     VALGRIND="valgrind --tool=memcheck --xml=yes --show-reachable=yes --error-limit=no --gen-suppressions=all --suppressions=$ESCRIPT_ROOT/scripts/escript.supp --leak-check=full --xml-file=$LOGFILE"
395     EXEC_CMD="$EXEC_CMD $VALGRIND"
396     fi
397 caltinay 4483 else
398 caltinay 4506 echo "Execution with valgrind requested but valgrind not in path!"
399 caltinay 4483 exit 1
400     fi
401     fi
402    
403 caltinay 4031 if [ ! -z $DO_BINARY ]
404     then
405     EXEC_CMD="$EXEC_CMD $@"
406     else
407 caltinay 3178 # Check to see if the python version we were compiled with matches the
408     # one of PYTHON_CMD.
409 caltinay 4970 compfull=$(get_buildvar python_version)
410     compversion=$(echo $compfull | cut -d. -f1,2)
411     compmajor=$(echo $compfull | cut -d. -f1)
412 caltinay 4031 if [ "$PYTHON_CMD" = "python" ] # if people have customised the command they
413 jfenwick 3892 then # might not want us changing it
414     if [ "$compmajor" = "3" ]
415     then
416     PYTHON_CMD=python3
417     fi
418     fi
419 caltinay 4970 intversion=$($PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))')
420 caltinay 3178 if [ "$compversion" != "$intversion" ]
421     then
422     echo "Python versions do not match. Escript was compiled for "$compversion"."
423     echo "Current version of Python appears to be "$intversion"."
424     exit 1
425     fi
426 caltinay 2806 if [ "$MPI_FLAVOUR" = "none" ]
427 jfenwick 2409 then
428 caltinay 4031 if [ ! -z $DO_INTERACTIVE ]
429 jfenwick 2409 then
430 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_CMD -i $@"
431 jfenwick 2409 else
432 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_CMD $@"
433 jfenwick 2409 fi
434     else
435 caltinay 4031 if [ ! -z $DO_INTERACTIVE ]
436 gross 2865 then
437 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_MPI -i $@"
438 gross 2865 else
439 caltinay 4031 EXEC_CMD="$EXEC_CMD $PYTHON_MPI $@"
440 gross 2865 fi
441 jfenwick 2409 fi
442     fi
443     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi
444 caltinay 4031 #==============================================================================
445 jfenwick 2409 #
446 caltinay 4031 # now we start to spawn things:
447 jfenwick 2409 #
448 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
449 jfenwick 2409 then
450     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
451     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
452     fi
453     EXIT_CODE=1
454     #=============== no MPI ===================================
455 caltinay 4927 if [ "$MPI_FLAVOUR" = "none" ]
456 jfenwick 2409 then
457 caltinay 4927 $EXEC_CMD
458 jfenwick 2409 EXIT_CODE=$?
459     #=============== OpenMPI ===================================
460 caltinay 4927 elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
461     then
462     EXPORT_ENV=$(echo $EXPORT_ENV|sed -e 's/,/ -x /g')
463     if [ ! -z "$HOSTFILE" ]
464 jfenwick 2409 then
465 caltinay 4970 HOST_LIST=$(sort -u "$HOSTFILE" | awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}')
466 caltinay 4927 CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV} --bynode --bind-to-none --host $HOST_LIST -np $TOTPROC $EXEC_CMD"
467 jfenwick 2409 else
468 caltinay 4927 CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV} --cpus-per-rank $ESCRIPT_NUM_THREADS -np $TOTPROC $EXEC_CMD"
469     fi
470 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
471     $CMD
472     EXIT_CODE=$?
473    
474     #=============== Intel MPI ===================================
475 caltinay 2806 elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
476 jfenwick 2409 then
477 gross 2510
478 jfenwick 3259 if [ "$WITH_OPENMP" = "1" ]
479 gross 2510 then
480     export I_MPI_PIN_DOMAIN=omp
481 caltinay 4927 EXPORT_ENV="$EXPORT_ENV,I_MPI_PIN_DOMAIN"
482 gross 2510 fi
483    
484 caltinay 4927 if [ ! -z "$HOSTFILE" ]
485 jfenwick 2409 then
486 jfenwick 4342 mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
487 caltinay 4927 if [ $? -ne 0 ]
488 jfenwick 2409 then
489     echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
490     exit 1
491 caltinay 4927 else
492 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
493     fi
494 gross 2866 else
495 caltinay 4927 mpdboot -n 1 -r ssh
496     if [ $? -ne 0 ]
497 gross 2866 then
498     echo "mpdboot failed."
499     exit 1
500 caltinay 4927 else
501 gross 2866 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
502     fi
503 jfenwick 2409 fi
504     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"
505     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
506     $CMD
507     EXIT_CODE=$?
508 gross 2866 mpdallexit
509     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
510 jfenwick 2409 #=============== SGI's MPIMPT ===================================
511 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPT" ]
512 jfenwick 2409 then
513     export MPI_NUM_MEMORY_REGIONS=0
514     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
515 caltinay 4927 if [ ! -z "$HOSTFILE" ]
516 jfenwick 2409 then
517 caltinay 4970 HOST_LIST=$(awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE")
518 gross 2866 CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
519 jfenwick 2409 else
520     CMD="mpirun -np $TOTPROC $EXEC_CMD"
521 caltinay 4927 fi
522 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
523     $CMD
524     EXIT_CODE=$?
525     #=============== MPICH ===================================
526 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPICH" ]
527 jfenwick 2409 then
528 caltinay 4927 if [ ! -z "$HOSTFILE" ]
529 jfenwick 2409 then
530 jfenwick 4342 touch "$HOSTFILE2"
531 caltinay 4970 for i in $(seq $ESCRIPT_NUM_PROCS); do cat "$HOSTFILE" >> "$HOSTFILE2"; done
532 caltinay 4927 CMD="mpirun -machinefile \"$HOSTFILE2\" -np $TOTPROC $EXEC_CMD"
533 jfenwick 2409 else
534     CMD="mpirun -np $TOTPROC $EXEC_CMD"
535 caltinay 4927 fi
536 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
537     $CMD
538     EXIT_CODE=$?
539     #=============== MPICH2 ===================================
540 caltinay 2806 elif [ "$MPI_FLAVOUR" = "MPICH2" ]
541 jfenwick 2409 then
542 caltinay 4927 if [ ! -z "$HOSTFILE" ]
543 jfenwick 2409 then
544 jfenwick 4342 mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
545 caltinay 4927 if [ $? -ne 0 ]
546 jfenwick 2409 then
547     echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
548     exit 1
549 caltinay 4927 else
550 jfenwick 2409 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
551     fi
552 gross 2866 else
553 caltinay 4927 mpdboot -n 1 -r ssh
554     if [ $? -ne 0 ]
555 gross 2866 then
556     echo "mpdboot failed."
557     exit 1
558 caltinay 4927 else
559 gross 2866 if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
560     fi
561 jfenwick 2409 fi
562     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"
563     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
564     $CMD
565     EXIT_CODE=$?
566 gross 2866 mpdallexit
567     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
568 jfenwick 2409 else
569 caltinay 2806 echo "unknown MPI flavour '$MPI_FLAVOUR'."
570 jfenwick 2409 fi
571 caltinay 4970
572     if [ ! -z "$DO_VALGRIND" ]; then
573     echo "Valgrind log file written to ${LOGFILE}"
574     fi
575    
576 jfenwick 2409 exit $EXIT_CODE
577 caltinay 4031

Properties

Name Value
svn:executable *
svn:mergeinfo /branches/3.4/bin/run-escript:4453-4490 /branches/lapack2681/bin/escript:2682-2741 /branches/pasowrap/bin/run-escript:3661-3674 /branches/py3_attempt2/bin/run-escript:3871-3891 /branches/release3.4/bin/run-escript:4452 /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