1 #----------------------------------*-sh-*--------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright (C) 1991-2009 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 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
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
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.x
38 ################################################################################
41 # either set $FOAM_INST_DIR before sourcing this file or set
42 # $foamInstall below to where OpenFOAM is installed
44 # Location of FOAM installation
45 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46 foamInstall=$HOME/$WM_PROJECT
47 # foamInstall=~$WM_PROJECT
48 # foamInstall=/usr/local/$WM_PROJECT
49 # foamInstall=/opt/$WM_PROJECT
51 # END OF (NORMAL) USER EDITABLE PART
52 ################################################################################
54 # note the location for later use (eg, in job scripts)
55 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
57 # The old dirs to be cleaned from the various environment variables
58 # - remove anything under top-level directory.
59 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
60 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
61 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
63 foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
67 # Location of site/user files
68 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
70 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
71 export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
74 # Location of third-party software
75 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
79 # Operating System/Platform
80 # ~~~~~~~~~~~~~~~~~~~~~~~~~
81 # WM_OSTYPE = POSIX | ????
82 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
85 # Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
86 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
89 export WM_COMPILER_ARCH=
90 export WM_COMPILER_LIB_ARCH=
93 # Compilation options (architecture, precision, optimised, debug or profiling)
94 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 # WM_ARCH_OPTION = 32 | 64
96 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
98 # WM_PRECISION_OPTION = DP | SP
99 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
101 # WM_COMPILE_OPTION = Opt | Debug | Prof
102 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
104 # WM_MPLIB = | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
105 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
108 # Run options (floating-point signal handling and memory initialisation)
109 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111 # export FOAM_SETNAN=
114 # Detect system type and set environment variables appropriately
115 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116 export WM_ARCH=`uname -s`
128 case $WM_ARCH_OPTION in
130 export WM_COMPILER_ARCH='-64'
133 export WM_CFLAGS='-m32 -fPIC'
134 export WM_CXXFLAGS='-m32 -fPIC'
135 export WM_LDFLAGS='-m32'
139 export WM_COMPILER_LIB_ARCH=64
142 export WM_CFLAGS='-m64 -fPIC'
143 export WM_CXXFLAGS='-m64 -fPIC'
144 export WM_LDFLAGS='-m64'
147 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
154 export WM_COMPILER=I64
159 export WM_COMPILER_LIB_ARCH=64
162 export WM_CFLAGS='-mabi=64 -fPIC'
163 export WM_CXXFLAGS='-mabi=64 -fPIC'
164 export WM_LDFLAGS='-mabi=64 -G0'
170 export WM_COMPILER_LIB_ARCH=64
173 export WM_CFLAGS='-m64 -fPIC'
174 export WM_CXXFLAGS='-m64 -fPIC'
175 export WM_LDFLAGS='-m64'
179 echo Unknown processor type `uname -m` for Linux
186 export WM_COMPILER_LIB_ARCH=64
189 export WM_CFLAGS='-mabi=64 -fPIC'
190 export WM_CXXFLAGS='-mabi=64 -fPIC'
191 export WM_LDFLAGS='-mabi=64 -G0'
192 export WM_MPLIB=FJMPI
195 *) # an unsupported operating system
198 Your "$WM_ARCH" operating system is not supported by this release
199 of OpenFOAM. For further assistance, please contact www.OpenFOAM.org
206 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
207 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
211 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
213 #- Clean LD_LIBRARY_PATH
214 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
217 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
219 export PATH LD_LIBRARY_PATH MANPATH
221 # Source project setup files
222 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
227 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
234 _foamSource $WM_PROJECT_DIR/etc/settings.sh
235 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
238 # Source user setup files for optional packages
239 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
241 _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
242 _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
245 # Clean environment paths again. Only remove duplicates
246 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
250 #- Clean LD_LIBRARY_PATH
251 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
254 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
256 export PATH LD_LIBRARY_PATH MANPATH
259 if [ "$LD_PRELOAD" != "" ]
261 cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
266 # cleanup environment:
267 # ~~~~~~~~~~~~~~~~~~~~
268 unset cleanEnv cleanProg foamInstall foamOldDirs
271 # -----------------------------------------------------------------------------