Merge branch 'master' of github.com:OpenFOAM/OpenFOAM-2.0.x
[OpenFOAM-2.0.x.git] / etc / bashrc
blobf5b1deeb9681f9a678364d40003e5df2aaa98b87
1 #----------------------------------*-sh-*--------------------------------------
2 # =========                 |
3 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4 #  \\    /   O peration     |
5 #   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13 #     the Free Software Foundation, either version 3 of the License, or
14 #     (at your 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, see <http://www.gnu.org/licenses/>.
24 # File
25 #     etc/bashrc
27 # Description
28 #     Startup file for OpenFOAM
29 #     Sourced from ~/.profile or ~/.bashrc
30 #     Should be usable by any POSIX-compliant shell (eg, ksh)
32 #------------------------------------------------------------------------------
34 export WM_PROJECT=OpenFOAM
35 export WM_PROJECT_VERSION=2.0.x
37 ################################################################################
38 # USER EDITABLE PART: Changes made here may be lost with the next upgrade
40 # either set $FOAM_INST_DIR before sourcing this file or set
41 # 'foamInstall' below to where OpenFOAM is installed
43 # Location of the OpenFOAM installation
44 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45 foamInstall=$HOME/$WM_PROJECT
46 # foamInstall=~$WM_PROJECT
47 # foamInstall=/opt/$WM_PROJECT
48 # foamInstall=/usr/local/$WM_PROJECT
50 # END OF (NORMAL) USER EDITABLE PART
51 ################################################################################
54 # These are the defaults for this version which should generally be
55 # overridden from the prefs.sh file or from command-line specification
57 #- note the location for later use (eg, in job scripts)
58 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
60 #- Compiler location:
61 #    foamCompiler= system | ThirdParty (OpenFOAM)
62 foamCompiler=system
64 #- Compiler:
65 #    WM_COMPILER = Gcc | Gcc43 | Gcc44 | Gcc45 | Gcc46 | Clang | Icc (Intel icc)
66 export WM_COMPILER=Gcc
67 unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
69 #- Architecture:
70 #    WM_ARCH_OPTION = 32 | 64
71 export WM_ARCH_OPTION=64
73 #- Precision:
74 #    WM_PRECISION_OPTION = DP | SP
75 export WM_PRECISION_OPTION=DP
77 #- Optimised, debug, profiling:
78 #    WM_COMPILE_OPTION = Opt | Debug | Prof
79 export WM_COMPILE_OPTION=Opt
81 #- MPI implementation:
82 #    WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI
83 #               | GAMMA | MPI | QSMPI
84 export WM_MPLIB=OPENMPI
86 #- Operating System:
87 #    WM_OSTYPE = POSIX | ???
88 export WM_OSTYPE=POSIX
90 #- Floating-point signal handling:
91 #    set or unset
92 export FOAM_SIGFPE=
94 #- memory initialisation:
95 #    set or unset
96 #export FOAM_SETNAN=
99 ################################################################################
101 # The old dirs to be cleaned from the various environment variables
102 # - remove anything under top-level directory.
103 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
104 foamOldDirs="$FOAM_INST_DIR $WM_PROJECT_SITE $HOME/$WM_PROJECT/$USER"
105 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
106 then
107     foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
111 # Location of installation
112 # ~~~~~~~~~~~~~~~~~~~~~~~~
113 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
114 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
116 # Location of third-party software
117 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118 export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
120 # Location of site-specific templates etc
121 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122 # unset is equivalent to $WM_PROJECT_INST_DIR/site
123 if [ -d "$WM_PROJECT_SITE" ]
124 then
125     export WM_PROJECT_SITE
126 else
127     unset WM_PROJECT_SITE
130 # Location of user files
131 # ~~~~~~~~~~~~~~~~~~~~~~
132 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
135 # Source files, possibly with some verbosity
136 _foamSource()
138     while [ $# -ge 1 ]
139     do
140         [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
141         . $1
142        shift
143     done
146 # Evaluate command-line parameters
147 _foamEval()
149     while [ $# -gt 0 ]
150     do
151         case "$1" in
152         -*)
153             # stray option (not meant for us here) -> get out
154             break
155             ;;
156         *=)
157             # name=       -> unset name
158             [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "unset ${1%=}"
159             eval "unset ${1%=}"
160             ;;
161         *=*)
162             # name=value  -> export name=value
163             [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1"
164             eval "export $1"
165             ;;
166         *)
167             # filename: source it
168             if [ -f "$1" ]
169             then
170                 _foamSource "$1"
171             else
172                 _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"`
173             fi
174             ;;
175         esac
176         shift
177     done
181 # Add in preset user or site preferences:
182 _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh`
184 # Evaluate command-line parameters and record settings for later
185 # these can be used to set/unset values, or specify alternative pref files
186 export FOAM_SETTINGS="$@"
187 _foamEval $@
189 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
190 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191 foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
193 #- Clean PATH
194 cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned"
196 #- Clean LD_LIBRARY_PATH
197 cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` \
198     && LD_LIBRARY_PATH="$cleaned"
200 #- Clean MANPATH
201 cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned"
203 export PATH LD_LIBRARY_PATH MANPATH
206 # Source project setup files
207 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
208 _foamSource $WM_PROJECT_DIR/etc/config/settings.sh
209 _foamSource $WM_PROJECT_DIR/etc/config/aliases.sh
212 # Source user setup files for optional packages
213 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214 _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/paraview.sh`
215 _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/ensight.sh`
218 # Clean environment paths again. Only remove duplicates
219 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220 #- Clean PATH
221 cleaned=`$foamClean "$PATH"` && PATH="$cleaned"
223 #- Clean LD_LIBRARY_PATH
224 cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned"
226 #- Clean MANPATH (trailing ':' to find system pages)
227 cleaned=`$foamClean "$MANPATH"`: && MANPATH="$cleaned"
229 export PATH LD_LIBRARY_PATH MANPATH
231 #- Clean LD_PRELOAD
232 if [ -n "$LD_PRELOAD" ]
233 then
234     cleaned=`$foamClean "$LD_PRELOAD"` && LD_PRELOAD="$cleaned"
235     export LD_PRELOAD
239 # cleanup environment:
240 # ~~~~~~~~~~~~~~~~~~~~
241 unset cleaned foamClean foamInstall foamOldDirs
242 unset _foamSource _foamEval
244 # ----------------------------------------------------------------- end-of-file