foamToTecplot360/tecio/tecsrc/Make/tecioOptions: Added '-DENGINE', so that building...
[foam-extend-3.2.git] / etc / bashrc
blob137daddc9481399691066cd9fe6065f88e4723b3
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 OpenFOAM
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.0
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 OpenFOAM 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 # Source files, possibly with some verbosity
84 _foamSource()
86 while [ $# -ge 1 ]
88 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
89 . $1
90 shift
91 done
94 # Add in preset user or site preferences:
95 if [ -e $WM_PROJECT_DIR/etc/prefs.sh ]
96 then
97 _foamSource $WM_PROJECT_DIR/etc/prefs.sh
98 else
99 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "No prefs.sh found"
103 # Evaluate command-line parameters
104 while [ $# -gt 0 ]
106 case "$1" in
108 # name= -> unset name
109 eval "unset ${1%=}"
111 *=*)
112 # name=value -> export name=value
113 eval "export $1"
115 esac
116 shift
117 done
120 # Operating System/Platform
121 # ~~~~~~~~~~~~~~~~~~~~~~~~~
122 # WM_OSTYPE = POSIX | ????
123 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
126 # Compiler: set to Gcc or Icc (for Intel's icc)
127 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
129 #: ${WM_COMPILER:=Icc}; export WM_COMPILER
131 export WM_COMPILER_ARCH=
132 export WM_COMPILER_LIB_ARCH=
135 # Compilation options (architecture, precision, optimised, debug or profiling)
136 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138 # WM_ARCH_OPTION = 32 | 64
139 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
141 # WM_PRECISION_OPTION = DP | SP
142 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
144 # WM_COMPILE_OPTION = Opt | Debug | Prof
145 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
147 # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
148 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
150 # WM_NCOMPPROCS = <number of processes to use>
151 # Warning: Need to use a complete path for foamGetSystemInfo because the PATH
152 # environment variable is not properly initialized yet.
153 : ${WM_NCOMPPROCS:=`$WM_PROJECT_DIR/bin/foamGetSystemInfo -nbrCores`}; export WM_NCOMPPROCS
156 # Run options (floating-point signal handling and memory initialisation)
157 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158 export FOAM_SIGFPE=
159 # export FOAM_SETNAN=
162 # Detect system type and set environment variables appropriately
163 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164 export WM_ARCH=`uname -s`
166 case $WM_ARCH in
167 Linux)
168 WM_ARCH=linux
170 # compiler specifics
171 case `uname -m` in
172 i686)
175 x86_64)
176 case $WM_ARCH_OPTION in
178 export WM_COMPILER_ARCH='-64'
179 export WM_CFLAGS='-m32 -fPIC'
180 export WM_CXXFLAGS='-m32 -fPIC'
181 export WM_LDFLAGS='-m32'
184 WM_ARCH=linux64
185 export WM_COMPILER_LIB_ARCH=64
186 export WM_CFLAGS='-m64 -fPIC'
187 export WM_CXXFLAGS='-m64 -fPIC'
188 export WM_LDFLAGS='-m64'
191 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
193 esac
196 ia64)
197 WM_ARCH=linuxIA64
198 export WM_COMPILER=I64
201 mips64)
202 WM_ARCH=SiCortex64
203 export WM_COMPILER_LIB_ARCH=64
204 export WM_CFLAGS='-mabi=64 -fPIC'
205 export WM_CXXFLAGS='-mabi=64 -fPIC'
206 export WM_LDFLAGS='-mabi=64 -G0'
207 export WM_MPLIB=MPI
210 ppc64)
211 WM_ARCH=linuxPPC64
212 export WM_COMPILER_LIB_ARCH=64
213 export WM_CFLAGS='-m64 -fPIC'
214 export WM_CXXFLAGS='-m64 -fPIC'
215 export WM_LDFLAGS='-m64'
219 echo Unknown processor type `uname -m` for Linux
221 esac
224 Darwin)
225 # this makes certain things easier
226 export WM_ARCH_BASE=darwin
228 # Remove limit of open files
229 ulimit -n 1000
231 case `uname -p` in
232 powerpc)
233 export WM_ARCH=darwinPpc
235 i386)
236 export WM_ARCH=darwinIntel
239 echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
240 export WM_ARCH=darwinUnknown
242 esac
244 case $WM_ARCH_OPTION in
246 export WM_CFLAGS='-m32 -fPIC'
247 export WM_CXXFLAGS='-m32 -fPIC'
248 export WM_LDFLAGS='-m32'
251 export WM_ARCH=${WM_ARCH}64
252 export WM_CFLAGS='-m64 -fPIC'
253 export WM_CXXFLAGS='-m64 -fPIC'
254 export WM_LDFLAGS='-m64'
257 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
259 esac
261 # Make sure that binaries use the best features of the used OS-Version
262 # We need to get rid of the revision number from this string. eg turn "10.7.5" into "10.7"
263 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"`
265 which -s port >/dev/null
266 if [ $? -eq "0" -a -d '/opt/local/etc/macports' ]
267 then
268 if [ "$FOAM_VERBOSE" -a "$PS1" ]
269 then
270 echo "Using Macports binaries"
273 export WM_USE_MACPORT=1
275 if [ -e '/opt/local/bin/openmpicc' ]
276 then
277 export WM_MPLIB=MACPORTOPENMPI
278 else
279 if [ -z "$WM_CHOSEN_MAC_MPI" ]
280 then
281 echo "WM_CHOSEN_MAC_MPI unset. Using OPENMPI"
282 export WM_MPLIB=OPENMPI
283 else
284 export WM_MPLIB=$WM_CHOSEN_MAC_MPI
288 if [ "$compilerInstall" == "System" ]
289 then
290 # Use Mac-Ports-Compiler instead of Apple-gcc-4.2
291 case $WM_COMPILER in
292 Gcc42)
293 export WM_MACPORT_VERSION=4.2
294 export WM_BASE_COMPILER=Gcc
296 Gcc43)
297 export WM_MACPORT_VERSION=4.3
298 export WM_BASE_COMPILER=Gcc
300 Gcc44)
301 export WM_MACPORT_VERSION=4.4
302 export WM_BASE_COMPILER=Gcc
304 Gcc45)
305 export WM_MACPORT_VERSION=4.5
306 export WM_BASE_COMPILER=Gcc
308 Gcc46)
309 export WM_MACPORT_VERSION=4.6
310 export WM_BASE_COMPILER=Gcc
312 Gcc47)
313 export WM_MACPORT_VERSION=4.7
314 export WM_BASE_COMPILER=Gcc
316 Gcc48)
317 export WM_MACPORT_VERSION=4.8
318 export WM_BASE_COMPILER=Gcc
320 Clang32)
321 export WM_BASE_COMPILER=Clang
322 export WM_MACPORT_VERSION=3.2
324 Clang33)
325 export WM_BASE_COMPILER=Clang
326 export WM_MACPORT_VERSION=3.3
328 Clang34)
329 export WM_BASE_COMPILER=Clang
330 export WM_MACPORT_VERSION=3.4
332 Gcc)
335 echo "Unsupported MacPorts-Compiler $WM_COMPILER"
337 esac
338 if [ "$WM_MACPORT_VERSION" != "" ]
339 then
340 if [ "$WM_BASE_COMPILER" == "Gcc" ]
341 then
342 export WM_CC="gcc-mp-$WM_MACPORT_VERSION"
343 export WM_CXX="g++-mp-$WM_MACPORT_VERSION"
344 export WM_FC="gfortran-mp-$WM_MACPORT_VERSION"
345 else
346 export WM_CC="clang-mp-$WM_MACPORT_VERSION"
347 export WM_CXX="clang++-mp-$WM_MACPORT_VERSION"
349 # hardcoded. Needed for ThirdParty
350 export WM_FC="gfortran-mp-4.5"
353 ruleDirBase=$WM_PROJECT_DIR/wmake/rules/$WM_ARCH$WM_BASE_COMPILER
354 ruleDir=$WM_PROJECT_DIR/wmake/rules/$WM_ARCH$WM_COMPILER
355 if [ ! -e $ruleDir ]
356 then
357 echo "Rule directory $ruleDir not existing. Linking to $ruleDirBase"
358 ln -s $ruleDirBase $ruleDir
360 unset ruleDir ruleDirBase
366 SunOS)
367 WM_ARCH=SunOS64
368 export WM_COMPILER_LIB_ARCH=64
369 export WM_CFLAGS='-mabi=64 -fPIC'
370 export WM_CXXFLAGS='-mabi=64 -fPIC'
371 export WM_LDFLAGS='-mabi=64 -G0'
372 export WM_MPLIB=FJMPI
375 *) # an unsupported operating system
376 cat <<USAGE
378 Your "$WM_ARCH" operating system is not supported by this release
379 of OpenFOAM. For further assistance, please contact www.extend-project.de
381 USAGE
383 esac
386 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
387 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
388 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
390 #- Clean PATH
391 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
393 #- Clean LD_LIBRARY_PATH
394 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
396 #- Clean DYLD_LIBRARY_PATH
397 if [[ "$WM_ARCH_BASE" == "darwin" ]]
398 then
399 cleanEnv=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH="$cleanEnv"
402 #- Clean MANPATH
403 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
405 export PATH LD_LIBRARY_PATH MANPATH
407 # Source project setup files
408 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
410 _foamSource $WM_PROJECT_DIR/etc/settings.sh
411 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
414 # Source user setup files for optional packages
415 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
417 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
418 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
421 # Clean environment paths again. Only remove duplicates
422 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
423 #- Clean PATH
424 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
426 #- Clean LD_LIBRARY_PATH
427 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
429 #- Clean MANPATH
430 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
432 export PATH LD_LIBRARY_PATH MANPATH
434 #- Clean LD_PRELOAD
435 if [ "$LD_PRELOAD" != "" ]
436 then
437 cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
438 export LD_PRELOAD
442 # cleanup environment:
443 # ~~~~~~~~~~~~~~~~~~~~
444 unset cleanEnv cleanProg foamInstall foamOldDirs
445 unset _foamSource
447 # -----------------------------------------------------------------------------