/[escript]/trunk/scripts/finley_wrapper_template
ViewVC logotype

Diff of /trunk/scripts/finley_wrapper_template

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

revision 2331 by jfenwick, Tue Mar 17 01:42:02 2009 UTC revision 2332 by jfenwick, Tue Mar 24 01:13:08 2009 UTC
# Line 14  STANDALONE=0 Line 14  STANDALONE=0
14  scriptdir=""  scriptdir=""
15  CURDIR=`pwd`  CURDIR=`pwd`
16    
17    #Environment vars which control operations:
18    # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROC, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_STDFILES
19    
20    
21  #Need to match if the name contains /  #Need to match if the name contains /
22  if [[ $0 =~ / ]]  if [[ $0 =~ / ]]
23  then  then
# Line 66  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib: Line 70  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib:
70    
71  HELP_TEXT="  HELP_TEXT="
72  Usage: escript [options] script.py [arguments...]  Usage: escript [options] script.py [arguments...]
73      -O N        Use N OpenMP threads (OMP_NUM_THREADS=N)      -n nn       number of nodes to use
74      -M K        Use K MPI processes      -p np       number of MPI processes to spawn
75      -l 'launcher'   MPI launcher, usually -l 'mpirun -np' or -l 'mpiexec -n'      -t nt       number of OpenMP threads to use
76      -L /path    Prepend /path to library search path      -f file     name of MPI hostfile
77      -P /path    Prepend /path to python module search path      -c      print compile information for escript and exit
78      -e      Print export statements for environment and exit      -V      print escript version and exit
79        -i      interactive mode
80        -e      print export statements for environment and exit
81        -o      redirect output from MPI to files
82        -v      print diagnostics
83        -x      ..reserved for future use ..
84      script.py   Your python script      script.py   Your python script
85      arguments...    The optional command-line arguments to your python script      arguments...    The optional command-line arguments to your script
86  "  "
87    
88  if [ "$1" = "--help" ]; then  if [ "$1" = "--help" ]; then
# Line 100  MPI_NUM_PROCS=1 Line 109  MPI_NUM_PROCS=1
109    
110  # Parse the command-line options  # Parse the command-line options
111  # option e should not be followed by a :  # option e should not be followed by a :
112  while getopts 'L:P:O:M:l:e' option  while getopts 'n:p:t:f:h:ecVviox' option
113  do  do
114      case "$option" in      case "$option" in
115        "L")  EXTRA_LD_LIBRARY_PATH="$OPTARG:$EXTRA_LD_LIBRARY_PATH"        "n")  ESCRIPT_NUM_NODES=$OPTARG
116            ;;
117          "p")  ESCRIPT_NUM_PROC=$OPTARG
118            ;;
119          "t")  ESCRIPT_NUM_THREADS=$OPTARG
120          ;;          ;;
121        "P")  EXTRA_PYTHONPATH="$OPTARG:$EXTRA_PYTHONPATH"        "f")  ESCRIPT_HOSTFILE=$OPTARG
122          ;;          ;;
123        "O")  OMP_NUM_THREADS="$OPTARG"        "c")  cat $ESCRIPT_ROOT/lib/buildvars
124            exit 0
125            ;;
126          "V")  echo "escript-pre2.0(build "`grep svn_revision $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`")"
127            exit 0
128          ;;          ;;
129        "M")  MPI_NUM_PROCS="$OPTARG"        "h")  echo "$HELPTEXT"
130            exit 0
131          ;;          ;;
132        "l")  mpi_launcher="$OPTARG"        "i")  DOINTERACTIVE=yes
133          ;;          ;;
134        "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"
135          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
# Line 122  do Line 140  do
140          fi          fi
141          exit 0          exit 0
142          ;;          ;;
143          "o")  ESCRIPT_STDFILES="yes"
144            ;;
145          "v")  echo "Diagnostics:"
146            exit 0
147            ;;
148          "x")  echo "-x not implemented yet"
149            exit 1
150            ;;
151        ?)    echo "$HELP_TEXT"        ?)    echo "$HELP_TEXT"
152          exit 1          exit 1
153          ;;          ;;
# Line 129  do Line 155  do
155  done  done
156  shift `expr $OPTIND - 1`  shift `expr $OPTIND - 1`
157    
158    
159    
160    
161  export PATH=$EXTRA_PATH:$PATH  export PATH=$EXTRA_PATH:$PATH
162  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
163  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
# Line 153  fi Line 182  fi
182  # Must have at least one command-line arg: the python script  # Must have at least one command-line arg: the python script
183  if [ $# -eq 0 ]; then  if [ $# -eq 0 ]; then
184    echo "No python script specified. Starting python interpreter."    echo "No python script specified. Starting python interpreter."
185  #   echo "Missing python script"  fi
186  #   echo "$HELP_TEXT"  
187  #   exit 1  #Ensure the variables have sensible values
188    if [ -z $ESCRIPT_NUM_NODES ]
189    then
190      ESCRIPT_NUM_NODES=1
191    fi
192    
193    if [ -z $ESCRIPT_NUM_PROCS ]
194    then
195      ESCRIPT_NUM_PROCS=1
196    fi
197    
198    if [ -z $ESCRIPT_NUM_THREADS ]
199    then
200      ESCRIPT_NUM_THREADS=$OMP_NUM_THREADS
201      if [ -z $ESCRIPT_NUM_THREADS ]
202      then
203        ESCRIPT_NUM_THREADS=1
204      fi
205    fi
206    
207    #Now we compute total number of Processes
208    (( TOTPROC=$ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS))
209    if [ $? -ne 0 ]     #Some compute error
210    then            #This could happen if the args were not a number
211      ESCRIPT_NUM_NODES=1
212      ESCRIPT_NUM_PROCS=1
213    fi
214    
215    # Test to ensure people aren't trying to combine interactive and multi-process
216    
217    if [[ ( ( -z $DOINTERACTIVE ) || ( $# -eq 0 ) ) && ( $TOTPROC -gt 1) ]]
218    then
219      echo "Interactive mode cannot be used with more than one process"
220      exit 1
221  fi  fi
222    
223  # Using OpenMP?  # Using OpenMP?
224  OMP_OPTIONS=''  OMP_OPTIONS=''
225  if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then  if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then
226  #  PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"  #  PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
227    OMP_OPTIONS="env OMP_NUM_THREADS=$OMP_NUM_THREADS"    OMP_OPTIONS="env OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS"
228  fi  fi
229    
230  # Using MPI?  # Using MPI?
231  if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then  if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then
232    PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"    PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
233  else  else
234    if [ "$MPI_NUM_PROCS" -ne 1 ]; then    if [ "$TOTPROC" -ne 1 ]; then
235      echo "Escript/Finley was not compiled for MPI so you must use -M 1"      echo "Escript/Finley was not compiled for MPI. You can not use the -n and -p options."
236      exit 1      exit 1
237    fi    fi
238  fi  fi

Legend:
Removed from v.2331  
changed lines
  Added in v.2332

  ViewVC Help
Powered by ViewVC 1.1.26