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 # 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. For example,
36 # mpirun -np <nProcs> \
37 # foamExec -version <foamVersion> <foamCommand> ... -parallel
41 # This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
42 # or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
44 # foamEtcFile must be found in the same directory as this script
49 #------------------------------------------------------------------------------
52 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
55 Usage: ${0##*/} [OPTION] <application> ...
58 -prefix <dir> specify an alternative installation prefix
59 pass through to foamEtcFile and set as FOAM_INST_DIR
60 -version <ver> specify an alternative OpenFOAM version
61 pass through to foamEtcFile
64 * run a particular OpenFOAM version of <application>
70 #-------------------------------------------------------------------------------
76 projectDir
="${binDir%/bin}"
78 # the prefix dir (same as foamInstall):
79 prefixDir
="${projectDir%/*}"
81 # # the name used for the project directory
82 # projectDirName="${projectDir##*/}"
94 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
95 etcOpts
="$etcOpts $1 $2" # pass-thru to foamEtcFile
99 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
100 etcOpts
="$etcOpts $1 $2" # pass-thru to foamEtcFile
105 [ "$#" -ge 2 ] || usage
"'$1' option requires an argument"
106 etcOpts
="$etcOpts $1 $2" # pass-thru to foamEtcFile
115 usage
"invalid option '$1'"
125 # Find and source OpenFOAM settings (bashrc)
126 # placed in function to preserve command-line arguments
130 foamDotFile
="$($binDir/foamEtcFile $etcOpts bashrc)" ||
{
131 echo "Error : bashrc file could not be found for OpenFOAM-${version:-${WM_PROJECT_VERSION:-???}}" 1>&2
135 # set to consistent value before sourcing the bashrc
136 export FOAM_INST_DIR
="$prefixDir"
138 .
$foamDotFile $FOAM_SETTINGS
142 [ "$#" -ge 1 ] || usage
"no application specified"
147 #------------------------------------------------------------------------------