2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
14 # Free Software Foundation; either version 2 of the License, or (at your
15 # 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, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #------------------------------------------------------------------------------
33 . @FF_DATA_DIR@
/shellFunctions
/jobControlFunctions
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
39 usage: ${0##*/} [OPTION] <application> ...
42 -case dir specify case directory
43 -s also sends output to screen
44 -p parallel run of processors
45 -hosts hostfile specify file with host names
46 -log logfile specify logfile name for output, defaults to 'log'
47 -fg run the job in the foreground (i.e. don't background it)
48 this option is ignored if -s is specified
51 * run an FreeFOAM job in background.
52 Redirects the output to 'log' in the case directory
60 ps
-u $LOGNAME -o 'pid,args' | fgrep
"$1 " | fgrep
-v grep |
head -1 |
awk '{ print $1 }'
67 Please consult the User Guide for details of parallel running
89 [ "$#" -ge 2 ] || usage
"'-case' option requires an argument"
92 cd "$caseDir" 2>/dev
/null || usage
"directory does not exist: '$caseDir'"
103 [ "$#" -ge 2 ] || usage
"'-hosts' options requires an argument"
104 HOSTFILE
="-hostfile $2"
108 [ "$#" -ge 2 ] || usage
"'-log' options requires an argument"
121 usage
"invalid option '$1'"
131 if [ -z "$APPNAME" ]; then
132 usage
"No application specified"
135 if [ "${APPNAME##*/}" = "$APPNAME" ]; then
136 FOAMEXEC
=@FF_BIN_DIR@
/freefoam
141 if [ "$PARALLEL" = no
]; then
143 # RUN ON SINGLE PROCESSOR
145 if [ "$SCREEN" = no
]; then
146 if [ "$FG" = no
]; then
147 echo "Executing: $FOAMEXEC $APPNAME $@ > $LOGFILE 2>&1 &"
148 $FOAMEXEC $APPNAME $@
> $LOGFILE 2>&1 &
150 echo "Executing: $FOAMEXEC $APPNAME $@ > $LOGFILE 2>&1"
151 $FOAMEXEC $APPNAME $@
> $LOGFILE 2>&1
154 echo "Executing: $FOAMEXEC $APPNAME $@ | tee $LOGFILE &"
155 $FOAMEXEC $APPNAME $@ |
tee $LOGFILE &
161 # IS THE CASE DECOMPOSED?
163 if [ -r "processor0" ] ; then
164 NPROCS
="`/bin/ls -1d processor* | wc -l`"
165 NPROCS
="${NPROCS// /}"
167 echo "Case is not currently decomposed"
168 if [ -r system
/decomposeParDict
] ; then
169 echo "system/decomposeParDict exists"
170 echo "Try decomposing with \"freefoam decomposePar\""
173 echo "Cannot find system/decomposeParDict file required to decompose the case for parallel running."
181 controlDict
=`findControlDict`
182 mpirun
=`getEntry $controlDict parRunTemplate`
183 mpirun
=`echo $mpirun | sed -e "s|\\\${NPROCS}|$NPROCS|g" \
184 -e "s|\\\${PAROPTS}|$HOSTFILE|g" \
185 -e "s|\\\${APPLICATION}|$FOAMEXEC $APPNAME|g" \
186 -e "s|\\\${ARGS}|$@|"`
192 if [ "$SCREEN" = no
] ; then
193 if [ "FG" = no
]; then
194 echo "Executing: $mpirun > $LOGFILE 2>&1 &"
195 $mpirun > $LOGFILE 2>&1 &
197 echo "Executing: $mpirun > $LOGFILE 2>&1"
198 $mpirun > $LOGFILE 2>&1
201 echo "Executing: $mpirun | tee $LOGFILE"
202 $mpirun |
tee $LOGFILE
206 #------------------------------------------------------------------------------