fixed writing out entries in advective bc
[openfoam-extend-OpenFOAM-1.6-ext.git] / etc / bashrc
blobaec1cc2a32bd2325cfdc4ecc2158de012c135e6e
1 #----------------------------------*-sh-*--------------------------------------
2 # =========                 |
3 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4 #  \\    /   O peration     |
5 #   \\  /    A nd           | Copyright held by original author
6 #    \\/     M anipulation  |
7 #------------------------------------------------------------------------------
8 # License
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 the
13 #     Free Software Foundation; either version 2 of the License, or (at your
14 #     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
19 #     for more details.
21 #     You should have received a copy of the GNU General Public License
22 #     along with OpenFOAM; if not, write to the Free Software Foundation,
23 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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=OpenFOAM
36 export WM_PROJECT_VERSION=1.6-ext
38 # helps to easily write #ifdefs to detect a dev-version
39 export FOAM_DEV=1
41 ###############################################################################
42 # USER EDITABLE PART
44 # either set $FOAM_INST_DIR before sourcing this file or set
45 #    $foamInstall below to where OpenFOAM is installed
47 # Location of FOAM installation
48 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 foamInstall=$HOME/$WM_PROJECT
50 # foamInstall=~$WM_PROJECT
51 # foamInstall=/usr/local/$WM_PROJECT
52 # foamInstall=/opt/$WM_PROJECT
53 # foamInstall=/usr/lib
55 # END OF (NORMAL) USER EDITABLE PART
56 ################################################################################
58 # note the location for later use (eg, in job scripts)
59 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
61 # The old dirs to be cleaned from the various environment variables
62 # - remove anything under top-level directory.
63 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
64 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
65 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
66 then
67     foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
71 # Location of site/user files
72 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
74 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
75 : ${WM_PROJECT_USER_DIR:=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION}; export WM_PROJECT_USER_DIR
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 : ${WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty}; export WM_THIRD_PARTY_DIR
83 # Source files, possibly with some verbosity
84 _foamSource()
86    while [ $# -ge 1 ]
87    do
88       [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
89       . $1
90       shift
91    done
94 # Add in preset user or site preferences:
95 foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` && _foamSource $foamPrefs
96 unset foamPrefs
98 # Evaluate command-line parameters
99 while [ $# -gt 0 ]
101     case "$1" in
102     *=)
103         # name=       -> unset name
104         eval "unset ${1%=}"
105         ;;
106     *=*)
107         # name=value  -> export name=value
108         eval "export $1"
109         ;;
110     esac
111     shift
112 done
115 # Operating System/Platform
116 # ~~~~~~~~~~~~~~~~~~~~~~~~~
117 # WM_OSTYPE = POSIX | ????
118 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
121 # Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
122 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
125 export WM_COMPILER_ARCH=
126 export WM_COMPILER_LIB_ARCH=
129 # Compilation options (architecture, precision, optimised, debug or profiling)
130 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131 : ${WM_NCOMPPROCS:=2}; export WM_NCOMPPROCS
133 # WM_ARCH_OPTION = 32 | 64
134 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
136 # WM_PRECISION_OPTION = DP | SP
137 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
139 # WM_COMPILE_OPTION = Opt | Debug | Prof
140 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
142 # WM_MPLIB = | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
143 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
146 # Run options (floating-point signal handling and memory initialisation)
147 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148 export FOAM_SIGFPE=
149 # export FOAM_SETNAN=
152 # Detect system type and set environment variables appropriately
153 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154 export WM_ARCH=`uname -s`
156 case $WM_ARCH in
157 Linux)
158     WM_ARCH=linux
160     # compiler specifics
161     case `uname -m` in
162     i686)
163         ;;
165     x86_64)
166         case $WM_ARCH_OPTION in
167         32)
168             export WM_COMPILER_ARCH='-64'
169             export WM_CFLAGS='-m32 -fPIC'
170             export WM_CXXFLAGS='-m32 -fPIC'
171             export WM_LDFLAGS='-m32'
172             ;;
173         64)
174             WM_ARCH=linux64
175             export WM_COMPILER_LIB_ARCH=64
176             export WM_CFLAGS='-m64 -fPIC'
177             export WM_CXXFLAGS='-m64 -fPIC'
178             export WM_LDFLAGS='-m64'
179             ;;
180         *)
181             echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
182             ;;
183         esac
184         ;;
186     ia64)
187         WM_ARCH=linuxIA64
188         export WM_COMPILER=I64
189         ;;
191     mips64)
192         WM_ARCH=SiCortex64
193         export WM_COMPILER_LIB_ARCH=64
194         export WM_CFLAGS='-mabi=64 -fPIC'
195         export WM_CXXFLAGS='-mabi=64 -fPIC'
196         export WM_LDFLAGS='-mabi=64 -G0'
197         export WM_MPLIB=MPI
198         ;;
200     ppc64)
201         WM_ARCH=linuxPPC64
202         export WM_COMPILER_LIB_ARCH=64
203         export WM_CFLAGS='-m64 -fPIC'
204         export WM_CXXFLAGS='-m64 -fPIC'
205         export WM_LDFLAGS='-m64'
206         ;;
208     *)
209         echo Unknown processor type `uname -m` for Linux
210         ;;
211     esac
212     ;;
214 Darwin)
215     # this makes certain things easier
216     export WM_ARCH_BASE=darwin
218     case `uname -p` in
219     powerpc)
220         export WM_ARCH=darwinPpc
221         ;;
222     i386)
223         export WM_ARCH=darwinIntel
224         ;;
225     *)
226         echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
227         export WM_ARCH=darwinUnknown
228         ;;
229     esac
230     case $WM_ARCH_OPTION in
231     32)
232         export WM_CFLAGS='-m32 -fPIC'
233         export WM_CXXFLAGS='-m32 -fPIC'
234         export WM_LDFLAGS='-m32'
235         ;;
236     64)
237         export WM_ARCH=${WM_ARCH}64
238         export WM_CFLAGS='-m64 -fPIC'
239         export WM_CXXFLAGS='-m64 -fPIC'
240         export WM_LDFLAGS='-m64'
241         ;;
242     *)
243         echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
244         ;;
245     esac
247     # Make sure that binaries use the best features of the used OS-Version
248     export MACOSX_DEPLOYMENT_TARGET=`sw_vers -productVersion`
250     if [ "$compilerInstall" == "System" ]
251     then
252         # Use Mac-Ports-Compiler instead of Apple-gcc-4.2
253         case $WM_COMPILER in
254         Gcc43)
255             export WM_CC='gcc-mp-4.3'
256             export WM_CXX='g++-mp-4.3'
257             ;;
258         Gcc44)
259             export WM_CC='gcc-mp-4.4'
260             export WM_CXX='g++-mp-4.4'
261             ;;
262         Gcc45)
263             export WM_CC='gcc-mp-4.5'
264             export WM_CXX='g++-mp-4.5'
265             ;;
266         *)
267             export WM_COMPILER=
268             ;;
269         esac
270     fi
272     ;;
274 SunOS)
275     WM_ARCH=SunOS64
276     export WM_COMPILER_LIB_ARCH=64
277     export WM_CFLAGS='-mabi=64 -fPIC'
278     export WM_CXXFLAGS='-mabi=64 -fPIC'
279     export WM_LDFLAGS='-mabi=64 -G0'
280     export WM_MPLIB=FJMPI
281     ;;
283 *)      # an unsupported operating system
284     cat <<USAGE
286     Your "$WM_ARCH" operating system is not supported by this release
287     of OpenFOAM. For further assistance, please contact www.extend-project.de
289 USAGE
290     ;;
291 esac
294 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
295 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
298 #- Clean PATH
299 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
301 #- Clean LD_LIBRARY_PATH
302 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
304 #- Clean DYLD_LIBRARY_PATH
305 if [[ "$WM_ARCH_BASE" == "darwin" ]] 
306 then
307     cleanEnv=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH="$cleanEnv"
310 #- Clean MANPATH
311 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
313 export PATH LD_LIBRARY_PATH MANPATH
315 # Source project setup files
316 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
318 _foamSource $WM_PROJECT_DIR/etc/settings.sh
319 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
322 # Source user setup files for optional packages
323 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
325 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
326 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
329 # Clean environment paths again. Only remove duplicates
330 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
331 #- Clean PATH
332 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
334 #- Clean LD_LIBRARY_PATH
335 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
337 #- Clean MANPATH
338 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
340 export PATH LD_LIBRARY_PATH MANPATH
342 #- Clean LD_PRELOAD
343 if [ "$LD_PRELOAD" != "" ]
344 then
345     cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
346     export LD_PRELOAD
350 # cleanup environment:
351 # ~~~~~~~~~~~~~~~~~~~~
352 unset cleanEnv cleanProg foamInstall foamOldDirs
353 unset _foamSource
355 # -----------------------------------------------------------------------------