/[escript]/trunk/run-escript.in
ViewVC logotype

Diff of /trunk/run-escript.in

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

revision 4362 by caltinay, Tue Apr 16 04:37:13 2013 UTC revision 4506 by caltinay, Wed Jul 24 01:28:42 2013 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/usr/bin/env bash
2    
3  # Escript/Finley wrapper for python  # Escript/Finley wrapper for python
4  # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher  # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
# Line 28  HOSTFILE2=/tmp/escript2.$USER.$$ Line 28  HOSTFILE2=/tmp/escript2.$USER.$$
28  #Begin finding ESCRIPT_ROOT  #Begin finding ESCRIPT_ROOT
29  if [ $STDLOCATION -ne 0 ]  if [ $STDLOCATION -ne 0 ]
30  then  then
31      ESCRIPT_ROOT=/usr/lib/escript      ESCRIPT_ROOT=/usr/lib/python-escript
32  else  else
33    # We don't know the escript root so we need to work it out from the invocation    # We don't know the escript root so we need to work it out from the invocation
34    # Need to match if the name contains /    # Need to match if the name contains /
# Line 71  EXTRA_PYTHONPATH=$ESCRIPT_ROOT Line 71  EXTRA_PYTHONPATH=$ESCRIPT_ROOT
71    
72  if [ $STDLOCATION -eq 1 ]  if [ $STDLOCATION -eq 1 ]
73  then  then
74      EXTRA_LD_LIBRARY_PATH=/usr/lib/escript      EXTRA_LD_LIBRARY_PATH=/usr/lib/python-escript
75  else  else
76      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
77  fi  fi
# Line 90  fi Line 90  fi
90  BUILDINFO_FILE="$ESCRIPT_ROOT/lib/buildvars"  BUILDINFO_FILE="$ESCRIPT_ROOT/lib/buildvars"
91  if [ "$STDLOCATION" = "1" ]  if [ "$STDLOCATION" = "1" ]
92  then  then
93      BUILDINFO_FILE=/usr/lib/escript/buildvars      BUILDINFO_FILE=/usr/lib/python-escript/buildvars
94  fi  fi
95  if [ ! -r "$BUILDINFO_FILE" ]; then  if [ ! -r "$BUILDINFO_FILE" ]; then
96      if [ "$1" = "-e" ]; then      if [ "$1" = "-e" ]; then
# Line 140  Usage: run-escript [options] script.py [ Line 140  Usage: run-escript [options] script.py [
140      -o      redirect output from MPI to files      -o      redirect output from MPI to files
141      -v      print diagnostics      -v      print diagnostics
142      -x      run in new xterm instance      -x      run in new xterm instance
143        -m tool     run with valgrind {tool=m[emcheck]/c[allgrind]}
144      script.py   Your python script      script.py   Your python script
145      arguments...    The optional command-line arguments to your script      arguments...    The optional command-line arguments to your script
146  "  "
# Line 151  fi Line 152  fi
152  #==============================================================================  #==============================================================================
153    
154  # Parse the command-line options  # Parse the command-line options
155  # option e should not be followed by a :  while getopts 'bn:p:t:f:echim:oVvx' option
 while getopts 'bn:p:t:f:hecVviox' option  
156  do  do
157      case "$option" in      case "$option" in
158        "b")  DO_BINARY=y        "b")  DO_BINARY=y
159          ;;          ;;
160          "m")  DO_VALGRIND=$OPTARG
161            ;;
162        "n")  ESCRIPT_NUM_NODES=$OPTARG        "n")  ESCRIPT_NUM_NODES=$OPTARG
163          ;;          ;;
164        "p")  ESCRIPT_NUM_PROCS=$OPTARG        "p")  ESCRIPT_NUM_PROCS=$OPTARG
# Line 361  then Line 363  then
363  fi  fi
364    
365  #==============================================================================  #==============================================================================
366    
367  if [ ! -z $DO_XTERM ]  if [ ! -z $DO_XTERM ]
368  then  then
369      EXEC_CMD="xterm -e"      EXEC_CMD="xterm -e"
# Line 368  else Line 371  else
371      EXEC_CMD=""      EXEC_CMD=""
372  fi  fi
373    
374    if [ ! -z "$DO_VALGRIND" ]
375    then
376        VALGRIND_BIN=`which valgrind 2>/dev/null`
377        if [ $? -eq 0 ]; then
378            LOGDIR=$ESCRIPT_ROOT/valgrind_logs
379            [ -d $LOGDIR ] || mkdir $LOGDIR
380            if [ ${DO_VALGRIND:0:1} = "c" ];
381            then
382                # run callgrind
383                LOGFILE=${LOGDIR}/callgrind.%p.xml
384                VALGRIND="valgrind --tool=callgrind --callgrind-out-file=$LOGFILE"
385                EXEC_CMD="$EXEC_CMD $VALGRIND"
386            else
387                # run memcheck by default
388                LAST_N=`ls -1 $LOGDIR|grep "^memcheck"|tail -1|cut -d. -f2`
389                NEW_N=`printf "%04d" $((10#$LAST_N + 1))`
390                LOGFILE=${LOGDIR}/memcheck.${NEW_N}.xml
391                VALGRIND="valgrind --tool=memcheck --xml=yes --show-reachable=yes --error-limit=no --gen-suppressions=all --suppressions=$ESCRIPT_ROOT/scripts/escript.supp --leak-check=full --xml-file=$LOGFILE"
392                EXEC_CMD="$EXEC_CMD $VALGRIND"
393            fi
394        else
395            echo "Execution with valgrind requested but valgrind not in path!"
396            exit 1
397        fi
398    fi
399    
400  if [ ! -z $DO_BINARY ]  if [ ! -z $DO_BINARY ]
401  then  then
402      EXEC_CMD="$EXEC_CMD $@"      EXEC_CMD="$EXEC_CMD $@"

Legend:
Removed from v.4362  
changed lines
  Added in v.4506

  ViewVC Help
Powered by ViewVC 1.1.26