ThirdParty: llvm-3.6.0
[foam-extend-3.2.git] / etc / bashrc
blobca7171f3d2dfe88ea98a59050519da0649fea670
1 #!/bin/bash
2 #----------------------------------*-sh-*--------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration |
6 # \\ / A nd | For copyright notice see file Copyright
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # etc/bashrc
28 # Description
29 # Startup file for FOAM
30 # Sourced from ~/.profile or ~/.bashrc
31 # Should be usable by any POSIX-compliant shell (eg, ksh)
33 #------------------------------------------------------------------------------
35 export WM_PROJECT=foam
36 export WM_FORK=extend
37 export WM_PROJECT_VERSION=3.1
39 # helps to easily write #ifdefs to detect a dev-version
40 export FOAM_DEV=1
42 ###############################################################################
43 # USER EDITABLE PART
45 # either set $FOAM_INST_DIR before sourcing this file or set
46 # $foamInstall below to where FOAM is installed
48 # Location of FOAM installation
49 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50 foamInstall=$HOME/$WM_PROJECT
51 # foamInstall=~$WM_PROJECT
52 # foamInstall=/usr/local/$WM_PROJECT
53 # foamInstall=/opt/$WM_PROJECT
54 # foamInstall=/usr/lib
56 # END OF (NORMAL) USER EDITABLE PART
57 ################################################################################
59 # note the location for later use (eg, in job scripts)
60 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
62 # The old dirs to be cleaned from the various environment variables
63 # - remove anything under top-level directory.
64 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
65 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
66 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
67 then
68 foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
72 # Location of site/user files
73 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
75 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_FORK-$WM_PROJECT_VERSION
76 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
78 # Location of third-party software
79 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 #: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION}; export WM_THIRD_PARTY_DIR
81 export WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty
83 # Enabling the usage of third-party software
84 # This can be overriden in prefs.sh
85 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86 # For AllMake.stage1
87 export WM_THIRD_PARTY_USE_CMAKE_322=1
90 # For AllMake.stage2
91 export WM_THIRD_PARTY_USE_OPENMPI_184=1
94 # For AllMake.stage3
95 export WM_THIRD_PARTY_USE_METIS_510=1
96 export WM_THIRD_PARTY_USE_PARMGRIDGEN_10=1
97 export WM_THIRD_PARTY_USE_LIBCCMIO_261=1
98 export WM_THIRD_PARTY_USE_MESQUITE_212=1
99 export WM_THIRD_PARTY_USE_SCOTCH_604=1
100 export WM_THIRD_PARTY_USE_PARMETIS_403=1
101 export WM_THIRD_PARTY_USE_PYFOAM_064=1
102 export WM_THIRD_PARTY_USE_HWLOC_1101=1
105 # For AllMake.stage4
106 export WM_THIRD_PARTY_USE_QT_486=1
107 export WM_THIRD_PARTY_USE_PARAVIEW_431=1
110 # Source files, possibly with some verbosity
111 _foamSource()
113 while [ $# -ge 1 ]
115 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
116 . $1
117 shift
118 done
121 # Add in preset user or site preferences:
122 if [ -e $WM_PROJECT_DIR/etc/prefs.sh ]
123 then
124 _foamSource $WM_PROJECT_DIR/etc/prefs.sh
125 else
126 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "No prefs.sh found"
130 # Evaluate command-line parameters
131 while [ $# -gt 0 ]
133 case "$1" in
135 # name= -> unset name
136 eval "unset ${1%=}"
138 *=*)
139 # name=value -> export name=value
140 eval "export $1"
142 esac
143 shift
144 done
147 # Operating System/Platform
148 # ~~~~~~~~~~~~~~~~~~~~~~~~~
149 # WM_OSTYPE = POSIX | ????
150 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
153 # Compiler: set to Gcc or Icc (for Intel's icc)
154 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
156 #: ${WM_COMPILER:=Icc}; export WM_COMPILER
158 export WM_COMPILER_ARCH=
159 export WM_COMPILER_LIB_ARCH=
162 # Compilation options (architecture, precision, optimised, debug or profiling)
163 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165 # WM_ARCH_OPTION = 32 | 64
166 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
168 # WM_PRECISION_OPTION = LDP | DP | SP
169 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
171 # WM_COMPILE_OPTION = Opt | Debug | Prof
172 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
174 # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI | MVAPICH2
175 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
177 # WM_NCOMPPROCS = <number of processes to use>
178 # Warning: Need to use a complete path for foamGetSystemInfo because the PATH
179 # environment variable is not properly initialized yet.
180 : ${WM_NCOMPPROCS:=`$WM_PROJECT_DIR/bin/foamGetSystemInfo -nbrCores`}; export WM_NCOMPPROCS
183 # Run options (floating-point signal handling and memory initialisation)
184 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185 export FOAM_SIGFPE=
186 # export FOAM_SETNAN=
189 # Detect system type and set environment variables appropriately
190 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191 export WM_ARCH=`uname -s`
193 case $WM_ARCH in
194 Linux)
195 WM_ARCH=linux
197 # compiler specifics
198 case `uname -m` in
199 i686)
202 x86_64)
203 case $WM_ARCH_OPTION in
205 export WM_COMPILER_ARCH='-64'
206 export WM_CFLAGS='-m32 -fPIC'
207 export WM_CXXFLAGS='-m32 -fPIC'
208 export WM_LDFLAGS='-m32'
211 WM_ARCH=linux64
212 export WM_COMPILER_LIB_ARCH=64
213 export WM_CFLAGS='-m64 -fPIC'
214 export WM_CXXFLAGS='-m64 -fPIC'
215 export WM_LDFLAGS='-m64'
218 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
220 esac
223 ia64)
224 WM_ARCH=linuxIA64
225 export WM_COMPILER=I64
228 mips64)
229 WM_ARCH=SiCortex64
230 export WM_COMPILER_LIB_ARCH=64
231 export WM_CFLAGS='-mabi=64 -fPIC'
232 export WM_CXXFLAGS='-mabi=64 -fPIC'
233 export WM_LDFLAGS='-mabi=64 -G0'
234 export WM_MPLIB=MPI
237 ppc64)
238 WM_ARCH=linuxPPC64
239 export WM_COMPILER_LIB_ARCH=64
240 export WM_CFLAGS='-m64 -fPIC'
241 export WM_CXXFLAGS='-m64 -fPIC'
242 export WM_LDFLAGS='-m64'
246 echo Unknown processor type `uname -m` for Linux
248 esac
251 Darwin)
252 # this makes certain things easier
253 export WM_ARCH_BASE=darwin
255 case `uname -p` in
256 powerpc)
257 export WM_ARCH=darwinPpc
259 i386)
260 export WM_ARCH=darwinIntel
263 echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
264 export WM_ARCH=darwinUnknown
266 esac
268 case $WM_ARCH_OPTION in
270 export WM_CFLAGS='-m32 -fPIC'
271 export WM_CXXFLAGS='-m32 -fPIC'
272 export WM_LDFLAGS='-m32'
275 export WM_ARCH=${WM_ARCH}64
276 export WM_CFLAGS='-m64 -fPIC'
277 export WM_CXXFLAGS='-m64 -fPIC'
278 export WM_LDFLAGS='-m64'
281 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
283 esac
285 # Using MacPorts
286 : ${MACOSX_MACPORTS_ROOT:='/opt/local/etc/macports'}; export MACOSX_MACPORTS_ROOT
287 which -s port >/dev/null
288 if [ $? -eq "0" ] && [ -d "$MACOSX_MACPORTS_ROOT" ]
289 then
290 if [ "$FOAM_VERBOSE" -a "$PS1" ]
291 then
292 echo "Using Macports binaries"
295 export WM_USE_MACPORT=1
296 export WM_BASE_COMPILER=`echo $WM_COMPILER | tr -d "[:digit:]"`
297 export WM_MACPORT_MPI_VERSION=`echo $WM_COMPILER | tr "[:upper:]" "[:lower:]"`
298 export WM_MACPORT_VERSION=`echo $WM_MACPORT_MPI_VERSION | tr -d "[:alpha:]" | sed -e "s/\(.\)\(.\)/\1\.\2/"`
300 if [ -z "$WM_CHOSEN_MAC_MPI" ]
301 then
302 if [ -e '/opt/local/bin/mpicc' ]
303 then
304 readlink /opt/local/bin/mpicc | grep openmpi >/dev/null
305 if [ $? -eq "0" ]
306 then
307 export WM_MPLIB=MACPORTOPENMPI
308 if [ "$FOAM_VERBOSE" -a "$PS1" ]
309 then
310 echo "Using OpenMPI from MacPorts"
312 else
313 readlink /opt/local/bin/mpicc | grep mpich >/dev/null
314 if [ $? -eq "0" ]
315 then
316 export WM_MPLIB=MACPORTMPICH
317 if [ "$FOAM_VERBOSE" -a "$PS1" ]
318 then
319 echo "Using MPICH from MacPorts"
321 else
322 echo "/opt/local/bin/mpicc neither OpenMPI nor MPICH. Confused. Defaulting to OPENMPI"
323 export WM_MPLIB=OPENMPI
327 else
328 export WM_MPLIB=$WM_CHOSEN_MAC_MPI
329 if [ "$FOAM_VERBOSE" -a "$PS1" ]
330 then
331 echo "User chose WM_CHOSEN_MAC_MPI=$WM_CHOSEN_MAC_MPI"
335 if [ "$WM_MPLIB" == "MACPORTOPENMPI" ]
336 then
337 if [ ! -e "/opt/local/lib/openmpi-$WM_MACPORT_MPI_VERSION" ]
338 then
339 export WM_MACPORT_MPI_VERSION=mp
340 if [ ! -e "/opt/local/lib/openmpi-$WM_MACPORT_MPI_VERSION" ]
341 then
342 echo "Proper OpenMPI not installed. Either do 'port install openmpi-$WM_MACPORT_MPI_VERSION' or 'port install openmpi-default'"
345 else
346 if [ "$WM_MPLIB" == "MACPORTMPICH" ]
347 then
348 if [ ! -e "/opt/local/lib/mpich-$WM_MACPORT_MPI_VERSION" ]
349 then
350 echo "MPICH wants the same version as the used compiler. Do 'port install mpich-$WM_MACPORT_MPI_VERSION'"
355 if [ "$WM_COMPILER" != "Gcc" ]
356 then
357 if [ "$WM_BASE_COMPILER" == "Gcc" ]
358 then
359 export WM_CC="gcc-mp-$WM_MACPORT_VERSION"
360 export WM_CXX="g++-mp-$WM_MACPORT_VERSION"
361 export WM_FC="gfortran-mp-$WM_MACPORT_VERSION"
362 elif [ "$WM_BASE_COMPILER" == "Clang" ]
363 then
364 export WM_CC="clang-mp-$WM_MACPORT_VERSION"
365 export WM_CXX="clang++-mp-$WM_MACPORT_VERSION"
366 # Seems like there is no Fortran-frontend for LLVM at thistime
367 elif [ "$WM_BASE_COMPILER" == "Dragonegg" ]
368 then
369 export WM_CC="dragonegg-$WM_MACPORT_VERSION-gcc"
370 export WM_CXX="dragonegg-$WM_MACPORT_VERSION-g++"
371 export WM_CXX="dragonegg-$WM_MACPORT_VERSION-gfortran"
372 else
373 echo "Unknown base compiler $WM_BASE_COMPILER"
376 ruleDirBase=$WM_PROJECT_DIR/wmake/rules/$WM_ARCH
377 ruleDirTarget=$ruleDirBase$WM_BASE_COMPILER
378 ruleDir=$ruleDirBase$WM_COMPILER
379 if [ ! -e $ruleDir ]
380 then
381 echo "Rule directory $ruleDir not existing. Linking to $ruleDirTarget"
382 ln -s $ruleDirTarget $ruleDir
384 unset ruleDir ruleDirBase
386 else
387 echo "Warning: You are not using MacPorts. Make sure your compilation and MPI environment is correctly initialized"
390 # Make sure that binaries use the best features of the used OS-Version
391 # We need to get rid of the revision number from this string. eg turn "10.7.5" into "10.7"
392 # v=(`sw_vers -productVersion | sed 's/\./ /g'`)
393 # export MACOSX_DEPLOYMENT_TARGET="${v[1]}.${v[2]}"
394 export MACOSX_DEPLOYMENT_TARGET=`sw_vers -productVersion | sed -e "s/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2/g"`
397 SunOS)
398 WM_ARCH=SunOS64
399 export WM_COMPILER_LIB_ARCH=64
400 export WM_CFLAGS='-mabi=64 -fPIC'
401 export WM_CXXFLAGS='-mabi=64 -fPIC'
402 export WM_LDFLAGS='-mabi=64 -G0'
403 export WM_MPLIB=FJMPI
406 *) # an unsupported operating system
407 cat <<USAGE
409 Your "$WM_ARCH" operating system is not supported by this release
410 of foam-extend. For further assistance, please contact www.foam-extend.org
412 USAGE
414 esac
417 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
418 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
419 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
421 #- Clean PATH
422 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
424 #- Clean LD_LIBRARY_PATH
425 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
427 #- Clean DYLD_LIBRARY_PATH
428 if [[ "$WM_ARCH_BASE" == "darwin" ]]
429 then
430 cleanEnv=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH="$cleanEnv"
433 #- Clean MANPATH
434 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
436 export PATH LD_LIBRARY_PATH MANPATH
438 # Source project setup files
439 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
441 _foamSource $WM_PROJECT_DIR/etc/settings.sh
442 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
445 # Source user setup files for optional packages
446 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
447 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
448 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
449 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
452 # Clean environment paths again. Only remove duplicates
453 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454 #- Clean PATH
455 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
457 #- Clean LD_LIBRARY_PATH
458 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
460 #- Clean MANPATH
461 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
463 export PATH LD_LIBRARY_PATH MANPATH
465 #- Clean LD_PRELOAD
466 if [ "$LD_PRELOAD" != "" ]
467 then
468 cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
469 export LD_PRELOAD
472 # temporarily disabled. HJ, 13/Jun/2014
473 # if [[ `uname -s` == "Darwin" ]]
474 # then
475 # if [[ `ulimit -n` == "unlimited" || `ulimit -n` < 8192 ]]
476 # then
477 # # higher limit needed for wmkdeps
478 # ulimit -n 8192
479 # fi
480 # fi
482 # cleanup environment:
483 # ~~~~~~~~~~~~~~~~~~~~
484 unset cleanEnv cleanProg foamInstall foamOldDirs
485 unset _foamSource
487 # -----------------------------------------------------------------------------