Skip to content
Snippets Groups Projects
bashrc 6.72 KiB
Newer Older
#----------------------------------*-sh-*--------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM, licensed under GNU General Public License
#     <http://www.gnu.org/licenses/>.
#     etc/bashrc
#     Set OpenFOAM environment for POSIX shell (eg, bash,dash,zsh,...)
#     Source manually or from the ~/.profile or ~/.bashrc files.
# Note
#     Many environment variables can be overridden using a <prefs.sh> file
#     from one of these locations:
#     * user-specific:
#         * ~/.OpenFOAM/$WM_PROJECT_VERSION
#         * ~/.OpenFOAM
#     * group-specific:
#         * $WM_PROJECT_SITE/site/$WM_PROJECT_VERSION
#         * $WM_PROJECT_SITE/site
#     * general:
#         * $WM_PROJECT_DIR/etc
#
#     Any changes made to this bashrc file may be lost with the next upgrade.
#
#------------------------------------------------------------------------------

export WM_PROJECT=OpenFOAM
export WM_PROJECT_VERSION=plus
# [FOAM_INST_DIR] - parent directory containing the OpenFOAM installation.
#  * When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines
#    should work when sourced by BASH or ZSH shells. If this however fails,
#    set one of the fallback values to an appropriate path.
# --
rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
[ -n "$rc" ] && FOAM_INST_DIR=$(\cd $(dirname $rc)/../.. && \pwd -L) || \
FOAM_INST_DIR=$HOME/$WM_PROJECT
# FOAM_INST_DIR=/opt/$WM_PROJECT
# FOAM_INST_DIR=/usr/local/$WM_PROJECT
#
# END OF (NORMAL) USER EDITABLE PART
################################################################################
: # Extra safety - if the user commented out all fallback values
# Default environment variables.
# Can override with a <prefs.sh> file instead of editing below.
# [WM_COMPILER_TYPE] - Compiler location:
# = system | ThirdParty
export WM_COMPILER_TYPE=system
# [WM_COMPILER] - Compiler:
# = Gcc | Gcc4[8-9] | Gcc5[1-5] | Gcc6[1-3] | Gcc7[1-2] | GccKNL |
#   Clang | Clang3[8-9] | Clang[45]0 | Icc | IccKNL | Cray
# [WM_ARCH_OPTION] - Memory addressing:
# = 32 | 64
#   * on a 64-bit OS this can be 32 or 64
#   * on a 32-bit OS, it is always 32-bit and this option is ignored
# [WM_PRECISION_OPTION] - Floating-point precision:
# = DP | SP
export WM_PRECISION_OPTION=DP

# [WM_LABEL_SIZE] - Label size in bits:
# = 32 | 64
export WM_LABEL_SIZE=32

# [WM_COMPILE_OPTION] - Optimised, debug, profiling:
# = Opt | Debug | Prof
export WM_COMPILE_OPTION=Opt

# [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
#   HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
export WM_MPLIB=SYSTEMOPENMPI
# [FOAM_SIGFPE] - Trapping of floating-point exceptions.
#               - overrides the 'trapFpe' controlDict entry
# = true | false
# [FOAM_SETNAN] - Memory initialisation as NaN
#               - overrides the 'setNaN' controlDict entry
# = true | false
#export FOAM_SETNAN=false
# [WM_OSTYPE] - Operating System Type:
# = POSIX
#export WM_OSTYPE=POSIX

################################################################################

# The old dirs to be cleaned from the environment variables
foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
    $HOME/$WM_PROJECT/$USER $FOAM_USER_APPBIN $FOAM_USER_LIBBIN \
    $WM_PROJECT_SITE $FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN"
# Location of installation
# ~~~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
# Location of third-party software
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
# Location of site-specific templates etc
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# unset is equivalent to $WM_PROJECT_INST_DIR/site
if [ -d "$WM_PROJECT_SITE" ]
then
    export WM_PROJECT_SITE
else
    unset WM_PROJECT_SITE
fi

# Location of user files
# ~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION

# Load shell functions
# ~~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/functions
# Override definitions via prefs, with 'other' first so the sys-admin
# can provide base values independent of WM_PROJECT_SITE
_foamEtc -mode=o  prefs.sh
_foamEtc -mode=ug prefs.sh
# Evaluate command-line parameters and record settings for later.
# These can be used to set/unset values, specify additional files etc.
export FOAM_SETTINGS="$@"
# Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned"
cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \
cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned"
export PATH LD_LIBRARY_PATH MANPATH
# Source project setup files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamEtc config.sh/settings
if /usr/bin/tty -s 2>/dev/null  # Interactive shell
    _foamEtc config.sh/aliases

    # Bash completions
    if [ "${BASH_VERSINFO:-0}" -ge 4 ]
        _foamEtc config.sh/bash_completion


# Source user setup files for optional packages
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamEtc config.sh/mpi
_foamEtc config.sh/paraview
_foamEtc config.sh/vtk
_foamEtc config.sh/ensight
_foamEtc config.sh/gperftools
#_foamEtc config.sh/ADIOS
_foamEtc config.sh/CGAL
_foamEtc config.sh/scotch
_foamEtc config.sh/FFTW
# Clean environment paths again. Only remove duplicates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cleaned=$($foamClean "$PATH") && PATH="$cleaned"
cleaned=$($foamClean "$LD_LIBRARY_PATH") && LD_LIBRARY_PATH="$cleaned"
# Clean MANPATH (trailing ':' to find system pages)
cleaned=$($foamClean "$MANPATH") && MANPATH="${cleaned}:"

export PATH LD_LIBRARY_PATH MANPATH
    cleaned=$($foamClean "$LD_PRELOAD") && LD_PRELOAD="$cleaned"
# Cleanup environment
# ~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/functions
# Variables (do as last for a clean exit code)
unset cleaned foamClean foamOldDirs

#------------------------------------------------------------------------------