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

Diff of /trunk/bin/run-escript

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

revision 2568 by jfenwick, Fri Jul 31 05:37:41 2009 UTC revision 2905 by gross, Tue Feb 2 04:26:42 2010 UTC
# Line 26  HOSTFILE=/tmp/escript.$$ Line 26  HOSTFILE=/tmp/escript.$$
26  HOSTFILE2=/tmp/escript2.$$  HOSTFILE2=/tmp/escript2.$$
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
# 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 239  else Line 247  else
247        ESCRIPT_NUM_PROCS=1        ESCRIPT_NUM_PROCS=1
248      fi      fi
249    
250      if [ ! -z $ESCRIPT_VERBOSE  ]      if [ ! -z $ESCRIPT_VERBOSE ]
251      then      then
252            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
253            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
254      fi      fi
255  fi  fi
256    
257  if [  $WITH_OPENMP == "y"  ]  if [ "$WITH_OPENMP" = "y" ]
258  then  then
259     if [ -z $ESCRIPT_NUM_THREADS ]     if [ -z $ESCRIPT_NUM_THREADS ]
260     then     then
# Line 288  fi Line 296  fi
296    
297  if [ $TOTPROC -gt 1 ]  if [ $TOTPROC -gt 1 ]
298  then  then
299     if [ "$ESCRIPT_CREATESTDFILES" == "yes" ]     if [ "$ESCRIPT_CREATESTDFILES" = "yes" ]
300     then     then
301         PYTHON_MPI=$PYTHON_MPI_REDIRECT         PYTHON_MPI=$PYTHON_MPI_REDIRECT
302     else     else
# Line 307  then Line 315  then
315      exit 1      exit 1
316    fi    fi
317  fi  fi
318    if [ -z $@ ]
319    then
320       if [ ! -z $DOBINARY ]
321       then
322           echo "Program must be given."
323           exit 1
324       else
325          DOINTERACTIVE="yes"
326       fi
327    fi
328    
329  #=========================================================================================================  #=========================================================================================================
330  if [ ! -z $DOBINARY ]  if [ ! -z $DOBINARY ]
331  then  then
332      EXEC_CMD="$@"      EXEC_CMD="$@"
333  else  else
334      if [ $MPI_FLAVOUR  == "none" ]      if [ "$MPI_FLAVOUR" = "none" ]
335      then      then
336          # 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
337          # 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 353  else
353             EXEC_CMD="$PYTHON_CMD $@"             EXEC_CMD="$PYTHON_CMD $@"
354          fi          fi
355      else      else
356          EXEC_CMD="$PYTHON_MPI $@"      if [ ! -z $DOINTERACTIVE ]
357            then
358               EXEC_CMD="$PYTHON_MPI -i $@"
359            else
360               EXEC_CMD="$PYTHON_MPI $@"
361            fi
362      fi      fi
363  fi  fi
364  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 366  if [ ! -z $ESCRIPT_VERBOSE ]; then echo
366  #  #
367  #   now we start to spwan things:  #   now we start to spwan things:
368  #  #
369  if [  $WITH_OPENMP == "y"  ]  if [ "$WITH_OPENMP" = "y" ]
370  then  then
371     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
372     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
373  fi  fi
374  EXIT_CODE=1  EXIT_CODE=1
375  #=============== no MPI ===================================  #=============== no MPI ===================================
376  if [ $MPI_FLAVOUR  == "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
377  then  then
378     $EXEC_CMD     $EXEC_CMD
379     EXIT_CODE=$?     EXIT_CODE=$?
380  #=============== OpenMPI ===================================  #=============== OpenMPI ===================================
381  elif [ $MPI_FLAVOUR == "OPENMPI" ]  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
382  then  then
383     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
384     then     then
385        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`
386        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"
387     else     else
388        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"
389     fi     fi
390     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
391     $CMD     $CMD
392     EXIT_CODE=$?     EXIT_CODE=$?
393    
394  #=============== Intel MPI ===================================  #=============== Intel MPI ===================================
395  elif [ $MPI_FLAVOUR == "INTELMPI" ]  elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
396  then  then
397    
398     if [  $WITH_OPENMP == "y"  ]     if [ "$WITH_OPENMP" = "y" ]
399     then     then
400         export I_MPI_PIN_DOMAIN=omp         export I_MPI_PIN_DOMAIN=omp
401         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"
# Line 388  then Line 411  then
411        else        else
412            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
413        fi        fi
414       else
415          mpdboot -n 1 -r ssh
416          if [ $? -ne 0 ]
417          then
418             echo "mpdboot failed."
419             exit 1
420          else
421              if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
422          fi
423     fi     fi
424     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"
425     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
426     $CMD     $CMD
427     EXIT_CODE=$?     EXIT_CODE=$?
428     if [ ! -z $HOSTFILE ]     mpdallexit
429     then     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
        mpdallexit  
        if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
    fi  
430  #=============== SGI's MPIMPT ===================================  #=============== SGI's MPIMPT ===================================
431  elif [ $MPI_FLAVOUR == "MPT" ]  elif [ "$MPI_FLAVOUR" = "MPT" ]
432  then  then
433     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
434     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
435     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
436     then     then
437        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`
438        CMD="mpirun $HOST_LIST $ESCRIPT_NUM_PROCS $EXEC_CMD"        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
439     else     else
440        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
441     fi     fi
# Line 414  then Line 443  then
443     $CMD     $CMD
444     EXIT_CODE=$?     EXIT_CODE=$?
445  #=============== MPICH ===================================  #=============== MPICH ===================================
446  elif [ $MPI_FLAVOUR == "MPICH" ]  elif [ "$MPI_FLAVOUR" = "MPICH" ]
447  then  then
448     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
449     then     then
# Line 428  then Line 457  then
457     $CMD     $CMD
458     EXIT_CODE=$?     EXIT_CODE=$?
459  #=============== MPICH2 ===================================  #=============== MPICH2 ===================================
460  elif [ $MPI_FLAVOUR == "MPICH2" ]  elif [ "$MPI_FLAVOUR" = "MPICH2" ]
461  then  then
462     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
463     then     then
# Line 440  then Line 469  then
469           else           else
470               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
471           fi           fi
472       else
473          mpdboot -n 1 -r ssh
474          if [ $? -ne 0 ]
475          then
476             echo "mpdboot failed."
477             exit 1
478          else
479              if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
480          fi
481     fi     fi
482     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"
483     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
484     $CMD     $CMD
485     EXIT_CODE=$?     EXIT_CODE=$?
486     if [ ! -z $HOSTFILE ]     mpdallexit
487     then     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
        mpdallexit  
        if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
    fi  
488  else  else
489     echo "unknown MPI falvour $MPI_FLAVOUR."     echo "unknown MPI flavour '$MPI_FLAVOUR'."
490  fi  fi
491  exit $EXIT_CODE  exit $EXIT_CODE

Legend:
Removed from v.2568  
changed lines
  Added in v.2905

  ViewVC Help
Powered by ViewVC 1.1.26