Debian Codegraph @

python/test/unit/mpipipe.sh

raw
1 #!/bin/sh
2
3 # Copyright (C) 2015 Martin Alnæs
4 # Copyright (C) 2015 Johannes Ring
5 #
6 # This file is part of DOLFIN.
7 #
8 # DOLFIN is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # DOLFIN is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
20
21 # This script redirects output from a command to output.MYRANK
22
23 # See: http://docs.roguewave.com/threadspotter/2012.1/linux/manual_html/apas03.html
24 if [ ! -z $OMPI_COMM_WORLD_RANK ]; then
25 MYRANK=$OMPI_COMM_WORLD_RANK
26 elif [ ! -z $PMI_RANK ]; then
27 MYRANK=$PMI_RANK
28 else
29 MYRANK=`python -c "import dolfin;c=dolfin.mpi_comm_world();r=dolfin.MPI.rank(c);print(r);dolfin.MPI.barrier(c)"`
30 fi
31
32 OUT=output.$MYRANK
33 echo My rank is $MYRANK, writing to $OUT
34 if [ $MYRANK -eq 0 ]; then
35 $@ | tee $OUT
36 else
37 $@ > $OUT
38 fi