3 # Driver script to run mpi jobs with the processes in separate
4 # windows or to separate log files.
5 # Requires bash on all processors.
11 if [ `uname -s` = 'Linux' ]; then
20 echo "Usage: $PROGNAME -np <dd> <executable> <args>"
22 echo "This will run like mpirun but with each process in an xterm"
29 while [ "$1" != "" ]; do
36 if [ ! "$exec" ]; then
38 elif [ ! "$args" ]; then
53 if [ ! "$nProcs" ]; then
57 if [ ! "$args" ]; then
61 if [ ! "$exec" ]; then
67 if [ ! -x "$exec" ]; then
68 echo "Cannot find executable $exec or is not executable"
75 echo "run $args" > $HOME/gdbCommands
76 echo "where" >> $HOME/gdbCommands
77 echo "Constructed gdb initialization file $HOME/gdbCommands"
79 $ECHO "Choose running method: 1)gdb+xterm 2)gdb 3)log 4)xterm+valgrind: \c"
81 if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 ]; then
86 $ECHO "Run all processes local or distributed? 1)local 2)remote: \c"
88 if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then
93 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
94 # check ~/.$WM_PROJECT/
95 # check <installedProject>/etc/
96 if [ "$WM_PROJECT" ]; then
99 $HOME/.WM_PROJECT
/$WM_PROJECT_VERSION \
101 $WM_PROJECT_DIR/etc \
104 if [ -f "$i/bashrc" ]; then
105 sourceFoam
="$i/bashrc"
111 # Construct test string for remote execution.
112 # Source OpenFOAM settings if OpenFOAM environment not set.
113 # attempt to preserve the installation directory 'FOAM_INST_DIR'
114 if [ "$FOAM_INST_DIR" ]; then
115 sourceFoam
='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam"
117 sourceFoam
='[ "$WM_PROJECT" ] || '". $sourceFoam"
120 echo "**sourceFoam:$sourceFoam"
122 rm -f $HOME/mpirun.schema
123 touch $HOME/mpirun.schema
128 for ((proc
=0; proc
<$nProcs; proc
++))
130 procCmdFile
="$HOME/processor${proc}.sh"
131 procLog
="processor${proc}.log"
132 geom
="-geometry 120x20+$xpos+$ypos"
135 if [ .
$WM_MPLIB = .OPENMPI
]; then
137 elif [ .
$WM_MPLIB = .LAM
]; then
138 if [ "$spawn" -eq 2 ]; then
143 echo "#!/bin/sh" > $procCmdFile
144 if [ "$method" -eq 1 ]; then
145 echo "$sourceFoam; cd $PWD; gdb -command $HOME/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile
146 #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile
147 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema
148 elif [ "$method" -eq 2 ]; then
149 echo "$sourceFoam; cd $PWD; gdb -command $HOME/gdbCommands >& $procLog" >> $procCmdFile
150 echo "${node}$procCmdFile" >> $HOME/mpirun.schema
151 elif [ "$method" -eq 3 ]; then
152 echo "$sourceFoam; cd $PWD; $exec $args >& $procLog" >> $procCmdFile
153 echo "${node}$procCmdFile" >> $HOME/mpirun.schema
154 elif [ "$method" -eq 4 ]; then
155 echo "$sourceFoam; cd $PWD; valgrind $exec $args; read dummy" >> $procCmdFile
156 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema
159 chmod +x
$procCmdFile
162 if [ $proc -ne 0 -a $column -eq 0 ]; then
170 for ((proc
=0; proc
<$nProcs; proc
++))
172 procLog
="processor${proc}.log"
173 echo " tail -f $procLog"
176 $ECHO "Constructed $HOME/mpirun.schema file. Press return to execute.\c"
178 if [ .
$WM_MPLIB = .OPENMPI
]; then
179 mpirun
-app $HOME/mpirun.schema
</dev
/null
180 elif [ .
$WM_MPLIB = .LAM
]; then
181 mpirun
$HOME/mpirun.schema
</dev
/null