/[escript]/branches/more_shared_ptrs_from_1812/scripts/finley_wrapper_template
ViewVC logotype

Contents of /branches/more_shared_ptrs_from_1812/scripts/finley_wrapper_template

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1850 - (show annotations)
Mon Oct 6 03:07:02 2008 UTC (10 years, 6 months ago) by jfenwick
File size: 1977 byte(s)
Branch commit
Merging trunk changes upto and including 1849.

1 #!/bin/sh
2
3 # Escript/Finley wrapper for python
4 # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
5
6 HELP_TEXT="
7 Usage: escript [options] script.py [arguments...]
8 -O N Use N OpenMP threads (OMP_NUM_THREADS=N)
9 -M K Use K MPI processes
10 -l 'launcher' MPI launcher, usually -l 'mpirun -np' or -l 'mpiexec -n'
11 -L /path Prepend /path to library search path
12 -P /path Prepend /path to python module search path
13 script.py Your python script
14 arguments... The optional command-line arguments to your python script
15 "
16
17 if [ "$1" = "--help" ]; then
18 echo "$HELP_TEXT"
19 exit 0
20 fi
21
22 PYTHON_CMD="@@PYTHON_CMD@@"
23
24 ESCRIPT_ROOT="@@ESCRIPT_ROOT@@"
25
26 export LD_LIBRARY_PATH="@@LD_LIBRARY_PATH@@"
27
28 export PYTHONPATH="@@PYTHONPATH@@"
29
30 # Try to guess the MPI launcher (mpirun unless in PBS batch job in which case mpiexec)
31 mpi_launcher='mpirun -np'
32 if [ $?PBS_ENVIRONMENT ]; then
33 if [ "X_$PBS_ENVIRONMENT" = "X_PBS_BATCH" ]; then
34 mpi_launcher='mpiexec -n'
35 fi
36 fi
37
38 PYTHON_MPI="$ESCRIPT_ROOT/lib/pythonMPI"
39 OMP_NUM_THREADS=1
40 MPI_NUM_PROCS=1
41
42 # Parse the command-line options
43 while getopts 'L:P:O:M:l:' option
44 do
45 case "$option" in
46 "L") export LD_LIBRARY_PATH="$OPTARG:$LD_LIBRARY_PATH"
47 ;;
48 "P") export PYTHONPATH="$OPTARG:$PYTHONPATH"
49 ;;
50 "O") OMP_NUM_THREADS="$OPTARG"
51 ;;
52 "M") MPI_NUM_PROCS="$OPTARG"
53 ;;
54 "l") mpi_launcher="$OPTARG"
55 ;;
56 ?) echo "$HELP_TEXT"
57 exit 1
58 ;;
59 esac
60 done
61 shift `expr $OPTIND - 1`
62
63 # Must have at least one command-line arg: the python script
64 if [ $# -eq 0 ]; then
65 echo "Missing python script"
66 echo "$HELP_TEXT"
67 exit 1
68 fi
69
70 # Using OpenMP?
71 OMP_OPTIONS=''
72 if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then
73 PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
74 OMP_OPTIONS="env OMP_NUM_THREADS=$OMP_NUM_THREADS"
75 fi
76
77 # Using MPI?
78 if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then
79 PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
80 fi
81
82 set -x
83 $OMP_OPTIONS time $PYTHON_CMD "$@"
84

  ViewVC Help
Powered by ViewVC 1.1.26