Skip to content
Snippets Groups Projects
Commit 4114a1e2 authored by Henry Weller's avatar Henry Weller
Browse files

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.
parent bf099f1d
Branches
Tags
1 merge request!60Merge foundation
......@@ -39,8 +39,8 @@
# \endcode
#
# Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
# This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/
# or $FOAM_INST_DIR/openfoam<VERSION>/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
......
......@@ -38,8 +38,8 @@
# \endcode
#
# Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
# This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/
# or $FOAM_INST_DIR/openfoam<VERSION>/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
......
......@@ -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:
......
......@@ -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
#------------------------------------------------------------------------------
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment