1 #----------------------------------*-sh-*--------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 #------------------------------------------------------------------------------
9 # This file is part of OpenFOAM.
11 # OpenFOAM is free software: you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
16 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # etc/config/settings.sh
28 # Startup file for OpenFOAM
29 # Sourced from OpenFOAM-<VERSION>/etc/bashrc
31 #------------------------------------------------------------------------------
43 # prefix to LD_LIBRARY_PATH
48 export LD_LIBRARY_PATH
=$1:$LD_LIBRARY_PATH
58 export MANPATH
=$1:$MANPATH
63 #------------------------------------------------------------------------------
64 # Set environment variables according to system type
65 export WM_ARCH
=`uname -s`
77 case "$WM_ARCH_OPTION" in
79 export WM_COMPILER_ARCH
=64
82 export WM_CFLAGS
='-m32 -fPIC'
83 export WM_CXXFLAGS
='-m32 -fPIC'
84 export WM_LDFLAGS
='-m32'
88 export WM_COMPILER_LIB_ARCH
=64
91 export WM_CFLAGS
='-m64 -fPIC'
92 export WM_CXXFLAGS
='-m64 -fPIC'
93 export WM_LDFLAGS
='-m64'
96 echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64"
103 export WM_COMPILER
=I64
109 export WM_COMPILER_LIB_ARCH
=64
112 export WM_CFLAGS
='-mabi=64 -fPIC'
113 export WM_CXXFLAGS
='-mabi=64 -fPIC'
114 export WM_LDFLAGS
='-mabi=64 -G0'
119 export WM_COMPILER_LIB_ARCH
=64
122 export WM_CFLAGS
='-m64 -fPIC'
123 export WM_CXXFLAGS
='-m64 -fPIC'
124 export WM_LDFLAGS
='-m64'
128 echo Unknown processor
type `uname -m` for Linux
136 export WM_COMPILER_LIB_ARCH
=64
139 export WM_CFLAGS
='-mabi=64 -fPIC'
140 export WM_CXXFLAGS
='-mabi=64 -fPIC'
141 export WM_LDFLAGS
='-mabi=64 -G0'
144 *) # an unsupported operating system
147 Your "$WM_ARCH" operating system is not supported by this release
148 of OpenFOAM. For further assistance, please contact www.OpenFOAM.org
155 #------------------------------------------------------------------------------
157 # location of the jobControl directory
158 export FOAM_JOB_DIR
=$WM_PROJECT_INST_DIR/jobControl
160 # wmake configuration
161 export WM_DIR
=$WM_PROJECT_DIR/wmake
162 export WM_LINK_LANGUAGE
=c
++
163 export WM_OPTIONS
=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
165 # base executables/libraries
166 export FOAM_APPBIN
=$WM_PROJECT_DIR/platforms
/$WM_OPTIONS/bin
167 export FOAM_LIBBIN
=$WM_PROJECT_DIR/platforms
/$WM_OPTIONS/lib
169 # external (ThirdParty) libraries
170 export FOAM_EXT_LIBBIN
=$WM_THIRD_PARTY_DIR/platforms
/$WM_OPTIONS/lib
172 # shared site executables/libraries
173 # similar naming convention as ~OpenFOAM expansion
174 if [ -n "$WM_PROJECT_SITE" ]
176 export FOAM_SITE_APPBIN
=$WM_PROJECT_SITE/$WM_PROJECT_VERSION/platforms
/$WM_OPTIONS/bin
177 export FOAM_SITE_LIBBIN
=$WM_PROJECT_SITE/$WM_PROJECT_VERSION/platforms
/$WM_OPTIONS/lib
179 export FOAM_SITE_APPBIN
=$WM_PROJECT_INST_DIR/site
/$WM_PROJECT_VERSION/platforms
/$WM_OPTIONS/bin
180 export FOAM_SITE_LIBBIN
=$WM_PROJECT_INST_DIR/site
/$WM_PROJECT_VERSION/platforms
/$WM_OPTIONS/lib
183 # user executables/libraries
184 export FOAM_USER_APPBIN
=$WM_PROJECT_USER_DIR/platforms
/$WM_OPTIONS/bin
185 export FOAM_USER_LIBBIN
=$WM_PROJECT_USER_DIR/platforms
/$WM_OPTIONS/lib
187 # dynamicCode templates
188 # - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion
189 # export FOAM_CODE_TEMPLATES=$WM_PROJECT_DIR/etc/codeTemplates/dynamicCode
192 export FOAM_APP
=$WM_PROJECT_DIR/applications
193 export FOAM_SRC
=$WM_PROJECT_DIR/src
194 export FOAM_TUTORIALS
=$WM_PROJECT_DIR/tutorials
195 export FOAM_UTILITIES
=$FOAM_APP/utilities
196 export FOAM_SOLVERS
=$FOAM_APP/solvers
197 export FOAM_RUN
=$WM_PROJECT_USER_DIR/run
199 # add wmake to the path - not required for runtime only environment
200 [ -d "$WM_DIR" ] && PATH
=$WM_DIR:$PATH
201 # add OpenFOAM scripts to the path
202 export PATH
=$WM_PROJECT_DIR/bin
:$PATH
204 _foamAddPath
$FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN
205 # Make sure to pick up dummy versions of external libraries last
206 _foamAddLib
$FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$FOAM_LIBBIN/dummy
210 unset gcc_version gmp_version mpfr_version mpc_version
211 unset MPFR_ARCH_PATH GMP_ARCH_PATH
213 # Location of compiler installation
214 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215 if [ -z "$foamCompiler" ]
218 echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
219 echo " foamCompiler not set, using '$foamCompiler'" 1>&2
222 case "${foamCompiler}" in
223 OpenFOAM | ThirdParty
)
224 case "$WM_COMPILER" in
225 Gcc | Gcc
++0x | Gcc46 | Gcc46
++0x
)
226 gcc_version
=gcc-4.6
.1
227 gmp_version
=gmp-5.0
.1
228 mpfr_version
=mpfr-2.4
.2
229 mpc_version
=mpc-0.8
.1
232 gcc_version
=gcc-4.5
.2
233 gmp_version
=gmp-5.0
.1
234 mpfr_version
=mpfr-2.4
.2
235 mpc_version
=mpc-0.8
.1
238 gcc_version
=gcc-4.4
.3
239 gmp_version
=gmp-5.0
.1
240 mpfr_version
=mpfr-2.4
.2
243 gcc_version
=gcc-4.3
.3
244 gmp_version
=gmp-4.2
.4
245 mpfr_version
=mpfr-2.4
.1
248 # using clang - not gcc
250 export WM_CXX
='clang++'
251 #clang_version=llvm-2.9
252 clang_version
=llvm-svn
256 echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:"
257 echo " Unknown OpenFOAM compiler type '$WM_COMPILER'"
258 echo " Please check your settings"
263 # optional configuration tweaks:
264 _foamSource
`$WM_PROJECT_DIR/bin/foamEtcFile config/compiler.sh`
266 if [ -n "$gcc_version" ]
268 gccDir
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER_ARCH/$gcc_version
269 gmpDir
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version
270 mpfrDir
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version
271 mpcDir
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER_ARCH/$mpc_version
273 # Check that the compiler directory can be found
274 [ -d "$gccDir" ] ||
{
276 echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:"
277 echo " Cannot find $gccDir installation."
278 echo " Please install this compiler version or if you wish to use the system compiler,"
279 echo " change the 'foamCompiler' setting to 'system'"
283 _foamAddMan
$gccDir/man
284 _foamAddPath
$gccDir/bin
286 # add compiler libraries to run-time environment
287 # 64-bit needs lib64, but 32-bit needs lib (not lib32)
288 if [ "$WM_ARCH_OPTION" = 64 ]
290 _foamAddLib
$gccDir/lib
$WM_COMPILER_LIB_ARCH
292 _foamAddLib
$gccDir/lib
296 # add gmp/mpfr libraries to run-time environment
297 _foamAddLib
$gmpDir/lib
298 _foamAddLib
$mpfrDir/lib
300 # add mpc libraries (not need for older gcc) to run-time environment
301 if [ -n "$mpc_version" ]
303 _foamAddLib
$mpcDir/lib
306 # used by boost/CGAL:
307 export MPFR_ARCH_PATH
=$mpfrDir
308 export GMP_ARCH_PATH
=$gmpDir
310 unset gcc_version gccDir
311 unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
313 if [ -n "$clang_version" ]
315 clangDir
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER_ARCH/$clang_version
317 # Check that the compiler directory can be found
318 [ -d "$clangDir" ] ||
{
320 echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:"
321 echo " Cannot find $clangDir installation."
322 echo " Please install this compiler version or if you wish to use the system compiler,"
323 echo " change the 'foamCompiler' setting to 'system'"
327 _foamAddMan
$clangDir/share
/man
328 _foamAddPath
$clangDir/bin
330 unset clang_version clangDir
333 # okay, use system compiler
336 echo "Warn: foamCompiler='$foamCompiler' is unsupported" 1>&2
337 echo " treating as 'system' instead" 1>&2
343 # add c++0x flags for external programs
345 if [ -n "$WM_CXXFLAGS" ]
347 case "$WM_COMPILER" in
349 WM_CXXFLAGS
="$WM_CXXFLAGS -std=c++0x"
358 boost_version
=boost_1_45_0
359 cgal_version
=CGAL-3.8
361 export BOOST_ARCH_PATH
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER/$boost_version
362 export CGAL_ARCH_PATH
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER/$cgal_version
364 # enabled if CGAL is available
365 if [ -d "$CGAL_ARCH_PATH" ]
367 if [ -d "$BOOST_ARCH_PATH" ]
369 _foamAddLib
$BOOST_ARCH_PATH/lib
371 unset BOOST_ARCH_PATH
373 _foamAddLib
$CGAL_ARCH_PATH/lib
375 unset BOOST_ARCH_PATH CGAL_ARCH_PATH MPFR_ARCH_PATH GMP_ARCH_PATH
378 unset boost_version cgal_version
381 # Communications library
382 # ~~~~~~~~~~~~~~~~~~~~~~
384 unset MPI_ARCH_PATH MPI_HOME FOAM_MPI_LIBBIN
388 export FOAM_MPI
=openmpi-1.5
.3
389 # optional configuration tweaks:
390 _foamSource
`$WM_PROJECT_DIR/bin/foamEtcFile config/openmpi.sh`
392 export MPI_ARCH_PATH
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER/$FOAM_MPI
394 # Tell OpenMPI where to find its install directory
395 export OPAL_PREFIX
=$MPI_ARCH_PATH
397 _foamAddPath
$MPI_ARCH_PATH/bin
398 _foamAddLib
$MPI_ARCH_PATH/lib
399 _foamAddMan
$MPI_ARCH_PATH/man
403 # Use the system installed openmpi, get library directory via mpicc
404 export FOAM_MPI
=openmpi-system
406 # Set compilation flags here instead of in wmake/rules/../mplibSYSTEMOPENMPI
407 export PINC
="`mpicc --showme:compile`"
408 export PLIBS
="`mpicc --showme:link`"
409 libDir
=`echo "$PLIBS" | sed -e 's/.*-L\([^ ]*\).*/\1/'`
411 # Bit of a hack: strip off 'lib' and hope this is the path to openmpi
412 # include files and libraries.
413 export MPI_ARCH_PATH
="${libDir%/*}"
415 if [ "$FOAM_VERBOSE" -a "$PS1" ]
417 echo "Using system installed MPI:"
418 echo " compile flags : $PINC"
419 echo " link flags : $PLIBS"
420 echo " libmpi dir : $libDir"
428 export FOAM_MPI
=mpich2-1.1
.1p1
429 export MPI_HOME
=$WM_THIRD_PARTY_DIR/$FOAM_MPI
430 export MPI_ARCH_PATH
=$WM_THIRD_PARTY_DIR/platforms
/$WM_ARCH$WM_COMPILER/$FOAM_MPI
432 _foamAddPath
$MPI_ARCH_PATH/bin
433 _foamAddLib
$MPI_ARCH_PATH/lib
434 _foamAddMan
$MPI_ARCH_PATH/share
/man
438 export FOAM_MPI
=mpich-gm
439 export MPI_ARCH_PATH
=/opt
/mpi
440 export MPICH_PATH
=$MPI_ARCH_PATH
441 export GM_LIB_PATH
=/opt
/gm
/lib64
443 _foamAddPath
$MPI_ARCH_PATH/bin
444 _foamAddLib
$MPI_ARCH_PATH/lib
445 _foamAddLib
$GM_LIB_PATH
449 export FOAM_MPI
=hpmpi
450 export MPI_HOME
=/opt
/hpmpi
451 export MPI_ARCH_PATH
=$MPI_HOME
453 _foamAddPath
$MPI_ARCH_PATH/bin
457 _foamAddLib
$MPI_ARCH_PATH/lib
/linux_ia32
461 _foamAddLib
$MPI_ARCH_PATH/lib
/linux_amd64
464 _foamAddLib
$MPI_ARCH_PATH/lib
/linux_ia64
467 echo Unknown processor
type `uname -m` for Linux
473 export FOAM_MPI
=gamma
474 export MPI_ARCH_PATH
=/usr
479 export MPI_ARCH_PATH
=/opt
/mpi
483 export FOAM_MPI
=fjmpi
484 export MPI_ARCH_PATH
=/opt
/FJSVmpi2
486 _foamAddPath
$MPI_ARCH_PATH/bin
487 _foamAddLib
$MPI_ARCH_PATH/lib
/sparcv9
488 _foamAddLib
/opt
/FSUNf90
/lib
/sparcv9
489 _foamAddLib
/opt
/FJSVpnidt
/lib
493 export FOAM_MPI
=qsmpi
494 export MPI_ARCH_PATH
=/usr
/lib
/mpi
496 _foamAddPath
$MPI_ARCH_PATH/bin
497 _foamAddLib
$MPI_ARCH_PATH/lib
501 lastCharID
=$
(( ${#MPI_ROOT} - 1 ))
502 if [ "${MPI_ROOT:$lastCharID:1}" == '/' ]
504 MPI_ROOT
=${MPI_ROOT:0:$lastCharID}
507 export FOAM_MPI
=${MPI_ROOT##*/}
508 export MPI_ARCH_PATH
=$MPI_ROOT
510 if [ ! -d "$MPI_ROOT" -o -z "$MPI_ARCH_PATH" ]
512 echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
513 echo " MPI_ROOT not a valid mpt installation directory or ending in a '/'." 1>&2
514 echo " Please set MPI_ROOT to the mpt installation directory." 1>&2
515 echo " MPI_ROOT currently set to '$MPI_ROOT'" 1>&2
518 if [ "$FOAM_VERBOSE" -a "$PS1" ]
520 echo "Using SGI MPT:"
521 echo " MPI_ROOT : $MPI_ROOT"
522 echo " FOAM_MPI : $FOAM_MPI"
525 _foamAddPath
$MPI_ARCH_PATH/bin
526 _foamAddLib
$MPI_ARCH_PATH/lib
530 export FOAM_MPI
=dummy
534 # add (non-dummy) MPI implementation
535 # dummy MPI already added to LD_LIBRARY_PATH and has no external libraries
536 if [ "$FOAM_MPI" != dummy
]
538 _foamAddLib
$FOAM_LIBBIN/$FOAM_MPI:$FOAM_EXT_LIBBIN/$FOAM_MPI
543 # Set the minimum MPI buffer size (used by all platforms except SGI MPI)
544 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
545 : ${minBufferSize:=20000000}
547 if [ "${MPI_BUFFER_SIZE:=$minBufferSize}" -lt $minBufferSize ]
549 MPI_BUFFER_SIZE
=$minBufferSize
551 export MPI_BUFFER_SIZE
554 # cleanup environment:
555 # ~~~~~~~~~~~~~~~~~~~~
556 unset _foamAddPath _foamAddLib _foamAddMan foamCompiler minBufferSize
558 # ----------------------------------------------------------------- end-of-file