1 #----------------------------------*-sh-*--------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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=1.7.x
37 ################################################################################
38 # USER EDITABLE PART. Note 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=/usr/local/$WM_PROJECT
48 # foamInstall=/opt/$WM_PROJECT
50 # END OF (NORMAL) USER EDITABLE PART
51 ################################################################################
53 # note the location for later use (eg, in job scripts)
54 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
56 # The old dirs to be cleaned from the various environment variables
57 # - remove anything under top-level directory.
58 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
59 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
60 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
62 foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
66 # Location of site/user files
67 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
69 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
70 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
72 # Location of third-party software
73 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
77 # Source files, possibly with some verbosity
82 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
89 # Add in preset user or site preferences:
90 foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` && _foamSource $foamPrefs
93 # Evaluate command-line parameters
102 # name=value -> export name=value
110 # Operating System/Platform
111 # ~~~~~~~~~~~~~~~~~~~~~~~~~
112 # WM_OSTYPE = POSIX | ????
113 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
116 # Compiler: set to Gcc, Gcc43, Gcc44, or Icc (for Intel's icc)
117 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
120 unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
123 # Compilation options (architecture, precision, optimised, debug or profiling)
124 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125 # WM_ARCH_OPTION = 32 | 64
126 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
128 # WM_PRECISION_OPTION = DP | SP
129 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
131 # WM_COMPILE_OPTION = Opt | Debug | Prof
132 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
134 # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | MPI | QSMPI
135 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
138 # Run options (floating-point signal handling and memory initialisation)
139 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141 # export FOAM_SETNAN=
144 # Detect system type and set environment variables appropriately
145 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146 export WM_ARCH=`uname -s`
158 case $WM_ARCH_OPTION in
160 export WM_COMPILER_ARCH='-64'
163 export WM_CFLAGS='-m32 -fPIC'
164 export WM_CXXFLAGS='-m32 -fPIC'
165 export WM_LDFLAGS='-m32'
169 export WM_COMPILER_LIB_ARCH=64
172 export WM_CFLAGS='-m64 -fPIC'
173 export WM_CXXFLAGS='-m64 -fPIC'
174 export WM_LDFLAGS='-m64'
177 echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64"
184 export WM_COMPILER=I64
189 export WM_COMPILER_LIB_ARCH=64
192 export WM_CFLAGS='-mabi=64 -fPIC'
193 export WM_CXXFLAGS='-mabi=64 -fPIC'
194 export WM_LDFLAGS='-mabi=64 -G0'
200 export WM_COMPILER_LIB_ARCH=64
203 export WM_CFLAGS='-m64 -fPIC'
204 export WM_CXXFLAGS='-m64 -fPIC'
205 export WM_LDFLAGS='-m64'
209 echo Unknown processor type `uname -m` for Linux
216 export WM_COMPILER_LIB_ARCH=64
219 export WM_CFLAGS='-mabi=64 -fPIC'
220 export WM_CXXFLAGS='-mabi=64 -fPIC'
221 export WM_LDFLAGS='-mabi=64 -G0'
222 export WM_MPLIB=FJMPI
225 *) # an unsupported operating system
228 Your "$WM_ARCH" operating system is not supported by this release
229 of OpenFOAM. For further assistance, please contact www.OpenFOAM.com
236 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
237 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
238 foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
241 cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned"
243 #- Clean LD_LIBRARY_PATH
244 cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleaned"
247 cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned"
249 export PATH LD_LIBRARY_PATH MANPATH
252 # Source project setup files
253 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
254 _foamSource $WM_PROJECT_DIR/etc/settings.sh
255 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
258 # Source user setup files for optional packages
259 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260 paraview3=`$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/bashrc` \
261 && _foamSource $paraview3
264 ensight=`$WM_PROJECT_DIR/bin/foamEtcFile apps/ensight/bashrc` \
265 && _foamSource $ensight
269 # Clean environment paths again. Only remove duplicates
270 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
272 cleaned=`$foamClean "$PATH"` && PATH="$cleaned"
274 #- Clean LD_LIBRARY_PATH
275 cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned"
277 #- Clean MANPATH (trailing ':' to find system pages)
278 cleaned=`$foamClean "$MANPATH"`: && MANPATH="$cleaned"
280 export PATH LD_LIBRARY_PATH MANPATH
283 if [ -n "$LD_PRELOAD" ]
285 cleaned=`$foamClean "$LD_PRELOAD"` && LD_PRELOAD="$cleaned"
290 # cleanup environment:
291 # ~~~~~~~~~~~~~~~~~~~~
292 unset cleaned foamClean foamInstall foamOldDirs
295 # ----------------------------------------------------------------- end-of-file