BUG: FOAM_INST_DIR (or prefix) not passed correctly from foamExec

This commit is contained in:
Mark Olesen
2011-04-28 15:33:38 +02:00
parent 80a391a4f3
commit 22fae65263
2 changed files with 37 additions and 24 deletions

View File

@ -38,6 +38,10 @@
# && _foamSource $foamPrefs # && _foamSource $foamPrefs
# \endcode # \endcode
# #
# Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
#
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
usage() { usage() {
[ "${quietOpt:-$silentOpt}" = true ] && exit 1 [ "${quietOpt:-$silentOpt}" = true ] && exit 1
@ -73,13 +77,9 @@ USAGE
exit 1 exit 1
} }
#
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
#
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# the bindir: # the bin dir:
binDir="${0%/*}" binDir="${0%/*}"
# the project dir: # the project dir:

View File

@ -31,12 +31,21 @@
# Runs the <foamVersion> version of executable <foamCommand> # Runs the <foamVersion> version of executable <foamCommand>
# with the rest of the arguments. # with the rest of the arguments.
# #
# Can also be used for parallel runs e.g. # Can also be used for parallel runs. For example,
# \code
# mpirun -np <nProcs> \ # mpirun -np <nProcs> \
# foamExec -version <foamVersion> <foamCommand> ... -parallel # foamExec -version <foamVersion> <foamCommand> ... -parallel
# \endcode
#
# Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
#
# foamEtcFile must be found in the same directory as this script
# #
# SeeAlso # SeeAlso
# foamEtcFile # foamEtcFile
#
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
exec 1>&2 exec 1>&2
@ -58,14 +67,22 @@ USAGE
exit 1 exit 1
} }
#
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
#
# foamEtcFile must be found in the same directory as this script
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
unset etcOpts prefix version # the bin dir:
binDir="${0%/*}"
# the project dir:
projectDir="${binDir%/bin}"
# the prefix dir (same as foamInstall):
prefixDir="${projectDir%/*}"
# # the name used for the project directory
# projectDirName="${projectDir##*/}"
unset etcOpts version
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
@ -80,14 +97,14 @@ do
;; ;;
-p | -prefix) -p | -prefix)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
prefix="$2"
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
prefixDir="$2"
shift shift
;; ;;
-v | -version) -v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version="$2"
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
version="$2"
shift shift
;; ;;
--) --)
@ -104,23 +121,19 @@ do
shift shift
done done
# #
# Find and source OpenFOAM settings (bashrc) # Find and source OpenFOAM settings (bashrc)
# placed in function to preserve command-line arguments # placed in function to preserve command-line arguments
# #
sourceRc() sourceRc()
{ {
# default is the current version foamDotFile="$($binDir/foamEtcFile $etcOpts bashrc)" || {
: ${version:=${WM_PROJECT_VERSION:-unknown}} echo "Error : bashrc file could not be found for OpenFOAM-${version:-${WM_PROJECT_VERSION:-???}}" 1>&2
foamDotFile="$(${0%/*}/foamEtcFile $etcOpts bashrc)" || {
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
exit 1 exit 1
} }
# extra safety when sourcing the bashrc # set to consistent value before sourcing the bashrc
[ -n "$prefix" ] && export FOAM_INST_DIR="$prefix" export FOAM_INST_DIR="$prefixDir"
. $foamDotFile $FOAM_SETTINGS . $foamDotFile $FOAM_SETTINGS
} }