CONFIG: eliminate most occurances of outdated FOAM_INST_DIR (issue #444)

- 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.
This commit is contained in:
Mark Olesen
2018-06-25 09:56:34 +02:00
parent f4d3c071ff
commit 831a47b81e
11 changed files with 128 additions and 171 deletions

View File

@ -33,7 +33,7 @@
# Input defaults # Input defaults
dirName='.' dirName='.'
prefix='image' prefix='image.'
inputMask='%04d' # (avconv only) inputMask='%04d' # (avconv only)
unset startNumber # (avconv only) unset startNumber # (avconv only)
@ -53,23 +53,21 @@ usage () {
Usage: ${0##*/} [OPTIONS] ... Usage: ${0##*/} [OPTIONS] ...
options: options:
-d | -dir <dir> input directory with png images (default: '.') -d | -dir <dir> input directory with png images (default: '.')
-f | -fps <fps> frames per second (default = 10) -f | -fps <fps> frames per second (default: 10)
-i | -image <name> prefix for input image sequence (default: 'image') -i | -image <name> input image sequence prefix (default: 'image.')
-o | -out <name> name of output video file (default: 'video') -o | -out <name> output video name (default: 'video')
-start <frame> start frame number (avconv only) -mask <width> input mask width for avconv (default: 4)
-start <frame> start frame number for avconv
-webm WebM output video file format (avconv only) -webm WebM output video file format (avconv only)
-mask <width> input mask width (avconv only, default: 4)
-h | -help help -h | -help help
Creates a video file from a sequence of PNG images. Creates a video file from a sequence of PNG images.
For example, image.0000.png, image.0001.png, ... With the default prefix ('image.'), from image.0000.png, image.0001.png, ...
- The output format is MPEG4
- Can use -i/-image to specify other values. Eg, -i "pressure_" ...
- The output format is MPEG-4
- The output name (with mp4 format), is "video.mp4" - The output name (with mp4 format), is "video.mp4"
- By default the video codec is high resolution - By default the video codec is high resolution
MPEG-4 output requires avconv or mencoder. MPEG4 output requires avconv or mencoder.
WebM output requires avconv. WebM output requires avconv.
USAGE USAGE
@ -118,7 +116,7 @@ do
shift shift
;; ;;
-mask) -mask)
[ "$#" -ge 2 ] || die "'-out' requires an argument" [ "$#" -ge 2 ] || die "'-mask' requires an argument"
digits="$(( $2 + 0 ))" digits="$(( $2 + 0 ))"
if [ "$digits" -gt 0 ] if [ "$digits" -gt 0 ]
then then
@ -152,16 +150,6 @@ done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Add trailing '.' to the prefix if it does not already end with [-._]
case "$prefix" in
*[-_.])
: # OK, use prefix as it is
;;
(*)
prefix="$prefix."
;;
esac
# See how many files exist # See how many files exist
nFiles="$(\ls $dirName/$prefix*.png 2>/dev/null | wc -l)" nFiles="$(\ls $dirName/$prefix*.png 2>/dev/null | wc -l)"
@ -182,7 +170,7 @@ then
echo "Creating video with avconv..." echo "Creating video with avconv..."
avconv \ avconv \
-framerate $frameRate $startNumber \ -framerate $frameRate $startNumber \
-i "${dirName}/${prefix}$inputMask.png" \ -i "$dirName/$prefix$inputMask.png" \
-c:v libvpx -crf 15 -b:v 1M \ -c:v libvpx -crf 15 -b:v 1M \
"$outputPrefix.$outputFormat" "$outputPrefix.$outputFormat"
else else
@ -194,7 +182,7 @@ else
echo "Creating video with avconv..." echo "Creating video with avconv..."
avconv \ avconv \
-framerate $frameRate $startNumber \ -framerate $frameRate $startNumber \
-i "${dirName}/${prefix}$inputMask.png" \ -i "$dirName/$prefix$inputMask.png" \
-c:v libx264 -pix_fmt yuv420p \ -c:v libx264 -pix_fmt yuv420p \
"$outputPrefix.$outputFormat" "$outputPrefix.$outputFormat"

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -38,10 +38,10 @@
# \endcode # \endcode
# #
# Note # Note
# This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/ # This script must exist in $WM_PROJECT_INST_DIR/OpenFOAM-<VERSION>/bin
# or $FOAM_INST_DIR/openfoam<VERSION>/bin/ (for the debian version) # or $WM_PROJECT_INST_DIR/openfoam<VERSION>/bin (debian)
# #
# foamEtcFile must be found in the same directory as this script # foamEtcFile located in the same directory as this script
# #
# See also # See also
# foamEtcFile # foamEtcFile
@ -57,7 +57,7 @@ Usage: ${0##*/} [OPTION] <application> ...
options: options:
-mode=MODE Any combination of u(user), g(group), o(other) -mode=MODE Any combination of u(user), g(group), o(other)
-prefix=DIR Specify an alternative installation prefix -prefix=DIR Specify an alternative installation prefix
pass through to foamEtcFile and set as FOAM_INST_DIR pass through to foamEtcFile
-version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...) -version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...)
pass through to foamEtcFile pass through to foamEtcFile
-help Print the usage -help Print the usage
@ -71,11 +71,9 @@ USAGE
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
binDir="${0%/*}" # The bin dir binDir="${0%/*}" # The bin dir
projectDir="${binDir%/bin}" # The project dir projectDir="${binDir%/bin}" # The project dir
prefixDir="${projectDir%/*}" # The prefix dir (same as $WM_PROJECT_INST_DIR) # prefixDir="${projectDir%/*}" # The prefix dir (same as $WM_PROJECT_INST_DIR)
## projectDirName="${projectDir##*/}" # The project directory name projectVersion="${WM_PROJECT_VERSION:-unknown}"
version="${WM_PROJECT_VERSION:-unknown}"
unset etcOpts unset etcOpts
# parse options # parse options
@ -90,11 +88,10 @@ do
;; ;;
-prefix=/*) -prefix=/*)
etcOpts="$etcOpts $1" # pass-thru to foamEtcFile etcOpts="$etcOpts $1" # pass-thru to foamEtcFile
prefixDir="${1#*=}"
;; ;;
-version=*) -version=*)
etcOpts="$etcOpts $1" # pass-thru to foamEtcFile etcOpts="$etcOpts $1" # pass-thru to foamEtcFile
version="${1#*=}" projectVersion="${1#*=}" # for reporting
;; ;;
-m | -mode) -m | -mode)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
@ -104,13 +101,12 @@ do
-p | -prefix) -p | -prefix)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
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"
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
version="$2" projectVersion="$2" # for reporting
shift shift
;; ;;
--) --)
@ -127,27 +123,23 @@ do
shift shift
done done
#
# Find and source OpenFOAM settings (bashrc) # Find and source the OpenFOAM <etc/bashrc>
# placed in function to preserve command-line arguments # placed in function to preserve command-line arguments
# sourceBashrc()
sourceRc()
{ {
rcFile="$($binDir/foamEtcFile $etcOpts bashrc)" || { rcFile="$($binDir/foamEtcFile $etcOpts bashrc)" || {
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2 echo "Error: bashrc file could not be found for OpenFOAM-$projectVersion" 1>&2
exit 1 exit 2
} }
# set to consistent value before sourcing the bashrc
export FOAM_INST_DIR="$prefixDir"
. $rcFile $FOAM_SETTINGS . $rcFile $FOAM_SETTINGS
} }
[ "$#" -ge 1 ] || usage "no application specified" [ "$#" -ge 1 ] || usage "no application specified"
sourceRc sourceBashrc
exec "$@" exec "$@"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -42,7 +42,7 @@ options:
-screen also sends output to screen -screen also sends output to screen
-append append to log file instead of overwriting it -append append to log file instead of overwriting it
-wait wait for execution to complete (when not using -screen) -wait wait for execution to complete (when not using -screen)
-version <ver> specify an alternative OpenFOAM version -version=VER specify an alternative OpenFOAM version
-help print the usage -help print the usage
* run an OpenFOAM job in background. * run an OpenFOAM job in background.
@ -56,8 +56,8 @@ USAGE
echoArgs() { echoArgs() {
addSpace="" addSpace=""
for stringItem in "$@"; do for stringItem in "$@"
do
echo -n "${addSpace}" echo -n "${addSpace}"
if [ "${stringItem##* }" = "$stringItem" ] if [ "${stringItem##* }" = "$stringItem" ]
@ -68,13 +68,11 @@ echoArgs() {
echo -n "'$stringItem'" echo -n "'$stringItem'"
addSpace=" " addSpace=" "
fi fi
done done
unset stringItem addSpace unset stringItem addSpace
} }
unset version
# Replacement for possibly buggy 'which' # Replacement for possibly buggy 'which'
findExec() { findExec() {
@ -111,7 +109,7 @@ findExec() {
# Main script # Main script
#~~~~~~~~~~~~ #~~~~~~~~~~~~
unset parallelOpt screenOpt waitOpt unset parallelOpt screenOpt waitOpt
unset projectVersion
# Parse options # Parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
@ -123,28 +121,27 @@ do
-case) -case)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'" cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
shift 2 shift
;; ;;
-p | -parallel) -p | -parallel)
parallelOpt=true parallelOpt=true
shift
;; ;;
-s | -screen) -s | -screen)
screenOpt=true screenOpt=true
shift
;; ;;
-a | -append) -a | -append)
appendOpt=true appendOpt=true
shift
;; ;;
-w | -wait) -w | -wait)
waitOpt=true waitOpt=true
shift ;;
-version=*)
projectVersion="${1#*=}" # for foamExec
;; ;;
-v | -version) -v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version="$2" projectVersion="$2" # for foamExec
shift 2 shift
;; ;;
--) --)
shift shift
@ -157,35 +154,34 @@ do
break break
;; ;;
esac esac
shift
done done
# ------------------------------------------------------------------------------
[ "$#" -ge 1 ] || usage "No application specified" [ "$#" -ge 1 ] || usage "No application specified"
# The requested application
appName="$1"
# Use foamExec for a specified version # Use foamExec for a specified version
# Also need foamExec for remote (parallel) runs # Also need foamExec for remote (parallel) runs
if [ -n "$version" -o "$parallelOpt" = true ] if [ -n "$projectVersion" -o "$parallelOpt" = true ]
then then
# When possible, determine if application even exists # When possible, determine if application even exists
if [ -z "$version" ] if [ -z "$projectVersion" ]
then then
findExec $1 >/dev/null || usage "Application '$1' not found" findExec "$appName" >/dev/null || usage "Application '$appName' not found"
fi fi
# Use foamExec for dispatching # Use foamExec for dispatching
APPLICATION=`findExec foamExec` || usage "'foamExec' not found" APPLICATION=$(findExec foamExec) || usage "'foamExec' not found"
[ -n "$version" ] && APPLICATION="$APPLICATION -version $version" [ -n "$projectVersion" ] && APPLICATION="$APPLICATION -version $projectVersion"
# Attempt to preserve the installation directory 'FOAM_INST_DIR'
if [ -d "$FOAM_INST_DIR" ]
then
APPLICATION="$APPLICATION -prefix $FOAM_INST_DIR"
fi
else else
APPLICATION=`findExec $1` || usage "Application '$1' not found" APPLICATION=$(findExec "$appName") || usage "Application '$appName' not found"
echo "Application : $1" echo "Application : $appName"
shift shift
fi fi
@ -200,7 +196,7 @@ then
# #
if [ -r "processor0" -o -r "processors" ] if [ -r "processor0" -o -r "processors" ]
then then
NPROCS="$(foamDictionary -entry numberOfSubdomains -value system/decomposeParDict)" nprocs="$(foamDictionary -entry numberOfSubdomains -value system/decomposeParDict 2>/dev/null)"
else else
echo "Case is not currently decomposed" echo "Case is not currently decomposed"
if [ -r system/decomposeParDict ] if [ -r system/decomposeParDict ]
@ -218,16 +214,16 @@ then
# #
# Find mpirun # Find mpirun
# #
mpirun=`findExec mpirun` || usage "'mpirun' not found" mpirun=$(findExec mpirun) || usage "'mpirun' not found"
mpiopts="-np $NPROCS" mpiopts="-np $nprocs"
# #
# Check if the machine ready to run parallel # Check if the machine ready to run parallel
# #
echo "Parallel processing using $WM_MPLIB with $NPROCS processors" echo "Parallel processing using $WM_MPLIB with $nprocs processors"
case "$WM_MPLIB" in case "$WM_MPLIB" in
*OPENMPI) *OPENMPI)
# add hostfile info # Add hostfile info
for hostfile in \ for hostfile in \
hostfile \ hostfile \
machines \ machines \
@ -242,12 +238,9 @@ then
fi fi
done done
#
# Send FOAM_SETTINGS to parallel processes, so that the proper # Send FOAM_SETTINGS to parallel processes, so that the proper
# definitions are sent as well. # definitions are sent as well.
#
mpiopts="$mpiopts -x FOAM_SETTINGS" mpiopts="$mpiopts -x FOAM_SETTINGS"
;; ;;
esac esac

View File

@ -191,6 +191,8 @@ then
fi fi
sourceFoam=false # Fallback command
# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
# check ~/.$WM_PROJECT/ # check ~/.$WM_PROJECT/
# check <installedProject>/etc/ # check <installedProject>/etc/
@ -210,16 +212,14 @@ then
done done
fi fi
# Construct test string for remote execution.
# Source OpenFOAM settings if OpenFOAM environment not set. # Source OpenFOAM settings if OpenFOAM environment not set.
# attempt to preserve the installation directory 'FOAM_INST_DIR'
# use FOAM_SETTINGS to pass command-line settings # use FOAM_SETTINGS to pass command-line settings
if [ -n "$FOAM_INST_DIR" ]
then case "$sourceFoam" in
sourceFoam="FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS" */bashrc)
else
sourceFoam=". $sourceFoam $FOAM_SETTINGS" sourceFoam=". $sourceFoam $FOAM_SETTINGS"
fi ;;
esac
echo "**sourceFoam: $sourceFoam" echo "**sourceFoam: $sourceFoam"

View File

@ -181,7 +181,7 @@ do
-foamInstall | --foamInstall) -foamInstall | --foamInstall)
# Replace FOAM_INST_DIR=... # Replace FOAM_INST_DIR=...
[ "$#" -ge 2 ] || die "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
foamInstDir="$2" prefixDir="$2"
_inlineSed \ _inlineSed \
etc/bashrc \ etc/bashrc \
'\(.*BASH_SOURCE.*\)' \ '\(.*BASH_SOURCE.*\)' \
@ -195,8 +195,8 @@ do
_inlineSed \ _inlineSed \
etc/bashrc \ etc/bashrc \
'^ *FOAM_INST_DIR=.*' \ '^ *FOAM_INST_DIR=.*' \
'FOAM_INST_DIR='"$foamInstDir" \ 'FOAM_INST_DIR='"$prefixDir" \
"Setting FOAM_INST_DIR to '$foamInstDir'" "Setting fallback FOAM_INST_DIR to '$prefixDir'"
adjusted=true adjusted=true
shift shift

View File

@ -47,7 +47,6 @@ FOAM_INST_DIR=$HOME/$WM_PROJECT
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
################################################################################ ################################################################################
: # Extra safety - if the user commented out all fallback values : # Extra safety - if the user commented out all fallback values
export FOAM_INST_DIR
unset rc unset rc
# Configuration environment variables. # Configuration environment variables.
@ -199,6 +198,7 @@ fi
. $WM_PROJECT_DIR/etc/config.sh/functions . $WM_PROJECT_DIR/etc/config.sh/functions
# Variables (done as the last statement for a clean exit code) # Variables (done as the last statement for a clean exit code)
unset FOAM_INST_DIR # Old variable name (OpenFOAM-v1606) - now unneeded
unset cleaned foamOldDirs unset cleaned foamOldDirs
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -57,13 +57,13 @@ alias uutil 'cd $WM_PROJECT_USER_DIR/applications/utilities'
# Refresh the environment # Refresh the environment
# ~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~
alias wmRefresh 'set wmProjectDir=$WM_PROJECT_DIR; set foamSettings=$FOAM_SETTINGS; wmUnset; source $wmProjectDir/etc/cshrc $foamSettings' alias wmRefresh 'set projectDir=$WM_PROJECT_DIR; set foamSettings=$FOAM_SETTINGS; wmUnset; source $projectDir/etc/cshrc $foamSettings'
# Change OpenFOAM version # Change OpenFOAM version
# ~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~
alias foamVersion \ alias foamVersion \
'if ( "\!*" != "" ) source $FOAM_INST_DIR/OpenFOAM-\!*/etc/cshrc; foam; echo OpenFOAM-$WM_PROJECT_VERSION' 'if ( "\!*" != "" ) source ${WM_PROJECT_DIR:h}/OpenFOAM-\!*/etc/cshrc; foam; echo OpenFOAM-$WM_PROJECT_VERSION'
# Change ParaView version # Change ParaView version

View File

@ -65,31 +65,30 @@ wmRefresh()
} }
# Change OpenFOAM version # Query the current OpenFOAM version
# ~~~~~~~~~~~~~~~~~~~~~~~ # or change to another version (if installed in a parallel directory)
unset -f foamVersion 2>/dev/null unset -f foamVersion 2>/dev/null
foamVersion() foamVersion()
{ {
if [ "$#" -gt 0 ] if [ "$#" -gt 0 ]
then then
local dir="${WM_PROJECT_DIR%/*}" # Parent directory
local ver=$1 local ver=$1
shift shift
# The variable foamInstDir had meaning for older OpenFOAM versions
foamInstDir=$FOAM_INST_DIR if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ]
if [ -f "$foamInstDir/OpenFOAM-$ver/etc/bashrc" ]
then then
wmUnset wmUnset
. $foamInstDir/OpenFOAM-$ver/etc/bashrc . $dir/OpenFOAM-$ver/etc/bashrc
unset foamInstDir
foam foam
echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2 echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2
else else
unset foamInstDir echo "No OpenFOAM-$ver available in $dir" 1>&2
echo "No OpenFOAM-$ver available" 1>&2
echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2 echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2
return 1 return 1
fi fi
else else
# Treat as query. Report current version
echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2 echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2
fi fi
} }

View File

@ -38,11 +38,11 @@ setenv WM_PROJECT_VERSION plus
# should work when sourced by CSH or TCSH shells. If this however fails, # should work when sourced by CSH or TCSH shells. If this however fails,
# set one of the fallback values to an appropriate path. # set one of the fallback values to an appropriate path.
# -- # --
setenv FOAM_INST_DIR `lsof +p $$ |& \ set FOAM_INST_DIR=`lsof +p $$ |& \
sed -n -e 's@[^/]*@@' -e 's@/'$WM_PROJECT'[^/]*/etc/cshrc.*@@p'` sed -n -e 's@[^/]*@@' -e 's@/'$WM_PROJECT'[^/]*/etc/cshrc.*@@p'`
# setenv FOAM_INST_DIR $HOME/$WM_PROJECT # set FOAM_INST_DIR=$HOME/$WM_PROJECT
# setenv FOAM_INST_DIR /opt/$WM_PROJECT # set FOAM_INST_DIR=/opt/$WM_PROJECT
# setenv FOAM_INST_DIR /usr/local/$WM_PROJECT # set FOAM_INST_DIR=/usr/local/$WM_PROJECT
# #
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
################################################################################ ################################################################################
@ -240,6 +240,7 @@ unalias _foamAddLib
unalias _foamAddLibAuto unalias _foamAddLibAuto
# Variables (done as the last statement for a clean exit code) # Variables (done as the last statement for a clean exit code)
unset FOAM_INST_DIR # Old variable name (OpenFOAM-v1606) - now unneeded
unset cleaned foamOldDirs unset cleaned foamOldDirs
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -45,7 +45,6 @@
# #
# WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set # WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
# before calling this routine. # before calling this routine.
# FOAM_INST_DIR may possibly have been set (to find installation)
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
Script=${0##*/} Script=${0##*/}
@ -90,7 +89,7 @@ esac
# Check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # Check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
# Check ~/.$WM_PROJECT/ # Check ~/.$WM_PROJECT/
# Check <installedProject>/etc/ # Check <installedProject>/etc/
if [ "$WM_PROJECT" ] if [ -n "$WM_PROJECT" ]
then then
for i in \ for i in \
$HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
@ -108,20 +107,13 @@ fi
# Construct test string for remote execution. # Construct test string for remote execution.
# Source WM_PROJECT settings if WM_PROJECT environment not set. # Source WM_PROJECT settings if WM_PROJECT environment not set.
# Attempt to preserve the installation directory 'FOAM_INST_DIR'
# Use FOAM_SETTINGS to pass command-line settings # Use FOAM_SETTINGS to pass command-line settings
case $sourceFoam in case "$sourceFoam" in
*/bashrc) */bashrc)
if [ "$FOAM_INST_DIR" ] sourceFoam='[ -n "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
then
sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
else
sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
fi
;; ;;
*/cshrc) */cshrc)
# TODO: csh equivalent to bash code (preserving FOAM_INST_DIR)
sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam $FOAM_SETTINGS" sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam $FOAM_SETTINGS"
;; ;;
esac esac

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -45,7 +45,6 @@
# #
# WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set # WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
# before calling this routine. # before calling this routine.
# FOAM_INST_DIR may possibly have been set (to find installation)
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
Script=${0##*/} Script=${0##*/}
@ -89,7 +88,7 @@ esac
# Check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # Check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
# Check ~/.$WM_PROJECT/ # Check ~/.$WM_PROJECT/
# Check <installedProject>/etc/ # Check <installedProject>/etc/
if [ "$WM_PROJECT" ] if [ -n "$WM_PROJECT" ]
then then
for i in \ for i in \
$HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
@ -107,20 +106,13 @@ fi
# Construct test string for remote execution. # Construct test string for remote execution.
# Source WM_PROJECT settings if WM_PROJECT environment not set. # Source WM_PROJECT settings if WM_PROJECT environment not set.
# Attempt to preserve the installation directory 'FOAM_INST_DIR'
# Use FOAM_SETTINGS to pass command-line settings # Use FOAM_SETTINGS to pass command-line settings
case $sourceFoam in case "$sourceFoam" in
*/bashrc) */bashrc)
if [ "$FOAM_INST_DIR" ] sourceFoam='[ -n "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
then
sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
else
sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
fi
;; ;;
*/cshrc) */cshrc)
# TODO: csh equivalent to bash code (preserving FOAM_INST_DIR)
sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam $FOAM_SETTINGS" sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam $FOAM_SETTINGS"
;; ;;
esac esac
@ -151,7 +143,7 @@ set -o pipefail
# #
colourPipe() colourPipe()
{ {
if [ "$1" ] if [ -n "$1" ]
then then
( (
while read line while read line