2 #----------------------------------*-sh-*--------------------------------------
4 # \\ / F ield | foam-extend: Open Source CFD
6 # \\ / A nd | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
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
=foam
37 export WM_PROJECT_VERSION
=3.0
39 # helps to easily write #ifdefs to detect a dev-version
42 ###############################################################################
45 # either set $FOAM_INST_DIR before sourcing this file or set
46 # $foamInstall below to where OpenFOAM is installed
48 # Location of FOAM installation
49 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50 foamInstall
=$HOME/$WM_PROJECT
51 # foamInstall=~$WM_PROJECT
52 # foamInstall=/usr/local/$WM_PROJECT
53 # foamInstall=/opt/$WM_PROJECT
54 # foamInstall=/usr/lib
56 # END OF (NORMAL) USER EDITABLE PART
57 ################################################################################
59 # note the location for later use (eg, in job scripts)
60 : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
62 # The old dirs to be cleaned from the various environment variables
63 # - remove anything under top-level directory.
64 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
65 foamOldDirs
="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
66 if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
68 foamOldDirs
="$WM_PROJECT_INST_DIR $foamOldDirs"
72 # Location of site/user files
73 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 export WM_PROJECT_INST_DIR
=$FOAM_INST_DIR
75 export WM_PROJECT_DIR
=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_FORK-$WM_PROJECT_VERSION
76 export WM_PROJECT_USER_DIR
=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
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 export WM_THIRD_PARTY_DIR
=$WM_PROJECT_DIR/ThirdParty
83 # Source files, possibly with some verbosity
88 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
94 # Add in preset user or site preferences:
95 if [ -e $WM_PROJECT_DIR/etc
/prefs.sh
]
97 _foamSource
$WM_PROJECT_DIR/etc
/prefs.sh
99 [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "No prefs.sh found"
103 # Evaluate command-line parameters
108 # name= -> unset name
112 # name=value -> export name=value
120 # Operating System/Platform
121 # ~~~~~~~~~~~~~~~~~~~~~~~~~
122 # WM_OSTYPE = POSIX | ????
123 : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
126 # Compiler: set to Gcc or Icc (for Intel's icc)
127 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128 : ${WM_COMPILER:=Gcc}; export WM_COMPILER
129 #: ${WM_COMPILER:=Icc}; export WM_COMPILER
131 export WM_COMPILER_ARCH
=
132 export WM_COMPILER_LIB_ARCH
=
135 # Compilation options (architecture, precision, optimised, debug or profiling)
136 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138 # WM_ARCH_OPTION = 32 | 64
139 : ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
141 # WM_PRECISION_OPTION = DP | SP
142 : ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
144 # WM_COMPILE_OPTION = Opt | Debug | Prof
145 : ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
147 # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
148 : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
150 # WM_NCOMPPROCS = <number of processes to use>
151 # Warning: Need to use a complete path for foamGetSystemInfo because the PATH
152 # environment variable is not properly initialized yet.
153 : ${WM_NCOMPPROCS:=`$WM_PROJECT_DIR/bin/foamGetSystemInfo -nbrCores`}; export WM_NCOMPPROCS
156 # Run options (floating-point signal handling and memory initialisation)
157 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159 # export FOAM_SETNAN=
162 # Detect system type and set environment variables appropriately
163 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164 export WM_ARCH
=`uname -s`
176 case $WM_ARCH_OPTION in
178 export WM_COMPILER_ARCH
='-64'
179 export WM_CFLAGS
='-m32 -fPIC'
180 export WM_CXXFLAGS
='-m32 -fPIC'
181 export WM_LDFLAGS
='-m32'
185 export WM_COMPILER_LIB_ARCH
=64
186 export WM_CFLAGS
='-m64 -fPIC'
187 export WM_CXXFLAGS
='-m64 -fPIC'
188 export WM_LDFLAGS
='-m64'
191 echo Unknown WM_ARCH_OPTION
$WM_ARCH_OPTION, should be
32 or
64
198 export WM_COMPILER
=I64
203 export WM_COMPILER_LIB_ARCH
=64
204 export WM_CFLAGS
='-mabi=64 -fPIC'
205 export WM_CXXFLAGS
='-mabi=64 -fPIC'
206 export WM_LDFLAGS
='-mabi=64 -G0'
212 export WM_COMPILER_LIB_ARCH
=64
213 export WM_CFLAGS
='-m64 -fPIC'
214 export WM_CXXFLAGS
='-m64 -fPIC'
215 export WM_LDFLAGS
='-m64'
219 echo Unknown processor
type `uname -m` for Linux
225 # this makes certain things easier
226 export WM_ARCH_BASE
=darwin
228 # Remove limit of open files
233 export WM_ARCH
=darwinPpc
236 export WM_ARCH
=darwinIntel
239 echo "This seems to be neither an Intel-Mac nor a PPC-Mac please tell me the output of 'uname -p'. Bernhard."
240 export WM_ARCH
=darwinUnknown
244 case $WM_ARCH_OPTION in
246 export WM_CFLAGS
='-m32 -fPIC'
247 export WM_CXXFLAGS
='-m32 -fPIC'
248 export WM_LDFLAGS
='-m32'
251 export WM_ARCH
=${WM_ARCH}64
252 export WM_CFLAGS
='-m64 -fPIC'
253 export WM_CXXFLAGS
='-m64 -fPIC'
254 export WM_LDFLAGS
='-m64'
257 echo Unknown WM_ARCH_OPTION
$WM_ARCH_OPTION, should be
32 or
64
261 # Make sure that binaries use the best features of the used OS-Version
262 # We need to get rid of the revision number from this string. eg turn "10.7.5" into "10.7"
263 export MACOSX_DEPLOYMENT_TARGET
=`sw_vers -productVersion | sed -e "s/\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2/g"`
265 which -s port
>/dev
/null
266 if [ $?
-eq "0" -a -d '/opt/local/etc/macports' ]
268 if [ "$FOAM_VERBOSE" -a "$PS1" ]
270 echo "Using Macports binaries"
273 export WM_USE_MACPORT
=1
275 if [ -e '/opt/local/bin/openmpicc' ]
277 export WM_MPLIB
=MACPORTOPENMPI
279 if [ -z "$WM_CHOSEN_MAC_MPI" ]
281 echo "WM_CHOSEN_MAC_MPI unset. Using OPENMPI"
282 export WM_MPLIB
=OPENMPI
284 export WM_MPLIB
=$WM_CHOSEN_MAC_MPI
288 if [ "$compilerInstall" == "System" ]
290 # Use Mac-Ports-Compiler instead of Apple-gcc-4.2
293 export WM_MACPORT_VERSION
=4.2
294 export WM_BASE_COMPILER
=Gcc
297 export WM_MACPORT_VERSION
=4.3
298 export WM_BASE_COMPILER
=Gcc
301 export WM_MACPORT_VERSION
=4.4
302 export WM_BASE_COMPILER
=Gcc
305 export WM_MACPORT_VERSION
=4.5
306 export WM_BASE_COMPILER
=Gcc
309 export WM_MACPORT_VERSION
=4.6
310 export WM_BASE_COMPILER
=Gcc
313 export WM_MACPORT_VERSION
=4.7
314 export WM_BASE_COMPILER
=Gcc
317 export WM_MACPORT_VERSION
=4.8
318 export WM_BASE_COMPILER
=Gcc
321 export WM_BASE_COMPILER
=Clang
322 export WM_MACPORT_VERSION
=3.2
325 export WM_BASE_COMPILER
=Clang
326 export WM_MACPORT_VERSION
=3.3
329 export WM_BASE_COMPILER
=Clang
330 export WM_MACPORT_VERSION
=3.4
335 echo "Unsupported MacPorts-Compiler $WM_COMPILER"
338 if [ "$WM_MACPORT_VERSION" != "" ]
340 if [ "$WM_BASE_COMPILER" == "Gcc" ]
342 export WM_CC
="gcc-mp-$WM_MACPORT_VERSION"
343 export WM_CXX
="g++-mp-$WM_MACPORT_VERSION"
344 export WM_FC
="gfortran-mp-$WM_MACPORT_VERSION"
346 export WM_CC
="clang-mp-$WM_MACPORT_VERSION"
347 export WM_CXX
="clang++-mp-$WM_MACPORT_VERSION"
349 # hardcoded. Needed for ThirdParty
350 export WM_FC
="gfortran-mp-4.5"
353 ruleDirBase
=$WM_PROJECT_DIR/wmake
/rules
/$WM_ARCH$WM_BASE_COMPILER
354 ruleDir
=$WM_PROJECT_DIR/wmake
/rules
/$WM_ARCH$WM_COMPILER
357 echo "Rule directory $ruleDir not existing. Linking to $ruleDirBase"
358 ln -s $ruleDirBase $ruleDir
360 unset ruleDir ruleDirBase
368 export WM_COMPILER_LIB_ARCH
=64
369 export WM_CFLAGS
='-mabi=64 -fPIC'
370 export WM_CXXFLAGS
='-mabi=64 -fPIC'
371 export WM_LDFLAGS
='-mabi=64 -G0'
372 export WM_MPLIB
=FJMPI
375 *) # an unsupported operating system
378 Your "$WM_ARCH" operating system is not supported by this release
379 of OpenFOAM. For further assistance, please contact www.extend-project.de
386 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
387 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
388 cleanProg
=$WM_PROJECT_DIR/bin
/foamCleanPath
391 cleanEnv
=`$cleanProg "$PATH" "$foamOldDirs"` && PATH
="$cleanEnv"
393 #- Clean LD_LIBRARY_PATH
394 cleanEnv
=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH
="$cleanEnv"
396 #- Clean DYLD_LIBRARY_PATH
397 if [[ "$WM_ARCH_BASE" == "darwin" ]]
399 cleanEnv
=`$cleanProg "$DYLD_LIBRARY_PATH" "$foamOldDirs"` && DYLD_LIBRARY_PATH
="$cleanEnv"
403 cleanEnv
=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH
="$cleanEnv"
405 export PATH LD_LIBRARY_PATH MANPATH
407 # Source project setup files
408 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
410 _foamSource
$WM_PROJECT_DIR/etc
/settings.sh
411 _foamSource
$WM_PROJECT_DIR/etc
/aliases.sh
414 # Source user setup files for optional packages
415 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/bashrc
417 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview3/bashrc
418 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
421 # Clean environment paths again. Only remove duplicates
422 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
424 cleanEnv
=`$cleanProg "$PATH"` && PATH
="$cleanEnv"
426 #- Clean LD_LIBRARY_PATH
427 cleanEnv
=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH
="$cleanEnv"
430 cleanEnv
=`$cleanProg "$MANPATH"` && MANPATH
="$cleanEnv:"
432 export PATH LD_LIBRARY_PATH MANPATH
435 if [ "$LD_PRELOAD" != "" ]
437 cleanEnv
=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD
="$cleanEnv"
442 # cleanup environment:
443 # ~~~~~~~~~~~~~~~~~~~~
444 unset cleanEnv cleanProg foamInstall foamOldDirs
447 # -----------------------------------------------------------------------------