2 #------------------------------------------------------------------------------
4 # \\ / F ield | foam-extend: Open Source CFD
6 # \\ / A nd | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
10 # This file is part of foam-extend.
12 # foam-extend 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 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. 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
38 #------------------------------------------------------------------------------
42 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
45 usage: ${0##*/} [OPTION] <application> ...
48 -v ver specify foam version
51 * run a particular foam version of <application>
58 # This script should exist in <foamInstall>/foam-extend-<VERSION>/bin/
59 # extract the <foamInstall> and <version> elements
60 # using a function preserves the command args
62 set -- $
(echo $0 |
sed -e 's@/foam-extend-\([^/]*\)/bin/[^/]*$@ \1@')
86 usage
"invalid option '$1'"
96 usage
"no application specified"
101 # Check user-specific foam-extend bashrc file
102 foamDotFile
="$HOME/.foam-extend-$version/bashrc"
103 if [ -f $foamDotFile ]
108 # Use the FOAM_INST_DIR variable for locating the installed version
109 for FOAM_INST_DIR
in $foamInstall $WM_PROJECT_INST_DIR
111 foamDotFile
="$FOAM_INST_DIR/foam-extend-$version/etc/bashrc"
112 if [ -f $foamDotFile ]
122 if [ "$foamDotFile" != okay
]
124 echo "Error : bashrc file could not be found for foam-extend-$version" 1>&2
128 # Pass on the rest of the arguments
131 #------------------------------------------------------------------------------