/[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 3177 by jfenwick, Tue Sep 7 05:29:32 2010 UTC revision 3178 by caltinay, Tue Sep 14 00:31:59 2010 UTC
# 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  BUILDINFO_FILE=$ESCRIPT_ROOT/lib/buildvars
62    if [ ! -r $BUILDINFO_FILE ]; then
63      echo "Error! Unable to read escript build information. Exiting."      echo "Error! Unable to read escript build information. Exiting."
64      exit 1      exit 1
65  fi  fi
66    
67    function get_buildvar {
68        echo `grep $1 $BUILDINFO_FILE |cut -d= -f2`
69    }
70    
71  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"  PYTHON_MPI_NULL="$ESCRIPT_ROOT/lib/pythonMPI"
72  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"  PYTHON_MPI_REDIRECT="$ESCRIPT_ROOT/lib/pythonMPIredirect"
73  PYTHON_CMD=python  PYTHON_CMD=python
# Line 87  fi Line 92  fi
92  #  #
93  #   Add VisIt paths if required  #   Add VisIt paths if required
94  #  #
95  WITH_VISIT=`grep usevisit $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  WITH_VISIT=`get_buildvar usevisit`
96  if [ "$WITH_VISIT" = "y" ]; then  if [ "$WITH_VISIT" = "y" ]; then
97      VISIT_BIN=`which visit`      VISIT_BIN=`which visit`
98      if [ $? -eq 0 ]; then      if [ $? -eq 0 ]; then
# Line 144  do Line 149  do
149        "c")  cat $ESCRIPT_ROOT/lib/buildvars        "c")  cat $ESCRIPT_ROOT/lib/buildvars
150          exit 0          exit 0
151          ;;          ;;
152        "V")  echo "escript-development(build "`grep svn_revision $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`")"        "V")  echo "escript-development(build "`get_buildvar svn_revision`")"
153          exit 0          exit 0
154          ;;          ;;
155        "h")  echo "$HELPTEXT"        "h")  echo "$HELPTEXT"
# Line 176  done Line 181  done
181  shift `expr $OPTIND - 1`  shift `expr $OPTIND - 1`
182  #==============================================  #==============================================
183  #  #
184  #   Read the MPI_FLAVOUR from the buildvars  #   Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
185  #  #
186  MPI_FLAVOUR=`grep mpi_flavour $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  MPI_FLAVOUR=`get_buildvar mpi_flavour`
187  WITH_OPENMP=`grep useopenmp $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  WITH_OPENMP=`get_buildvar useopenmp`
188    
189  if [ ! -z $ESCRIPT_VERBOSE ]; then  if [ ! -z $ESCRIPT_VERBOSE ]; then
190      echo "MPI flavour is $MPI_FLAVOUR."      echo "MPI flavour is $MPI_FLAVOUR."
# Line 229  else Line 234  else
234      # use the PBS_NODEFILE if not otherwise specified      # use the PBS_NODEFILE if not otherwise specified
235      if [[ ( ! -z $PBS_NODEFILE ) && ( -z $ESCRIPT_HOSTFILE ) ]]      if [[ ( ! -z $PBS_NODEFILE ) && ( -z $ESCRIPT_HOSTFILE ) ]]
236      then      then
237      ESCRIPT_HOSTFILE=$PBS_NODEFILE          ESCRIPT_HOSTFILE=$PBS_NODEFILE
   
238      fi      fi
239    
240      if [ ! -z $ESCRIPT_HOSTFILE ]      if [ ! -z $ESCRIPT_HOSTFILE ]
# Line 259  else Line 263  else
263    
264      if [ -z $ESCRIPT_NUM_NODES ]      if [ -z $ESCRIPT_NUM_NODES ]
265      then      then
266        ESCRIPT_NUM_NODES=1          ESCRIPT_NUM_NODES=1
267      fi      fi
268    
269      if [ -z $ESCRIPT_NUM_PROCS ]      if [ -z $ESCRIPT_NUM_PROCS ]
270      then      then
271        ESCRIPT_NUM_PROCS=1          ESCRIPT_NUM_PROCS=1
272      fi      fi
273    
274      if [ ! -z $ESCRIPT_VERBOSE ]      if [ ! -z $ESCRIPT_VERBOSE ]
275      then      then
276            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "          echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
277            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "          echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
278      fi      fi
279  fi  fi
280    
# Line 301  fi Line 305  fi
305  (( TOTPROC=$ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS))  (( TOTPROC=$ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS))
306  if [ $? -ne 0 ]     #Some compute error  if [ $? -ne 0 ]     #Some compute error
307  then            #This could happen if the args were not a number  then            #This could happen if the args were not a number
308    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."
309    exit 1      exit 1
310  fi  fi
311    
312  #  #
# Line 310  fi Line 314  fi
314  #  #
315  if [[ ( ( ! -z $DOINTERACTIVE ) || ( $# -eq 0 ) ) && ( $TOTPROC -gt 1) ]]  if [[ ( ( ! -z $DOINTERACTIVE ) || ( $# -eq 0 ) ) && ( $TOTPROC -gt 1) ]]
316  then  then
317    echo "Interactive mode cannot be used with more than one process"      echo "Interactive mode cannot be used with more than one process"
318    exit 1      exit 1
319  fi  fi
320    
321  if [ $TOTPROC -gt 1 ]  if [ $TOTPROC -gt 1 ]
322  then  then
323     if [ "$ESCRIPT_CREATESTDFILES" = "yes" ]      if [ "$ESCRIPT_CREATESTDFILES" = "yes" ]
324     then      then
325         PYTHON_MPI=$PYTHON_MPI_REDIRECT          PYTHON_MPI=$PYTHON_MPI_REDIRECT
326     else      else
327         PYTHON_MPI=$PYTHON_MPI_NULL          PYTHON_MPI=$PYTHON_MPI_NULL
328     fi      fi
329  else  else
330      PYTHON_MPI=$PYTHON_MPI_NULL      PYTHON_MPI=$PYTHON_MPI_NULL
331  fi  fi
# Line 329  fi Line 333  fi
333  # Must have at least one command-line arg: the python script  # Must have at least one command-line arg: the python script
334  if [ $# -eq 0 ]  if [ $# -eq 0 ]
335  then  then
336    if [ ! -z $DOBINARY ]      if [ ! -z $DOBINARY ]
337    then      then
338      echo "No program to run was specified. Exiting."          echo "No program to run was specified. Exiting."
339      exit 1          exit 1
340    else      else
341      DOINTERACTIVE="yes"          DOINTERACTIVE="yes"
342    fi      fi
343  fi  fi
344    
345  #=========================================================================================================  #=========================================================================================================
# Line 343  if [ ! -z $DOBINARY ] Line 347  if [ ! -z $DOBINARY ]
347  then  then
348      EXEC_CMD="$@"      EXEC_CMD="$@"
349  else  else
350        # Check to see if the python version we were compiled with matches the
351        # one of PYTHON_CMD.
352        compversion=`get_buildvar python`
353        intversion=`$PYTHON_CMD -c 'import sys;print "%d.%d.%d"%(sys.version_info[0], sys.version_info[1], sys.version_info[2])'`
354        if [ "$compversion" != "$intversion" ]
355        then
356            echo "Python versions do not match. Escript was compiled for "$compversion"."
357            echo "Current version of Python appears to be "$intversion"."
358            exit 1
359        fi
360      if [ "$MPI_FLAVOUR" = "none" ]      if [ "$MPI_FLAVOUR" = "none" ]
361      then      then
362          # Check to see if the python version we were compiled with matches the one of EXEC_CMD          if [ ! -z $DOINTERACTIVE ]
         # We should only do this check if they are running a python script  
         if [ -f $ESCRIPT_ROOT/lib/pyversion ]  
         then  
            compversion=`cat $ESCRIPT_ROOT/lib/pyversion`  
        intversion=`$PYTHON_CMD -c 'import sys;print "%d.%d.%d"%(sys.version_info[0], sys.version_info[1], sys.version_info[2])'`  
            if [ "$compversion" != "$intversion" ]  
            then  
               echo "Python versions do not match. Escript was compiled for "$compversion"."  
               echo "Current version of Python appears to be "$intversion"."  
               exit 1  
            fi  
         fi  
     if [ ! -z $DOINTERACTIVE ]  
363          then          then
364             EXEC_CMD="$PYTHON_CMD -i $@"             EXEC_CMD="$PYTHON_CMD -i $@"
365          else          else
366             EXEC_CMD="$PYTHON_CMD $@"             EXEC_CMD="$PYTHON_CMD $@"
367          fi          fi
368      else      else
369      if [ ! -z $DOINTERACTIVE ]          if [ ! -z $DOINTERACTIVE ]
370          then          then
371             EXEC_CMD="$PYTHON_MPI -i $@"             EXEC_CMD="$PYTHON_MPI -i $@"
372          else          else

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

  ViewVC Help
Powered by ViewVC 1.1.26