BUG: UIPread: missing constructor
[OpenFOAM-2.0.x.git] / bin / foamExec
blob509ed5d83cb8cecdef7fabfef8c11c1bab0fb39f
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
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
20 # for more details.
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/>.
25 # Script
26 # foamExec
28 # Description
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,
35 # \code
36 # mpirun -np <nProcs> \
37 # foamExec -version <foamVersion> <foamCommand> ... -parallel
38 # \endcode
40 # Note
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
46 # SeeAlso
47 # foamEtcFile
49 #------------------------------------------------------------------------------
50 usage() {
51 exec 1>&2
52 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
53 cat<<USAGE
55 Usage: ${0##*/} [OPTION] <application> ...
57 options:
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
62 -help print the usage
64 * run a particular OpenFOAM version of <application>
66 USAGE
67 exit 1
70 #-------------------------------------------------------------------------------
72 # the bin dir:
73 binDir="${0%/*}"
75 # the project dir:
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##*/}"
85 unset etcOpts version
86 # parse options
87 while [ "$#" -gt 0 ]
89 case "$1" in
90 -h | -help)
91 usage
93 -m | -mode)
94 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
95 etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
96 shift
98 -p | -prefix)
99 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
100 etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
101 prefixDir="$2"
102 shift
104 -v | -version)
105 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
106 etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
107 version="$2"
108 shift
111 shift
112 break
115 usage "invalid option '$1'"
118 break
120 esac
121 shift
122 done
125 # Find and source OpenFOAM settings (bashrc)
126 # placed in function to preserve command-line arguments
128 sourceRc()
130 foamDotFile="$($binDir/foamEtcFile $etcOpts bashrc)" || {
131 echo "Error : bashrc file could not be found for OpenFOAM-${version:-${WM_PROJECT_VERSION:-???}}" 1>&2
132 exit 1
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"
144 sourceRc
145 exec "$@"
147 #------------------------------------------------------------------------------