2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 1991-2010 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
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 # Usage: foamExec [-v foamVersion] <foamCommand> ...
31 # Runs the <foamVersion> version of executable <foamCommand>
32 # with the rest of the arguments.
34 # Can also be used for parallel runs e.g.
35 # mpirun -np <nProcs> \
36 # foamExec -v <foamVersion> <foamCommand> ... -parallel
40 #------------------------------------------------------------------------------
42 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
45 Usage: ${0##*/} [OPTION] <application> ...
48 -version <ver> specify an alternative OpenFOAM version
49 pass through to foamEtcFile
52 * run a particular OpenFOAM version of <application>
59 # This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
60 # or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
62 # foamEtcFile must be found in the same directory as this script
63 #-------------------------------------------------------------------------------
74 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
76 etcOpts
="$etcOpts $1 $2" # pass-thru to foamEtcFile
79 -m |
-mode |
-p |
-prefix)
80 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
81 etcOpts
="$etcOpts $1 $2" # pass-thru to foamEtcFile
89 usage
"invalid option '$1'"
100 # Find and source OpenFOAM settings (bashrc)
101 # placed in function to preserve command-line arguments
105 # default is the current version
106 : ${version:=${WM_PROJECT_VERSION:-unknown}}
108 foamDotFile
="$(${0%/*}/foamEtcFile $etcOpts bashrc)" ||
{
109 echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
117 [ "$#" -ge 1 ] || usage
"no application specified"
122 #------------------------------------------------------------------------------