335 lines
11 KiB
Bash
335 lines
11 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/config.sh/settings
|
|
#
|
|
# Description
|
|
# Setup file for OpenFOAM
|
|
# Sourced from OpenFOAM-<VERSION>/etc/bashrc
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
# Set environment variables according to system type
|
|
: ${WM_OSTYPE:=POSIX}; export WM_OSTYPE # Default is POSIX
|
|
|
|
export WM_ARCH=$(uname -s)
|
|
case "$WM_ARCH" in
|
|
Linux)
|
|
WM_ARCH=linux
|
|
|
|
# Compiler specifics
|
|
case $(uname -m) in
|
|
i686)
|
|
export WM_ARCH_OPTION=32
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-fPIC'
|
|
export WM_CXXFLAGS='-fPIC -std=c++11'
|
|
export WM_LDFLAGS=
|
|
;;
|
|
|
|
x86_64)
|
|
: ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION # Default to 64-bit
|
|
case "$WM_ARCH_OPTION" in
|
|
32)
|
|
export WM_COMPILER_ARCH=64
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-m32 -fPIC'
|
|
export WM_CXXFLAGS='-m32 -fPIC -std=c++11'
|
|
export WM_LDFLAGS='-m32'
|
|
;;
|
|
64)
|
|
WM_ARCH=linux64
|
|
export WM_COMPILER_LIB_ARCH=64
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-m64 -fPIC'
|
|
export WM_CXXFLAGS='-m64 -fPIC -std=c++11'
|
|
export WM_LDFLAGS='-m64'
|
|
;;
|
|
*)
|
|
echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64" 1>&2
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
ia64)
|
|
WM_ARCH=linuxIA64
|
|
export WM_COMPILER=I64
|
|
;;
|
|
|
|
armv7l)
|
|
WM_ARCH=linuxARM7
|
|
export WM_ARCH_OPTION=32
|
|
export WM_COMPILER_LIB_ARCH=32
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-fPIC'
|
|
export WM_CXXFLAGS='-fPIC -std=c++11'
|
|
export WM_LDFLAGS=
|
|
;;
|
|
|
|
ppc64)
|
|
WM_ARCH=linuxPPC64
|
|
export WM_COMPILER_LIB_ARCH=64
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-m64 -fPIC'
|
|
export WM_CXXFLAGS='-m64 -fPIC -std=c++11'
|
|
export WM_LDFLAGS='-m64'
|
|
;;
|
|
|
|
ppc64le)
|
|
WM_ARCH=linuxPPC64le
|
|
export WM_COMPILER_LIB_ARCH=64
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-m64 -fPIC'
|
|
export WM_CXXFLAGS='-m64 -fPIC -std=c++11'
|
|
export WM_LDFLAGS='-m64'
|
|
;;
|
|
|
|
*)
|
|
echo Unknown processor type $(uname -m) for Linux 1>&2
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
SunOS)
|
|
WM_ARCH=SunOS64
|
|
WM_MPLIB=FJMPI
|
|
export WM_COMPILER_LIB_ARCH=64
|
|
export WM_CC='gcc'
|
|
export WM_CXX='g++'
|
|
export WM_CFLAGS='-mabi=64 -fPIC'
|
|
export WM_CXXFLAGS='-mabi=64 -fPIC -std=c++11'
|
|
export WM_LDFLAGS='-mabi=64 -G0'
|
|
;;
|
|
|
|
*) # An unsupported operating system
|
|
/bin/cat << UNSUPPORTED_OS 1>&2
|
|
===============================================================================
|
|
Your '$WM_ARCH' operating system is unsupported by this OpenFOAM release.
|
|
For further assistance, please contact www.OpenFOAM.com
|
|
===============================================================================
|
|
UNSUPPORTED_OS
|
|
;;
|
|
esac
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Optional jobControl directory: unset is equivalent to ~/.OpenFOAM/jobControl
|
|
# export FOAM_JOB_DIR="$HOME/.OpenFOAM/jobControl"
|
|
|
|
# wmake configuration
|
|
export WM_DIR=$WM_PROJECT_DIR/wmake
|
|
export WM_LINK_LANGUAGE=c++
|
|
export WM_LABEL_OPTION=Int$WM_LABEL_SIZE
|
|
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION
|
|
|
|
# Base executables/libraries
|
|
export FOAM_APPBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/bin
|
|
export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib
|
|
|
|
# External (ThirdParty) libraries
|
|
export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib
|
|
|
|
# Site-specific directory
|
|
siteDir="${WM_PROJECT_SITE:-$WM_PROJECT_INST_DIR/site}"
|
|
|
|
# Shared site executables/libraries
|
|
# Similar naming convention as ~OpenFOAM expansion
|
|
export FOAM_SITE_APPBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin
|
|
export FOAM_SITE_LIBBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib
|
|
|
|
# User executables/libraries
|
|
export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin
|
|
export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib
|
|
|
|
# DynamicCode templates
|
|
# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion
|
|
# export FOAM_CODE_TEMPLATES=$WM_PROJECT_DIR/etc/codeTemplates/dynamicCode
|
|
|
|
# Convenience
|
|
export FOAM_ETC=$WM_PROJECT_DIR/etc
|
|
export FOAM_APP=$WM_PROJECT_DIR/applications
|
|
export FOAM_SRC=$WM_PROJECT_DIR/src
|
|
export FOAM_TUTORIALS=$WM_PROJECT_DIR/tutorials
|
|
export FOAM_UTILITIES=$WM_PROJECT_DIR/applications/utilities
|
|
export FOAM_SOLVERS=$WM_PROJECT_DIR/applications/solvers
|
|
export FOAM_RUN=$WM_PROJECT_USER_DIR/run
|
|
|
|
# Add wmake to the path - not required for runtime-only environment
|
|
[ -d "$WM_DIR" ] && PATH=$WM_DIR:$PATH
|
|
# Add OpenFOAM scripts to the path
|
|
export PATH=$WM_PROJECT_DIR/bin:$PATH
|
|
|
|
# Add site-specific scripts to path - only if they exist
|
|
if [ -d "$siteDir/bin" ] # Generic
|
|
then
|
|
_foamAddPath "$siteDir/bin"
|
|
fi
|
|
if [ -d "$siteDir/$WM_PROJECT_VERSION/bin" ] # Version-specific
|
|
then
|
|
_foamAddPath "$siteDir/$WM_PROJECT_VERSION/bin"
|
|
fi
|
|
unset siteDir
|
|
|
|
_foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN
|
|
_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last
|
|
if [ -n "$FOAM_EXT_LIBBIN" ] # External libraries (allowed to be unset)
|
|
then
|
|
_foamAddLib $FOAM_EXT_LIBBIN
|
|
fi
|
|
_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Compiler settings
|
|
# ~~~~~~~~~~~~~~~~~
|
|
|
|
# Default to system compiler
|
|
: ${WM_COMPILER_TYPE:=system}; export WM_COMPILER_TYPE
|
|
|
|
# Adjust for non-gcc compilers
|
|
case "$WM_COMPILER" in
|
|
Clang*)
|
|
# Using clang - not gcc
|
|
export WM_CC='clang'
|
|
export WM_CXX='clang++'
|
|
;;
|
|
Icc*)
|
|
# Using icc - not gcc
|
|
export WM_CC='icc'
|
|
export WM_CXX='icpc'
|
|
;;
|
|
esac
|
|
|
|
# Clear prior to sourcing
|
|
unset gcc_version gmp_version mpfr_version mpc_version
|
|
unset GMP_ARCH_PATH MPFR_ARCH_PATH
|
|
|
|
# Load pre-defined compiler versions
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
_foamEtc config.sh/compiler
|
|
|
|
case "$WM_COMPILER_TYPE-$WM_COMPILER" in
|
|
ThirdParty-Gcc*)
|
|
gccDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gcc_version
|
|
gmpDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/${gmp_version:-gmp-system}
|
|
mpfrDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/${mpfr_version:-mpfr-system}
|
|
mpcDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/${mpc_version:-mpc-system}
|
|
|
|
# Check that the compiler directory can be found
|
|
[ -d "$gccDir" ] || /bin/cat << GCC_NOT_FOUND 1>&2
|
|
===============================================================================
|
|
Warning in $WM_PROJECT_DIR/etc/config.sh/settings:
|
|
Cannot find '$WM_COMPILER' compiler installation
|
|
$gccDir
|
|
|
|
Either install this compiler version, or use the system compiler by setting
|
|
WM_COMPILER_TYPE to 'system' in \$WM_PROJECT_DIR/etc/bashrc.
|
|
===============================================================================
|
|
GCC_NOT_FOUND
|
|
|
|
_foamAddMan $gccDir/man
|
|
_foamAddPath $gccDir/bin
|
|
|
|
# Add ThirdParty compiler libraries to run-time environment
|
|
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH
|
|
|
|
# Add ThirdParty gmp/mpfr/mpc libraries to run-time environment
|
|
if [ "${gmpDir##*-}" != system ]
|
|
then
|
|
_foamAddLib $gmpDir/lib$WM_COMPILER_LIB_ARCH
|
|
export GMP_ARCH_PATH=$gmpDir # For ThirdParty CGAL
|
|
fi
|
|
if [ "${mpfrDir##*-}" != system ]
|
|
then
|
|
_foamAddLib $mpfrDir/lib$WM_COMPILER_LIB_ARCH
|
|
export MPFR_ARCH_PATH=$mpfrDir # For ThirdParty CGAL
|
|
fi
|
|
if [ "${mpcDir##*-}" != system ]
|
|
then
|
|
_foamAddLib $mpcDir/lib$WM_COMPILER_LIB_ARCH
|
|
fi
|
|
|
|
if [ "$FOAM_VERBOSE" -a "$PS1" ]
|
|
then
|
|
echo "Using ThirdParty compiler"
|
|
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})"
|
|
fi
|
|
;;
|
|
|
|
ThirdParty-Clang*)
|
|
clangDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$clang_version
|
|
|
|
# Check that the compiler directory can be found
|
|
[ -d "$clangDir" ] || /bin/cat << CLANG_NOT_FOUND 1>&2
|
|
===============================================================================
|
|
Warning in $WM_PROJECT_DIR/etc/config.sh/settings:
|
|
Cannot find '$WM_COMPILER' compiler installation
|
|
$clangDir
|
|
|
|
Either install this compiler version, or use the system compiler by setting
|
|
WM_COMPILER_TYPE to 'system' in \$WM_PROJECT_DIR/etc/bashrc.
|
|
===============================================================================
|
|
CLANG_NOT_FOUND
|
|
|
|
_foamAddMan $clangDir/share/man
|
|
_foamAddPath $clangDir/bin
|
|
|
|
if [ "$FOAM_VERBOSE" -a "$PS1" ]
|
|
then
|
|
echo "Using ThirdParty compiler"
|
|
echo " ${clangDir##*/}"
|
|
fi
|
|
;;
|
|
|
|
system-* | ThirdParty-*)
|
|
# Using system compiler or other ThirdParty compiler
|
|
;;
|
|
|
|
*)
|
|
/bin/cat << UNKNOWN_TYPE 1>&2
|
|
===============================================================================
|
|
Unknown WM_COMPILER_TYPE="$WM_COMPILER_TYPE" - treating as 'system'
|
|
Please check your settings
|
|
===============================================================================
|
|
UNKNOWN_TYPE
|
|
export WM_COMPILER_TYPE=system
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
# Cleanup
|
|
# ~~~~~~~
|
|
unset gcc_version gccDir
|
|
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
|
|
unset clang_version clangDir
|
|
|
|
#------------------------------------------------------------------------------
|