Merge remote-tracking branch 'origin/feature/equationReader' into nextRelease
[foam-extend-3.0.git] / etc / bashrc
blob046dbf65d1850418b8ebb00182f993e50446b9cb
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 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132 # WM_ARCH_OPTION = 32 | 64
133 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
135 # WM_PRECISION_OPTION = DP | SP
136 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
138 # WM_COMPILE_OPTION = Opt | Debug | Prof
139 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
141 # WM_MPLIB = | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
142 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
144 # WM_NCOMPPROCS = <number of processes to use>
145 : ${WM_NCOMPPROCS:=`foamGetSystemInfo -nbrCores`}; export WM_NCOMPPROCS
148 # Run options (floating-point signal handling and memory initialisation)
149 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150 export FOAM_SIGFPE=
151 # export FOAM_SETNAN=
154 # Detect system type and set environment variables appropriately
155 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156 export WM_ARCH=`uname -s`
158 case $WM_ARCH in
159 Linux)
160     WM_ARCH=linux
162     # compiler specifics
163     case `uname -m` in
164     i686)
165         ;;
167     x86_64)
168         case $WM_ARCH_OPTION in
169         32)
170             export WM_COMPILER_ARCH='-64'
171             export WM_CFLAGS='-m32 -fPIC'
172             export WM_CXXFLAGS='-m32 -fPIC'
173             export WM_LDFLAGS='-m32'
174             ;;
175         64)
176             WM_ARCH=linux64
177             export WM_COMPILER_LIB_ARCH=64
178             export WM_CFLAGS='-m64 -fPIC'
179             export WM_CXXFLAGS='-m64 -fPIC'
180             export WM_LDFLAGS='-m64'
181             ;;
182         *)
183             echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
184             ;;
185         esac
186         ;;
188     ia64)
189         WM_ARCH=linuxIA64
190         export WM_COMPILER=I64
191         ;;
193     mips64)
194         WM_ARCH=SiCortex64
195         export WM_COMPILER_LIB_ARCH=64
196         export WM_CFLAGS='-mabi=64 -fPIC'
197         export WM_CXXFLAGS='-mabi=64 -fPIC'
198         export WM_LDFLAGS='-mabi=64 -G0'
199         export WM_MPLIB=MPI
200         ;;
202     ppc64)
203         WM_ARCH=linuxPPC64
204         export WM_COMPILER_LIB_ARCH=64
205         export WM_CFLAGS='-m64 -fPIC'
206         export WM_CXXFLAGS='-m64 -fPIC'
207         export WM_LDFLAGS='-m64'
208         ;;
210     *)
211         echo Unknown processor type `uname -m` for Linux
212         ;;
213     esac
214     ;;
216 Darwin)
217     # this makes certain things easier
218     export WM_ARCH_BASE=darwin
220     case `uname -p` in
221     powerpc)
222         export WM_ARCH=darwinPpc
223         ;;
224     i386)
225         export WM_ARCH=darwinIntel
226         ;;
227     *)
228         echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
229         export WM_ARCH=darwinUnknown
230         ;;
231     esac
233     case $WM_ARCH_OPTION in
234     32)
235         export WM_CFLAGS='-m32 -fPIC'
236         export WM_CXXFLAGS='-m32 -fPIC'
237         export WM_LDFLAGS='-m32'
238         ;;
239     64)
240         export WM_ARCH=${WM_ARCH}64
241         export WM_CFLAGS='-m64 -fPIC'
242         export WM_CXXFLAGS='-m64 -fPIC'
243         export WM_LDFLAGS='-m64'
244         ;;
245     *)
246         echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
247         ;;
248     esac
250     # Make sure that binaries use the best features of the used OS-Version
251     # We need to get rid of the revision number from this string. eg turn "10.7.5" into "10.7"
252     v=( ${MACOSX_DEPLOYMENT_TARGET//./ } )
253     export MACOSX_DEPLOYMENT_TARGET="${v[0]}.${v[1]}"
255     if [ "$compilerInstall" == "System" ]
256     then
257         # Use Mac-Ports-Compiler instead of Apple-gcc-4.2
258         case $WM_COMPILER in
259         Gcc43)
260             export WM_CC='gcc-mp-4.3'
261             export WM_CXX='g++-mp-4.3'
262             ;;
263         Gcc44)
264             export WM_CC='gcc-mp-4.4'
265             export WM_CXX='g++-mp-4.4'
266             ;;
267         Gcc45)
268             export WM_CC='gcc-mp-4.5'
269             export WM_CXX='g++-mp-4.5'
270             ;;
271         *)
272             export WM_COMPILER=
273             ;;
274         esac
275     fi
276     ;;
278 SunOS)
279     WM_ARCH=SunOS64
280     export WM_COMPILER_LIB_ARCH=64
281     export WM_CFLAGS='-mabi=64 -fPIC'
282     export WM_CXXFLAGS='-mabi=64 -fPIC'
283     export WM_LDFLAGS='-mabi=64 -G0'
284     export WM_MPLIB=FJMPI
285     ;;
287 *)      # an unsupported operating system
288     cat <<USAGE
290     Your "$WM_ARCH" operating system is not supported by this release
291     of OpenFOAM. For further assistance, please contact www.extend-project.de
293 USAGE
294     ;;
295 esac
298 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
299 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
302 #- Clean PATH
303 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
305 #- Clean LD_LIBRARY_PATH
306 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
308 #- Clean DYLD_LIBRARY_PATH
309 if [[ "$WM_ARCH_BASE" == "darwin" ]]
310 then
311     cleanEnv=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH="$cleanEnv"
314 #- Clean MANPATH
315 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
317 export PATH LD_LIBRARY_PATH MANPATH
319 # Source project setup files
320 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
322 _foamSource $WM_PROJECT_DIR/etc/settings.sh
323 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
326 # Source user setup files for optional packages
327 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
329 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
330 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
333 # Clean environment paths again. Only remove duplicates
334 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335 #- Clean PATH
336 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
338 #- Clean LD_LIBRARY_PATH
339 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
341 #- Clean MANPATH
342 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
344 export PATH LD_LIBRARY_PATH MANPATH
346 #- Clean LD_PRELOAD
347 if [ "$LD_PRELOAD" != "" ]
348 then
349     cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
350     export LD_PRELOAD
354 # cleanup environment:
355 # ~~~~~~~~~~~~~~~~~~~~
356 unset cleanEnv cleanProg foamInstall foamOldDirs
357 unset _foamSource
359 # -----------------------------------------------------------------------------