settings 10.6 KB
Newer Older
Henry's avatar
Henry committed
1
2
3
4
#----------------------------------*-sh-*--------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
Henry Weller's avatar
Henry Weller committed
5
#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
6
#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
Henry's avatar
Henry committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#------------------------------------------------------------------------------
# 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
25
#     etc/config.sh/settings
Henry's avatar
Henry committed
26
27
#
# Description
28
#     Setup file for OpenFOAM
Henry's avatar
Henry committed
29
30
31
32
#     Sourced from OpenFOAM-<VERSION>/etc/bashrc
#
#------------------------------------------------------------------------------
# Set environment variables according to system type
mark's avatar
mark committed
33
: ${WM_OSTYPE:=POSIX}; export WM_OSTYPE  # Default is POSIX
Henry's avatar
Henry committed
34

mark's avatar
mark committed
35
export WM_ARCH=$(uname -s)
Henry's avatar
Henry committed
36
37
38
39
case "$WM_ARCH" in
Linux)
    WM_ARCH=linux

40
    # Compiler specifics
41
42
43
44
45
46
    case $(uname -m) in
    i686)
        export WM_ARCH_OPTION=32
        export WM_CC='gcc'
        export WM_CXX='g++'
        export WM_CFLAGS='-fPIC'
47
        export WM_CXXFLAGS='-fPIC -std=c++11'
48
        export WM_LDFLAGS=
Henry's avatar
Henry committed
49
50
51
        ;;

    x86_64)
52
        : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION  # Default to 64-bit
Henry's avatar
Henry committed
53
54
55
56
57
58
        case "$WM_ARCH_OPTION" in
        32)
            export WM_COMPILER_ARCH=64
            export WM_CC='gcc'
            export WM_CXX='g++'
            export WM_CFLAGS='-m32 -fPIC'
59
            export WM_CXXFLAGS='-m32 -fPIC -std=c++11'
Henry's avatar
Henry committed
60
61
62
63
64
65
66
67
            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'
68
            export WM_CXXFLAGS='-m64 -fPIC -std=c++11'
Henry's avatar
Henry committed
69
70
71
            export WM_LDFLAGS='-m64'
            ;;
        *)
72
            echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64" 1>&2
Henry's avatar
Henry committed
73
74
75
76
77
78
79
80
81
82
83
            ;;
        esac
        ;;

    ia64)
        WM_ARCH=linuxIA64
        export WM_COMPILER=I64
        ;;

    armv7l)
        WM_ARCH=linuxARM7
84
        export WM_ARCH_OPTION=32
Henry's avatar
Henry committed
85
86
87
88
        export WM_COMPILER_LIB_ARCH=32
        export WM_CC='gcc'
        export WM_CXX='g++'
        export WM_CFLAGS='-fPIC'
89
        export WM_CXXFLAGS='-fPIC -std=c++11'
Henry's avatar
Henry committed
90
91
92
93
94
95
96
97
98
        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'
99
        export WM_CXXFLAGS='-m64 -fPIC -std=c++11'
100
101
102
103
104
105
106
107
108
        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'
109
        export WM_CXXFLAGS='-m64 -fPIC -std=c++11'
Henry's avatar
Henry committed
110
111
112
113
        export WM_LDFLAGS='-m64'
        ;;

    *)
114
        echo Unknown processor type $(uname -m) for Linux 1>&2
Henry's avatar
Henry committed
115
116
117
118
119
120
121
122
123
124
125
        ;;
    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'
126
    export WM_CXXFLAGS='-mabi=64 -fPIC -std=c++11'
Henry's avatar
Henry committed
127
128
129
    export WM_LDFLAGS='-mabi=64 -G0'
    ;;

130
*)  # An unsupported operating system
131
132
133
    /bin/cat << UNSUPPORTED_OS 1>&2
===============================================================================
Your '$WM_ARCH' operating system is unsupported by this OpenFOAM release.
134
For further assistance, please contact www.OpenFOAM.com
135
136
===============================================================================
UNSUPPORTED_OS
Henry's avatar
Henry committed
137
138
139
140
141
142
    ;;
esac


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

143
144
# Optional jobControl directory: unset is equivalent to ~/.OpenFOAM/jobControl
# export FOAM_JOB_DIR="$HOME/.OpenFOAM/jobControl"
Henry's avatar
Henry committed
145
146
147
148

# wmake configuration
export WM_DIR=$WM_PROJECT_DIR/wmake
export WM_LINK_LANGUAGE=c++
149
150
export WM_LABEL_OPTION=Int$WM_LABEL_SIZE
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION
Henry's avatar
Henry committed
151

152
# Base executables/libraries
Henry's avatar
Henry committed
153
154
155
export FOAM_APPBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/bin
export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib

156
# External (ThirdParty) libraries
157
export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib
Henry's avatar
Henry committed
158

159
# Site-specific directory
Henry's avatar
Henry committed
160
161
siteDir="${WM_PROJECT_SITE:-$WM_PROJECT_INST_DIR/site}"

162
163
# Shared site executables/libraries
# Similar naming convention as ~OpenFOAM expansion
Henry's avatar
Henry committed
164
165
166
export FOAM_SITE_APPBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin
export FOAM_SITE_LIBBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib

167
# User executables/libraries
Henry's avatar
Henry committed
168
169
170
export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin
export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib

171
# DynamicCode templates
Henry's avatar
Henry committed
172
173
174
# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion
# export FOAM_CODE_TEMPLATES=$WM_PROJECT_DIR/etc/codeTemplates/dynamicCode

175
# Convenience
Henry's avatar
Henry committed
176
export FOAM_ETC=$WM_PROJECT_DIR/etc
Henry's avatar
Henry committed
177
178
179
180
181
182
183
export FOAM_APP=$WM_PROJECT_DIR/applications
export FOAM_SRC=$WM_PROJECT_DIR/src
export FOAM_TUTORIALS=$WM_PROJECT_DIR/tutorials
export FOAM_UTILITIES=$FOAM_APP/utilities
export FOAM_SOLVERS=$FOAM_APP/solvers
export FOAM_RUN=$WM_PROJECT_USER_DIR/run

184
# Add wmake to the path - not required for runtime-only environment
Henry's avatar
Henry committed
185
[ -d "$WM_DIR" ] && PATH=$WM_DIR:$PATH
186
# Add OpenFOAM scripts to the path
Henry's avatar
Henry committed
187
188
export PATH=$WM_PROJECT_DIR/bin:$PATH

189
190
# Add site-specific scripts to path - only if they exist
if [ -d "$siteDir/bin" ]                        # Generic
Henry's avatar
Henry committed
191
192
193
then
    _foamAddPath "$siteDir/bin"
fi
194
if [ -d "$siteDir/$WM_PROJECT_VERSION/bin" ]    # Version-specific
Henry's avatar
Henry committed
195
196
197
198
199
200
then
    _foamAddPath "$siteDir/$WM_PROJECT_VERSION/bin"
fi
unset siteDir

_foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN
201
202
203
204
205
206
_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
Henry's avatar
Henry committed
207

mark's avatar
mark committed
208
209
#------------------------------------------------------------------------------

Henry's avatar
Henry committed
210
211
212
# Compiler settings
# ~~~~~~~~~~~~~~~~~

mark's avatar
mark committed
213
# Default to system compiler
214
: ${WM_COMPILER_TYPE:=system}; export WM_COMPILER_TYPE
Henry's avatar
Henry committed
215

mark's avatar
mark committed
216
217
218
219
220
221
222
223
224
225
226
# 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'
227
    ;;
mark's avatar
mark committed
228
esac
229

mark's avatar
mark committed
230
231
232
233
234
235
236
# 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
Henry's avatar
Henry committed
237

mark's avatar
mark committed
238
239
240
241
242
243
244
245
246
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
247
248
249
250
251
252
253
254
255
===============================================================================
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
Henry's avatar
Henry committed
256

mark's avatar
mark committed
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
    _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
Henry's avatar
Henry committed
277
278
    fi

mark's avatar
mark committed
279
    if [ "$FOAM_VERBOSE" -a "$PS1" ]
Henry's avatar
Henry committed
280
    then
mark's avatar
mark committed
281
282
283
284
        echo "Using ThirdParty compiler"
        echo "    ${gccDir##*/}  (${gmpDir##*/}  $${mpfrDir##*/}  ${mpcDir##*/})"
    fi
    ;;
Henry's avatar
Henry committed
285

mark's avatar
mark committed
286
287
288
289
290
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
291
292
293
294
295
296
297
298
299
===============================================================================
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
Henry's avatar
Henry committed
300

mark's avatar
mark committed
301
302
    _foamAddMan     $clangDir/share/man
    _foamAddPath    $clangDir/bin
303

mark's avatar
mark committed
304
305
306
307
    if [ "$FOAM_VERBOSE" -a "$PS1" ]
    then
        echo "Using ThirdParty compiler"
        echo "    ${clangDir##*/}"
Henry's avatar
Henry committed
308
    fi
mark's avatar
mark committed
309
    ;;
310

mark's avatar
mark committed
311
312
system-* | ThirdParty-*)
    # Using system compiler or other ThirdParty compiler
Henry's avatar
Henry committed
313
    ;;
mark's avatar
mark committed
314

Henry's avatar
Henry committed
315
*)
316
317
318
319
320
321
322
    /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
Henry's avatar
Henry committed
323
    ;;
324

Henry's avatar
Henry committed
325
326
esac

mark's avatar
mark committed
327
328
329
330
331
332
333

# Cleanup
# ~~~~~~~
unset gcc_version gccDir
unset gmp_version gmpDir  mpfr_version mpfrDir  mpc_version mpcDir
unset clang_version clangDir

334
#------------------------------------------------------------------------------