preserved word format
[OpenFOAM-1.5.x.git] / etc / bashrc
blob960d72a3ead7a3df134411e3db0fb3834fcc869a
1 #----------------------------------*-sh-*--------------------------------------
2 # =========                 |
3 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4 #  \\    /   O peration     |
5 #   \\  /    A nd           | Copyright (C) 1991-2008 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 #     bashrc
28 # Description
29 #     Startup file for OpenFOAM
30 #     Sourced from ~/.profile or ~/.bashrc
32 #------------------------------------------------------------------------------
34 export WM_PROJECT=OpenFOAM
35 export WM_PROJECT_VERSION=1.5.x
36 : ${WM_PROJECT_VERSION:=dev}; export WM_PROJECT_VERSION
39 #!!User:
40 #    either set $FOAM_INST_DIR before sourcing this file or set
41 #    $foamInstall below to where OpenFOAM is installed
43 # Location of FOAM installation
44 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45 foamInstall=$HOME/$WM_PROJECT
46 # foamInstall=~$WM_PROJECT
47 # foamInstall=/usr/local/$WM_PROJECT
48 # foamInstall=/opt/$WM_PROJECT
50 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
53 # Location of site/user files
54 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
55 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
56 export WM_PROJECT_DIR=$FOAM_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
57 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
60 # Location of third-party software
61 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty
65 # Operating System/Platform from Unix or MSWindows
66 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67 # WM_OS = Unix | MSWindows
68 : ${WM_OS:=Unix}; export WM_OS
71 # Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
72 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
75 export WM_COMPILER_ARCH=
76 export WM_COMPILER_LIB_ARCH=
79 # Compilation options (architecture, precision, optimised, debug or profiling)
80 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81 # WM_ARCH_OPTION = 32 | 64
82 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
84 # WM_PRECISION_OPTION = DP | SP
85 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
87 # WM_COMPILE_OPTION = Opt | Debug | Prof
88 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
90 # WM_JAVAC_OPTION = Opt | Debug
91 : ${WM_JAVAC_OPTION:=Opt}; export WM_JAVAC_OPTION
93 # WM_MPLIB = | OPENMPI| LAM | MPICH | MPICH-GM | GAMMA | MPI
94 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
97 # Run options (floating-point signal handling and memory initialisation)
98 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99 export FOAM_SIGFPE=
100 # export FOAM_SETNAN=
103 # Detect system type and set environment variables appropriately
104 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 export WM_ARCH=`uname -s`
107 case $WM_ARCH in
108 Linux)
109     WM_ARCH=linux
111     # compiler specifics
112     case `uname -m` in
113     i686)
114         ;;
116     x86_64)
117         case $WM_ARCH_OPTION in
118         32)
119             export WM_COMPILER_ARCH='-64'
120             export WM_CC='gcc'
121             export WM_CXX='g++'
122             export WM_CFLAGS='-m32 -fPIC'
123             export WM_CXXFLAGS='-m32 -fPIC'
124             export WM_LDFLAGS='-m32'
125             ;;
126         64)
127             WM_ARCH=linux64
128             export WM_COMPILER_LIB_ARCH=64
129             export WM_CC='gcc'
130             export WM_CXX='g++'
131             export WM_CFLAGS='-m64 -fPIC'
132             export WM_CXXFLAGS='-m64 -fPIC'
133             export WM_LDFLAGS='-m64'
134             ;;
135         *)
136             echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
137             ;;
138         esac
139         ;;
140     ia64)
141         WM_ARCH=linuxIA64
142         export WM_COMPILER=I64
143         ;;
144     *)
145         echo Unknown processor type `uname -m` for Linux
146         ;;
147     esac
148     ;;
150 *)      # an unsupported operating system
151     cat <<USAGE
153     Your "$WM_ARCH" operating system is not supported by this release
154     of OpenFOAM. For further assistance, please contact www.openfoam.org
156 USAGE
157     ;;
158 esac
161 # Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH)
162 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
165 # Remove anything under top-level foam directory
166 wildCards="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
168 #- Clean path/PATH
169 cleanPath=`$cleanProg "$PATH" "$wildCards"` && PATH="$cleanPath"
171 #- Clean LD_LIBRARY_PATH
172 cleanPath=`$cleanProg "$LD_LIBRARY_PATH" "$wildCards"` && LD_LIBRARY_PATH="$cleanPath"
174 #- Clean MANPATH
175 cleanPath=`$cleanProg "$MANPATH" "$wildCards"` && MANPATH="$cleanPath"
177 export PATH LD_LIBRARY_PATH MANPATH
179 # Source project setup files
180 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
181 _foamSource()
183    while [ $# -ge 1 ]
184    do
185       if [ "$FOAM_VERBOSE" -a "$PS1" ]; then
186          echo "Sourcing: $1"
187       fi
188       . $1
189       shift
190    done
194 _foamSource $WM_PROJECT_DIR/etc/settings.sh
195 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
198 # Source user setup files for optional packages
199 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
201 _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
202 # _foamSource $WM_PROJECT_DIR/etc/apps/ensightFoam/bashrc
203 _foamSource $WM_PROJECT_DIR/etc/apps/cint/bashrc
206 # Again clean environment (path, PATH, MANPATH, LD_LIBRARY_PATH)
207 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208 #- Clean path/PATH. Only remove duplicates
209 cleanPath=`$cleanProg "$PATH"` && PATH="$cleanPath"
211 #- Clean LD_LIBRARY_PATH
212 cleanPath=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanPath"
214 #- Clean MANPATH
215 cleanPath=`$cleanProg "$MANPATH"` && MANPATH="$cleanPath"
217 export PATH LD_LIBRARY_PATH MANPATH
219 #- Clean LD_PRELOAD
220 if [ "$LD_PRELOAD" != "" ]; then
221     cleanPath=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanPath"
222     export LD_PRELOAD
226 # cleanup environment:
227 # ~~~~~~~~~~~~~~~~~~~~
228 unset cleanPath cleanProg foamInstall
229 unset _foamSource
231 # -----------------------------------------------------------------------------