Git clean-up
[foam-extend-4.0.git] / etc / bashrc
blobba0118b36598c9b81cb905ced7b464c1a1732a4a
1 #!/bin/bash
2 #----------------------------------*-sh-*--------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 3.2
6 # \\ / A nd | Web: http://www.foam-extend.org
7 # \\/ M anipulation | For copyright notice see file Copyright
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.2
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 # Set $USER if it has not been set (eg. on Windows/MSYS systems)
60 if [ -z $USER ]
61 then
62 export USER=`whoami`
65 # note the location for later use (eg, in job scripts)
66 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
68 # The old dirs to be cleaned from the various environment variables
69 # - remove anything under top-level directory.
70 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
71 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
72 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
73 then
74 foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
78 # Location of site/user files
79 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
81 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_FORK-$WM_PROJECT_VERSION
82 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
84 # Location of third-party software
85 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86 #: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION}; export WM_THIRD_PARTY_DIR
87 export WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty
89 # Enabling the usage of third-party software
90 # This can be overriden in prefs.sh
91 # Use 'set' and 'unset' to adjust for your environent
92 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93 # For AllMake.stage1
94 export WM_THIRD_PARTY_USE_CMAKE_322=1
97 # For AllMake.stage2
98 export WM_THIRD_PARTY_USE_OPENMPI_165=1
101 # For AllMake.stage3
102 export WM_THIRD_PARTY_USE_METIS_510=1
103 export WM_THIRD_PARTY_USE_PARMGRIDGEN_10=1
104 export WM_THIRD_PARTY_USE_LIBCCMIO_261=1
105 export WM_THIRD_PARTY_USE_MESQUITE_212=1
106 export WM_THIRD_PARTY_USE_SCOTCH_604=1
107 export WM_THIRD_PARTY_USE_PARMETIS_403=1
108 export WM_THIRD_PARTY_USE_PYFOAM_064=1
109 export WM_THIRD_PARTY_USE_HWLOC_1101=1
112 # For AllMake.stage4
113 #export WM_THIRD_PARTY_USE_QT_486=1
114 export WM_THIRD_PARTY_USE_PARAVIEW_431=1
117 # Source files, possibly with some verbosity
118 _foamSource()
120 while [ $# -ge 1 ]
122 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
123 . $1
124 shift
125 done
128 # Add in preset user or site preferences:
129 if [ "$WM_OSTYPE" == "MSWindows" ]
130 then
131 _foamSource $WM_PROJECT_DIR/etc/prefs.sh.mingw
132 elif [ -e $WM_PROJECT_DIR/etc/prefs.sh ]
133 then
134 _foamSource $WM_PROJECT_DIR/etc/prefs.sh
135 else
136 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "No prefs.sh found"
140 # Evaluate command-line parameters
141 while [ $# -gt 0 ]
143 case "$1" in
145 # name= -> unset name
146 eval "unset ${1%=}"
148 *=*)
149 # name=value -> export name=value
150 eval "export $1"
152 esac
153 shift
154 done
157 # Operating System/Platform
158 # ~~~~~~~~~~~~~~~~~~~~~~~~~
159 # WM_OSTYPE = POSIX | ????
160 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
163 # Compiler: set to Gcc or Icc (for Intel's icc)
164 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
166 #: ${WM_COMPILER:=Icc}; export WM_COMPILER
168 export WM_COMPILER_ARCH=
169 export WM_COMPILER_LIB_ARCH=
172 # Compilation options (architecture, precision, optimised, debug or profiling)
173 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175 # WM_ARCH_OPTION = 32 | 64
176 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
178 # WM_PRECISION_OPTION = LDP | DP | SP
179 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
181 # WM_COMPILE_OPTION = Opt | Debug | Prof
182 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
184 # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI | MVAPICH2
185 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
187 # WM_NCOMPPROCS = <number of processes to use>
188 # Warning: Need to use a complete path for foamGetSystemInfo because the PATH
189 # environment variable is not properly initialized yet.
190 : ${WM_NCOMPPROCS:=`$WM_PROJECT_DIR/bin/foamGetSystemInfo -nbrCores`}; export WM_NCOMPPROCS
193 # Run options (floating-point signal handling and memory initialisation)
194 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 export FOAM_SIGFPE=
196 # export FOAM_SETNAN=
199 # Detect system type and set environment variables appropriately
200 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201 export WM_ARCH=`uname -s`
203 case $WM_ARCH in
204 MINGW32_NT-6.1)
205 WM_ARCH=mingw
206 export WM_ARCH_BASE=mingw
207 export WM_COMPILER_LIB_ARCH=64
208 export WM_CFLAGS='-m64 -fPIC'
209 export WM_CXXFLAGS='-m64 -fPIC'
210 export WM_LDFLAGS='-m64'
213 MINGW32_NT-6.2)
214 WM_ARCH=mingw
215 export WM_ARCH_BASE=mingw
216 export WM_COMPILER_LIB_ARCH=64
217 export WM_CFLAGS='-m64 -fPIC'
218 export WM_CXXFLAGS='-m64 -fPIC'
219 export WM_LDFLAGS='-m64'
222 MINGW64_NT-6.1)
223 WM_ARCH=mingw
224 export WM_ARCH_BASE=mingw
225 export WM_COMPILER_LIB_ARCH=64
226 export WM_CFLAGS='-m64 -fPIC'
227 export WM_CXXFLAGS='-m64 -fPIC'
228 export WM_LDFLAGS='-m64'
231 MINGW64_NT-6.2)
232 WM_ARCH=mingw
233 export WM_ARCH_BASE=mingw
234 export WM_COMPILER_LIB_ARCH=64
235 export WM_CFLAGS='-m64 -fPIC'
236 export WM_CXXFLAGS='-m64 -fPIC'
237 export WM_LDFLAGS='-m64'
240 MINGW64_NT-6.1)
241 WM_ARCH=mingw
242 export WM_ARCH_BASE=mingw
243 export WM_COMPILER_LIB_ARCH=64
244 export WM_CFLAGS='-m64 -fPIC'
245 export WM_CXXFLAGS='-m64 -fPIC'
246 export WM_LDFLAGS='-m64'
249 MINGW64_NT-6.2)
250 WM_ARCH=mingw
251 export WM_ARCH_BASE=mingw
252 export WM_COMPILER_LIB_ARCH=64
253 export WM_CFLAGS='-m64 -fPIC'
254 export WM_CXXFLAGS='-m64 -fPIC'
255 export WM_LDFLAGS='-m64'
258 Linux)
259 WM_ARCH=linux
261 # compiler specifics
262 case `uname -m` in
263 i686)
266 x86_64)
267 case $WM_ARCH_OPTION in
269 export WM_COMPILER_ARCH='-64'
270 export WM_CFLAGS='-m32 -fPIC'
271 export WM_CXXFLAGS='-m32 -fPIC'
272 export WM_LDFLAGS='-m32'
275 WM_ARCH=linux64
276 export WM_COMPILER_LIB_ARCH=64
277 export WM_CFLAGS='-m64 -fPIC'
278 export WM_CXXFLAGS='-m64 -fPIC'
279 export WM_LDFLAGS='-m64'
282 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
284 esac
287 ia64)
288 WM_ARCH=linuxIA64
289 export WM_COMPILER=I64
292 mips64)
293 WM_ARCH=SiCortex64
294 export WM_COMPILER_LIB_ARCH=64
295 export WM_CFLAGS='-mabi=64 -fPIC'
296 export WM_CXXFLAGS='-mabi=64 -fPIC'
297 export WM_LDFLAGS='-mabi=64 -G0'
298 export WM_MPLIB=MPI
301 ppc64)
302 WM_ARCH=linuxPPC64
303 export WM_COMPILER_LIB_ARCH=64
304 export WM_CFLAGS='-m64 -fPIC'
305 export WM_CXXFLAGS='-m64 -fPIC'
306 export WM_LDFLAGS='-m64'
309 armv7l)
310 WM_ARCH=linuxARM7
311 export WM_COMPILER_LIB_ARCH=32
312 export WM_CC='gcc'
313 export WM_CXX='g++'
314 export WM_CFLAGS='-fPIC -mfloat-abi=hard'
315 export WM_CXXFLAGS='-fPIC -mfloat-abi=hard'
316 export WM_LDFLAGS='-mfloat-abi=hard'
320 echo Unknown processor type `uname -m` for Linux
322 esac
325 Darwin)
326 # this makes certain things easier
327 export WM_ARCH_BASE=darwin
329 case `uname -p` in
330 powerpc)
331 export WM_ARCH=darwinPpc
333 i386)
334 export WM_ARCH=darwinIntel
337 echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
338 export WM_ARCH=darwinUnknown
340 esac
342 case $WM_ARCH_OPTION in
344 export WM_CFLAGS='-m32 -fPIC'
345 export WM_CXXFLAGS='-m32 -fPIC'
346 export WM_LDFLAGS='-m32'
349 export WM_ARCH=${WM_ARCH}64
350 export WM_CFLAGS='-m64 -fPIC'
351 export WM_CXXFLAGS='-m64 -fPIC'
352 export WM_LDFLAGS='-m64'
355 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
357 esac
359 # Using MacPorts
360 : ${MACOSX_MACPORTS_ROOT:='/opt/local/etc/macports'}; export MACOSX_MACPORTS_ROOT
361 which -s port >/dev/null
362 if [ $? -eq "0" ] && [ -d "$MACOSX_MACPORTS_ROOT" ]
363 then
364 if [ "$FOAM_VERBOSE" -a "$PS1" ]
365 then
366 echo "Using Macports binaries"
369 export WM_USE_MACPORT=1
370 export WM_BASE_COMPILER=`echo $WM_COMPILER | tr -d "[:digit:]"`
371 export WM_MACPORT_MPI_VERSION=`echo $WM_COMPILER | tr "[:upper:]" "[:lower:]"`
372 export WM_MACPORT_VERSION=`echo $WM_MACPORT_MPI_VERSION | tr -d "[:alpha:]" | sed -e "s/\(.\)\(.\)/\1\.\2/"`
374 if [ -z "$WM_CHOSEN_MAC_MPI" ]
375 then
376 if [ -e '/opt/local/bin/mpicc' ]
377 then
378 readlink /opt/local/bin/mpicc | grep openmpi >/dev/null
379 if [ $? -eq "0" ]
380 then
381 export WM_MPLIB=MACPORTOPENMPI
382 if [ "$FOAM_VERBOSE" -a "$PS1" ]
383 then
384 echo "Using OpenMPI from MacPorts"
386 else
387 readlink /opt/local/bin/mpicc | grep mpich >/dev/null
388 if [ $? -eq "0" ]
389 then
390 export WM_MPLIB=MACPORTMPICH
391 if [ "$FOAM_VERBOSE" -a "$PS1" ]
392 then
393 echo "Using MPICH from MacPorts"
395 else
396 echo "/opt/local/bin/mpicc neither OpenMPI nor MPICH. Confused. Defaulting to OPENMPI"
397 export WM_MPLIB=OPENMPI
401 else
402 export WM_MPLIB=$WM_CHOSEN_MAC_MPI
403 if [ "$FOAM_VERBOSE" -a "$PS1" ]
404 then
405 echo "User chose WM_CHOSEN_MAC_MPI=$WM_CHOSEN_MAC_MPI"
409 if [ "$WM_MPLIB" == "MACPORTOPENMPI" ]
410 then
411 if [ ! -e "/opt/local/lib/openmpi-$WM_MACPORT_MPI_VERSION" ]
412 then
413 export WM_MACPORT_MPI_VERSION=mp
414 if [ ! -e "/opt/local/lib/openmpi-$WM_MACPORT_MPI_VERSION" ]
415 then
416 echo "Proper OpenMPI not installed. Either do 'port install openmpi-$WM_MACPORT_MPI_VERSION' or 'port install openmpi-default'"
419 else
420 if [ "$WM_MPLIB" == "MACPORTMPICH" ]
421 then
422 if [ ! -e "/opt/local/lib/mpich-$WM_MACPORT_MPI_VERSION" ]
423 then
424 echo "MPICH wants the same version as the used compiler. Do 'port install mpich-$WM_MACPORT_MPI_VERSION'"
429 if [ "$WM_COMPILER" != "Gcc" ]
430 then
431 if [ "$WM_BASE_COMPILER" == "Gcc" ]
432 then
433 export WM_CC="gcc-mp-$WM_MACPORT_VERSION"
434 export WM_CXX="g++-mp-$WM_MACPORT_VERSION"
435 export WM_FC="gfortran-mp-$WM_MACPORT_VERSION"
436 elif [ "$WM_BASE_COMPILER" == "Clang" ]
437 then
438 export WM_CC="clang-mp-$WM_MACPORT_VERSION"
439 export WM_CXX="clang++-mp-$WM_MACPORT_VERSION"
440 # Seems like there is no Fortran-frontend for LLVM at thistime
441 elif [ "$WM_BASE_COMPILER" == "Dragonegg" ]
442 then
443 export WM_CC="dragonegg-$WM_MACPORT_VERSION-gcc"
444 export WM_CXX="dragonegg-$WM_MACPORT_VERSION-g++"
445 export WM_CXX="dragonegg-$WM_MACPORT_VERSION-gfortran"
446 else
447 echo "Unknown base compiler $WM_BASE_COMPILER"
450 ruleDirBase=$WM_PROJECT_DIR/wmake/rules/$WM_ARCH
451 ruleDirTarget=$ruleDirBase$WM_BASE_COMPILER
452 ruleDir=$ruleDirBase$WM_COMPILER
453 if [ ! -e $ruleDir ]
454 then
455 echo "Rule directory $ruleDir not existing. Linking to $ruleDirTarget"
456 ln -s $ruleDirTarget $ruleDir
458 unset ruleDir ruleDirBase
460 else
461 echo "Warning: You are not using MacPorts. Make sure your compilation and MPI environment is correctly initialized"
464 # Make sure that binaries use the best features of the used OS-Version
465 # We need to get rid of the revision number from this string. eg turn "10.7.5" into "10.7"
466 # v=(`sw_vers -productVersion | sed 's/\./ /g'`)
467 # export MACOSX_DEPLOYMENT_TARGET="${v[1]}.${v[2]}"
468 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"`
471 SunOS)
472 WM_ARCH=SunOS64
473 export WM_COMPILER_LIB_ARCH=64
474 export WM_CFLAGS='-mabi=64 -fPIC'
475 export WM_CXXFLAGS='-mabi=64 -fPIC'
476 export WM_LDFLAGS='-mabi=64 -G0'
477 export WM_MPLIB=FJMPI
480 *) # an unsupported operating system
481 cat <<USAGE
483 Your "$WM_ARCH" operating system is not supported by this release
484 of foam-extend. For further assistance, please contact www.foam-extend.org
486 USAGE
488 esac
491 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
492 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
493 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
495 #- Clean PATH
496 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
498 #- Clean LD_LIBRARY_PATH
499 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
501 #- Clean DYLD_LIBRARY_PATH
502 if [[ "$WM_ARCH_BASE" == "darwin" ]]
503 then
504 cleanEnv=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH="$cleanEnv"
507 #- Clean MANPATH
508 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
510 export PATH LD_LIBRARY_PATH MANPATH
512 # Source project setup files
513 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
515 _foamSource $WM_PROJECT_DIR/etc/settings.sh
516 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
519 # Source user setup files for optional packages
520 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
521 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
522 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
523 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
526 # Clean environment paths again. Only remove duplicates
527 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
528 #- Clean PATH
529 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
531 #- Clean LD_LIBRARY_PATH
532 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
534 #- Clean MANPATH
535 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
537 export PATH LD_LIBRARY_PATH MANPATH
539 #- Clean LD_PRELOAD
540 if [ "$LD_PRELOAD" != "" ]
541 then
542 cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
543 export LD_PRELOAD
546 # temporarily disabled. HJ, 13/Jun/2014
547 # if [[ `uname -s` == "Darwin" ]]
548 # then
549 # if [[ `ulimit -n` == "unlimited" || `ulimit -n` < 8192 ]]
550 # then
551 # # higher limit needed for wmkdeps
552 # ulimit -n 8192
553 # fi
554 # fi
556 # cleanup environment:
557 # ~~~~~~~~~~~~~~~~~~~~
558 unset cleanEnv cleanProg foamInstall foamOldDirs
559 unset _foamSource
561 # -----------------------------------------------------------------------------