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"
77 echo "run $args" > $PWD/gdbCommands
78 echo "where" >> $PWD/gdbCommands
79 echo "Constructed gdb initialization file $PWD/gdbCommands"
81 $ECHO "Choose running method: 0)normal 1)gdb+xterm 2)gdb 3)log 4)log+xterm 5)xterm+valgrind: \c"
83 if [ "$method" -ne 0 -a "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 -a "$method" -ne 5 ]; then
88 $ECHO "Run all processes local or distributed? 1)local 2)remote: \c"
90 if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then
95 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
96 # check ~/.$WM_PROJECT/
97 # check <installedProject>/etc/
98 if [ "$WM_PROJECT" ]; then
101 $HOME/.WM_PROJECT
/$WM_PROJECT_VERSION \
103 $WM_PROJECT_DIR/etc \
106 if [ -f "$i/bashrc" ]; then
107 sourceFoam
="$i/bashrc"
113 # Construct test string for remote execution.
114 # Source OpenFOAM settings if OpenFOAM environment not set.
115 # attempt to preserve the installation directory 'FOAM_INST_DIR'
116 if [ "$FOAM_INST_DIR" ]; then
117 sourceFoam
='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam"
119 sourceFoam
='[ "$WM_PROJECT" ] || '". $sourceFoam"
122 echo "**sourceFoam:$sourceFoam"
124 rm -f $PWD/mpirun.schema
125 touch $PWD/mpirun.schema
130 for ((proc
=0; proc
<$nProcs; proc
++))
132 procCmdFile
="$PWD/processor${proc}.sh"
133 procLog
="processor${proc}.log"
134 geom
="-geometry 120x20+$xpos+$ypos"
137 if [ .
$WM_MPLIB = .OPENMPI
]; then
139 elif [ .
$WM_MPLIB = .LAM
]; then
140 if [ "$spawn" -eq 2 ]; then
145 echo "#!/bin/sh" > $procCmdFile
146 if [ "$method" -eq 0 ]; then
147 echo "$sourceFoam; cd $PWD; $exec $args | tee $procLog" >> $procCmdFile
148 echo "${node}$procCmdFile" >> $PWD/mpirun.schema
149 elif [ "$method" -eq 1 ]; then
150 echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile
151 #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile
152 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
153 elif [ "$method" -eq 2 ]; then
154 echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands >& $procLog" >> $procCmdFile
155 echo "${node}$procCmdFile" >> $PWD/mpirun.schema
156 elif [ "$method" -eq 3 ]; then
157 echo "$sourceFoam; cd $PWD; $exec $args >& $procLog" >> $procCmdFile
158 echo "${node}$procCmdFile" >> $PWD/mpirun.schema
159 elif [ "$method" -eq 4 ]; then
160 echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile
161 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
162 elif [ "$method" -eq 5 ]; then
163 echo "$sourceFoam; cd $PWD; valgrind $exec $args; read dummy" >> $procCmdFile
164 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
167 chmod +x
$procCmdFile
170 if [ $proc -ne 0 -a $column -eq 0 ]; then
178 for ((proc
=0; proc
<$nProcs; proc
++))
180 procLog
="processor${proc}.log"
181 echo " tail -f $procLog"
185 if [ .
$WM_MPLIB = .OPENMPI
]; then
186 cmd
="mpirun -app $PWD/mpirun.schema </dev/null"
187 elif [ .
$WM_MPLIB = .LAM
]; then
188 cmd
="mpirun $PWD/mpirun.schema </dev/null"
191 echo "Constructed $PWD/mpirun.schema file."
195 $ECHO "Press return to execute.\c"