/[escript]/branches/py3_attempt2/bin/run-escript
ViewVC logotype

Diff of /branches/py3_attempt2/bin/run-escript

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

revision 3178 by caltinay, Tue Sep 14 00:31:59 2010 UTC revision 3853 by caltinay, Thu Mar 1 07:25:03 2012 UTC
# Line 35  else Line 35  else
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    
 BUILDINFO_FILE=$ESCRIPT_ROOT/lib/buildvars  
 if [ ! -r $BUILDINFO_FILE ]; then  
     echo "Error! Unable to read escript build information. Exiting."  
     exit 1  
 fi  
61    
 function get_buildvar {  
     echo `grep $1 $BUILDINFO_FILE |cut -d= -f2`  
 }  
62    
63  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"
64  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"
# Line 82  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib Line 74  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
74    
75  if [ $STANDALONE -eq 1 ]  if [ $STANDALONE -eq 1 ]
76  then  then
77      EXTRA_PATH=$ESCRIPT_PARENT/pkg/python/bin:$EXTRA_PATH      EXTRA_PATH=$ESCRIPT_PARENT/pkg/python/bin:$ESCRIPT_PARENT/pkg/scons/bin:$EXTRA_PATH
78      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
79      EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH      EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH
80      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
81      EXTRA_PYTHONPATH=$ESCRIPT_PARENT/pkg/numpy/lib/python2.6/site-packages:$ESCRIPT_PARENT/pkg/matplotlib/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
82  fi  fi
83    
84    
85    BUILDINFO_FILE=$ESCRIPT_ROOT/lib/buildvars
86    if [ ! -r $BUILDINFO_FILE ]; then
87        if [ "$1" = "-e" ];then
88        echo "export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:\$LD_LIBRARY_PATH"
89        echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
90        echo "export PATH=$EXTRA_PATH:\$PATH"
91        if [ "`uname`" = "Darwin" ]
92        then
93            echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
94        fi  
95            exit 0
96        fi
97        echo "Error! Unable to read escript build information. Exiting."
98        exit 1
99    fi
100    
101    function get_buildvar {
102        echo `grep "^$1=" $BUILDINFO_FILE |cut -d= -f2`
103    }
104    
105  #  #
106  #   Add VisIt paths if required  #   Add VisIt paths if required
107  #  #
108  WITH_VISIT=`get_buildvar usevisit`  WITH_VISIT=`get_buildvar visit`
109  if [ "$WITH_VISIT" = "y" ]; then  if [ "$WITH_VISIT" = "1" ]; then
110      VISIT_BIN=`which visit`      VISIT_BIN=`which visit`
111      if [ $? -eq 0 ]; then      if [ $? -eq 0 ]; then
112          VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`          VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`
# Line 107  fi Line 120  fi
120  HELP_TEXT="  HELP_TEXT="
121  Usage: escript [options] script.py [arguments...]  Usage: escript [options] script.py [arguments...]
122      -n nn       number of nodes to use      -n nn       number of nodes to use
123      -p np       number of MPI processes to spawn      -p np       number of MPI processes to spawn per node
124      -t nt       number of OpenMP threads to use      -t nt       number of OpenMP threads to use
125      -f file     name of MPI hostfile      -f file     name of MPI hostfile
126      -c      print compile information for escript and exit      -c      print compile information for escript and exit
# Line 183  shift `expr $OPTIND - 1` Line 196  shift `expr $OPTIND - 1`
196  #  #
197  #   Read MPI_FLAVOUR and WITH_OPENMP from the buildvars  #   Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
198  #  #
199  MPI_FLAVOUR=`get_buildvar mpi_flavour`  MPI_FLAVOUR=`get_buildvar mpi`
200  WITH_OPENMP=`get_buildvar useopenmp`  WITH_OPENMP=`get_buildvar openmp`
201    
202  if [ ! -z $ESCRIPT_VERBOSE ]; then  if [ ! -z $ESCRIPT_VERBOSE ]; then
203      echo "MPI flavour is $MPI_FLAVOUR."      echo "MPI flavour is $MPI_FLAVOUR."
204      if [ "$WITH_OPENMP" = "y" ]; then echo "OpenMP enabled."; fi      if [ "$WITH_OPENMP" = "1" ]; then echo "OpenMP enabled."; fi
205  fi  fi
206    
207  #  #
# Line 278  else Line 291  else
291      fi      fi
292  fi  fi
293    
294  if [ "$WITH_OPENMP" = "y" ]  if [ "$WITH_OPENMP" = "1" ]
295  then  then
296     if [ -z $ESCRIPT_NUM_THREADS ]     if [ -z $ESCRIPT_NUM_THREADS ]
297     then     then
# Line 349  then Line 362  then
362  else  else
363      # 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
364      # one of PYTHON_CMD.      # one of PYTHON_CMD.
365      compversion=`get_buildvar python`      compversion=`get_buildvar python_version | cut -d. -f1,2`
366      intversion=`$PYTHON_CMD -c 'import sys;print "%d.%d.%d"%(sys.version_info[0], sys.version_info[1], sys.version_info[2])'`      intversion=`$PYTHON_CMD -c 'import sys;print "%d.%d"%(sys.version_info[0], sys.version_info[1])'`
367      if [ "$compversion" != "$intversion" ]      if [ "$compversion" != "$intversion" ]
368      then      then
369          echo "Python versions do not match. Escript was compiled for "$compversion"."          echo "Python versions do not match. Escript was compiled for "$compversion"."
# Line 379  if [ ! -z $ESCRIPT_VERBOSE ]; then echo Line 392  if [ ! -z $ESCRIPT_VERBOSE ]; then echo
392  #  #
393  #   now we start to spwan things:  #   now we start to spwan things:
394  #  #
395  if [ "$WITH_OPENMP" = "y" ]  if [ "$WITH_OPENMP" = "1" ]
396  then  then
397     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
398     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
# Line 396  then Line 409  then
409     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
410     then     then
411        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`
412        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"
413     else     else
414        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"
415     fi     fi
416     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
417     $CMD     $CMD
# Line 408  then Line 421  then
421  elif [ "$MPI_FLAVOUR" = "INTELMPI" ]  elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
422  then  then
423    
424     if [ "$WITH_OPENMP" = "y" ]     if [ "$WITH_OPENMP" = "1" ]
425     then     then
426         export I_MPI_PIN_DOMAIN=omp         export I_MPI_PIN_DOMAIN=omp
427         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"         EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"

Legend:
Removed from v.3178  
changed lines
  Added in v.3853

  ViewVC Help
Powered by ViewVC 1.1.26