/[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 2349 by gross, Mon Mar 30 08:14:23 2009 UTC revision 2350 by gross, Tue Mar 31 08:26:05 2009 UTC
# Line 17  CURDIR=`pwd` Line 17  CURDIR=`pwd`
17  #Environment vars which control operations:  #Environment vars which control operations:
18  # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROC, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES  # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROC, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES
19    
20    HOSTFILE=/tmp/escript.$$
21    
22    
23  #Need to match if the name contains /  #Need to match if the name contains /
24  if [[ $0 =~ / ]]  if [[ $0 =~ / ]]
# Line 44  cd $CURDIR Line 46  cd $CURDIR
46  ##### End finding ESCRIPT_ROOT  ########  ##### End finding ESCRIPT_ROOT  ########
47    
48  PYTHON_MPI="$ESCRIPT_ROOT/lib/pythonMPI"  PYTHON_MPI="$ESCRIPT_ROOT/lib/pythonMPI"
49    PYTHON_CMD=python
50    
51  # if possible please express paths relative to $ESCRIPT_ROOT unless  # if possible please express paths relative to $ESCRIPT_ROOT unless
52  # they are in an unrelated location  # they are in an unrelated location
# Line 190  then Line 193  then
193      then      then
194          echo "Warning: MPI disabled but number of processors per node set. Option ignored."          echo "Warning: MPI disabled but number of processors per node set. Option ignored."
195      fi      fi
196        if [ ! -z $ESCRIPT_HOSTFILE ]
197        then
198            echo "Warning: MPI disabled but host file is given. Option ignored."
199        fi
200      ESCRIPT_NUM_NODES=1      ESCRIPT_NUM_NODES=1
201      ESCRIPT_NUM_PROCS=1      ESCRIPT_NUM_PROCS=1
202  else  else
203        if [ ! -z $ESCRIPT_HOSTFILE ]
204        then
205            if [ -f $ESCRIPT_HOSTFILE ]
206            then
207                cat $ESCRIPT_HOSTFILE | sort -u > $HOSTFILE
208                NUM_HOSTS = `wc -l $HOSTFILE`
209                if [ ! -z $ESCRIPT_NUM_NODES ]
210                then
211                    if [ $NUM_HOSTS -ne $ESCRIPT_NUM_NODES ]
212                    then
213                        echo "number of hosts selected in the host file $ESCRIPT_HOSTFILE needs to match the requested number of nodes $ESCRIPT_NUM_NODES."
214                        exit 1
215                    fi
216                 else
217                    ESCRIPT_NUM_NODES = $NUM_HOSTS
218                 fi
219            else
220               echo "cannot find hostfile $ESCRIPT_HOSTFILE."
221               exit 1
222            fi
223        else
224            HOSTFILE=''
225        fi
226    
227      if [ -z $ESCRIPT_NUM_NODES ]      if [ -z $ESCRIPT_NUM_NODES ]
228      then      then
229        ESCRIPT_NUM_NODES=1        ESCRIPT_NUM_NODES=1
230      fi      fi
231    
232      if [ -z $ESCRIPT_NUM_PROCS ]      if [ -z $ESCRIPT_NUM_PROCS ]
233      then      then
234        ESCRIPT_NUM_PROCS=1        ESCRIPT_NUM_PROCS=1
235      fi      fi
236    
237      if [ ! -z $ESCRIPT_VERBOSE  ]      if [ ! -z $ESCRIPT_VERBOSE  ]
238      then      then
239            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
240            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
241      fi      fi
242  fi  fi
243    
244  if [ ! -z $ESCRIPT_WITH_OPENMP ]  if [ ! -z $ESCRIPT_WITH_OPENMP ]
245  then  then
246     if [ -z $ESCRIPT_NUM_THREADS ]     if [ -z $ESCRIPT_NUM_THREADS ]
# Line 239  then Line 273  then
273    exit 1    exit 1
274  fi  fi
275  #=========================================================================================================  #=========================================================================================================
276    # Must have at least one command-line arg: the python script
277    if [ $# -eq 0 ]
278    then
279      if [ ! -z $DOBINARY ]
280      then
281        echo "No program to run was specified. Exiting."
282        exit 1
283      fi
284    fi
285    
286    #=========================================================================================================
287  if [ ! -z $DOBINARY ]  if [ ! -z $DOBINARY ]
288  then  then
289      PYTHON_CMD=""      EXEC_CMD="$@"
290  else  else
291      PYTHON_CMD=python      if [ $MPI_FLAVOUR  == "none" ]
     if [ $TOTPROC -gt 1 ]  
292      then      then
293          PYTHON_CMD="$PYTHONMPI $@"          # Check to see if the python version we were compiled with matches the one of EXEC_CMD
     else  
         # Check to see if the python version we were compiled with matches the one of PYTHON_CMD  
294          # 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
295          if [ -f $ESCRIPT_ROOT/lib/pyversion ]          if [ -f $ESCRIPT_ROOT/lib/pyversion ]
296          then          then
# Line 263  else Line 305  else
305          fi          fi
306      if [ ! -z $DOINTERACTIVE ]      if [ ! -z $DOINTERACTIVE ]
307          then          then
308             PYTHON_CMD="python -i $@"             EXEC_CMD="$PYTHON_CMD -i $@"
309          else          else
310             PYTHON_CMD="python $@"             EXEC_CMD="$PYTHON_CMD $@"
311          fi          fi
312        else
313            EXEC_CMD="$PYTHONMPI $@"
314      fi      fi
     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Python command is $PYTHON_CMD."; fi  
 fi  
 #=========================================================================================================  
 # Must have at least one command-line arg: the python script  
 if [ $# -eq 0 ]  
 then  
   if [ ! -z $DOBINARY ]  
   then  
     echo "No program to run was specified. Exiting."  
     exit 1  
   fi  
315  fi  fi
316    if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is $EXEC_CMD."; fi
317  #===============================================================================================  #===============================================================================================
318  #  #
319  #   now we start to spwan things:  #   now we start to spwan things:
# Line 292  fi Line 326  fi
326    
327  if [ $MPI_FLAVOUR  == "none" ]  if [ $MPI_FLAVOUR  == "none" ]
328  then  then
329     $PYTHON_CMD     $EXEC_CMD
330  elif [ $MPI_FLAVOUR == "OPENMPI" ]  elif [ $MPI_FLAVOUR == "OPENMPI" ]
331  then  then
332     echo "OPENMPI not implemented yet."     echo "OPENMPI not implemented yet."
333    
334  elif [ $MPI_FLAVOR == "MLP" ]  elif [ $MPI_FLAVOR == "MPT" ]
335  then  then
336     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
337     echo "MLP not implemented yet."     EXPORT_ENV="$EXPORT_ENV, MPI_NUM_MEMORY_REGIONS"
338       if [ -z $HOSTFILE ]
339       then
340          HOST_LIST=`awk 'BEGIN{S=""}{if (S == "") { S = $0 } else {S = S "," $0}}END{print S}' $HOSTFILE`
341          CMD="mpiexec $HOST_LIST $ESCRIPT_NUM_PROCS $EXEC_CMD"
342       else
343          CMD="mpiexec -np $TOTPROC -$EXEC_CMD"
344       fi
345       if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is $CMD."; fi
346       $CMD
347  elif [ $MPI_FLAVOR == "MPICH" ]  elif [ $MPI_FLAVOR == "MPICH" ]
348  then  then
349     echo "MPICH not implemented yet."     echo "MPICH not implemented yet."
# Line 313  exit 0 Line 355  exit 0
355  # Using OpenMP?  # Using OpenMP?
356  #OMP_OPTIONS=''  #OMP_OPTIONS=''
357  #if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then  #if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then
358  #  PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"  #  EXEC_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
359  #  ESCRIPT_NUM_THREADS=$OMP_NUM_THREADS  #  ESCRIPT_NUM_THREADS=$OMP_NUM_THREADS
360  #  OMP_OPTIONS="env OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS"  #  OMP_OPTIONS="env OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS"
361  #fi  #fi
362    
363  # Using MPI?  # Using MPI?
364  #if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then  #if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then
365  #  PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"  #  EXEC_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
366  #else  #else
367  #  if [ "$TOTPROC" -ne 1 ]; then  #  if [ "$TOTPROC" -ne 1 ]; then
368  #    echo "Escript/Finley was not compiled for MPI. You can not use the -n and -p options."  #    echo "Escript/Finley was not compiled for MPI. You can not use the -n and -p options."

Legend:
Removed from v.2349  
changed lines
  Added in v.2350

  ViewVC Help
Powered by ViewVC 1.1.26