/[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 4506 by caltinay, Wed Jul 24 01:28:42 2013 UTC revision 5092 by sshaw, Mon Jul 7 00:47:44 2014 UTC
# Line 1  Line 1 
1  #!/usr/bin/env bash  #!/usr/bin/env sh
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 17  STDLOCATION=0 Line 17  STDLOCATION=0
17  #Now we find the location of this script  #Now we find the location of this script
18  #Note that this location should be absolute but does not need to be unique  #Note that this location should be absolute but does not need to be unique
19  scriptdir=""  scriptdir=""
20  CURDIR=`pwd`  CURDIR=$(pwd)
21    
22  #Environment vars which control operations:  #Environment vars which control operations:
23  # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROCS, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES  # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROCS, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES
24    
25    #set up thread binding if unset
26    if [ "$OMP_PROC_BIND" == "" ]; then
27        #Force OpenMP binding for Intel (and GCC, though GCC is on by default)
28        export OMP_PROC_BIND=true
29    fi
30    if [ "$KMP_AFFINITY" == "" ]; then
31        #Set the style of binding (overrides OMP_PROC_BIND in many cases)
32        export KMP_AFFINITY=verbose,compact
33    fi
34    
35  HOSTFILE=/tmp/escript.$USER.$$  HOSTFILE=/tmp/escript.$USER.$$
36  HOSTFILE2=/tmp/escript2.$USER.$$  HOSTFILE2=/tmp/escript2.$USER.$$
37    
# Line 32  then Line 42  then
42  else  else
43    # 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
44    # Need to match if the name contains /    # Need to match if the name contains /
45    if [[ $0 =~ / ]]    if $(echo $0|grep -q /)
46    then    then
47        # We are not using the PATH to find the script        # We are not using the PATH to find the script
48        cd "`dirname $0`"        cd "$(dirname $0)"
49        scriptdir=`pwd`        scriptdir=$(pwd)
50        cd "$CURDIR"        cd "$CURDIR"
51    else    else
52        # name does not contain / therefore we are using        # name does not contain / therefore we are using
53        tscriptdir=`which $0`        tscriptdir=$(which $0)
54        if [ $? -ne 0 ]        if [ $? -ne 0 ]
55        then        then
56            echo "Error! Unable to determine script directory. Exiting."            echo "Error! Unable to determine script directory. Exiting."
57            exit 1            exit 1
58        fi        fi
59        scriptdir=`dirname $tscriptdir`        scriptdir=$(dirname $tscriptdir)
60    fi    fi
61    
62    cd "$scriptdir/.."    cd "$scriptdir/.."
63    ESCRIPT_ROOT=`pwd`    ESCRIPT_ROOT=$(pwd)
64    cd ..    cd ..
65    ESCRIPT_PARENT=`pwd`    ESCRIPT_PARENT=$(pwd)
66    cd "$CURDIR"    cd "$CURDIR"
67    
68  fi  fi
# Line 97  if [ ! -r "$BUILDINFO_FILE" ]; then Line 107  if [ ! -r "$BUILDINFO_FILE" ]; then
107          echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"          echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
108          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
109          echo "export PATH=$EXTRA_PATH:\$PATH"          echo "export PATH=$EXTRA_PATH:\$PATH"
110          if [ "`uname`" = "Darwin" ]          if [ "$(uname)" = "Darwin" ]
111          then          then
112              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
113          fi            fi
114          exit 0          exit 0
115      fi      fi
116      echo "Error! Unable to read escript build information. Exiting."      echo "Error! Unable to read escript build information. Exiting."
# Line 108  if [ ! -r "$BUILDINFO_FILE" ]; then Line 118  if [ ! -r "$BUILDINFO_FILE" ]; then
118  fi  fi
119    
120  get_buildvar () {  get_buildvar () {
121      echo `grep "^$1=" "$BUILDINFO_FILE" |cut -d= -f2`      echo $(grep "^$1=" "$BUILDINFO_FILE" |cut -d= -f2)
122  }  }
123    
124  #  #
125  #   Add VisIt paths if required  #   Add VisIt paths if required
126  #  #
127  WITH_VISIT=`get_buildvar visit`  WITH_VISIT=$(get_buildvar visit)
128  if [ "$WITH_VISIT" = "1" ]; then  if [ "$WITH_VISIT" = "1" ]; then
129      VISIT_BIN=`which visit 2>/dev/null`      VISIT_BIN=$(which visit 2>/dev/null)
130      if [ $? -eq 0 ]; then      if [ $? -eq 0 ]; then
131          VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`          VISIT_PY_PATH=$($VISIT_BIN -env | grep LIBPATH | cut -d= -f2)
132          EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH          EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH
133          EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$VISIT_PY_PATH          EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$VISIT_PY_PATH
134      elif [ ! -z $ESCRIPT_VERBOSE ]; then      elif [ ! -z $ESCRIPT_VERBOSE ]; then
# Line 134  Usage: run-escript [options] script.py [ Line 144  Usage: run-escript [options] script.py [
144      -f file     name of MPI hostfile      -f file     name of MPI hostfile
145      -c      print compile information for escript and exit      -c      print compile information for escript and exit
146      -V      print escript version and exit      -V      print escript version and exit
147      -i      interactive mode      -i      interactive mode
148      -b      do not invoke python (run non-python programs)      -b      do not invoke python (run non-python programs)
149      -e      print export statements for environment and exit      -e      print export statements for environment and exit
150      -o      redirect output from MPI to files      -o      redirect output from MPI to files
# Line 170  do Line 180  do
180        "c")  cat "$BUILDINFO_FILE"        "c")  cat "$BUILDINFO_FILE"
181          exit 0          exit 0
182          ;;          ;;
183        "V")  echo "escript-development(build "`get_buildvar svn_revision`")"        "V")  echo "escript-development(build "$(get_buildvar svn_revision)")"
184          exit 0          exit 0
185          ;;          ;;
186        "h")  echo "$HELP_TEXT"        "h")  echo "$HELP_TEXT"
# Line 181  do Line 191  do
191        "e")  echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"        "e")  echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
192          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
193          echo "export PATH=$EXTRA_PATH:\$PATH"          echo "export PATH=$EXTRA_PATH:\$PATH"
194          if [ "`uname`" = "Darwin" ]          if [ "$(uname)" = "Darwin" ]
195          then          then
196              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
197          fi          fi
# Line 198  do Line 208  do
208          ;;          ;;
209      esac      esac
210  done  done
211  shift `expr $OPTIND - 1`  shift $(($OPTIND - 1))
212  #==============================================  #==============================================
213  #  #
214  #   Read MPI_FLAVOUR and WITH_OPENMP from the buildvars  #   Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
215  #  #
216  MPI_FLAVOUR=`get_buildvar mpi`  MPI_FLAVOUR=$(get_buildvar mpi)
217  WITH_OPENMP=`get_buildvar openmp`  WITH_OPENMP=$(get_buildvar openmp)
218    
219  if [ ! -z $ESCRIPT_VERBOSE ]; then  if [ ! -z $ESCRIPT_VERBOSE ]; then
220      echo "MPI flavour is $MPI_FLAVOUR."      echo "MPI flavour is $MPI_FLAVOUR."
# Line 218  export PATH=$EXTRA_PATH:$PATH Line 228  export PATH=$EXTRA_PATH:$PATH
228  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
229  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
230  EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"  EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"
231  if [ "`uname`" = "Darwin" ]  if [ "$(uname)" = "Darwin" ]
232  then  then
233      export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH      export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH
234      EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"      EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"
235  fi  fi
236  if [ ! -z $ESCRIPT_VERBOSE ]  if [ ! -z $ESCRIPT_VERBOSE ]
237  then  then
238      echo "PATH = $PATH "      echo "PATH = $PATH "
239      echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "      echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "
240      echo "PYTHONPATH = $PYTHONPATH "      echo "PYTHONPATH = $PYTHONPATH "
# Line 234  fi Line 244  fi
244  #  #
245  #  Ensure the variables have sensible values  #  Ensure the variables have sensible values
246  #  #
247  if [ "$MPI_FLAVOUR" = "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
248  then  then
249      if [ ! -z $ESCRIPT_NUM_NODES ]      if [ ! -z "$ESCRIPT_NUM_NODES" ]; then
250      then          if [ $ESCRIPT_NUM_NODES -gt 1 ]; then
251          echo "Warning: MPI disabled but number of nodes set. Option ignored."              echo "Warning: MPI disabled but number of nodes set. Option ignored."
252            fi
253      fi      fi
254      if [ ! -z $ESCRIPT_NUM_PROCS ]      if [ ! -z "$ESCRIPT_NUM_PROCS" ]; then
255      then          if [ $ESCRIPT_NUM_PROCS -gt 1 ]; then
256          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."
257            fi
258      fi      fi
259      if [ ! -z "$ESCRIPT_HOSTFILE" ]      if [ ! -z "$ESCRIPT_HOSTFILE" ]
260      then      then
# Line 257  else Line 269  else
269          ESCRIPT_HOSTFILE=$PBS_NODEFILE          ESCRIPT_HOSTFILE=$PBS_NODEFILE
270      fi      fi
271    
272      if [ ! -z "$ESCRIPT_HOSTFILE" ]      if [ ! -z "$ESCRIPT_HOSTFILE" ]
273      then      then
274          if [ -f "$ESCRIPT_HOSTFILE" ]          if [ -f "$ESCRIPT_HOSTFILE" ]
275          then          then
276              cat "$ESCRIPT_HOSTFILE" | sort -u > $HOSTFILE              cat "$ESCRIPT_HOSTFILE" | sort -u > $HOSTFILE
277              NUM_HOSTS=`cat "$HOSTFILE" | wc -l`              NUM_HOSTS=$(cat "$HOSTFILE" | wc -l)
278              if [ ! -z $ESCRIPT_NUM_NODES ]              if [ ! -z $ESCRIPT_NUM_NODES ]
279              then              then
280                  if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]                  if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]
281                  then                  then
# Line 292  else Line 304  else
304      fi      fi
305    
306      if [ ! -z $ESCRIPT_VERBOSE ]      if [ ! -z $ESCRIPT_VERBOSE ]
307      then      then
308          echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "          echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
309          echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "          echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
310      fi      fi
# Line 323  fi Line 335  fi
335  # Now we compute total number of Processes  # Now we compute total number of Processes
336  #  #
337  TOTPROC=$((ESCRIPT_NUM_NODES * ESCRIPT_NUM_PROCS))  TOTPROC=$((ESCRIPT_NUM_NODES * ESCRIPT_NUM_PROCS))
338  if [ $? -ne 0 ]     #Some compute error  if [ $? -ne 0 ]     #Some compute error
339  then            #This could happen if the args were not a number  then            #This could happen if the args were not a number
340      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."
341      exit 1      exit 1
# Line 338  then Line 350  then
350      exit 1      exit 1
351  fi  fi
352    
353  if [ $TOTPROC -gt 1 ]  if [ $TOTPROC -gt 1 ]
354  then  then
355      if [ "$ESCRIPT_CREATESTDFILES" = "y" ]      if [ "$ESCRIPT_CREATESTDFILES" = "y" ]
356      then      then
# Line 373  fi Line 385  fi
385    
386  if [ ! -z "$DO_VALGRIND" ]  if [ ! -z "$DO_VALGRIND" ]
387  then  then
388      VALGRIND_BIN=`which valgrind 2>/dev/null`      VALGRIND_BIN=$(which valgrind 2>/dev/null)
389      if [ $? -eq 0 ]; then      if [ $? -eq 0 ]; then
390          LOGDIR=$ESCRIPT_ROOT/valgrind_logs          LOGDIR=$ESCRIPT_ROOT/valgrind_logs
391          [ -d $LOGDIR ] || mkdir $LOGDIR          [ -d $LOGDIR ] || mkdir $LOGDIR
392          if [ ${DO_VALGRIND:0:1} = "c" ];          VG_TOOL=$(echo $DO_VALGRIND | awk '{ s=substr($0,1,1);print s;}')
393            if [ $VG_TOOL = "c" ];
394          then          then
395              # run callgrind              # run callgrind
396              LOGFILE=${LOGDIR}/callgrind.%p.xml              LOGFILE=${LOGDIR}/callgrind.%p.xml
# Line 385  then Line 398  then
398              EXEC_CMD="$EXEC_CMD $VALGRIND"              EXEC_CMD="$EXEC_CMD $VALGRIND"
399          else          else
400              # run memcheck by default              # run memcheck by default
401              LAST_N=`ls -1 $LOGDIR|grep "^memcheck"|tail -1|cut -d. -f2`              LAST_N=$(ls -1 $LOGDIR|grep "^memcheck"|tail -1|cut -d. -f2)
402              NEW_N=`printf "%04d" $((10#$LAST_N + 1))`              NEW_N=$(printf "%04d" $((LAST_N + 1)))
403              LOGFILE=${LOGDIR}/memcheck.${NEW_N}.xml              LOGFILE=${LOGDIR}/memcheck.${NEW_N}.xml
404              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"              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"
405              EXEC_CMD="$EXEC_CMD $VALGRIND"              EXEC_CMD="$EXEC_CMD $VALGRIND"
# Line 403  then Line 416  then
416  else  else
417      # 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
418      # one of PYTHON_CMD.      # one of PYTHON_CMD.
419      compfull=`get_buildvar python_version`      compfull=$(get_buildvar python_version)
420      compversion=`echo $compfull | cut -d. -f1,2`      compversion=$(echo $compfull | cut -d. -f1,2)
421      compmajor=`echo $compfull | cut -d. -f1`      compmajor=$(echo $compfull | cut -d. -f1)
422      if [ "$PYTHON_CMD" = "python" ] # if people have customised the command they      if [ "$PYTHON_CMD" = "python" ] # if people have customised the command they
423      then                                # might not want us changing it      then                                # might not want us changing it
424          if [ "$compmajor" = "3" ]          if [ "$compmajor" = "3" ]
# Line 413  else Line 426  else
426              PYTHON_CMD=python3              PYTHON_CMD=python3
427          fi          fi
428      fi      fi
429      intversion=`$PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))'`      intversion=$($PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))')
430      if [ "$compversion" != "$intversion" ]      if [ "$compversion" != "$intversion" ]
431      then      then
432          echo "Python versions do not match. Escript was compiled for "$compversion"."          echo "Python versions do not match. Escript was compiled for "$compversion"."
# Line 449  then Line 462  then
462  fi  fi
463  EXIT_CODE=1  EXIT_CODE=1
464  #=============== no MPI ===================================  #=============== no MPI ===================================
465  if [ "$MPI_FLAVOUR" = "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
466  then  then
467     $EXEC_CMD     $EXEC_CMD
468     EXIT_CODE=$?     EXIT_CODE=$?
469  #=============== OpenMPI ===================================  #=============== OpenMPI ===================================
470  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
471  then  then
472     if [ ! -z "$HOSTFILE" ]     EXPORT_ENV=$(echo $EXPORT_ENV|sed -e 's/,/ -x /g')
473       if [ ! -z "$HOSTFILE" ]
474     then     then
475        HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' "$HOSTFILE"`        HOST_LIST=$(sort -u "$HOSTFILE" | awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}')
476        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"        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV} --bynode --bind-to-none --host $HOST_LIST -np $TOTPROC $EXEC_CMD"
477     else     else
478        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } --cpus-per-rank $ESCRIPT_NUM_THREADS -np $TOTPROC $EXEC_CMD"        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV} --cpus-per-rank $ESCRIPT_NUM_THREADS -np $TOTPROC $EXEC_CMD"
479     fi     fi
480     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
481     $CMD     $CMD
482     EXIT_CODE=$?     EXIT_CODE=$?
# Line 474  then Line 488  then
488     if [ "$WITH_OPENMP" = "1" ]     if [ "$WITH_OPENMP" = "1" ]
489     then     then
490         export I_MPI_PIN_DOMAIN=omp         export I_MPI_PIN_DOMAIN=omp
491         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"         EXPORT_ENV="$EXPORT_ENV,I_MPI_PIN_DOMAIN"
492     fi     fi
493    
494     if [ ! -z "$HOSTFILE" ]     if [ ! -z "$HOSTFILE" ]
495     then     then
496        mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"          CMD="mpirun -hostfile $HOSTFILE -n $TOTPROC -ppn $ESCRIPT_NUM_PROCS $EXEC_CMD"
       if [ $? -ne 0 ]  
       then  
          echo "mpdboot with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes failed."  
          exit 1  
       else  
           if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi  
       fi  
497     else     else
498        mpdboot -n 1 -r ssh          if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Empty hostfile, running on single node"; fi
499        if [ $? -ne 0 ]          CMD="mpirun -n 1 -ppn $ESCRIPT_NUM_PROCS $EXEC_CMD"
       then  
          echo "mpdboot failed."  
          exit 1  
       else  
           if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi  
       fi  
500     fi     fi
    CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"  
501     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
502     $CMD     $CMD
503     EXIT_CODE=$?     EXIT_CODE=$?
    mpdallexit  
    if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
504  #=============== SGI's MPIMPT ===================================  #=============== SGI's MPIMPT ===================================
505  elif [ "$MPI_FLAVOUR" = "MPT" ]  elif [ "$MPI_FLAVOUR" = "MPT" ]
506  then  then
507     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
508     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
509     if [ ! -z "$HOSTFILE" ]     if [ ! -z "$HOSTFILE" ]
510     then     then
511        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")
512        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
513     else     else
514        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
515     fi     fi
516     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
517     $CMD     $CMD
518     EXIT_CODE=$?     EXIT_CODE=$?
519  #=============== MPICH ===================================  #=============== MPICH ===================================
520  elif [ "$MPI_FLAVOUR" = "MPICH" ]  elif [ "$MPI_FLAVOUR" = "MPICH" ]
521  then  then
522     if [ ! -z "$HOSTFILE" ]     if [ ! -z "$HOSTFILE" ]
523     then     then
524        touch "$HOSTFILE2"        touch "$HOSTFILE2"
525        for (( i=1;i<=$ESCRIPT_NUM_PROCS;i+=1 )) ; do cat "$HOSTFILE" >> "$HOSTFILE2"  ; done        for i in $(seq $ESCRIPT_NUM_PROCS); do cat "$HOSTFILE" >> "$HOSTFILE2"; done
526        CMD="mpirun -machinefile \"$HOSTFILE2\"  -np $TOTPROC $EXEC_CMD"        CMD="mpirun -machinefile \"$HOSTFILE2\" -np $TOTPROC $EXEC_CMD"
527     else     else
528        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
529     fi     fi
530     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
531     $CMD     $CMD
532     EXIT_CODE=$?     EXIT_CODE=$?
533  #=============== MPICH2 ===================================  #=============== MPICH2 ===================================
534  elif [ "$MPI_FLAVOUR" = "MPICH2" ]  elif [ "$MPI_FLAVOUR" = "MPICH2" ]
535  then  then
536     if [ ! -z "$HOSTFILE" ]     if [ ! -z "$HOSTFILE" ]
537     then     then
538           mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"           mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f "$HOSTFILE"
539           if [ $? -ne 0 ]           if [ $? -ne 0 ]
540           then           then
541              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."
542              exit 1              exit 1
543           else           else
544               if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi               if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
545           fi           fi
546     else     else
547        mpdboot -n 1 -r ssh        mpdboot -n 1 -r ssh
548        if [ $? -ne 0 ]        if [ $? -ne 0 ]
549        then        then
550           echo "mpdboot failed."           echo "mpdboot failed."
551           exit 1           exit 1
552        else        else
553            if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi            if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
554        fi        fi
555     fi     fi
# Line 564  then Line 562  then
562  else  else
563     echo "unknown MPI flavour '$MPI_FLAVOUR'."     echo "unknown MPI flavour '$MPI_FLAVOUR'."
564  fi  fi
565    
566    if [ ! -z "$DO_VALGRIND" ]; then
567       echo "Valgrind log file written to ${LOGFILE}"
568    fi
569    
570  exit $EXIT_CODE  exit $EXIT_CODE
571    

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

  ViewVC Help
Powered by ViewVC 1.1.26