/[escript]/branches/4.0fordebian/run-escript.in
ViewVC logotype

Diff of /branches/4.0fordebian/run-escript.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3340 by jfenwick, Mon Nov 8 01:25:58 2010 UTC revision 4506 by caltinay, Wed Jul 24 01:28:42 2013 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/usr/bin/env bash
2    
3  # Escript/Finley wrapper for python  # Escript/Finley wrapper for python
4  # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher  # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
# Line 28  HOSTFILE2=/tmp/escript2.$USER.$$ Line 28  HOSTFILE2=/tmp/escript2.$USER.$$
28  #Begin finding ESCRIPT_ROOT  #Begin finding ESCRIPT_ROOT
29  if [ $STDLOCATION -ne 0 ]  if [ $STDLOCATION -ne 0 ]
30  then  then
31      ESCRIPT_ROOT=/usr/lib/escript      ESCRIPT_ROOT=/usr/lib/python-escript
32  else  else
33    #We don't know the escript root so we need to work it out from the invocation    # 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 /    # Need to match if the name contains /
35    if [[ $0 =~ / ]]    if [[ $0 =~ / ]]
36    then    then
37        # We are not using the PATH to find the script        # We are not using the PATH to find the script
38        cd `dirname $0`        cd "`dirname $0`"
39        scriptdir=`pwd`        scriptdir=`pwd`
40        cd $CURDIR        cd "$CURDIR"
41    else    else
42        # name does not contain / therefore we are using        # name does not contain / therefore we are using
43        tscriptdir=`which $0`        tscriptdir=`which $0`
# Line 49  else Line 49  else
49        scriptdir=`dirname $tscriptdir`        scriptdir=`dirname $tscriptdir`
50    fi    fi
51    
52    cd $scriptdir/..    cd "$scriptdir/.."
53    ESCRIPT_ROOT=`pwd`    ESCRIPT_ROOT=`pwd`
54    cd ..    cd ..
55    ESCRIPT_PARENT=`pwd`    ESCRIPT_PARENT=`pwd`
56    cd $CURDIR    cd "$CURDIR"
57    
58  fi  fi
59  ##### End finding ESCRIPT_ROOT  ########  ##### End finding ESCRIPT_ROOT ########
   
   
60    
61  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"
62  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"
# Line 70  PYTHON_CMD=python Line 68  PYTHON_CMD=python
68  EXTRA_DYLD_LIBRARY_PATH=""  EXTRA_DYLD_LIBRARY_PATH=""
69  EXTRA_PATH=$ESCRIPT_ROOT/bin  EXTRA_PATH=$ESCRIPT_ROOT/bin
70  EXTRA_PYTHONPATH=$ESCRIPT_ROOT  EXTRA_PYTHONPATH=$ESCRIPT_ROOT
71  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib  
72    if [ $STDLOCATION -eq 1 ]
73    then
74        EXTRA_LD_LIBRARY_PATH=/usr/lib/python-escript
75    else
76        EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
77    fi
78    
79    
80  if [ $STANDALONE -eq 1 ]  if [ $STANDALONE -eq 1 ]
81  then  then
# Line 82  then Line 87  then
87  fi  fi
88    
89    
90  BUILDINFO_FILE=$ESCRIPT_ROOT/lib/buildvars  BUILDINFO_FILE="$ESCRIPT_ROOT/lib/buildvars"
91  if [ ! -r $BUILDINFO_FILE ]; then  if [ "$STDLOCATION" = "1" ]
92      if [ "$1" = "-e" ];then  then
93      echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"      BUILDINFO_FILE=/usr/lib/python-escript/buildvars
94      echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"  fi
95      echo "export PATH=$EXTRA_PATH:\$PATH"  if [ ! -r "$BUILDINFO_FILE" ]; then
96      if [ "`uname`" = "Darwin" ]      if [ "$1" = "-e" ]; then
97      then          echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
98          echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
99      fi            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          exit 0          exit 0
105      fi      fi
106      echo "Error! Unable to read escript build information. Exiting."      echo "Error! Unable to read escript build information. Exiting."
107      exit 1      exit 1
108  fi  fi
109    
110  function get_buildvar {  get_buildvar () {
111      echo `grep "^$1=" $BUILDINFO_FILE |cut -d= -f2`      echo `grep "^$1=" "$BUILDINFO_FILE" |cut -d= -f2`
112  }  }
113    
114  #  #
# Line 107  function get_buildvar { Line 116  function get_buildvar {
116  #  #
117  WITH_VISIT=`get_buildvar visit`  WITH_VISIT=`get_buildvar visit`
118  if [ "$WITH_VISIT" = "1" ]; then  if [ "$WITH_VISIT" = "1" ]; then
119      VISIT_BIN=`which visit`      VISIT_BIN=`which visit 2>/dev/null`
120      if [ $? -eq 0 ]; then      if [ $? -eq 0 ]; then
121          VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`          VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`
122          EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH          EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH
# Line 118  if [ "$WITH_VISIT" = "1" ]; then Line 127  if [ "$WITH_VISIT" = "1" ]; then
127  fi  fi
128    
129  HELP_TEXT="  HELP_TEXT="
130  Usage: escript [options] script.py [arguments...]  Usage: run-escript [options] script.py [arguments...]
131      -n nn       number of nodes to use      -n nn       number of nodes to use
132      -p np       number of MPI processes to spawn per node      -p np       number of MPI processes to spawn per node
133      -t nt       number of OpenMP threads to use      -t nt       number of OpenMP threads to use
134      -f file     name of MPI hostfile      -f file     name of MPI hostfile
135      -c      print compile information for escript and exit      -c      print compile information for escript and exit
136      -V      print escript version and exit      -V      print escript version and exit
137      -i      interactive mode      -i      interactive mode
138      -b      do not invoke python (run non-python programs)      -b      do not invoke python (run non-python programs)
139      -e      print export statements for environment and exit      -e      print export statements for environment and exit
140      -o      redirect output from MPI to files      -o      redirect output from MPI to files
141      -v      print diagnostics      -v      print diagnostics
142      -x      ..reserved for future use ..      -x      run in new xterm instance
143        -m tool     run with valgrind {tool=m[emcheck]/c[allgrind]}
144      script.py   Your python script      script.py   Your python script
145      arguments...    The optional command-line arguments to your script      arguments...    The optional command-line arguments to your script
146  "  "
# Line 139  if [ "$1" = "--help" ]; then Line 149  if [ "$1" = "--help" ]; then
149    echo "$HELP_TEXT"    echo "$HELP_TEXT"
150    exit 0    exit 0
151  fi  fi
152  #=======================================================================================  #==============================================================================
   
 # Avoid bug in hybrid runs with MPT MPI  
   
153    
154  # Parse the command-line options  # Parse the command-line options
155  # option e should not be followed by a :  while getopts 'bn:p:t:f:echim:oVvx' option
 while getopts 'bn:p:t:f:h:ecVviox' option  
156  do  do
157      case "$option" in      case "$option" in
158        "b")  DOBINARY=yes        "b")  DO_BINARY=y
159          ;;          ;;
160        "n")  ESCRIPT_NUM_NODES=$OPTARG        "m")  DO_VALGRIND=$OPTARG
161          ;;          ;;
162        "p")  ESCRIPT_NUM_PROCS=$OPTARG        "n")  ESCRIPT_NUM_NODES=$OPTARG
163          ;;          ;;
164        "t")  ESCRIPT_NUM_THREADS=$OPTARG        "p")  ESCRIPT_NUM_PROCS=$OPTARG
165          ;;          ;;
166        "f")  ESCRIPT_HOSTFILE=$OPTARG        "t")  ESCRIPT_NUM_THREADS=$OPTARG
167          ;;          ;;
168        "c")  cat $ESCRIPT_ROOT/lib/buildvars        "f")  ESCRIPT_HOSTFILE=$OPTARG
169          exit 0          ;;
170          ;;        "c")  cat "$BUILDINFO_FILE"
171        "V")  echo "escript-development(build "`get_buildvar svn_revision`")"          exit 0
172          exit 0          ;;
173          ;;        "V")  echo "escript-development(build "`get_buildvar svn_revision`")"
174        "h")  echo "$HELPTEXT"          exit 0
175          exit 0          ;;
176          ;;        "h")  echo "$HELP_TEXT"
177        "i")  DOINTERACTIVE=yes          exit 0
178          ;;          ;;
179        "e")  echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"        "i")  DO_INTERACTIVE=y
180          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"          ;;
181          echo "export PATH=$EXTRA_PATH:\$PATH"        "e")  echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
182          if [ "`uname`" = "Darwin" ]          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
183          then          echo "export PATH=$EXTRA_PATH:\$PATH"
184              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"          if [ "`uname`" = "Darwin" ]
185          fi          then
186          exit 0              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
187          ;;          fi
188        "o")  ESCRIPT_CREATESTDFILES="yes"          exit 0
189          ;;          ;;
190        "v")  ESCRIPT_VERBOSE="yes"        "o")  ESCRIPT_CREATESTDFILES=y
191          ;;          ;;
192        "x")  echo "-x not implemented yet"        "v")  ESCRIPT_VERBOSE=y
193          exit 1          ;;
194          ;;        "x")  DO_XTERM=y
195        ?)    echo "$HELP_TEXT"          ;;
196          exit 1        ?)    echo "$HELP_TEXT"
197          ;;          exit 1
198      esac          ;;
199        esac
200  done  done
201  shift `expr $OPTIND - 1`  shift `expr $OPTIND - 1`
202  #==============================================  #==============================================
# Line 237  then Line 244  then
244      then      then
245          echo "Warning: MPI disabled but number of processors per node set. Option ignored."          echo "Warning: MPI disabled but number of processors per node set. Option ignored."
246      fi      fi
247      if [ ! -z $ESCRIPT_HOSTFILE ]      if [ ! -z "$ESCRIPT_HOSTFILE" ]
248      then      then
249          echo "Warning: MPI disabled but host file is given. Option ignored."          echo "Warning: MPI disabled but host file is given. Option ignored."
250      fi      fi
# Line 245  then Line 252  then
252      ESCRIPT_NUM_PROCS=1      ESCRIPT_NUM_PROCS=1
253  else  else
254      # use the PBS_NODEFILE if not otherwise specified      # use the PBS_NODEFILE if not otherwise specified
255      if [[ ( ! -z $PBS_NODEFILE ) && ( -z $ESCRIPT_HOSTFILE ) ]]      if [ ! -z "$PBS_NODEFILE" ] && [ -z "$ESCRIPT_HOSTFILE" ]
256      then      then
257          ESCRIPT_HOSTFILE=$PBS_NODEFILE          ESCRIPT_HOSTFILE=$PBS_NODEFILE
258      fi      fi
259    
260      if [ ! -z $ESCRIPT_HOSTFILE ]      if [ ! -z "$ESCRIPT_HOSTFILE" ]
261      then      then
262          if [ -f $ESCRIPT_HOSTFILE ]          if [ -f "$ESCRIPT_HOSTFILE" ]
263          then          then
264              cat $ESCRIPT_HOSTFILE | sort -u > $HOSTFILE              cat "$ESCRIPT_HOSTFILE" | sort -u > $HOSTFILE
265              NUM_HOSTS=`cat $HOSTFILE | wc -l`              NUM_HOSTS=`cat "$HOSTFILE" | wc -l`
266              if [ ! -z $ESCRIPT_NUM_NODES ]              if [ ! -z $ESCRIPT_NUM_NODES ]
267              then              then
268                  if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]                  if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]
# Line 306  then Line 313  then
313          echo "ESCRIPT_NUM_THREADS is $ESCRIPT_NUM_THREADS."          echo "ESCRIPT_NUM_THREADS is $ESCRIPT_NUM_THREADS."
314     fi     fi
315  else  else
316     if [[ ( ! -z $ESCRIPT_NUM_THREADS ) && ( $ESCRIPT_NUM_THREADS != 1 ) ]]     if [ ! -z $ESCRIPT_NUM_THREADS ] && [ $ESCRIPT_NUM_THREADS != 1 ]
317     then     then
318         echo "Warning: OpenMP is disabled but number of threads requested is $ESCRIPT_NUM_THREADS!=1. Running without threads."         echo "Warning: OpenMP is disabled but number of threads requested is $ESCRIPT_NUM_THREADS!=1. Running without threads."
319     fi     fi
# Line 315  fi Line 322  fi
322  #  #
323  # Now we compute total number of Processes  # Now we compute total number of Processes
324  #  #
325  (( TOTPROC=$ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS))  TOTPROC=$((ESCRIPT_NUM_NODES * ESCRIPT_NUM_PROCS))
326  if [ $? -ne 0 ]     #Some compute error  if [ $? -ne 0 ]     #Some compute error
327  then            #This could happen if the args were not a number  then            #This could happen if the args were not a number
328      echo "expression of total number of processors = $ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS is not numerical."      echo "expression of total number of processors = $ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS is not numerical."
329      exit 1      exit 1
330  fi  fi
# Line 325  fi Line 332  fi
332  #  #
333  # Test to ensure people aren't trying to combine interactive and multi-process  # Test to ensure people aren't trying to combine interactive and multi-process
334  #  #
335  if [[ ( ( ! -z $DOINTERACTIVE ) || ( $# -eq 0 ) ) && ( $TOTPROC -gt 1) ]]  if ([ ! -z $DO_INTERACTIVE ] || [ $# -eq 0 ]) && ([ $TOTPROC -gt 1 ])
336  then  then
337      echo "Interactive mode cannot be used with more than one process"      echo "Interactive mode cannot be used with more than one process"
338      exit 1      exit 1
# Line 333  fi Line 340  fi
340    
341  if [ $TOTPROC -gt 1 ]  if [ $TOTPROC -gt 1 ]
342  then  then
343      if [ "$ESCRIPT_CREATESTDFILES" = "yes" ]      if [ "$ESCRIPT_CREATESTDFILES" = "y" ]
344      then      then
345          PYTHON_MPI=$PYTHON_MPI_REDIRECT          PYTHON_MPI=$PYTHON_MPI_REDIRECT
346      else      else
# Line 342  then Line 349  then
349  else  else
350      PYTHON_MPI=$PYTHON_MPI_NULL      PYTHON_MPI=$PYTHON_MPI_NULL
351  fi  fi
352  #=========================================================================================================  #==============================================================================
353  # Must have at least one command-line arg: the python script  # Must have at least one command-line arg: the python script
354  if [ $# -eq 0 ]  if [ $# -eq 0 ]
355  then  then
356      if [ ! -z $DOBINARY ]      if [ ! -z $DO_BINARY ]
357      then      then
358          echo "No program to run was specified. Exiting."          echo "No program to run was specified. Exiting."
359          exit 1          exit 1
360      else      else
361          DOINTERACTIVE="yes"          DO_INTERACTIVE=y
362      fi      fi
363  fi  fi
364    
365  #=========================================================================================================  #==============================================================================
366  if [ ! -z $DOBINARY ]  
367    if [ ! -z $DO_XTERM ]
368  then  then
369      EXEC_CMD="$@"      EXEC_CMD="xterm -e"
370    else
371        EXEC_CMD=""
372    fi
373    
374    if [ ! -z "$DO_VALGRIND" ]
375    then
376        VALGRIND_BIN=`which valgrind 2>/dev/null`
377        if [ $? -eq 0 ]; then
378            LOGDIR=$ESCRIPT_ROOT/valgrind_logs
379            [ -d $LOGDIR ] || mkdir $LOGDIR
380            if [ ${DO_VALGRIND:0:1} = "c" ];
381            then
382                # run callgrind
383                LOGFILE=${LOGDIR}/callgrind.%p.xml
384                VALGRIND="valgrind --tool=callgrind --callgrind-out-file=$LOGFILE"
385                EXEC_CMD="$EXEC_CMD $VALGRIND"
386            else
387                # run memcheck by default
388                LAST_N=`ls -1 $LOGDIR|grep "^memcheck"|tail -1|cut -d. -f2`
389                NEW_N=`printf "%04d" $((10#$LAST_N + 1))`
390                LOGFILE=${LOGDIR}/memcheck.${NEW_N}.xml
391                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"
392                EXEC_CMD="$EXEC_CMD $VALGRIND"
393            fi
394        else
395            echo "Execution with valgrind requested but valgrind not in path!"
396            exit 1
397        fi
398    fi
399    
400    if [ ! -z $DO_BINARY ]
401    then
402        EXEC_CMD="$EXEC_CMD $@"
403  else  else
404      # Check to see if the python version we were compiled with matches the      # Check to see if the python version we were compiled with matches the
405      # one of PYTHON_CMD.      # one of PYTHON_CMD.
406      compversion=`get_buildvar python_version | cut -d. -f1,2`      compfull=`get_buildvar python_version`
407      intversion=`$PYTHON_CMD -c 'import sys;print "%d.%d"%(sys.version_info[0], sys.version_info[1])'`      compversion=`echo $compfull | cut -d. -f1,2`
408        compmajor=`echo $compfull | cut -d. -f1`
409        if [ "$PYTHON_CMD" = "python" ] # if people have customised the command they
410        then                                # might not want us changing it
411            if [ "$compmajor" = "3" ]
412            then
413                PYTHON_CMD=python3
414            fi
415        fi
416        intversion=`$PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))'`
417      if [ "$compversion" != "$intversion" ]      if [ "$compversion" != "$intversion" ]
418      then      then
419          echo "Python versions do not match. Escript was compiled for "$compversion"."          echo "Python versions do not match. Escript was compiled for "$compversion"."
# Line 372  else Line 422  else
422      fi      fi
423      if [ "$MPI_FLAVOUR" = "none" ]      if [ "$MPI_FLAVOUR" = "none" ]
424      then      then
425          if [ ! -z $DOINTERACTIVE ]          if [ ! -z $DO_INTERACTIVE ]
426          then          then
427             EXEC_CMD="$PYTHON_CMD -i $@"             EXEC_CMD="$EXEC_CMD $PYTHON_CMD -i $@"
428          else          else
429             EXEC_CMD="$PYTHON_CMD $@"             EXEC_CMD="$EXEC_CMD $PYTHON_CMD $@"
430          fi          fi
431      else      else
432          if [ ! -z $DOINTERACTIVE ]          if [ ! -z $DO_INTERACTIVE ]
433          then          then
434             EXEC_CMD="$PYTHON_MPI -i $@"             EXEC_CMD="$EXEC_CMD $PYTHON_MPI -i $@"
435          else          else
436             EXEC_CMD="$PYTHON_MPI $@"             EXEC_CMD="$EXEC_CMD $PYTHON_MPI $@"
437          fi          fi
438      fi      fi
439  fi  fi
440  if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi  if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi
441  #===============================================================================================  #==============================================================================
442  #  #
443  #   now we start to spwan things:  #   now we start to spawn things:
444  #  #
445  if [ "$WITH_OPENMP" = "1" ]  if [ "$WITH_OPENMP" = "1" ]
446  then  then
# Line 406  then Line 456  then
456  #=============== OpenMPI ===================================  #=============== OpenMPI ===================================
457  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
458  then  then
459     if [ ! -z $HOSTFILE ]     if [ ! -z "$HOSTFILE" ]
460     then     then
461        HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' $HOSTFILE`        HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE"`
462        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } --bynode -np $TOTPROC --host $HOST_LIST $EXEC_CMD"        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"
463     else     else
464        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } -np $TOTPROC $EXEC_CMD"        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } --cpus-per-rank $ESCRIPT_NUM_THREADS -np $TOTPROC $EXEC_CMD"
465     fi     fi
466     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
467     $CMD     $CMD
# Line 427  then Line 477  then
477         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"
478     fi     fi
479    
480     if [ ! -z $HOSTFILE ]     if [ ! -z "$HOSTFILE" ]
481     then     then
482        mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f $HOSTFILE        mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
483        if [ $? -ne 0 ]        if [ $? -ne 0 ]
484        then        then
485           echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."           echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
# Line 458  elif [ "$MPI_FLAVOUR" = "MPT" ] Line 508  elif [ "$MPI_FLAVOUR" = "MPT" ]
508  then  then
509     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
510     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
511     if [ ! -z $HOSTFILE ]     if [ ! -z "$HOSTFILE" ]
512     then     then
513        HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' $HOSTFILE`        HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE"`
514        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
515     else     else
516        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
# Line 471  then Line 521  then
521  #=============== MPICH ===================================  #=============== MPICH ===================================
522  elif [ "$MPI_FLAVOUR" = "MPICH" ]  elif [ "$MPI_FLAVOUR" = "MPICH" ]
523  then  then
524     if [ ! -z $HOSTFILE ]     if [ ! -z "$HOSTFILE" ]
525     then     then
526        touch $HOSTFILE2        touch "$HOSTFILE2"
527        for (( i=1;i<=$ESCRIPT_NUM_PROCS;i+=1 )) ; do cat $HOSTFILE >> $HOSTFILE2  ; done        for (( i=1;i<=$ESCRIPT_NUM_PROCS;i+=1 )) ; do cat "$HOSTFILE" >> "$HOSTFILE2"  ; done
528        CMD="mpirun -machinefile $HOSTFILE2  -np $TOTPROC $EXEC_CMD"        CMD="mpirun -machinefile \"$HOSTFILE2\"  -np $TOTPROC $EXEC_CMD"
529     else     else
530        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
531     fi     fi
# Line 485  then Line 535  then
535  #=============== MPICH2 ===================================  #=============== MPICH2 ===================================
536  elif [ "$MPI_FLAVOUR" = "MPICH2" ]  elif [ "$MPI_FLAVOUR" = "MPICH2" ]
537  then  then
538     if [ ! -z $HOSTFILE ]     if [ ! -z "$HOSTFILE" ]
539     then     then
540           mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f $HOSTFILE           mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
541           if [ $? -ne 0 ]           if [ $? -ne 0 ]
542           then           then
543              echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."              echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."
# Line 515  else Line 565  else
565     echo "unknown MPI flavour '$MPI_FLAVOUR'."     echo "unknown MPI flavour '$MPI_FLAVOUR'."
566  fi  fi
567  exit $EXIT_CODE  exit $EXIT_CODE
568    

Legend:
Removed from v.3340  
changed lines
  Added in v.4506

  ViewVC Help
Powered by ViewVC 1.1.26