openfoam/etc/bashrc
Mark Olesen af49eaf625 ENH: default jobControl now under the '~/.OpenFOAM/jobControl' directory
- this implies that jobControl is a user-resource for OpenFOAM.
  It was previously located under $WM_PROJECT_INST_DIR/jobControl,
  but few users will have write access there.

- an unset FOAM_JOB_DIR variable is treated as "~/.OpenFOAM/jobControl",
  which can partially reduce environment clutter.

- provide argList::noJobInfo() to conveniently suppress job-info on an
  individual basis for short-running utilities (eg, foamListTimes) to
  avoid unneeded clutter.
2017-04-03 08:28:15 +02:00

220 lines
6.9 KiB
Bash

#----------------------------------*-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.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# File
# etc/bashrc
#
# Description
# Set the environment for OpenFOAM when using a POSIX shell.
# To be sourced manually or from the ~/.profile or ~/.bashrc files.
# Should be usable by any POSIX-compliant shell (eg, dash, ksh)
#
#------------------------------------------------------------------------------
export WM_PROJECT=OpenFOAM
export WM_PROJECT_VERSION=plus
################################################################################
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
#
# FOAM_INST_DIR = the parent directory containing the OpenFOAM installation(s).
# - If the OpenFOAM installation has this OpenFOAM-<VERSION>/etc/bashrc, the
# next lines should work when sourced by a BASH or ZSH shell.
# - If this does not produce the desired result, please 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
export FOAM_INST_DIR
unset rc
# 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
export WM_COMPILER_TYPE=system
#- Compiler:
# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL
# | Clang | Clang3[8-9] | Icc | IccKNL
export WM_COMPILER=Gcc
unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
#- Memory addressing:
# WM_ARCH_OPTION = 32 | 64
# - on a 64-bit OS this can be 32 or 64
# - on a 32-bit OS addressing is 32-bit and this option is not used
export WM_ARCH_OPTION=64
#- Precision:
# WM_PRECISION_OPTION = DP | SP
export WM_PRECISION_OPTION=DP
#- Label size:
# WM_LABEL_SIZE = 32 | 64
export WM_LABEL_SIZE=32
#- Optimised, debug, profiling:
# WM_COMPILE_OPTION = Opt | Debug | Prof
export WM_COMPILE_OPTION=Opt
#- MPI implementation:
# WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI
# | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
export WM_MPLIB=SYSTEMOPENMPI
#- Operating System:
# WM_OSTYPE = POSIX
#export WM_OSTYPE=POSIX
#- Floating-point signal handling:
# set or unset
export FOAM_SIGFPE=
#- memory initialisation:
# set or unset
#export FOAM_SETNAN=
################################################################################
# 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="$@"
_foamEval $@
# Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
#- Clean PATH
cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned"
#- Clean LD_LIBRARY_PATH
cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \
&& LD_LIBRARY_PATH="$cleaned"
#- Clean MANPATH
cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned"
export PATH LD_LIBRARY_PATH MANPATH
# Source project setup files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamEtc config.sh/settings
_foamEtc config.sh/aliases
# 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
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean PATH
cleaned=$($foamClean "$PATH") && PATH="$cleaned"
#- Clean LD_LIBRARY_PATH
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
#- Clean LD_PRELOAD
if [ -n "$LD_PRELOAD" ]
then
cleaned=$($foamClean "$LD_PRELOAD") && LD_PRELOAD="$cleaned"
export LD_PRELOAD
fi
# Cleanup environment
# ~~~~~~~~~~~~~~~~~~~
#- Functions
. $WM_PROJECT_DIR/etc/config.sh/functions
#- Variables (do as last for a clean exit code)
unset cleaned foamClean foamOldDirs
#------------------------------------------------------------------------------