etc/bashrc,cshrc: Simplify and automate the setting of FOAM_INST_DIR

FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to
the directory containing the etc/bashrc,cshrc file.  If this default is
not appropriate FOAM_INST_DIR can be set explicitly.
This commit is contained in:
Henry Weller 2016-06-06 17:20:10 +01:00
parent 048a3a7ada
commit b7243e2d19
4 changed files with 35 additions and 36 deletions

View File

@ -39,8 +39,8 @@
# \endcode # \endcode
# #
# Note # Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/ # This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version) # or $FOAM_INST_DIR/openfoam<VERSION>/bin/ (for the debian version)
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
usage() { usage() {
@ -86,7 +86,7 @@ binDir="${0%/*}"
# the project dir: # the project dir:
projectDir="${binDir%/bin}" projectDir="${binDir%/bin}"
# the prefix dir (same as foamInstall): # the prefix dir (same as $FOAM_INST_DIR):
prefixDir="${projectDir%/*}" prefixDir="${projectDir%/*}"
# the name used for the project directory # the name used for the project directory

View File

@ -38,8 +38,8 @@
# \endcode # \endcode
# #
# Note # Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/ # This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version) # or $FOAM_INST_DIR/openfoam<VERSION>/bin/ (for the debian version)
# #
# foamEtcFile must be found in the same directory as this script # foamEtcFile must be found in the same directory as this script
# #
@ -75,7 +75,7 @@ binDir="${0%/*}"
# the project dir: # the project dir:
projectDir="${binDir%/bin}" projectDir="${binDir%/bin}"
# the prefix dir (same as foamInstall): # the prefix dir (same as $FOAM_INST_DIR):
prefixDir="${projectDir%/*}" prefixDir="${projectDir%/*}"
# # the name used for the project directory # # the name used for the project directory

View File

@ -37,25 +37,24 @@ export WM_PROJECT_VERSION=dev
################################################################################ ################################################################################
# USER EDITABLE PART: Changes made here may be lost with the next upgrade # USER EDITABLE PART: Changes made here may be lost with the next upgrade
# #
# either set $FOAM_INST_DIR before sourcing this file or set # FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to
# 'foamInstall' below to where OpenFOAM is installed # the directory containing this file if sourced by a bash shell.
# #
# Location of the OpenFOAM installation # Please set to the appropriate path if the default is not correct.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
foamInstall=$HOME/$WM_PROJECT [ $BASH_SOURCE ] && \
# foamInstall=~$WM_PROJECT export FOAM_INST_DIR=${BASH_SOURCE%/*/*/*} || \
# foamInstall=/opt/$WM_PROJECT export FOAM_INST_DIR=$HOME/OpenFOAM
# foamInstall=/usr/local/$WM_PROJECT # export FOAM_INST_DIR=~$WM_PROJECT
# export FOAM_INST_DIR=/opt/$WM_PROJECT
# export FOAM_INST_DIR=/usr/local/$WM_PROJECT
# #
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
################################################################################ ################################################################################
# # The default environment variables below can be overridden in a prefs.sh file
# These are the defaults for this version which should generally be # located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM,
# overridden from the prefs.sh file or from command-line specification # $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site
#
#- note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
#- Compiler location: #- Compiler location:
# WM_COMPILER_TYPE= system | ThirdParty (OpenFOAM) # WM_COMPILER_TYPE= system | ThirdParty (OpenFOAM)
@ -202,7 +201,7 @@ fi
# Cleanup environment: # Cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~
unset cleaned foamClean foamInstall foamOldDirs unset cleaned foamClean foamOldDirs
# Unload initialization functions: # Unload initialization functions:

View File

@ -36,25 +36,25 @@ setenv WM_PROJECT_VERSION dev
################################################################################ ################################################################################
# USER EDITABLE PART: Changes made here may be lost with the next upgrade # USER EDITABLE PART: Changes made here may be lost with the next upgrade
# #
# either setenv FOAM_INST_DIR before sourcing this file or set # FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to
# 'foamInstall' below to where OpenFOAM is installed # the directory containing this file.
# #
# Location of the OpenFOAM installation # Please set to the appropriate path if the default is not correct.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
set foamInstall = $HOME/$WM_PROJECT setenv FOAM_INST_DIR `lsof +p $$ |& grep -oE '/.*OpenFOAM[^/]*/etc/cshrc' | \
# set foamInstall = ~$WM_PROJECT sed 's%/OpenFOAM[^/]*/etc/cshrc%%'`
# set foamInstall = /opt/$WM_PROJECT echo $FOAM_INST_DIR
# set foamInstall = /usr/local/$WM_PROJECT # setenv FOAM_INST_DIR $HOME/$WM_PROJECT
# setenv FOAM_INST_DIR ~$WM_PROJECT
# setenv FOAM_INST_DIR /opt/$WM_PROJECT
# setenv FOAM_INST_DIR /usr/local/$WM_PROJECT
# #
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
################################################################################ ################################################################################
# # The default environment variables below can be overridden in a prefs.sh file
# These are the defaults for this version which should generally be # located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM,
# overridden from the prefs.csh file or from command-line specification # $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site
#
#- note the location for later use (eg, in job scripts)
if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
#- Compiler location: #- Compiler location:
# WM_COMPILER_TYPE = system | ThirdParty (OpenFOAM) # WM_COMPILER_TYPE = system | ThirdParty (OpenFOAM)
@ -231,7 +231,7 @@ endif
# cleanup environment: # cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~
unset cleaned foamClean foamInstall foamOldDirs unset cleaned foamClean foamOldDirs
unalias _foamSource unalias _foamSource
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------