/[escript]/trunk/bin/run-escript
ViewVC logotype

Diff of /trunk/bin/run-escript

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

trunk/bin/escript revision 2530 by jfenwick, Thu Jul 9 06:08:44 2009 UTC trunk/bin/run-escript revision 3059 by jfenwick, Tue Jul 6 03:31:48 2010 UTC
# Line 6  Line 6 
6  #Extra paths can be configured about a page further down  #Extra paths can be configured about a page further down
7  #Search for EXTRA_PATH=""  #Search for EXTRA_PATH=""
8    
9  #set to 1 if performing this is a standalone build and /packages contains the relevant tools  #set to 1 if performing this is a standalone build and ../../pkg contains the relevant tools
10  STANDALONE=0  STANDALONE=0
11    
12  #set to 1 if this is part of a packaged build (.deb) and files will be installed in standard locations  #set to 1 if this is part of a packaged build (.deb) and files will be installed in standard locations
# Line 22  CURDIR=`pwd` Line 22  CURDIR=`pwd`
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  HOSTFILE=/tmp/escript.$$  HOSTFILE=/tmp/escript.$USER.$$
26  HOSTFILE2=/tmp/escript2.$$  HOSTFILE2=/tmp/escript2.$USER.$$
27    
28  #Begin finding ESCRIPT_ROOT  #Begin finding ESCRIPT_ROOT
29  if [ $STDLOCATION != 0 ]  if [ $STDLOCATION -ne 0 ]
30  then  then
31      ESCRIPT_ROOT=/usr/lib/escript      ESCRIPT_ROOT=/usr/lib/escript
32  else  else
# Line 43  else Line 43  else
43        tscriptdir=`which $0`        tscriptdir=`which $0`
44        if [ $? != 0 ]        if [ $? != 0 ]
45        then        then
46            echo "Error unable to determine script directory. Exiting."            echo "Error! Unable to determine script directory. Exiting."
47        exit 1            exit 1
48        fi        fi
49        scriptdir=`dirname $tscriptdir`        scriptdir=`dirname $tscriptdir`
50    fi    fi
# Line 58  else Line 58  else
58  fi  fi
59  ##### End finding ESCRIPT_ROOT  ########  ##### End finding ESCRIPT_ROOT  ########
60    
61    if [ ! -r $ESCRIPT_ROOT/lib/buildvars ]; then
62        echo "Error! Unable to read escript build information. Exiting."
63        exit 1
64    fi
65    
66  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"
67  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"
68  PYTHON_CMD=python  PYTHON_CMD=python
# Line 70  EXTRA_PATH=$ESCRIPT_ROOT/bin Line 75  EXTRA_PATH=$ESCRIPT_ROOT/bin
75  EXTRA_PYTHONPATH=$ESCRIPT_ROOT  EXTRA_PYTHONPATH=$ESCRIPT_ROOT
76  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
77    
78  if [ $STANDALONE == 1 ]  if [ $STANDALONE -eq 1 ]
79  then  then
80      EXTRA_PATH=$ESCRIPT_PARENT/pkg/python/bin:$EXTRA_PATH      EXTRA_PATH=$ESCRIPT_PARENT/pkg/python/bin:$EXTRA_PATH
81      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/boost/lib:$ESCRIPT_PARENT/pkg/netcdf/lib/:$EXTRA_LD_LIBRARY_PATH      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/boost/lib:$ESCRIPT_PARENT/pkg/netcdf/lib/:$EXTRA_LD_LIBRARY_PATH
82      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/vtk/lib/vtk-5.2:$ESCRIPT_PARENT/pkg/mesa/lib:$EXTRA_LD_LIBRARY_PATH      EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH
83      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/python/lib:$EXTRA_LD_LIBRARY_PATH      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/python/lib:$EXTRA_LD_LIBRARY_PATH
84      EXTRA_PYTHONPATH=$ESCRIPT_PARENT/pkg/numpy/lib/python2.6/site-packages:$ESCRIPT_PARENT/pkg/vtk/lib/python2.6/site-packages:$EXTRA_PYTHONPATH      EXTRA_PYTHONPATH=$ESCRIPT_PARENT/pkg/numpy/lib/python2.6/site-packages:$ESCRIPT_PARENT/pkg/matplotlib/lib/python2.6/site-packages:$EXTRA_PYTHONPATH
85  fi  fi
86    
87    
# Line 126  do Line 131  do
131        "c")  cat $ESCRIPT_ROOT/lib/buildvars        "c")  cat $ESCRIPT_ROOT/lib/buildvars
132          exit 0          exit 0
133          ;;          ;;
134        "V")  echo "escript-pre2.0(build "`grep svn_revision $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`")"        "V")  echo "escript-development(build "`grep svn_revision $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`")"
135          exit 0          exit 0
136          ;;          ;;
137        "h")  echo "$HELPTEXT"        "h")  echo "$HELPTEXT"
# Line 137  do Line 142  do
142        "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"
143          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
144          echo "export PATH=$EXTRA_PATH:\$PATH"          echo "export PATH=$EXTRA_PATH:\$PATH"
145          if [ `uname` == Darwin ]          if [ "`uname`" = "Darwin" ]
146          then          then
147              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"
148          fi          fi
# Line 163  shift `expr $OPTIND - 1` Line 168  shift `expr $OPTIND - 1`
168  MPI_FLAVOUR=`grep mpi_flavour $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  MPI_FLAVOUR=`grep mpi_flavour $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`
169  WITH_OPENMP=`grep useopenmp $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  WITH_OPENMP=`grep useopenmp $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`
170    
171  if [ ! -z $ESCRIPT_VERBOSE  ]; then echo "MPI flavor is $MPI_FLAVOUR."; fi  if [ ! -z $ESCRIPT_VERBOSE ]; then
172  if [ ! -z $ESCRIPT_VERBOSE ] && [  $WITH_OPENMP == "y"  ]; then echo "OpenMP enabled."; fi      echo "MPI flavour is $MPI_FLAVOUR."
173        if [ "$WITH_OPENMP" = "y" ]; then echo "OpenMP enabled."; fi
174    fi
175    
176  #  #
177  #  extend path variables  #  extend path variables
178  #  #
# Line 172  export PATH=$EXTRA_PATH:$PATH Line 180  export PATH=$EXTRA_PATH:$PATH
180  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
181  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
182  EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"  EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"
183  if [ `uname` == Darwin ]  if [ "`uname`" = "Darwin" ]
184  then  then
185      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
186      EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"      EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"
187  fi  fi
188  if [ ! -z $ESCRIPT_VERBOSE  ]  if [ ! -z $ESCRIPT_VERBOSE ]
189  then  then
190      echo "PATH = $PATH "      echo "PATH = $PATH "
191      echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "      echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "
# Line 188  fi Line 196  fi
196  #  #
197  #  Ensure the variables have sensible values  #  Ensure the variables have sensible values
198  #  #
199  if [ $MPI_FLAVOUR  == "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
200  then  then
201      if [ ! -z $ESCRIPT_NUM_NODES ]      if [ ! -z $ESCRIPT_NUM_NODES ]
202      then      then
# Line 205  then Line 213  then
213      ESCRIPT_NUM_NODES=1      ESCRIPT_NUM_NODES=1
214      ESCRIPT_NUM_PROCS=1      ESCRIPT_NUM_PROCS=1
215  else  else
216        # use the PBS_NODEFILE if not otherwise specified
217        if [[ ( ! -z $PBS_NODEFILE ) && ( -z $ESCRIPT_HOSTFILE ) ]]
218        then
219        ESCRIPT_HOSTFILE=$PBS_NODEFILE
220    
221        fi
222    
223      if [ ! -z $ESCRIPT_HOSTFILE ]      if [ ! -z $ESCRIPT_HOSTFILE ]
224      then      then
225          if [ -f $ESCRIPT_HOSTFILE ]          if [ -f $ESCRIPT_HOSTFILE ]
# Line 239  else Line 254  else
254        ESCRIPT_NUM_PROCS=1        ESCRIPT_NUM_PROCS=1
255      fi      fi
256    
257      if [ ! -z $ESCRIPT_VERBOSE  ]      if [ ! -z $ESCRIPT_VERBOSE ]
258      then      then
259            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
260            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
261      fi      fi
262  fi  fi
263    
264  if [  $WITH_OPENMP == "y"  ]  if [ "$WITH_OPENMP" = "y" ]
265  then  then
266     if [ -z $ESCRIPT_NUM_THREADS ]     if [ -z $ESCRIPT_NUM_THREADS ]
267     then     then
# Line 288  fi Line 303  fi
303    
304  if [ $TOTPROC -gt 1 ]  if [ $TOTPROC -gt 1 ]
305  then  then
306     if [ "$ESCRIPT_CREATESTDFILES" == "yes" ]     if [ "$ESCRIPT_CREATESTDFILES" = "yes" ]
307     then     then
308         PYTHON_MPI=$PYTHON_MPI_REDIRECT         PYTHON_MPI=$PYTHON_MPI_REDIRECT
309     else     else
# Line 307  then Line 322  then
322      exit 1      exit 1
323    fi    fi
324  fi  fi
325    if [ -z "$@" ]
326    then
327       if [ ! -z $DOBINARY ]
328       then
329           echo "Program must be given."
330           exit 1
331       else
332          DOINTERACTIVE="yes"
333       fi
334    fi
335    
336  #=========================================================================================================  #=========================================================================================================
337  if [ ! -z $DOBINARY ]  if [ ! -z $DOBINARY ]
338  then  then
339      EXEC_CMD="$@"      EXEC_CMD="$@"
340  else  else
341      if [ $MPI_FLAVOUR  == "none" ]      if [ "$MPI_FLAVOUR" = "none" ]
342      then      then
343          # Check to see if the python version we were compiled with matches the one of EXEC_CMD          # Check to see if the python version we were compiled with matches the one of EXEC_CMD
344          # We should only do this check if they are running a python script          # We should only do this check if they are running a python script
# Line 335  else Line 360  else
360             EXEC_CMD="$PYTHON_CMD $@"             EXEC_CMD="$PYTHON_CMD $@"
361          fi          fi
362      else      else
363          EXEC_CMD="$PYTHON_MPI $@"      if [ ! -z $DOINTERACTIVE ]
364            then
365               EXEC_CMD="$PYTHON_MPI -i $@"
366            else
367               EXEC_CMD="$PYTHON_MPI $@"
368            fi
369      fi      fi
370  fi  fi
371  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
# Line 343  if [ ! -z $ESCRIPT_VERBOSE ]; then echo Line 373  if [ ! -z $ESCRIPT_VERBOSE ]; then echo
373  #  #
374  #   now we start to spwan things:  #   now we start to spwan things:
375  #  #
376  if [  $WITH_OPENMP == "y"  ]  if [ "$WITH_OPENMP" = "y" ]
377  then  then
378     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
379     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
380  fi  fi
381  EXIT_CODE=1  EXIT_CODE=1
382  #=============== no MPI ===================================  #=============== no MPI ===================================
383  if [ $MPI_FLAVOUR  == "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
384  then  then
385     $EXEC_CMD     $EXEC_CMD
386     EXIT_CODE=$?     EXIT_CODE=$?
387  #=============== OpenMPI ===================================  #=============== OpenMPI ===================================
388  elif [ $MPI_FLAVOUR == "OPENMPI" ]  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
389  then  then
390     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
391     then     then
392        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`
393        CMD="mpirun -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 --host $HOST_LIST $EXEC_CMD"
394     else     else
395        CMD="mpirun -x ${EXPORT_ENV//,/ -x } -np $TOTPROC $EXEC_CMD"        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } -np $TOTPROC $EXEC_CMD"
396     fi     fi
397     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
398     $CMD     $CMD
399     EXIT_CODE=$?     EXIT_CODE=$?
400    
401  #=============== Intel MPI ===================================  #=============== Intel MPI ===================================
402  elif [ $MPI_FLAVOUR == "INTELMPI" ]  elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
403  then  then
404    
405     if [  $WITH_OPENMP == "y"  ]     if [ "$WITH_OPENMP" = "y" ]
406     then     then
407         export I_MPI_PIN_DOMAIN=omp         export I_MPI_PIN_DOMAIN=omp
408         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"
# Line 388  then Line 418  then
418        else        else
419            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 $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
420        fi        fi
421       else
422          mpdboot -n 1 -r ssh
423          if [ $? -ne 0 ]
424          then
425             echo "mpdboot failed."
426             exit 1
427          else
428              if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
429          fi
430     fi     fi
431     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"
432     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
433     $CMD     $CMD
434     EXIT_CODE=$?     EXIT_CODE=$?
435     if [ ! -z $HOSTFILE ]     mpdallexit
436     then     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
        mpdallexit  
        if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
    fi  
437  #=============== SGI's MPIMPT ===================================  #=============== SGI's MPIMPT ===================================
438  elif [ $MPI_FLAVOUR == "MPT" ]  elif [ "$MPI_FLAVOUR" = "MPT" ]
439  then  then
440     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
441     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
442     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
443     then     then
444        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`
445        CMD="mpirun $HOST_LIST $ESCRIPT_NUM_PROCS $EXEC_CMD"        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
446     else     else
447        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
448     fi     fi
# Line 414  then Line 450  then
450     $CMD     $CMD
451     EXIT_CODE=$?     EXIT_CODE=$?
452  #=============== MPICH ===================================  #=============== MPICH ===================================
453  elif [ $MPI_FLAVOUR == "MPICH" ]  elif [ "$MPI_FLAVOUR" = "MPICH" ]
454  then  then
455     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
456     then     then
# Line 428  then Line 464  then
464     $CMD     $CMD
465     EXIT_CODE=$?     EXIT_CODE=$?
466  #=============== MPICH2 ===================================  #=============== MPICH2 ===================================
467  elif [ $MPI_FLAVOUR == "MPICH2" ]  elif [ "$MPI_FLAVOUR" = "MPICH2" ]
468  then  then
469     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
470     then     then
# Line 440  then Line 476  then
476           else           else
477               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 $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
478           fi           fi
479       else
480          mpdboot -n 1 -r ssh
481          if [ $? -ne 0 ]
482          then
483             echo "mpdboot failed."
484             exit 1
485          else
486              if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
487          fi
488     fi     fi
489     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"
490     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
491     $CMD     $CMD
492     EXIT_CODE=$?     EXIT_CODE=$?
493     if [ ! -z $HOSTFILE ]     mpdallexit
494     then     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
        mpdallexit  
        if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
    fi  
495  else  else
496     echo "unknown MPI falvour $MPI_FLAVOUR."     echo "unknown MPI flavour '$MPI_FLAVOUR'."
497  fi  fi
498  exit $EXIT_CODE  exit $EXIT_CODE

Legend:
Removed from v.2530  
changed lines
  Added in v.3059

  ViewVC Help
Powered by ViewVC 1.1.26