/[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 2541 by jfenwick, Mon Jul 20 00:25:55 2009 UTC revision 2865 by gross, Fri Jan 22 03:19:32 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 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-pre4.0(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 313  if [ ! -z $DOBINARY ] Line 321  if [ ! -z $DOBINARY ]
321  then  then
322      EXEC_CMD="$@"      EXEC_CMD="$@"
323  else  else
324      if [ $MPI_FLAVOUR  == "none" ]      if [ "$MPI_FLAVOUR" = "none" ]
325      then      then
326          # 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
327          # 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 343  else
343             EXEC_CMD="$PYTHON_CMD $@"             EXEC_CMD="$PYTHON_CMD $@"
344          fi          fi
345      else      else
346          EXEC_CMD="$PYTHON_MPI $@"      if [ ! -z $DOINTERACTIVE ]
347            then
348               EXEC_CMD="$PYTHON_MPI -i $@"
349            else
350               EXEC_CMD="$PYTHON_MPI $@"
351            fi
352      fi      fi
353  fi  fi
354  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 356  if [ ! -z $ESCRIPT_VERBOSE ]; then echo
356  #  #
357  #   now we start to spwan things:  #   now we start to spwan things:
358  #  #
359  if [  $WITH_OPENMP == "y"  ]  if [ "$WITH_OPENMP" = "y" ]
360  then  then
361     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
362     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
363  fi  fi
364  EXIT_CODE=1  EXIT_CODE=1
365  #=============== no MPI ===================================  #=============== no MPI ===================================
366  if [ $MPI_FLAVOUR  == "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
367  then  then
368     $EXEC_CMD     $EXEC_CMD
369     EXIT_CODE=$?     EXIT_CODE=$?
370  #=============== OpenMPI ===================================  #=============== OpenMPI ===================================
371  elif [ $MPI_FLAVOUR == "OPENMPI" ]  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
372  then  then
373     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
374     then     then
# Line 369  then Line 382  then
382     EXIT_CODE=$?     EXIT_CODE=$?
383    
384  #=============== Intel MPI ===================================  #=============== Intel MPI ===================================
385  elif [ $MPI_FLAVOUR == "INTELMPI" ]  elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
386  then  then
387    
388     if [  $WITH_OPENMP == "y"  ]     if [ "$WITH_OPENMP" = "y" ]
389     then     then
390         export I_MPI_PIN_DOMAIN=omp         export I_MPI_PIN_DOMAIN=omp
391         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"
# Line 399  then Line 412  then
412         if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi         if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
413     fi     fi
414  #=============== SGI's MPIMPT ===================================  #=============== SGI's MPIMPT ===================================
415  elif [ $MPI_FLAVOUR == "MPT" ]  elif [ "$MPI_FLAVOUR" = "MPT" ]
416  then  then
417     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
418     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
# Line 414  then Line 427  then
427     $CMD     $CMD
428     EXIT_CODE=$?     EXIT_CODE=$?
429  #=============== MPICH ===================================  #=============== MPICH ===================================
430  elif [ $MPI_FLAVOUR == "MPICH" ]  elif [ "$MPI_FLAVOUR" = "MPICH" ]
431  then  then
432     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
433     then     then
# Line 428  then Line 441  then
441     $CMD     $CMD
442     EXIT_CODE=$?     EXIT_CODE=$?
443  #=============== MPICH2 ===================================  #=============== MPICH2 ===================================
444  elif [ $MPI_FLAVOUR == "MPICH2" ]  elif [ "$MPI_FLAVOUR" = "MPICH2" ]
445  then  then
446     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
447     then     then
# Line 451  then Line 464  then
464         if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi         if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
465     fi     fi
466  else  else
467     echo "unknown MPI falvour $MPI_FLAVOUR."     echo "unknown MPI flavour '$MPI_FLAVOUR'."
468  fi  fi
469  exit $EXIT_CODE  exit $EXIT_CODE

Legend:
Removed from v.2541  
changed lines
  Added in v.2865

  ViewVC Help
Powered by ViewVC 1.1.26