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

Annotation of /trunk/scripts/finley_wrapper_template

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2294 - (hide annotations)
Mon Mar 2 03:44:27 2009 UTC (10 years, 6 months ago) by jfenwick
File size: 2273 byte(s)
Added instructions on how to install debian package to the install guide.
Wrapper script generation now produces two scripts (escript and finleypython).
The two are identical - eventually we will remove finleypython.

Modified the wrapper script so it will print a message and start the python interpreter if you don't specify a script.
1 ksteube 1756 #!/bin/sh
2    
3 ksteube 1824 # Escript/Finley wrapper for python
4     # Sets LD_LIBRARY_PATH and PYTHONPATH and then runs either python or the MPI launcher
5    
6 ksteube 1756 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 ksteube 1824 -l 'launcher' MPI launcher, usually -l 'mpirun -np' or -l 'mpiexec -n'
11 ksteube 1756 -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 ksteube 1912 export PATH="@@PATH@@"
27    
28 ksteube 1768 export LD_LIBRARY_PATH="@@LD_LIBRARY_PATH@@"
29 ksteube 1756
30 ksteube 1768 export PYTHONPATH="@@PYTHONPATH@@"
31 ksteube 1756
32 ksteube 1909 # Avoid bug in hybrid runs with MPT MPI
33     export MPI_NUM_MEMORY_REGIONS=0
34    
35 ksteube 1756 # Try to guess the MPI launcher (mpirun unless in PBS batch job in which case mpiexec)
36     mpi_launcher='mpirun -np'
37     if [ $?PBS_ENVIRONMENT ]; then
38     if [ "X_$PBS_ENVIRONMENT" = "X_PBS_BATCH" ]; then
39     mpi_launcher='mpiexec -n'
40     fi
41     fi
42    
43     PYTHON_MPI="$ESCRIPT_ROOT/lib/pythonMPI"
44     OMP_NUM_THREADS=1
45     MPI_NUM_PROCS=1
46    
47     # Parse the command-line options
48     while getopts 'L:P:O:M:l:' option
49     do
50     case "$option" in
51     "L") export LD_LIBRARY_PATH="$OPTARG:$LD_LIBRARY_PATH"
52     ;;
53     "P") export PYTHONPATH="$OPTARG:$PYTHONPATH"
54     ;;
55     "O") OMP_NUM_THREADS="$OPTARG"
56     ;;
57     "M") MPI_NUM_PROCS="$OPTARG"
58     ;;
59     "l") mpi_launcher="$OPTARG"
60     ;;
61     ?) echo "$HELP_TEXT"
62     exit 1
63     ;;
64     esac
65     done
66     shift `expr $OPTIND - 1`
67    
68     # Must have at least one command-line arg: the python script
69     if [ $# -eq 0 ]; then
70 jfenwick 2294 echo "No python script specified. Starting python interpreter."
71     # echo "Missing python script"
72     # echo "$HELP_TEXT"
73     # exit 1
74 ksteube 1756 fi
75    
76     # Using OpenMP?
77     OMP_OPTIONS=''
78     if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.openmp" ]; then
79 jfenwick 2102 # PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
80 ksteube 1756 OMP_OPTIONS="env OMP_NUM_THREADS=$OMP_NUM_THREADS"
81     fi
82    
83     # Using MPI?
84     if [ -f "$ESCRIPT_ROOT/lib/Compiled.with.mpi" ]; then
85     PYTHON_CMD="$mpi_launcher $MPI_NUM_PROCS $PYTHON_MPI"
86 ksteube 1912 else
87     if [ "$MPI_NUM_PROCS" -ne 1 ]; then
88     echo "Escript/Finley was not compiled for MPI so you must use -M 1"
89     exit 1
90     fi
91 ksteube 1756 fi
92    
93     set -x
94 ksteube 2110 $OMP_OPTIONS $PYTHON_CMD "$@"
95 ksteube 1756

  ViewVC Help
Powered by ViewVC 1.1.26