diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 72f1aa4a93..c0aac58a96 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -39,8 +39,8 @@ # \endcode # # Note -# This script must exist in /OpenFOAM-/bin/ -# or /openfoam/bin/ (for the debian version) +# This script must exist in $FOAM_INST_DIR/OpenFOAM-/bin/ +# or $FOAM_INST_DIR/openfoam/bin/ (for the debian version) # #------------------------------------------------------------------------------- usage() { @@ -86,7 +86,7 @@ binDir="${0%/*}" # the project dir: projectDir="${binDir%/bin}" -# the prefix dir (same as foamInstall): +# the prefix dir (same as $FOAM_INST_DIR): prefixDir="${projectDir%/*}" # the name used for the project directory diff --git a/bin/foamExec b/bin/foamExec index d0bf1d556e..a63f326ade 100755 --- a/bin/foamExec +++ b/bin/foamExec @@ -38,8 +38,8 @@ # \endcode # # Note -# This script must exist in /OpenFOAM-/bin/ -# or /openfoam/bin/ (for the debian version) +# This script must exist in $FOAM_INST_DIR/OpenFOAM-/bin/ +# or $FOAM_INST_DIR/openfoam/bin/ (for the debian version) # # foamEtcFile must be found in the same directory as this script # @@ -75,7 +75,7 @@ binDir="${0%/*}" # the project dir: projectDir="${binDir%/bin}" -# the prefix dir (same as foamInstall): +# the prefix dir (same as $FOAM_INST_DIR): prefixDir="${projectDir%/*}" # # the name used for the project directory diff --git a/etc/bashrc b/etc/bashrc index 98c22772cf..3394c0894f 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -37,25 +37,24 @@ export WM_PROJECT_VERSION=dev ################################################################################ # USER EDITABLE PART: Changes made here may be lost with the next upgrade # -# either set $FOAM_INST_DIR before sourcing this file or set -# 'foamInstall' below to where OpenFOAM is installed +# FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to +# the directory containing this file if sourced by a bash shell. # -# Location of the OpenFOAM installation -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -foamInstall=$HOME/$WM_PROJECT -# foamInstall=~$WM_PROJECT -# foamInstall=/opt/$WM_PROJECT -# foamInstall=/usr/local/$WM_PROJECT +# Please set to the appropriate path if the default is not correct. +# +[ $BASH_SOURCE ] && \ +export FOAM_INST_DIR=${BASH_SOURCE%/*/*/*} || \ +export FOAM_INST_DIR=$HOME/OpenFOAM +# 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 ################################################################################ -# -# These are the defaults for this version which should generally be -# overridden from the prefs.sh file or from command-line specification -# -#- note the location for later use (eg, in job scripts) -: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR +# The default environment variables below can be overridden in a prefs.sh file +# located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM, +# $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site #- Compiler location: # WM_COMPILER_TYPE= system | ThirdParty (OpenFOAM) @@ -202,7 +201,7 @@ fi # Cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ -unset cleaned foamClean foamInstall foamOldDirs +unset cleaned foamClean foamOldDirs # Unload initialization functions: diff --git a/etc/cshrc b/etc/cshrc index 795bfa5e26..13e7177a7f 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -36,25 +36,25 @@ setenv WM_PROJECT_VERSION dev ################################################################################ # USER EDITABLE PART: Changes made here may be lost with the next upgrade # -# either setenv FOAM_INST_DIR before sourcing this file or set -# 'foamInstall' below to where OpenFOAM is installed +# FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to +# the directory containing this file. # -# Location of the OpenFOAM installation -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -set foamInstall = $HOME/$WM_PROJECT -# set foamInstall = ~$WM_PROJECT -# set foamInstall = /opt/$WM_PROJECT -# set foamInstall = /usr/local/$WM_PROJECT +# Please set to the appropriate path if the default is not correct. +# +setenv FOAM_INST_DIR `lsof +p $$ |& grep -oE '/.*OpenFOAM[^/]*/etc/cshrc' | \ + sed 's%/OpenFOAM[^/]*/etc/cshrc%%'` +echo $FOAM_INST_DIR +# 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 ################################################################################ -# -# These are the defaults for this version which should generally be -# overridden from the prefs.csh file or from command-line specification -# -#- note the location for later use (eg, in job scripts) -if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall +# The default environment variables below can be overridden in a prefs.sh file +# located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM, +# $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site #- Compiler location: # WM_COMPILER_TYPE = system | ThirdParty (OpenFOAM) @@ -231,7 +231,7 @@ endif # cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ -unset cleaned foamClean foamInstall foamOldDirs +unset cleaned foamClean foamOldDirs unalias _foamSource #------------------------------------------------------------------------------