1 #----------------------------------*-sh-*--------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright held by original author
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-ext
38 # helps to easily write #ifdefs to detect a dev-version
41 ###############################################################################
44 # either set $FOAM_INST_DIR before sourcing this file or set
45 # $foamInstall below to where OpenFOAM is installed
47 # Location of FOAM installation
48 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 foamInstall=$HOME/$WM_PROJECT
50 # foamInstall=~$WM_PROJECT
51 # foamInstall=/usr/local/$WM_PROJECT
52 # foamInstall=/opt/$WM_PROJECT
53 # foamInstall=/usr/lib
55 # END OF (NORMAL) USER EDITABLE PART
56 ################################################################################
58 # note the location for later use (eg, in job scripts)
59 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
61 # The old dirs to be cleaned from the various environment variables
62 # - remove anything under top-level directory.
63 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
64 foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
65 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
67 foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
71 # Location of site/user files
72 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
74 export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
75 : ${WM_PROJECT_USER_DIR:=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION}; export WM_PROJECT_USER_DIR
78 # Location of third-party software
79 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 #: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION}; export WM_THIRD_PARTY_DIR
81 : ${WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty}; export WM_THIRD_PARTY_DIR
83 # Source files, possibly with some verbosity
88 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
94 # Add in preset user or site preferences:
95 foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` && _foamSource $foamPrefs
98 # Evaluate command-line parameters
103 # name= -> unset name
107 # name=value -> export name=value
115 # Operating System/Platform
116 # ~~~~~~~~~~~~~~~~~~~~~~~~~
117 # WM_OSTYPE = POSIX | ????
118 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
121 # Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
122 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
125 export WM_COMPILER_ARCH=
126 export WM_COMPILER_LIB_ARCH=
129 # Compilation options (architecture, precision, optimised, debug or profiling)
130 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131 : ${WM_NCOMPPROCS:=2}; export WM_NCOMPPROCS
133 # WM_ARCH_OPTION = 32 | 64
134 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
136 # WM_PRECISION_OPTION = DP | SP
137 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
139 # WM_COMPILE_OPTION = Opt | Debug | Prof
140 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
142 # WM_MPLIB = | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
143 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
146 # Run options (floating-point signal handling and memory initialisation)
147 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149 # export FOAM_SETNAN=
152 # Detect system type and set environment variables appropriately
153 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154 export WM_ARCH=`uname -s`
166 case $WM_ARCH_OPTION in
168 export WM_COMPILER_ARCH='-64'
169 export WM_CFLAGS='-m32 -fPIC'
170 export WM_CXXFLAGS='-m32 -fPIC'
171 export WM_LDFLAGS='-m32'
175 export WM_COMPILER_LIB_ARCH=64
176 export WM_CFLAGS='-m64 -fPIC'
177 export WM_CXXFLAGS='-m64 -fPIC'
178 export WM_LDFLAGS='-m64'
181 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
188 export WM_COMPILER=I64
193 export WM_COMPILER_LIB_ARCH=64
194 export WM_CFLAGS='-mabi=64 -fPIC'
195 export WM_CXXFLAGS='-mabi=64 -fPIC'
196 export WM_LDFLAGS='-mabi=64 -G0'
202 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
215 # this makes certain things easier
216 export WM_ARCH_BASE=darwin
220 export WM_ARCH=darwinPpc
223 export WM_ARCH=darwinIntel
226 echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
227 export WM_ARCH=darwinUnknown
230 case $WM_ARCH_OPTION in
232 export WM_CFLAGS='-m32 -fPIC'
233 export WM_CXXFLAGS='-m32 -fPIC'
234 export WM_LDFLAGS='-m32'
237 export WM_ARCH=${WM_ARCH}64
238 export WM_CFLAGS='-m64 -fPIC'
239 export WM_CXXFLAGS='-m64 -fPIC'
240 export WM_LDFLAGS='-m64'
243 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
247 # Make sure that binaries use the best features of the used OS-Version
248 export MACOSX_DEPLOYMENT_TARGET=`sw_vers -productVersion`
250 if [ "$compilerInstall" == "System" ]
252 # Use Mac-Ports-Compiler instead of Apple-gcc-4.2
255 export WM_CC='gcc-mp-4.3'
256 export WM_CXX='g++-mp-4.3'
259 export WM_CC='gcc-mp-4.4'
260 export WM_CXX='g++-mp-4.4'
263 export WM_CC='gcc-mp-4.5'
264 export WM_CXX='g++-mp-4.5'
276 export WM_COMPILER_LIB_ARCH=64
277 export WM_CFLAGS='-mabi=64 -fPIC'
278 export WM_CXXFLAGS='-mabi=64 -fPIC'
279 export WM_LDFLAGS='-mabi=64 -G0'
280 export WM_MPLIB=FJMPI
283 *) # an unsupported operating system
286 Your "$WM_ARCH" operating system is not supported by this release
287 of OpenFOAM. For further assistance, please contact www.extend-project.de
294 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
295 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296 cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
299 cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
301 #- Clean LD_LIBRARY_PATH
302 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
304 #- Clean DYLD_LIBRARY_PATH
305 if [[ "$WM_ARCH_BASE" == "darwin" ]]
307 cleanEnv=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH="$cleanEnv"
311 cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
313 export PATH LD_LIBRARY_PATH MANPATH
315 # Source project setup files
316 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
318 _foamSource $WM_PROJECT_DIR/etc/settings.sh
319 _foamSource $WM_PROJECT_DIR/etc/aliases.sh
322 # Source user setup files for optional packages
323 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
325 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
326 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
329 # Clean environment paths again. Only remove duplicates
330 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332 cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
334 #- Clean LD_LIBRARY_PATH
335 cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
338 cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv:"
340 export PATH LD_LIBRARY_PATH MANPATH
343 if [ "$LD_PRELOAD" != "" ]
345 cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
350 # cleanup environment:
351 # ~~~~~~~~~~~~~~~~~~~~
352 unset cleanEnv cleanProg foamInstall foamOldDirs
355 # -----------------------------------------------------------------------------