2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright held by original author
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 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
36 usage: ${0##*/} [OPTION] <application> ...
39 -case dir specify case directory
40 -s also sends output to screen
41 -p parallel run of processors
42 -v ver specify OpenFOAM version
45 * run an OpenFOAM job in background.
46 Redirects the output to 'log' in the case directory
54 # replacement for possibly buggy 'which'
69 # echo "testing: $d/$1" 1>&2
70 if [ -x "$d/$1" -a ! -d "$d/$1" ] ; then
71 # echo "Found exec: $d/$1" 1>&2
84 ps
-u $LOGNAME -o 'pid,args' | fgrep
"$1 " | fgrep
-v grep |
head -1 |
awk '{ print $1 }'
91 Please consult the User Guide for details of parallel running
109 [ "$#" -ge 2 ] || usage
"'-case' option requires an argument"
112 cd "$caseDir" 2>/dev
/null || usage
"directory does not exist: '$caseDir'"
132 usage
"invalid option '$1'"
140 if [ "$#" -lt 1 ]; then
141 usage
"No application specified"
144 # use foamExec for a specified version and for remote (parallel) runs
145 if [ -n "$version" -o "$PARALLEL" = yes ]; then
146 APPLICATION
=`findExec foamExec`
147 if [ $?
-ne 0 ]; then
148 usage
"'foamExec' not found"
150 if [ -n "$version" ]; then
151 APPLICATION
="$APPLICATION -v $version"
154 APPLICATION
=`findExec $1`
155 if [ $?
-ne 0 ]; then
156 usage
"Application '$1' executable not found"
158 echo "Application : $1"
162 if [ "$PARALLEL" = no
]; then
164 # RUN ON SINGLE PROCESSOR
166 if [ "$SCREEN" = no
]; then
167 echo "Executing: $APPLICATION $@ > log 2>&1 &"
168 $APPLICATION $@
> log
2>&1 &
170 echo "Executing: $APPLICATION $@ | tee log &"
171 $APPLICATION $@ |
tee log
&
177 # IS THE CASE DECOMPOSED?
179 if [ -r "processor0" ] ; then
180 NPROCS
="`/bin/ls -1d processor* | wc -l`"
182 echo "Case is not currently decomposed"
183 if [ -r system
/decomposeParDict
] ; then
184 echo "system/decomposeParDict exists"
185 echo "Try decomposing with \"foamJob decomposePar\""
188 echo "Cannot find system/decomposeParDict file required to decompose the case for parallel running."
196 mpirun
=`findExec mpirun`
197 if [ $?
-ne 0 ]; then
198 usage
"'mpirun' not found"
200 mpiopts
="-np $NPROCS"
203 # IS THE MACHINE READY TO RUN PARALLEL?
205 echo "Parallel processing using $WM_MPLIB with $NPROCS processors"
216 if [ -r $hostfile ]; then
217 mpiopts
="$mpiopts -hostfile $hostfile"
227 if [ "$SCREEN" = no
] ; then
228 echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1"
229 $mpirun $mpiopts $APPLICATION $@
-parallel > log
2>&1 &
231 echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel | tee log"
232 $mpirun $mpiopts $APPLICATION $@
-parallel |
tee log
236 #------------------------------------------------------------------------------