/[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

trunk/bin/escript revision 2462 by jfenwick, Fri Jun 5 06:04:01 2009 UTC branches/py3_attempt2/bin/run-escript revision 3871 by jfenwick, Thu Mar 15 07:06:51 2012 UTC
# Line 6  Line 6 
6  #Extra paths can be configured about a page further down  #Extra paths can be configured about a page further down
7  #Search for EXTRA_PATH=""  #Search for EXTRA_PATH=""
8    
9  #set to 1 if performing this is a standalone build and /packages contains the relevant tools  #set to 1 if performing this is a standalone build and ../../pkg contains the relevant tools
10  STANDALONE=0  STANDALONE=0
11    
12  #set to 1 if this is part of a packaged build (.deb) and files will be installed in standard locations  #set to 1 if this is part of a packaged build (.deb) and files will be installed in standard locations
# Line 22  CURDIR=`pwd` Line 22  CURDIR=`pwd`
22  #Environment vars which control operations:  #Environment vars which control operations:
23  # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROCS, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES  # ESCRIPT_NUM_NODES, ESCRIPT_NUM_PROCS, ESCRIPT_NUM_THREADS, ESCRIPT_HOSTFILE, ESCRIPT_CREATESTDFILES
24    
25  HOSTFILE=/tmp/escript.$$  HOSTFILE=/tmp/escript.$USER.$$
26  HOSTFILE2=/tmp/escript2.$$  HOSTFILE2=/tmp/escript2.$USER.$$
27    
28  #Begin finding ESCRIPT_ROOT  #Begin finding ESCRIPT_ROOT
29  if [ $STDLOCATION != 0 ]  if [ $STDLOCATION -ne 0 ]
30  then  then
31      ESCRIPT_ROOT=/usr/lib/escript      ESCRIPT_ROOT=/usr/lib/escript
32  else  else
# 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`
44        if [ $? != 0 ]        if [ $? -ne 0 ]
45        then        then
46            echo "Error unable to determine script directory. Exiting."            echo "Error! Unable to determine script directory. Exiting."
47        exit 1            exit 1
48        fi        fi
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    
61    
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"
65  PYTHON_CMD=python  PYTHON_CMD=python3
66    
67  # if possible please express paths relative to $ESCRIPT_ROOT unless  # if possible please express paths relative to $ESCRIPT_ROOT unless
68  # they are in an unrelated location  # they are in an unrelated location
# Line 70  EXTRA_PATH=$ESCRIPT_ROOT/bin Line 72  EXTRA_PATH=$ESCRIPT_ROOT/bin
72  EXTRA_PYTHONPATH=$ESCRIPT_ROOT  EXTRA_PYTHONPATH=$ESCRIPT_ROOT
73  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib  EXTRA_LD_LIBRARY_PATH=$ESCRIPT_ROOT/lib
74    
75  if [ $STANDALONE == 1 ]  if [ $STANDALONE -eq 1 ]
76  then  then
77      EXTRA_PATH=$ESCRIPT_PARENT/packages/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/packages/boost/lib:$ESCRIPT_PARENT/packages/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=$ESCRIPT_PARENT/packages/vtk/lib/vtk-5.2:$ESCRIPT_PARENT/packages/mesa/lib:$EXTRA_LD_LIBRARY_PATH      EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH
80      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/packages/python/lib:$EXTRA_LD_LIBRARY_PATH      EXTRA_LD_LIBRARY_PATH=$ESCRIPT_PARENT/pkg/python/lib:$EXTRA_LD_LIBRARY_PATH
81      EXTRA_PYTHONPATH=$ESCRIPT_PARENT/packages/numpy/lib/python2.6/site-packages:$ESCRIPT_PARENT/packages/vtk/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
107    #
108    WITH_VISIT=`get_buildvar visit`
109    if [ "$WITH_VISIT" = "1" ]; then
110        VISIT_BIN=`which visit`
111        if [ $? -eq 0 ]; then
112            VISIT_PY_PATH=`$VISIT_BIN -env | grep LIBPATH | cut -d= -f2`
113            EXTRA_PYTHONPATH=$EXTRA_PYTHONPATH:$VISIT_PY_PATH
114            EXTRA_LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$VISIT_PY_PATH
115        elif [ ! -z $ESCRIPT_VERBOSE ]; then
116            echo "VisIt module enabled but VisIt not in path!"
117        fi
118    fi
119    
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 126  do Line 162  do
162        "c")  cat $ESCRIPT_ROOT/lib/buildvars        "c")  cat $ESCRIPT_ROOT/lib/buildvars
163          exit 0          exit 0
164          ;;          ;;
165        "V")  echo "escript-pre2.0(build "`grep svn_revision $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`")"        "V")  echo "escript-development(build "`get_buildvar svn_revision`")"
166          exit 0          exit 0
167          ;;          ;;
168        "h")  echo "$HELPTEXT"        "h")  echo "$HELPTEXT"
# Line 137  do Line 173  do
173        "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"
174          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"          echo "export PYTHONPATH=$EXTRA_PYTHONPATH:\$PYTHONPATH"
175          echo "export PATH=$EXTRA_PATH:\$PATH"          echo "export PATH=$EXTRA_PATH:\$PATH"
176          if [ `uname` == Darwin ]          if [ "`uname`" = "Darwin" ]
177          then          then
178              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"              echo "export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:\$DYLD_LIBRARY_PATH"
179          fi          fi
# Line 158  done Line 194  done
194  shift `expr $OPTIND - 1`  shift `expr $OPTIND - 1`
195  #==============================================  #==============================================
196  #  #
197  #   Read the MPI_FLAVOUR from the buildvars  #   Read MPI_FLAVOUR and WITH_OPENMP from the buildvars
198  #  #
199  MPI_FLAVOUR=`grep mpi_flavour $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  MPI_FLAVOUR=`get_buildvar mpi`
200  WITH_OPENMP=`grep useopenmp $ESCRIPT_ROOT/lib/buildvars |cut -d= -f2`  WITH_OPENMP=`get_buildvar openmp`
201    
202    if [ ! -z $ESCRIPT_VERBOSE ]; then
203        echo "MPI flavour is $MPI_FLAVOUR."
204        if [ "$WITH_OPENMP" = "1" ]; then echo "OpenMP enabled."; fi
205    fi
206    
 if [ ! -z $ESCRIPT_VERBOSE  ]; then echo "MPI flavor is $MPI_FLAVOUR."; fi  
 if [ ! -z $ESCRIPT_VERBOSE ] && [  $WITH_OPENMP == "y"  ]; then echo "OpenMP enabled."; fi  
207  #  #
208  #  extend path variables  #  extend path variables
209  #  #
# Line 172  export PATH=$EXTRA_PATH:$PATH Line 211  export PATH=$EXTRA_PATH:$PATH
211  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH  export LD_LIBRARY_PATH=$EXTRA_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
212  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH  export PYTHONPATH=$EXTRA_PYTHONPATH:$PYTHONPATH
213  EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"  EXPORT_ENV="PATH,LD_LIBRARY_PATH,PYTHONPATH"
214  if [ `uname` == Darwin ]  if [ "`uname`" = "Darwin" ]
215  then  then
216      export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH      export DYLD_LIBRARY_PATH=$EXTRA_DYLD_LIBRARY_PATH:$EXTRA_LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH
217      EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"      EXPORT_ENV="$EXPORT_ENV,DYLD_LIBRARY_PATH"
218  fi  fi
219  if [ ! -z $ESCRIPT_VERBOSE  ]  if [ ! -z $ESCRIPT_VERBOSE ]
220  then  then
221      echo "PATH = $PATH "      echo "PATH = $PATH "
222      echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "      echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH "
# Line 188  fi Line 227  fi
227  #  #
228  #  Ensure the variables have sensible values  #  Ensure the variables have sensible values
229  #  #
230  if [ $MPI_FLAVOUR  == "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
231  then  then
232      if [ ! -z $ESCRIPT_NUM_NODES ]      if [ ! -z $ESCRIPT_NUM_NODES ]
233      then      then
# Line 205  then Line 244  then
244      ESCRIPT_NUM_NODES=1      ESCRIPT_NUM_NODES=1
245      ESCRIPT_NUM_PROCS=1      ESCRIPT_NUM_PROCS=1
246  else  else
247        # use the PBS_NODEFILE if not otherwise specified
248        if [[ ( ! -z $PBS_NODEFILE ) && ( -z $ESCRIPT_HOSTFILE ) ]]
249        then
250            ESCRIPT_HOSTFILE=$PBS_NODEFILE
251        fi
252    
253      if [ ! -z $ESCRIPT_HOSTFILE ]      if [ ! -z $ESCRIPT_HOSTFILE ]
254      then      then
255          if [ -f $ESCRIPT_HOSTFILE ]          if [ -f $ESCRIPT_HOSTFILE ]
# Line 231  else Line 276  else
276    
277      if [ -z $ESCRIPT_NUM_NODES ]      if [ -z $ESCRIPT_NUM_NODES ]
278      then      then
279        ESCRIPT_NUM_NODES=1          ESCRIPT_NUM_NODES=1
280      fi      fi
281    
282      if [ -z $ESCRIPT_NUM_PROCS ]      if [ -z $ESCRIPT_NUM_PROCS ]
283      then      then
284        ESCRIPT_NUM_PROCS=1          ESCRIPT_NUM_PROCS=1
285      fi      fi
286    
287      if [ ! -z $ESCRIPT_VERBOSE  ]      if [ ! -z $ESCRIPT_VERBOSE ]
288      then      then
289            echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "          echo "ESCRIPT_NUM_NODES = $ESCRIPT_NUM_NODES "
290            echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "          echo "ESCRIPT_NUM_PROCS = $ESCRIPT_NUM_PROCS "
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 273  fi Line 318  fi
318  (( TOTPROC=$ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS))  (( TOTPROC=$ESCRIPT_NUM_NODES * $ESCRIPT_NUM_PROCS))
319  if [ $? -ne 0 ]     #Some compute error  if [ $? -ne 0 ]     #Some compute error
320  then            #This could happen if the args were not a number  then            #This could happen if the args were not a number
321    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."
322    exit 1      exit 1
323  fi  fi
324    
325  #  #
# Line 282  fi Line 327  fi
327  #  #
328  if [[ ( ( ! -z $DOINTERACTIVE ) || ( $# -eq 0 ) ) && ( $TOTPROC -gt 1) ]]  if [[ ( ( ! -z $DOINTERACTIVE ) || ( $# -eq 0 ) ) && ( $TOTPROC -gt 1) ]]
329  then  then
330    echo "Interactive mode cannot be used with more than one process"      echo "Interactive mode cannot be used with more than one process"
331    exit 1      exit 1
332  fi  fi
333    
334  if [ $TOTPROC -gt 1 ]  if [ $TOTPROC -gt 1 ]
335  then  then
336     if [ "$ESCRIPT_CREATESTDFILES" == "yes" ]      if [ "$ESCRIPT_CREATESTDFILES" = "yes" ]
337     then      then
338         PYTHON_MPI=$PYTHON_MPI_REDIRECT          PYTHON_MPI=$PYTHON_MPI_REDIRECT
339     else      else
340         PYTHON_MPI=$PYTHON_MPI_NULL          PYTHON_MPI=$PYTHON_MPI_NULL
341     fi      fi
342  else  else
343      PYTHON_MPI=$PYTHON_MPI_NULL      PYTHON_MPI=$PYTHON_MPI_NULL
344  fi  fi
# Line 301  fi Line 346  fi
346  # Must have at least one command-line arg: the python script  # Must have at least one command-line arg: the python script
347  if [ $# -eq 0 ]  if [ $# -eq 0 ]
348  then  then
349    if [ ! -z $DOBINARY ]      if [ ! -z $DOBINARY ]
350    then      then
351      echo "No program to run was specified. Exiting."          echo "No program to run was specified. Exiting."
352      exit 1          exit 1
353    fi      else
354            DOINTERACTIVE="yes"
355        fi
356  fi  fi
357    
358  #=========================================================================================================  #=========================================================================================================
# Line 313  if [ ! -z $DOBINARY ] Line 360  if [ ! -z $DOBINARY ]
360  then  then
361      EXEC_CMD="$@"      EXEC_CMD="$@"
362  else  else
363      if [ $MPI_FLAVOUR  == "none" ]      # Check to see if the python version we were compiled with matches the
364        # one of PYTHON_CMD.
365        compversion=`get_buildvar python_version | cut -d. -f1,2`
366    
367        intversion=`$PYTHON_CMD -c 'from __future__ import print_function;import sys;print("%d.%d"%(sys.version_info[0], sys.version_info[1]))'`
368        if [ "$compversion" != "$intversion" ]
369      then      then
370          # Check to see if the python version we were compiled with matches the one of EXEC_CMD          echo "Python versions do not match. Escript was compiled for "$compversion"."
371          # We should only do this check if they are running a python script          echo "Current version of Python appears to be "$intversion"."
372          if [ -f $ESCRIPT_ROOT/lib/pyversion ]          exit 1
373          then      fi
374             compversion=`cat $ESCRIPT_ROOT/lib/pyversion`      if [ "$MPI_FLAVOUR" = "none" ]
375             intversion=`$PYTHON_CMD -V 2>&1`      then
376             if [ "$compversion" != "$intversion" ]          if [ ! -z $DOINTERACTIVE ]
            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 ]  
377          then          then
378             EXEC_CMD="$PYTHON_CMD -i $@"             EXEC_CMD="$PYTHON_CMD -i $@"
379          else          else
380             EXEC_CMD="$PYTHON_CMD $@"             EXEC_CMD="$PYTHON_CMD $@"
381          fi          fi
382      else      else
383          EXEC_CMD="$PYTHON_MPI $@"          if [ ! -z $DOINTERACTIVE ]
384            then
385               EXEC_CMD="$PYTHON_MPI -i $@"
386            else
387               EXEC_CMD="$PYTHON_MPI $@"
388            fi
389      fi      fi
390  fi  fi
391  if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi  if [ ! -z $ESCRIPT_VERBOSE ]; then echo "Command to be executed is \"$EXEC_CMD\"."; fi
# Line 343  if [ ! -z $ESCRIPT_VERBOSE ]; then echo Line 393  if [ ! -z $ESCRIPT_VERBOSE ]; then echo
393  #  #
394  #   now we start to spwan things:  #   now we start to spwan things:
395  #  #
396  if [  $WITH_OPENMP == "y"  ]  if [ "$WITH_OPENMP" = "1" ]
397  then  then
398     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS     export OMP_NUM_THREADS=$ESCRIPT_NUM_THREADS
399     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"     EXPORT_ENV="$EXPORT_ENV,OMP_NUM_THREADS"
400  fi  fi
401  EXIT_CODE=1  EXIT_CODE=1
402  #=============== no MPI ===================================  #=============== no MPI ===================================
403  if [ $MPI_FLAVOUR  == "none" ]  if [ "$MPI_FLAVOUR" = "none" ]
404  then  then
405     $EXEC_CMD     $EXEC_CMD
406     EXIT_CODE=$?     EXIT_CODE=$?
407  #=============== OpenMPI ===================================  #=============== OpenMPI ===================================
408  elif [ $MPI_FLAVOUR == "OPENMPI" ]  elif [ "$MPI_FLAVOUR" = "OPENMPI" ]
409  then  then
410     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
411     then     then
412        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`
413        CMD="mpirun  --bynode -np $TOTPROC --host $HOST_LIST $EXEC_CMD"        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } --bynode -np $TOTPROC --host $HOST_LIST $EXEC_CMD"
414     else     else
415        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun --gmca mpi_warn_on_fork 0 -x ${EXPORT_ENV//,/ -x } -np $TOTPROC $EXEC_CMD"
416     fi     fi
417     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
418     $CMD     $CMD
419     EXIT_CODE=$?     EXIT_CODE=$?
420    
421  #=============== Intel MPI ===================================  #=============== Intel MPI ===================================
422  elif [ $MPI_FLAVOUR == "INTELMPI" ]  elif [ "$MPI_FLAVOUR" = "INTELMPI" ]
423  then  then
424    
425       if [ "$WITH_OPENMP" = "1" ]
426       then
427           export I_MPI_PIN_DOMAIN=omp
428           EXPORT_ENV="$EXPORT_ENV, I_MPI_PIN_DOMAIN"
429       fi
430    
431     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
432     then     then
433        mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f $HOSTFILE        mpdboot -n $ESCRIPT_NUM_NODES -r ssh -f $HOSTFILE
# Line 381  then Line 438  then
438        else        else
439            if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi            if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
440        fi        fi
441       else
442          mpdboot -n 1 -r ssh
443          if [ $? -ne 0 ]
444          then
445             echo "mpdboot failed."
446             exit 1
447          else
448              if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
449          fi
450     fi     fi
451     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"     CMD="mpiexec -perhost $ESCRIPT_NUM_PROCS -envall -n $TOTPROC $EXEC_CMD"
452     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
453     $CMD     $CMD
454     EXIT_CODE=$?     EXIT_CODE=$?
455     if [ ! -z $HOSTFILE ]     mpdallexit
456     then     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
        mpdallexit  
        if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
    fi  
457  #=============== SGI's MPIMPT ===================================  #=============== SGI's MPIMPT ===================================
458  elif [ $MPI_FLAVOUR == "MPT" ]  elif [ "$MPI_FLAVOUR" = "MPT" ]
459  then  then
460     export MPI_NUM_MEMORY_REGIONS=0     export MPI_NUM_MEMORY_REGIONS=0
461     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"     EXPORT_ENV="$EXPORT_ENV,MPI_NUM_MEMORY_REGIONS"
462     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
463     then     then
464        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`
465        CMD="mpirun $HOST_LIST $ESCRIPT_NUM_PROCS $EXEC_CMD"        CMD="mpirun $HOST_LIST -np $ESCRIPT_NUM_PROCS $EXEC_CMD"
466     else     else
467        CMD="mpirun -np $TOTPROC $EXEC_CMD"        CMD="mpirun -np $TOTPROC $EXEC_CMD"
468     fi     fi
# Line 407  then Line 470  then
470     $CMD     $CMD
471     EXIT_CODE=$?     EXIT_CODE=$?
472  #=============== MPICH ===================================  #=============== MPICH ===================================
473  elif [ $MPI_FLAVOUR == "MPICH" ]  elif [ "$MPI_FLAVOUR" = "MPICH" ]
474  then  then
475     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
476     then     then
# Line 421  then Line 484  then
484     $CMD     $CMD
485     EXIT_CODE=$?     EXIT_CODE=$?
486  #=============== MPICH2 ===================================  #=============== MPICH2 ===================================
487  elif [ $MPI_FLAVOUR == "MPICH2" ]  elif [ "$MPI_FLAVOUR" = "MPICH2" ]
488  then  then
489     if [ ! -z $HOSTFILE ]     if [ ! -z $HOSTFILE ]
490     then     then
# Line 433  then Line 496  then
496           else           else
497               if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi               if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started with host file $ESCRIPT_HOSTFILE for $ESCRIPT_NUM_NODES nodes."; fi
498           fi           fi
499       else
500          mpdboot -n 1 -r ssh
501          if [ $? -ne 0 ]
502          then
503             echo "mpdboot failed."
504             exit 1
505          else
506              if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdboot was started."; fi
507          fi
508     fi     fi
509     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"     CMD="mpiexec -genvlist $EXPORT_ENV -np $TOTPROC $EXEC_CMD"
510     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "MPI command is \"$CMD\"."; fi
511     $CMD     $CMD
512     EXIT_CODE=$?     EXIT_CODE=$?
513     if [ ! -z $HOSTFILE ]     mpdallexit
514     then     if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi
        mpdallexit  
        if [ ! -z $ESCRIPT_VERBOSE ]; then echo "mpdallexit executed."; fi  
    fi  
515  else  else
516     echo "unknown MPI falvour $MPI_FLAVOUR."     echo "unknown MPI flavour '$MPI_FLAVOUR'."
517  fi  fi
518  exit $EXIT_CODE  exit $EXIT_CODE

Legend:
Removed from v.2462  
changed lines
  Added in v.3871

  ViewVC Help
Powered by ViewVC 1.1.26