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 ~/.login or ~/.cshrc
31 #------------------------------------------------------------------------------
33 setenv WM_PROJECT OpenFOAM
34 setenv WM_PROJECT_VERSION 1.7.x
36 ################################################################################
37 # USER EDITABLE PART. Note changes made here may be lost with the next upgrade
39 # either setenv FOAM_INST_DIR before sourcing this file or set
40 # foamInstall below to where OpenFOAM is installed
42 # Location of the OpenFOAM installation
43 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44 set foamInstall = $HOME/$WM_PROJECT
45 # set foamInstall = ~$WM_PROJECT
46 # set foamInstall = /usr/local/$WM_PROJECT
47 # set foamInstall = /opt/$WM_PROJECT
49 # END OF (NORMAL) USER EDITABLE PART
50 ################################################################################
52 # note the location for later use (eg, in job scripts)
53 if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
55 # The old dirs to be cleaned from the various environment variables
56 # - remove anything under top-level directory.
57 # NB: the WM_PROJECT_INST_DIR might not be identical between versions
58 set foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
60 # Location of site/user files
61 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 setenv WM_PROJECT_INST_DIR $FOAM_INST_DIR
63 setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
64 setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
66 # Location of third-party software
67 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
71 # Source files, possibly with some verbosity
72 alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; source \!*'
74 # Add in preset user or site preferences:
75 set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
76 if ( $status == 0 ) then
77 _foamSource $foamPrefs
81 # Evaluate command-line parameters
85 # name= -> unsetenv name
86 eval "unsetenv $argv[1]:s/=//"
89 # name=value -> setenv name value
90 eval "setenv $argv[1]:s/=/ /"
97 # Operating System/Platform
98 # ~~~~~~~~~~~~~~~~~~~~~~~~~
99 # WM_OSTYPE = POSIX | ????
100 if ( ! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX
103 # Compiler: set to Gcc, Gcc43, Gcc44 or Icc (for Intel's icc)
104 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 if ( ! $?WM_COMPILER ) setenv WM_COMPILER Gcc
107 setenv WM_COMPILER_ARCH
108 setenv WM_COMPILER_LIB_ARCH
111 # Compilation options (architecture, precision, optimised, debug or profiling)
112 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113 # WM_ARCH_OPTION = 32 | 64
114 if ( ! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64
116 # WM_PRECISION_OPTION = DP | SP
117 if ( ! $?WM_PRECISION_OPTION ) setenv WM_PRECISION_OPTION DP
119 # WM_COMPILE_OPTION = Opt | Debug | Prof
120 if ( ! $?WM_COMPILE_OPTION ) setenv WM_COMPILE_OPTION Opt
122 # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | MPI | QSMPI
123 if ( ! $?WM_MPLIB ) setenv WM_MPLIB OPENMPI
126 # Run options (floating-point signal handling and memory initialisation)
127 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132 # Detect system type and set environment variables
133 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134 setenv WM_ARCH `uname -s`
145 switch ($WM_ARCH_OPTION)
147 setenv WM_COMPILER_ARCH '-64'
150 setenv WM_CFLAGS '-m32 -fPIC'
151 setenv WM_CXXFLAGS '-m32 -fPIC'
152 setenv WM_LDFLAGS '-m32'
156 setenv WM_ARCH linux64
157 setenv WM_COMPILER_LIB_ARCH 64
160 setenv WM_CFLAGS '-m64 -fPIC'
161 setenv WM_CXXFLAGS '-m64 -fPIC'
162 setenv WM_LDFLAGS '-m64'
166 echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64"
173 setenv WM_ARCH linuxIA64
174 setenv WM_COMPILER I64
178 setenv WM_ARCH SiCortex64
179 setenv WM_COMPILER_LIB_ARCH 64
182 setenv WM_CFLAGS '-mabi=64 -fPIC'
183 setenv WM_CXXFLAGS '-mabi=64 -fPIC'
184 setenv WM_LDFLAGS '-mabi=64 -G0'
189 setenv WM_ARCH linuxPPC64
190 setenv WM_COMPILER_LIB_ARCH 64
193 setenv WM_CFLAGS '-m64 -fPIC'
194 setenv WM_CXXFLAGS '-m64 -fPIC'
195 setenv WM_LDFLAGS '-m64'
199 echo Unknown processor type `uname -m` for Linux
206 setenv WM_ARCH SunOS64
207 setenv WM_COMPILER_LIB_ARCH 64
210 setenv WM_CFLAGS '-mabi=64 -fPIC'
211 setenv WM_CXXFLAGS '-mabi=64 -fPIC'
212 setenv WM_LDFLAGS '-mabi=64 -G0'
213 setenv WM_MPLIB FJMPI
218 echo "Your '$WM_ARCH' operating system is not supported by this release"
219 echo "of OpenFOAM. For further assistance, please contact www.OpenFOAM.com"
226 # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
227 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228 set foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
230 #- prevent local variables from shadowing setenv variables
231 unset PATH MANPATH LD_LIBRARY_PATH LD_PRELOAD
233 if (! $?LD_LIBRARY_PATH ) setenv LD_LIBRARY_PATH ''
234 if (! $?MANPATH) setenv MANPATH ''
237 set cleaned=`$foamClean "$PATH" "$foamOldDirs"`
238 if ( $status == 0 ) then
242 #- Clean LD_LIBRARY_PATH
243 set cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"`
244 if ( $status == 0 ) setenv LD_LIBRARY_PATH $cleaned
247 set cleaned=`$foamClean "$MANPATH" "$foamOldDirs"`
248 if ( $status == 0 ) setenv MANPATH $cleaned
251 # Source project setup files
252 # ~~~~~~~~~~~~~~~~~~~~~~~~~~
253 _foamSource $WM_PROJECT_DIR/etc/settings.csh
254 _foamSource $WM_PROJECT_DIR/etc/aliases.csh
256 # Source user setup files for optional packages
257 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
258 set paraview3=`$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/cshrc`
259 if ( $status == 0 ) then
260 _foamSource $paraview3
264 set ensight=`$WM_PROJECT_DIR/bin/foamEtcFile apps/ensight/cshrc`
265 if ( $status == 0 ) then
271 # Clean environment paths again. Only remove duplicates
272 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274 set cleaned=`$foamClean "$PATH"`
275 if ( $status == 0 ) setenv PATH $cleaned
277 #- Clean LD_LIBRARY_PATH
278 set cleaned=`$foamClean "$LD_LIBRARY_PATH"`
279 if ( $status == 0 ) setenv LD_LIBRARY_PATH $cleaned
281 #- Clean MANPATH (trailing ':' to find system pages)
282 set cleaned=`$foamClean "$MANPATH"`:
283 if ( $status == 0 ) setenv MANPATH "$cleaned"
286 if ( $?LD_PRELOAD ) then
287 set cleaned=`$foamClean "$LD_PRELOAD"`
288 if ( $status == 0 ) setenv LD_PRELOAD $cleaned
291 # cleanup environment:
292 # ~~~~~~~~~~~~~~~~~~~~
293 unset cleaned foamClean foamInstall foamOldDirs
296 # ----------------------------------------------------------------- end-of-file