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

Annotation of /branches/arrexp_2137_win_merge/scripts/finley_wrapper_template

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1756 - (hide annotations)
Mon Sep 8 01:45:46 2008 UTC (10 years, 8 months ago) by ksteube
Original Path: trunk/scripts/finley_wrapper_template
File size: 1880 byte(s)
First version of a wrapper script that sets LD_LIBRARY_PATH and PYTHONPATH

Not yet ready for general use

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

  ViewVC Help
Powered by ViewVC 1.1.26