1 #----------------------------------*-sh-*--------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 #------------------------------------------------------------------------------
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
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/>.
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
61 # foamCompiler= system | ThirdParty (OpenFOAM)
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
70 # WM_ARCH_OPTION = 32 | 64
71 export WM_ARCH_OPTION=64
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
87 # WM_OSTYPE = POSIX | ???
88 export WM_OSTYPE=POSIX
90 #- Floating-point signal handling:
94 #- memory initialisation:
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" ]
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" ]
125 export WM_PROJECT_SITE
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
140 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
146 # Evaluate command-line parameters
153 # stray option (not meant for us here) -> get out
157 # name= -> unset name
158 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "unset ${1%=}"
162 # name=value -> export name=value
163 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1"
167 # filename: source it
172 _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"`
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="$@"
189 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
190 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191 foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
194 cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned"
196 #- Clean LD_LIBRARY_PATH
197 cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` \
198 && LD_LIBRARY_PATH="$cleaned"
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 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
232 if [ -n "$LD_PRELOAD" ]
234 cleaned=`$foamClean "$LD_PRELOAD"` && LD_PRELOAD="$cleaned"
239 # cleanup environment:
240 # ~~~~~~~~~~~~~~~~~~~~
241 unset cleaned foamClean foamInstall foamOldDirs
242 unset _foamSource _foamEval
244 # ----------------------------------------------------------------- end-of-file