- since 1612, FOAM_INST_DIR and foamInstDir longer have any special meanings when sourcing the bashrc or cshrc files. Thus no need for special treatment in any of the dispatch wrappers. Retained FOAM_INST_DIR as (unexported) variable in etc/bashrc, just in case people are using patched versions of etc/bashrc as part of their installation. ENH: relax prefix restrictions on foamCreateVideo (issue #904) - shift the implicit '.' to be part of the default prefix. This allows things like "-image myimages_00" to work as might be expected.
146 lines
4.3 KiB
Bash
Executable File
146 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#------------------------------------------------------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration |
|
|
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
# \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
|
#-------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM.
|
|
#
|
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
# for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Script
|
|
# foamExec
|
|
#
|
|
# Description
|
|
# Usage: foamExec [-version=foamVersion] <foamCommand> ...
|
|
#
|
|
# Runs the <foamVersion> version of executable <foamCommand>
|
|
# with the rest of the arguments.
|
|
#
|
|
# Can also be used for parallel runs. For example,
|
|
# \code
|
|
# mpirun -np <nProcs> \
|
|
# foamExec -version=VERSION <foamCommand> ... -parallel
|
|
# \endcode
|
|
#
|
|
# Note
|
|
# This script must exist in $WM_PROJECT_INST_DIR/OpenFOAM-<VERSION>/bin
|
|
# or $WM_PROJECT_INST_DIR/openfoam<VERSION>/bin (debian)
|
|
#
|
|
# foamEtcFile located in the same directory as this script
|
|
#
|
|
# See also
|
|
# foamEtcFile
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
usage() {
|
|
exec 1>&2
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
cat<<USAGE
|
|
|
|
Usage: ${0##*/} [OPTION] <application> ...
|
|
|
|
options:
|
|
-mode=MODE Any combination of u(user), g(group), o(other)
|
|
-prefix=DIR Specify an alternative installation prefix
|
|
pass through to foamEtcFile
|
|
-version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...)
|
|
pass through to foamEtcFile
|
|
-help Print the usage
|
|
|
|
Run a particular OpenFOAM version of <APPLICATION>
|
|
|
|
USAGE
|
|
exit 1
|
|
}
|
|
|
|
#-------------------------------------------------------------------------------
|
|
binDir="${0%/*}" # The bin dir
|
|
projectDir="${binDir%/bin}" # The project dir
|
|
# prefixDir="${projectDir%/*}" # The prefix dir (same as $WM_PROJECT_INST_DIR)
|
|
|
|
projectVersion="${WM_PROJECT_VERSION:-unknown}"
|
|
|
|
unset etcOpts
|
|
# parse options
|
|
while [ "$#" -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
-h | -help*)
|
|
usage
|
|
;;
|
|
-mode=*)
|
|
etcOpts="$etcOpts $1" # pass-thru to foamEtcFile
|
|
;;
|
|
-prefix=/*)
|
|
etcOpts="$etcOpts $1" # pass-thru to foamEtcFile
|
|
;;
|
|
-version=*)
|
|
etcOpts="$etcOpts $1" # pass-thru to foamEtcFile
|
|
projectVersion="${1#*=}" # for reporting
|
|
;;
|
|
-m | -mode)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
|
shift
|
|
;;
|
|
-p | -prefix)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
|
shift
|
|
;;
|
|
-v | -version)
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
|
projectVersion="$2" # for reporting
|
|
shift
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
-*)
|
|
usage "invalid option '$1'"
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
|
|
# Find and source the OpenFOAM <etc/bashrc>
|
|
# placed in function to preserve command-line arguments
|
|
sourceBashrc()
|
|
{
|
|
rcFile="$($binDir/foamEtcFile $etcOpts bashrc)" || {
|
|
echo "Error: bashrc file could not be found for OpenFOAM-$projectVersion" 1>&2
|
|
exit 2
|
|
}
|
|
|
|
. $rcFile $FOAM_SETTINGS
|
|
}
|
|
|
|
|
|
[ "$#" -ge 1 ] || usage "no application specified"
|
|
|
|
sourceBashrc
|
|
exec "$@"
|
|
|
|
#------------------------------------------------------------------------------
|