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 ~/.login or ~/.cshrc
32 #------------------------------------------------------------------------------
34 setenv WM_PROJECT OpenFOAM
35 setenv WM_PROJECT_VERSION 1.6-ext
37 # helps to easily write #ifdefs to detect a dev-version
40 ###############################################################################
43 # either setenv FOAM_INST_DIR before sourcing this file or set
44 # foamInstall below to where OpenFOAM is installed
46 # Location of FOAM installation
47 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48 set foamInstall = $HOME/$WM_PROJECT
49 # set foamInstall = ~$WM_PROJECT
50 # set foamInstall = /usr/local/$WM_PROJECT
51 # set foamInstall = /opt/$WM_PROJECT
53 # END OF (NORMAL) USER EDITABLE PART
54 ###############################################################################
56 # note the location for later use (eg, in job scripts)
57 if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
59 # The old dirs to be cleaned from the various environment variables
60 # - remove anything under top-level directory.
61 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
62 set foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
64 # Location of site/user files
65 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
66 setenv WM_PROJECT_INST_DIR $FOAM_INST_DIR
67 setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
68 setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
71 # Location of third-party software
72 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 #setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
74 setenv WM_THIRD_PARTY_DIR $WM_PROJECT_DIR/ThirdParty
76 # Source files, possibly with some verbosity
77 alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; source \!*'
79 # Add in preset user or site preferences:
80 set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
81 if ( $status == 0 ) then
82 if ( $?foamPrefs ) then
83 _foamSource $foamPrefs
88 # Evaluate command-line parameters
92 # name= -> unsetenv name
93 eval "unsetenv $argv[1]:s/=//"
96 # name=value -> setenv name value
97 eval "setenv $argv[1]:s/=/ /"
104 # Operating System/Platform
105 # ~~~~~~~~~~~~~~~~~~~~~~~~~
106 # WM_OSTYPE = POSIX | ????
107 if ( ! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX
110 # Compiler: set to Gcc, Gcc43 or Icc (for Intel's icc)
111 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112 if ( ! $?WM_COMPILER ) setenv WM_COMPILER Gcc
113 #setenv WM_COMPILER Gcc
114 #setenv WM_COMPILER Icc
116 setenv WM_COMPILER_ARCH
117 setenv WM_COMPILER_LIB_ARCH
120 # Compilation options (architecture, precision, optimised, debug or profiling)
121 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122 # WM_ARCH_OPTION = 32 | 64
123 if ( ! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64
125 # WM_PRECISION_OPTION = DP | SP
126 if ( ! $?WM_PRECISION_OPTION ) setenv WM_PRECISION_OPTION DP
128 # WM_COMPILE_OPTION = Opt | Debug | Prof
129 if ( ! $?WM_COMPILE_OPTION ) setenv WM_COMPILE_OPTION Opt
130 #setenv WM_COMPILE_OPTION Opt
131 #setenv WM_COMPILE_OPTION Debug
133 # WM_MPLIB = | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
134 if ( ! $?WM_MPLIB ) setenv WM_MPLIB OPENMPI
136 # WM_NCOMPPROCS = <number of processes to use>
137 if ( ! $?WM_NCOMPPROCS ) setenv WM_NCOMPPROCS `foamGetSystemInfo -nbrCores`
139 # Run options (floating-point signal handling and memory initialisation)
140 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145 # Detect system type and set environment variables
146 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147 setenv WM_ARCH `uname -s`
158 switch ($WM_ARCH_OPTION)
161 setenv WM_COMPILER_ARCH '-64'
162 setenv WM_CFLAGS '-m32 -fPIC'
163 setenv WM_CXXFLAGS '-m32 -fPIC'
164 setenv WM_LDFLAGS '-m32'
168 setenv WM_ARCH linux64
169 setenv WM_COMPILER_LIB_ARCH 64
170 setenv WM_CFLAGS '-m64 -fPIC'
171 setenv WM_CXXFLAGS '-m64 -fPIC'
172 setenv WM_LDFLAGS '-m64'
176 echo Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64
183 setenv WM_ARCH linuxIA64
184 setenv WM_COMPILER I64
188 setenv WM_ARCH SiCortex64
189 setenv WM_COMPILER_LIB_ARCH 64
190 setenv WM_CFLAGS '-mabi=64 -fPIC'
191 setenv WM_CXXFLAGS '-mabi=64 -fPIC'
192 setenv WM_LDFLAGS '-mabi=64 -G0'
197 setenv WM_ARCH linuxPPC64
198 setenv WM_COMPILER_LIB_ARCH 64
199 setenv WM_CFLAGS '-m64 -fPIC'
200 setenv WM_CXXFLAGS '-m64 -fPIC'
201 setenv WM_LDFLAGS '-m64'
205 echo Unknown processor type `uname -m` for Linux
212 # this makes certain things easier
213 setenv WM_ARCH_BASE darwin
217 setenv WM_ARCH darwinPpc
220 setenv WM_ARCH darwinIntel
223 echo "This seems to be an Intel-Mac please tell me the output of 'uname -p'. Bernhard."
224 setenv WM_ARCH darwinIntel
227 switch ($WM_ARCH_OPTION)
229 setenv WM_CFLAGS '-m32 -fPIC'
230 setenv WM_CXXFLAGS '-m32 -fPIC'
231 setenv WM_LDFLAGS '-m32'
234 setenv WM_ARCH ${WM_ARCH}64
235 setenv WM_CFLAGS '-m64 -fPIC'
236 setenv WM_CXXFLAGS '-m64 -fPIC'
237 setenv WM_LDFLAGS '-m64'
240 echo "Unknown WM_ARCH_OPTION $WM_ARCH_OPTION, should be 32 or 64"
244 # Make sure that binaries use the best features of the used OS-Version
245 # We need to get rid of the revision number from this string. eg turn "10.7.5" into "10.7"
246 set v=`sw_vers -productVersion | sed 's/\./ /g'`
247 setenv MACOSX_DEPLOYMENT_TARGET "$v[1].$v[2]"
249 # Use Mac-Ports-Compiler instead of Apple-gcc-4.2
250 if ( ! $?compilerInstall ) setenv compilerInstall System
251 if ( $compilerInstall == "System" ) then
252 switch ($WM_COMPILER)
254 setenv WM_CC 'gcc-mp-4.3'
255 setenv WM_CXX 'g++-mp-4.3'
258 setenv WM_CC 'gcc-mp-4.4'
259 setenv WM_CXX 'g++-mp-4.4'
262 setenv WM_CC 'gcc-mp-4.5'
263 setenv WM_CXX 'g++-mp-4.5'
266 #setenv WM_COMPILER ""
272 setenv WM_ARCH SunOS64
273 setenv WM_COMPILER_LIB_ARCH 64
274 setenv WM_CFLAGS '-mabi=64 -fPIC'
275 setenv WM_CXXFLAGS '-mabi=64 -fPIC'
276 setenv WM_LDFLAGS '-mabi=64 -G0'
277 setenv WM_MPLIB FJMPI
282 echo "Your '$WM_ARCH' operating system is not supported by this release"
283 echo "of OpenFOAM. For further assistance, please contact www.OpenFOAM.org"
290 # Clean standard environment variables (path/PATH, LD_LIBRARY_PATH, MANPATH)
291 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292 set cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
294 if (! $?LD_LIBRARY_PATH ) then
295 setenv LD_LIBRARY_PATH ''
297 if (! $?MANPATH) then
302 set colonPath=`echo "$path" | sed -e 's/ /:/g'`
303 set cleanEnv=`$cleanProg "$colonPath" "$foamOldDirs"`
304 if ( $status == 0 ) then
305 set path=`echo "$cleanEnv" | sed -e 's/:/ /g'`
308 #- Clean LD_LIBRARY_PATH
309 setenv LD_LIBRARY_PATH `$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"`
312 setenv MANPATH `$cleanProg "$MANPATH" "$foamOldDirs"`
315 # Source project setup files
316 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
317 _foamSource $WM_PROJECT_DIR/etc/settings.csh
318 _foamSource $WM_PROJECT_DIR/etc/aliases.csh
320 # Source user setup files for optional packages
321 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322 # _foamSource $WM_PROJECT_DIR/etc/apps/paraview/cshrc
323 #_foamSource $WM_PROJECT_DIR/etc/apps/paraview3/cshrc
324 # _foamSource $WM_PROJECT_DIR/etc/apps/ensight/cshrc
327 # Clean environment paths again. Only remove duplicates
328 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
330 set colonPath=`echo "$path" | sed -e 's/ /:/g'`
331 set cleanEnv=`$cleanProg "$colonPath"`
332 if ( $status == 0 ) then
333 set path=`echo "$cleanEnv" | sed -e 's/:/ /g'`
336 #- Clean LD_LIBRARY_PATH
337 setenv LD_LIBRARY_PATH `$cleanProg "$LD_LIBRARY_PATH"`
340 setenv MANPATH `$cleanProg "$MANPATH"`:
343 if ( $?LD_PRELOAD ) then
344 setenv LD_PRELOAD `$cleanProg "$LD_PRELOAD"`
347 #- Clean DYLD_LIBRARY_PATH
348 if ( $?DYLD_LIBRARY_PATH ) then
349 setenv DYLD_LIBRARY_PATH `$cleanProg "$DYLD_LIBRARY_PATH"`
352 # cleanup environment:
353 # ~~~~~~~~~~~~~~~~~~~~
354 unset cleanEnv cleanProg colonPath foamInstall foamOldDirs
357 # -----------------------------------------------------------------------------