2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
8 #-------------------------------------------------------------------------------
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
29 # Driver script to run mpi jobs with the processes in separate
30 # windows or to separate log files.
31 # Requires bash on all processors.
32 #------------------------------------------------------------------------------
34 if [ `uname -s` = Linux
]
46 Usage: ${0##*/} -np <dd> <executable> <args>
48 * This will run like mpirun but with each process in an XTerm
54 unset nProcs
exec args
83 [ "$nProcs" ] || usage
90 echo "Cannot find executable $exec or is not executable"
99 echo "run $args" > $PWD/gdbCommands
100 echo "where" >> $PWD/gdbCommands
101 echo "Constructed gdb initialization file $PWD/gdbCommands"
103 $ECHO "Choose running method: 0)normal 1)gdb+xterm 2)gdb 3)log 4)log+xterm 5)xterm+valgrind: \c"
106 0 |
1 |
2 |
3 |
4 |
5 )
114 $ECHO "Run all processes local or distributed? 1)local 2)remote: \c"
116 if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]
122 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
123 # check ~/.$WM_PROJECT/
124 # check <installedProject>/etc/
129 $HOME/.WM_PROJECT
/$WM_PROJECT_VERSION \
131 $WM_PROJECT_DIR/etc \
134 if [ -f "$i/bashrc" ]
136 sourceFoam
="$i/bashrc"
142 # Construct test string for remote execution.
143 # Source OpenFOAM settings if OpenFOAM environment not set.
144 # attempt to preserve the installation directory 'FOAM_INST_DIR'
145 # use FOAM_SETTINGS to pass command-line settings
146 if [ "$FOAM_INST_DIR" ]
148 sourceFoam
="FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
150 sourceFoam
=". $sourceFoam $FOAM_SETTINGS"
153 echo "**sourceFoam:$sourceFoam"
155 rm -f $PWD/mpirun.schema
156 touch $PWD/mpirun.schema
161 for ((proc
=0; proc
<$nProcs; proc
++))
163 procCmdFile
="$PWD/processor${proc}.sh"
164 procLog
="processor${proc}.log"
165 geom
="-geometry 120x15+$xpos+$ypos"
175 echo "#!/bin/bash" > $procCmdFile
178 echo "$sourceFoam; cd $PWD; $exec $args | tee $procLog" >> $procCmdFile
179 echo "${node}$procCmdFile" >> $PWD/mpirun.schema
182 echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile
183 #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile
184 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
187 echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec > $procLog 2>&1" >> $procCmdFile
188 echo "${node}$procCmdFile" >> $PWD/mpirun.schema
191 echo "$sourceFoam; cd $PWD; $exec $args > $procLog 2>&1" >> $procCmdFile
192 echo "${node}$procCmdFile" >> $PWD/mpirun.schema
195 echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile
196 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
199 echo "$sourceFoam; cd $PWD; valgrind $exec $args; read dummy" >> $procCmdFile
200 echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
204 chmod +x
$procCmdFile
207 if [ $proc -ne 0 -a $column -eq 0 ]
216 for ((proc
=0; proc
<$nProcs; proc
++))
218 procLog
="processor${proc}.log"
219 echo " tail -f $procLog"
226 cmd
="mpirun -app $PWD/mpirun.schema </dev/null"
230 for ((proc
=0; proc
<$nProcs; proc
++))
234 procXtermCmdFile
="$PWD/processor${proc}Xterm.sh"
235 echo "#!/bin/sh" > $procXtermCmdFile
236 echo "$procCmd" >> $procXtermCmdFile
237 chmod +x
$procXtermCmdFile
242 cmd
="${cmd} -n 1 ${procXtermCmdFile}"
243 done < $PWD/mpirun.schema
247 echo "Unsupported WM_MPLIB setting : $WM_MPLIB"
252 echo "Constructed $PWD/mpirun.schema file."
256 $ECHO "Press return to execute.\c"
260 #------------------------------------------------------------------------------