initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / etc / bashrc
blob0c460577e92c7aeece4bb225fbb58db8b84072fd
1 #----------------------------------*-sh-*--------------------------------------
2 # =========                 |
3 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4 #  \\    /   O peration     |
5 #   \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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
38 ################################################################################
39 # USER EDITABLE PART
41 # either set $FOAM_INST_DIR before sourcing this file or set
42 #    $foamInstall below to where OpenFOAM is installed
44 # Location of FOAM installation
45 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46 foamInstall=$HOME/$WM_PROJECT
47 # foamInstall=~$WM_PROJECT
48 # foamInstall=/usr/local/$WM_PROJECT
49 # foamInstall=/opt/$WM_PROJECT
51 # END OF (NORMAL) USER EDITABLE PART
52 ################################################################################
54 # note the location for later use (eg, in job scripts)
55 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
57 # The old dirs to be cleaned from the various environment variables
58 # - remove anything under top-level directory.
59 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
60 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
61 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
62 then
63     foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
67 # Location of site/user files
68 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
70 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
71 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
74 # Location of third-party software
75 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
79 # Operating System/Platform
80 # ~~~~~~~~~~~~~~~~~~~~~~~~~
81 # WM_OSTYPE = POSIX | ????
82 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
85 # Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
86 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
89 export WM_COMPILER_ARCH=
90 export WM_COMPILER_LIB_ARCH=
93 # Compilation options (architecture, precision, optimised, debug or profiling)
94 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 # WM_ARCH_OPTION = 32 | 64
96 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
98 # WM_PRECISION_OPTION = DP | SP
99 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
101 # WM_COMPILE_OPTION = Opt | Debug | Prof
102 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
104 # WM_MPLIB = | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
105 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
108 # Run options (floating-point signal handling and memory initialisation)
109 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110 export FOAM_SIGFPE=
111 # export FOAM_SETNAN=
114 # Detect system type and set environment variables appropriately
115 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116 export WM_ARCH=`uname -s`
118 case $WM_ARCH in
119 Linux)
120     WM_ARCH=linux
122     # compiler specifics
123     case `uname -m` in
124     i686)
125         ;;
127     x86_64)
128         case $WM_ARCH_OPTION in
129         32)
130             export WM_COMPILER_ARCH='-64'
131             export WM_CC='gcc'
132             export WM_CXX='g++'
133             export WM_CFLAGS='-m32 -fPIC'
134             export WM_CXXFLAGS='-m32 -fPIC'
135             export WM_LDFLAGS='-m32'
136             ;;
137         64)
138             WM_ARCH=linux64
139             export WM_COMPILER_LIB_ARCH=64
140             export WM_CC='gcc'
141             export WM_CXX='g++'
142             export WM_CFLAGS='-m64 -fPIC'
143             export WM_CXXFLAGS='-m64 -fPIC'
144             export WM_LDFLAGS='-m64'
145             ;;
146         *)
147             echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
148             ;;
149         esac
150         ;;
152     ia64)
153         WM_ARCH=linuxIA64
154         export WM_COMPILER=I64
155         ;;
157     mips64)
158         WM_ARCH=SiCortex64
159         export WM_COMPILER_LIB_ARCH=64
160         export WM_CC='gcc'
161         export WM_CXX='g++'
162         export WM_CFLAGS='-mabi=64 -fPIC'
163         export WM_CXXFLAGS='-mabi=64 -fPIC'
164         export WM_LDFLAGS='-mabi=64 -G0'
165         export WM_MPLIB=MPI
166         ;;
168     ppc64)
169         WM_ARCH=linuxPPC64
170         export WM_COMPILER_LIB_ARCH=64
171         export WM_CC='gcc'
172         export WM_CXX='g++'
173         export WM_CFLAGS='-m64 -fPIC'
174         export WM_CXXFLAGS='-m64 -fPIC'
175         export WM_LDFLAGS='-m64'
176         ;;
178     *)
179         echo Unknown processor type `uname -m` for Linux
180         ;;
181     esac
182     ;;
184 SunOS)
185     WM_ARCH=SunOS64
186     export WM_COMPILER_LIB_ARCH=64
187     export WM_CC='gcc'
188     export WM_CXX='g++'
189     export WM_CFLAGS='-mabi=64 -fPIC'
190     export WM_CXXFLAGS='-mabi=64 -fPIC'
191     export WM_LDFLAGS='-mabi=64 -G0'
192     export WM_MPLIB=FJMPI
193     ;;
195 *)      # an unsupported operating system
196     cat <<USAGE
198     Your "$WM_ARCH" operating system is not supported by this release
199     of OpenFOAM. For further assistance, please contact www.OpenFOAM.org
201 USAGE
202     ;;
203 esac
206 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
207 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
210 #- Clean PATH
211 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
213 #- Clean LD_LIBRARY_PATH
214 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
216 #- Clean MANPATH
217 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
219 export PATH LD_LIBRARY_PATH MANPATH
221 # Source project setup files
222 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
223 _foamSource()
225    while [ $# -ge 1 ]
226    do
227       [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
228       . $1
229       shift
230    done
234 _foamSource $WM_PROJECT_DIR/etc/settings.sh
235 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
238 # Source user setup files for optional packages
239 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
241 _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
242 _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
245 # Clean environment paths again. Only remove duplicates
246 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
247 #- Clean PATH
248 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
250 #- Clean LD_LIBRARY_PATH
251 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
253 #- Clean MANPATH
254 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
256 export PATH LD_LIBRARY_PATH MANPATH
258 #- Clean LD_PRELOAD
259 if [ "$LD_PRELOAD" != "" ]
260 then
261     cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
262     export LD_PRELOAD
266 # cleanup environment:
267 # ~~~~~~~~~~~~~~~~~~~~
268 unset cleanEnv cleanProg foamInstall foamOldDirs
269 unset _foamSource
271 # -----------------------------------------------------------------------------