Difference between revisions of "Installation/Outdated/Howto compile OpenFOAM"

From OpenFOAMWiki
m (Reverted edit of Bgschaid, changed back to last version by Fe0Eup)
m (Reverting spam)
Line 1: Line 1:
[http://people.msoe.edu/~millerni/forums.php?show=topic&id=114&forum=13 online meridia] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=157&forum=13 wwe ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=128&forum=13 cheap phentermine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=158&forum=13 cheap xanax] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=106&forum=13 cheap hydrocodone] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=160&forum=13 zanaflex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=102&forum=13 free free ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=97&forum=13 buy didrex] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=135&forum=13 real ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=100&forum=13 buy fioricet] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=96&forum=13 diazepam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=136&forum=13 cheap rivotril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=87&forum=13 cheap ativan] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=144&forum=13 sonyericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=137&forum=13 free sagem ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=152&forum=13 verizon ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=139&forum=13 sharp ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=125&forum=13 cheap ortho] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=156&forum=13 cheap wellbutrin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=151&forum=13 online valium] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=121&forum=13 cheap nexium] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=147&forum=13 free tracfone ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=142&forum=13 sony ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=94&forum=13 cool ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=161&forum=13 cheap zoloft] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=117&forum=13 motorola ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=133&forum=13 free qwest ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=138&forum=13 samsung ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=122&forum=13 free nextel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=89&forum=13 cheap celexa] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=99&forum=13 free ericsson ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=115&forum=13 free midi ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=146&forum=13 cheap tenuate] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=109&forum=13 cheap levitra] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=82&forum=13 adipex online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=132&forum=13 free punk ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=130&forum=13 cheap propecia] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=83&forum=13 cheap albuterol] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=85&forum=13 cheap alprazolam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=153&forum=13 viagra online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=148&forum=13 tramadol online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=143&forum=13 sony ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=86&forum=13 ambien online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=103&forum=13 free funny ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=104&forum=13 hgh online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=129&forum=13 polyphonic ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=90&forum=13 cialis online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=123&forum=13 nokia ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=101&forum=13 cheap flexeril] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=124&forum=13 norco online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=149&forum=13 ultracet online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=88&forum=13 cheap carisoprodol] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=108&forum=13 kyocera ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=93&forum=13 cheap clonazepam] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=127&forum=13 cheap pharmacy online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=95&forum=13 cheap cyclobenzaprine] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=150&forum=13 cheap ultram] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=111&forum=13 lisinopril online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=159&forum=13 xenical online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=162&forum=13 zyban online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=116&forum=13 mono ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=112&forum=13 lorazepam online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=145&forum=13 free sprint ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=110&forum=13 cheap lipitor] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=131&forum=13 cheap prozac] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=120&forum=13 music ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=105&forum=13 hoodia online] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=155&forum=13 vigrx] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=98&forum=13 cheap diethylpropion] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=113&forum=13 but lortab] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=154&forum=13 cheap vicodin] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=119&forum=13 free mtv ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=84&forum=13 alltel ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=141&forum=13 cheap soma] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=107&forum=13 free jazz ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=140&forum=13 cheap sildenafil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=126&forum=13 cheap paxil] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=118&forum=13 mp3 ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=92&forum=13 cheap clomid] [http://people.msoe.edu/~millerni/forums.php?show=topic&id=91&forum=13 cingular ringtones] [http://people.msoe.edu/~millerni/forums.php?show=topic
+
This document describes how to compile {{OpenFOAM}} on Unix from the source code provided by the nice folks at [http://www.opencfd.co.uk/ OpenCFD].
 +
 
 +
This document also describes how to download and compile some of the tools or packages needed for compiling OpenFOAM.
 +
 
 +
The process described in this document is based on the OpenFOAM [http://foam.sourceforge.net/README README] file, Section "4. Building from Sources (Optional)", but with more details.
 +
 
 +
The information presented here has been tested and validated by the author while compiling [http://www.opencfd.co.uk/openfoam/version1.3.html OpenFOAM 1.3], under SuSE 9.1 x86_64, RedHat/Centos 4 and Debian/Knoppix 5.0, and more recently with [http://www.opencfd.co.uk/openfoam/version1.4.html OpenFOAM 1.4] on the same RedHat system. Depending on your Operating System and/or your OS version, your milleage may vary...
 +
 
 +
Furthermore, the version numbers for the different packages involved in the recompilation of OpenFOAM are different for OpenFOAM version 1.3 and 1.4; please use the packages source code version associated with the binary package proposed by OpenCFD when upgrading and compiling a newer version of OpenFOAM. The current text is based on the packages version recommended for OpenFOAM 1.3.
 +
 +
This is work in progress; please don't hesitate to complement the information presented here.
 +
----
 +
== Preamble ==
 +
===Basic stuff===
 +
This document describes the compilation and installation of OpenFOAM 1.3 in the default installation directory $HOME/OpenFOAM and $HOME/OpenFOAM/linux, as suggested in http://www.openfoam.org/download.html.
 +
 
 +
<br>
 +
If not already available, you first need to create these directories:
 +
 
 +
 
 +
'''For x86:'''
 +
<bash>
 +
mkdir -p $HOME/OpenFOAM/linux
 +
</bash>
 +
 
 +
 
 +
'''For x86_64:'''
 +
<bash>
 +
mkdir -p $HOME/OpenFOAM/linuxAMD64
 +
</bash>
 +
 
 +
 
 +
For the rest of this document, only the x86 installation procedure will be presented in detail. The specific information for the installation on x86_64 platforms will be presented only when significantly different from the x86 installation procedure.
 +
 
 +
===Not so basic (but very useful) stuff===
 +
In the process of recompiling and installing OpenFOAM 1.3, you will have to modify some of the files provided by OpenCFD.
 +
 
 +
Before doing so, I highly recommend archiving the original version of the file under ''RCS'' first.
 +
 
 +
''RCS'' stands for ''Revision Control System''. It's a revision control system that is the ancestor of the well known ''CVS'' and ''Subversion'' revision systems. ''RCS'' comes standard with probably almost every modern flavors of Unix.
 +
 
 +
The nice thing about ''RCS'' is its simplicity, the fact that it stores the file revision archive locally, and most importantly, it's a system that will help you memorize every revisions of any given ASCII file, so you will always be able to return any modified file back to a known and valid version.
 +
 
 +
So, take the time to RTFM about ''RCS'' (eg: man rcs). It might save you some headaches later on.
 +
 
 +
===Finally, a little advice===
 +
As a rule of thumb, do not install OpenFOAM as the user ''root'' on your workstation. Instead, use your own username, or simply create a new user ''openfoam''. The super-user ''root'' should always be reserved for doing system administration tasks.
 +
----
 +
 
 +
== Compiling and installing GNU Gcc ==
 +
===The motivation for compiling GNU gcc===
 +
Compiling the GNU gcc/g++ compiler can be a daunting task for the non-initiated. Usually, the installation of the pre-compiled gcc/g++ binary package offered by OpenCFD with any new release of OpenFOAM should cover the need of most OpenFOAM developers.  
 +
 
 +
As mentioned on the mailing list by Hrvoje Jasak, it is usually recommended to keep your OpenFOAM gcc/g++ compiler very up-to-date because a new gcc/g++ release usually means fewer compiler bugs and better performance; OpenFOAM will usually benefit from the newer compiler. So this is one very good reason to visit the GNU gcc compiler  web site regularly, and recompile gcc/g++ from the source code.
 +
 
 +
However, another good reason for recompiling gcc/g++ is related to some compatibilities issues that can arise when deploying the OpenCFD pre-compiled gcc/g++ package on your platform.
 +
 
 +
One issue that I have encountered on a SuSE 9.1 platform with the pre-compiled gcc/g++ binary package was related to the interaction of the new g++ compiler and the system GNU linker ''ld''. Both the gcc/g++ compiler  and the ''ld'' linker are necessary when compiling applications on Unix. And of course, they both need to be compatible with one another.
 +
 
 +
To make a long story short, when configuring gcc/g++, the ''configure'' script will ''automagically'' explore the availability of the numerous runtime options of your system GNU linker ''ld'', and compile gcc/g++ accordingly. On recent operating systems like SuSE 10, the version of  system linker ''ld'' is newer, hence new runtime ''ld'' options are available, and, on that platform, gcc/g++ will be compiled to take advantage of them.
 +
 
 +
However, when the same pre-compiled gcc/g++ compiler is deployed with an older OS, your default system GNU linker ''ld'' will be older too, and there is a definite chance that the compatibility between gcc/g++ and ''ld'' will be broken. I know it did when I installed the pre-compiled gcc/g++ package from OpenFOAM 1.2 on my SuSE 9.1 workstation.
 +
 
 +
Some users also experienced the same kind of compatibility issues between gcc 4.1.0 and /usr/bin/ld on RedHat Enterprise AMD64 platforms.
 +
 
 +
In that situation, you have 3 options:
 +
# You upgrade your Operating System to a newer version.
 +
# You install a newer version of ''ld'' from GNU binutils for your spanking new gcc/g++ precompiled compiler.
 +
# You recompile gcc/g++ in order for the ''configure'' script to discover the runtime options available from your system linker ''ld''.
 +
 
 +
 
 +
The rest of this section will describe options #2 and #3.
 +
 
 +
Other reasons would be: (NB: these 2 lines should go in a section like "Motivation for recompiling OpenFOAM")
 +
* You're developing a new utility or are looking for a bug in OpenFOAM: in that case you may want to have a version of OpenFOAM with ''debugging'' enabled
 +
* You don't have enough memory and precision isn't your primary concern. In that case you want to compile a ''single-precision'' version of OpenFOAM.
 +
 
 +
===Selecting the right package to download===
 +
You should always download a GNU gcc/g++ source package with at least the same version, if not newer, as the version of the pre-compiled gcc/g++ compiler provided by OpenCFD, for the version of OpenFOAM you plan to use. The GNU gcc/g++ compiler source package is downloadable from the [http://gcc.gnu.org/ GCC GNU Web site], or from one of it's numerous mirrors.
 +
 
 +
Here is an example for OpenFOAM 1.3:
 +
 
 +
<bash>
 +
# create a temporary working directory
 +
mkdir -p $HOME/OpenFOAM/linux/tmp
 +
cd $HOME/OpenFOAM/linux/tmp
 +
 
 +
# download using standard ftp
 +
ftp ftp.gnu.org
 +
cd /gnu/gcc/gcc-4.1.0/
 +
bin
 +
get gcc-4.1.0.tar.bz2
 +
exit
 +
</bash>
 +
 
 +
If you decide or need to install a local version of binutils, you can get it from the GNU Web site or GNU ftp site as well:
 +
 
 +
<bash>
 +
cd $HOME/OpenFOAM/linux/tmp
 +
 
 +
# download the latest version of binutils using standard ftp
 +
ftp ftp.gnu.org
 +
cd /gnu/binutils
 +
bin
 +
get binutils-2.16.1.tar.bz2
 +
exit
 +
</bash>
 +
 
 +
===Configuration, compilation and full installation of GNU binutils (optional)===
 +
This subsection describes the full installation of GNU binutils under $HOME/OpenFOAM/linux. You should only do a full install of GNU binutils if you are experiencing or suspecting compatibility problems between gcc 4.1.0 and your system's default linker "/usr/bin/ld".  
 +
 
 +
You should also follow these installation steps prior to recompiling gcc 4.1.0; that way, the recompilation process of gcc will have access to the latest version of the linker "ld".
 +
 +
<bash>
 +
 
 +
# extraction
 +
cd $HOME/OpenFOAM/linux/tmp
 +
bzcat binutils-2.16.1.tar.bz2 | tar -xvf -
 +
 
 +
cd binutils-2.16.1
 +
 
 +
# configuration for x86 platforms
 +
./configure --prefix=$HOME/OpenFOAM/linux/binutils-2.16.1
 +
 
 +
# configuration for x86_64 platforms
 +
./configure --prefix=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1
 +
 
 +
# compilation
 +
make
 +
 
 +
#installation
 +
make install
 +
 
 +
# installation for the binutils header files for x86 platforms
 +
# for more information, see the section about the partial installation of binutils
 +
make target_header_dir=$HOME/OpenFOAM/linux/binutils-2.16.1/include -C libiberty install_to_libdir
 +
 
 +
# installation for the binutils header files for x86_64 platforms
 +
make target_header_dir=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/include -C libiberty install_to_libdir
 +
 
 +
#cleanup
 +
cd ..
 +
rm -rf binutils-2.16.1
 +
 
 +
# Update your path (for bash)
 +
export PATH=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/bin:$PATH
 +
 
 +
# Update your path (for csh)
 +
setenv PATH $HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/bin:$PATH
 +
 
 +
# Final validation
 +
# Should point to $HOME/OpenFOAM/linux/binutils-2.16.1/bin, or the AMD64 variant
 +
which ld
 +
 
 +
</bash>
 +
 
 +
 
 +
Finally, make sure the configuration steps described further down in the section documenting the <i>partial</i> installation of binutils are followed as well. Those steps are important in order to compile the new, automatic stack trace on code abort capabilities of OpenFOAM 1.3.
 +
 
 +
===Configuration, compilation and installation of GNU gcc===
 +
<bash>
 +
# extraction
 +
cd $HOME/OpenFOAM/linux/tmp
 +
 
 +
bzcat gcc-4.1.0.tar.bz2 | tar -xvf -
 +
mkdir gcc-4.1.0/gcc-4.1.0-obj
 +
cd gcc-4.1.0/gcc-4.1.0-obj
 +
 
 +
# configuration for x86 platforms
 +
../configure --prefix=$HOME/OpenFOAM/linux/gcc-4.1.0 --exec-prefix=$HOME/OpenFOAM/linux/gcc-4.1.0 \
 +
    --enable-languages=c,c++ --enable-shared --disable-multilib
 +
 
 +
# configuration for x86_64 platforms
 +
../configure --prefix=$HOME/OpenFOAM/linuxAMD64/gcc-4.1.0 --exec-prefix=$HOME/OpenFOAM/linuxAMD64/gcc-4.1.0 \
 +
    --enable-languages=c,c++ --enable-shared --disable-multilib
 +
 
 +
# compilation
 +
make bootstrap
 +
 
 +
#installation
 +
make install
 +
 
 +
#cleanup
 +
cd ../..
 +
rm -rf gcc-4.1.0
 +
</bash>
 +
----
 +
 
 +
== Installing the Java JSDK ==
 +
Nothing special to do here; simply download the default package from OpenCFD or SourceForge using your browser or a tool like ''wget'', and install it under the right directory:
 +
<bash>
 +
# download from a nearby SourceForge mirror
 +
cd $HOME/OpenFOAM/linux/
 +
wget http://umn.dl.sourceforge.net/sourceforge/foam/j2sdk1.4.2_05.linux.tgz
 +
 
 +
# extraction and installation
 +
tar -zxvf j2sdk1.4.2_05.linux.tgz
 +
 
 +
# cleanup
 +
rm j2sdk1.4.2_05.linux.tgz
 +
</bash>
 +
----
 +
 
 +
== Installing the OpenFOAM source code ==
 +
----
 +
===Downloading and extracting the source code===
 +
It is now time to install the OpenFOAM source code, not because we are ready to compile it right away, but simply because we need to properly set some environment variables, and the OpenFOAM initialization scripts are exactly what is needed for such a job.
 +
 
 +
<bash>
 +
# download the OpenFOAM source code from OpenCFD or the closest SourceForge mirror
 +
cd $HOME/OpenFOAM
 +
wget http://umn.dl.sourceforge.net/sourceforge/foam/OpenFOAM-1.3.General.gtgz
 +
 
 +
# extract the source code
 +
tar -zxvf OpenFOAM-1.3.General.gtgz
 +
</bash>
 +
 
 +
===Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc (optional)===
 +
Next, we need to adjust some environment variables to reflect our compiler version if the version of gcc installed is newer than the default version available from OpenCFD.
 +
 
 +
This is specified in the file
 +
 
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/.bashrc''
 +
or<br>
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/.cshrc''
 +
 
 +
For example, for the file ''$HOME/OpenFOAM/OpenFOAM-1.3/.bashrc'', we need to adjust the following line
 +
<bash>
 +
# replace gcc-4.1.0 by gcc-4.xx.yy for the version 4.xx.yy of gcc
 +
export WM_COMPILER_DIR=$WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH
 +
</bash>
 +
 
 +
For the file ''$HOME/OpenFOAM/OpenFOAM-1.3/.cshrc'', we need to adjust the following line
 +
<bash>
 +
# replace gcc-4.1.0 by gcc-4.xx.yy for the version 4.xx.yy of gcc
 +
setenv WM_COMPILER_DIR $WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH
 +
</bash>
 +
 
 +
===Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc (optional)===
 +
Next, we need to specify if we want to compile and use OpenFOAM on a x86 or x86_64 system, or if we want our root directory for OpenFOAM under a different directory than $HOME/OpenFOAM.
 +
 
 +
For this, we need to modify the file
 +
 
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc''
 +
or<br>
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc''
 +
 
 +
For example, for the file ''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc'', we may want to adjust or add the following lines
 +
<bash>
 +
# uncomment the following line on a AMD64 workstation
 +
#export WM_64=1
 +
 
 +
# uncomment the following line if your OpenFOAM root directory in under /opt
 +
#export WM_PROJECT_INST_DIR=/opt/$WM_PROJECT
 +
</bash>
 +
 
 +
For the file ''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc'', we may want to adjust or add the following lines
 +
<bash>
 +
# uncomment the following line on a AMD64 workstation
 +
#setenv WM_64 1
 +
 
 +
# uncomment the following line if your OpenFOAM root directory in under /opt
 +
#setenv WM_PROJECT_INST_DIR /opt/$WM_PROJECT
 +
</bash>
 +
 
 +
==== Modifications for a Single-Precision version of OpenFOAM ====
 +
 
 +
'''This works only for versions after 1.3'''
 +
 
 +
If you want a single-precision version of OpenFOAM (instead of the usual double-precision) change the lines in ''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc'' from
 +
<bash>
 +
# export WM_PRECISION_OPTION=SP
 +
export WM_PRECISION_OPTION=DP
 +
</bash>
 +
to
 +
<bash>
 +
export WM_PRECISION_OPTION=SP
 +
# export WM_PRECISION_OPTION=DP
 +
</bash>
 +
 
 +
==== Modifications for a debug version of OpenFOAM ====
 +
 
 +
If you want a debug version of OpenFOAM (which is slower but does range checking on containers etc) change the lines in ''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc'' from
 +
<bash>
 +
export WM_COMPILE_OPTION=Opt
 +
# export WM_COMPILE_OPTION=Debug
 +
# export WM_COMPILE_OPTION=Prof
 +
</bash>
 +
to
 +
<bash>
 +
# export WM_COMPILE_OPTION=Opt
 +
export WM_COMPILE_OPTION=Debug
 +
# export WM_COMPILE_OPTION=Prof
 +
</bash>
 +
(if you want a profiling-enabled version of OpenFOAM uncomment the third line)
 +
 
 +
===Initializing the OpenFOAM environment variables===
 +
We can now initialize all the required environment variables and aliases for properly compiling and running OpenFOAM.
 +
 
 +
If your current shell is ''bash''
 +
<bash>
 +
. $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc
 +
</bash>
 +
 
 +
If your current shell is ''csh'' or a csh look-alike like ''tcsh''
 +
<bash>
 +
source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc
 +
</bash>
 +
 
 +
----
 +
 
 +
== Compiling and installing cmake ==
 +
----
 +
[http://www.cmake.org/HTML/Index.html Cmake] is a cross-platform, open-source make system.
 +
 
 +
You need ''cmake'' for compiling [http://www.paraview.org/HTML/Index.html ParaView].
 +
 
 +
Even though ''cmake'' is not supplied by OpenCFD as a companion tool for OpenFOAM, I find it useful to install ''cmake'' under the $HOME/OpenFOAM/linux directory, close to ParaView.
 +
 
 +
Here is the procedure for downloading, compiling and installing ''cmake'':
 +
<bash>
 +
# download the latest cmake source package from Kitware's ftp site:
 +
mkdir $HOME/OpenFOAM/linux/tmp
 +
cd $HOME/OpenFOAM/linux/tmp
 +
 
 +
ftp public.kitware.com
 +
cd pub/cmake/v2.3
 +
bin
 +
get cmake-2.3.4-20060317.tar.gz
 +
 
 +
# extract the source code
 +
tar -zxvf ./cmake-2.3.4-20060317.tar.gz
 +
 
 +
# configure cmake
 +
cd cmake-2.3.4-20060317
 +
./configure --prefix=$HOME/OpenFOAM/linux/cmake-2.3.4
 +
make
 +
make install
 +
 
 +
# cleanup
 +
cd ../..
 +
rm -rf ./tmp
 +
</bash>
 +
 
 +
Next, you need to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc in order to add ''cmake'' to your $PATH environment variable. I usually insert those modifications at the end of the files.
 +
 
 +
Here is how to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc.
 +
<bash>
 +
#
 +
# cmake
 +
#
 +
# Make sure cmake is accessible
 +
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 +
export CMAKE=cmake-2.3.4
 +
export CMAKE_ARCH_PATH=$WM_PROJECT_INST_DIR/$WM_ARCH/$CMAKE
 +
AddPath $CMAKE_ARCH_PATH/bin
 +
</bash>
 +
 
 +
Here is how to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc.
 +
<bash>
 +
#
 +
# cmake
 +
#
 +
# Make sure cmake is accessible
 +
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 +
setenv CMAKE cmake-2.3.4
 +
setenv CMAKE_ARCH_PATH $WM_PROJECT_INST_DIR/$WM_ARCH/$CMAKE
 +
AddPath $CMAKE_ARCH_PATH/bin
 +
</bash>
 +
 
 +
And of course, don't forget to reinitialize your environment:
 +
 
 +
If your current shell is ''bash''
 +
<bash>
 +
. $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc
 +
</bash>
 +
 
 +
If your current shell is ''csh'' or a csh look-alike like ''tcsh''
 +
<bash>
 +
source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc
 +
</bash>
 +
 
 +
== Compiling and installing ParaView ==
 +
----
 +
ParaView is probably the trickiest package to recompile. Here is how.
 +
 
 +
=== Selecting the right version of ParaView ===
 +
 
 +
You first need to download the source code from Kitware's Web site.
 +
 
 +
But before doing so, please note the version number of the binary ParaView package provided by OpenCFD. You need to download the ParaView source package with the same version number, or very close to it if you like living on the bleeding edge. Otherwise, if your version is too different, you risk not being able to link in the modules needed for paraFoam. 
 +
 
 +
For example, for OpenFOAM 1.3, OpenCFD ParaView binary package version is paraview-2.4.2; you should then download the same version for the source package from Kitware's Web site.
 +
 
 +
Note however that ParaView latest stable version is 2.4.3; since the version number is very close to 2.4.2, I have chosen to use this version instead.   
 +
 
 +
=== Downloading and installing ParaView source code ===
 +
<bash>
 +
cd $HOME/OpenFOAM/linux
 +
wget http://www.paraview.org/files/v2.4/paraview-2.4.3.tar.gz
 +
 
 +
tar -zxvf ./paraview-2.4.3.tar.gz
 +
mkdir -p paraview-2.4.3/lib/paraview-2.4
 +
</bash>
 +
 
 +
 
 +
If you decide to install a newer version of ParaView, you need to adjust the files <br>
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/bashrc''
 +
<br>
 +
and
 +
<br>
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/cshrc''
 +
 
 +
For ''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/bashrc'', you need to modify this line
 +
<bash>
 +
#export ParaView_VERSION=2.4.2
 +
export ParaView_VERSION=2.4.3
 +
</bash>
 +
 
 +
For ''$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/cshrc'', you need to modify this line
 +
<bash>
 +
#setenv ParaView_VERSION 2.4.2
 +
setenv ParaView_VERSION 2.4.3
 +
</bash>
 +
 
 +
=== Patching Tcl/TK (optional) ===
 +
 
 +
{{VersionInfo}}{{Version1.3}}
 +
 
 +
 
 +
Next, you may need to correct a bug that is not yet corrected in the companion Tcl/Tk source package that comes with ParaView.
 +
 
 +
That bug is documented on the Tcl/Tk mailing list, and is only affecting systems running bash version 3.1 or later. I have stumbled on that bug when compiling OpenFOAM 1.3 under Knoppix 5.0.
 +
 
 +
For more information, please check out the following [http://sourceforge.net/mailarchive/message.php?msg_id=14641301 link]  
 +
 
 +
The correction is rather simple, there are two typos in the files ''paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix/tcl.m4'' and ''paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix/tcl.m4''.
 +
 
 +
Here is the first correction (the old code is commented out):
 +
<bash>
 +
# starting on line 776 for both files:
 +
 
 +
# Bug fix: Remove the extra single quote close to .relid
 +
#     if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 +
# system=MP-RAS-`awk '{print $3}' /etc/.relid'`
 +
#     fi
 +
 
 +
    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 +
system=MP-RAS-`awk '{print $3}' /etc/.relid`
 +
    fi
 +
 
 +
</bash>
 +
 
 +
The second correction is identical, only the line numbers are different:
 +
<bash>
 +
# starting on line 2107 for the file paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix/tcl.m4:
 +
# starting on line 2117 for the file paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix/tcl.m4:
 +
 
 +
# Bug fix: Remove the extra single quote close to .relid
 +
#     if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 +
# system=MP-RAS-`awk '{print $3}' /etc/.relid'`
 +
#     fi
 +
 
 +
    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 +
system=MP-RAS-`awk '{print $3}' /etc/.relid`
 +
    fi
 +
 
 +
</bash>
 +
 
 +
 
 +
Next, you need to regenerate the Automake files. The command ''autoreconf'' is part of the Automake package. You need this package for recompiling ParaView.
 +
 
 +
<bash>
 +
cd $HOME/OpenFOAM/linux/paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix
 +
autoreconf
 +
 
 +
cd $HOME/OpenFOAM/linux/paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix
 +
 
 +
#This invocation of autoreconf will end with some error message about AC_LIBOBJ.
 +
#You can ignore this error message.
 +
autoreconf
 +
</bash>
 +
 
 +
=== Modification to the file CMakeLists.txt ===
 +
Before you do this, make sure you'v installed the develep package of tcl, tk, xorg/xfree.
 +
Next, we need to modify the file $HOME/OpenFOAM/linux/paraview-2.4.3/CMakeLists.txt in order to force the installation of the ParaView header files when we will invoke the command ''make install'' a little bit later.
 +
 
 +
With version 1.4 of OpenFOAM and version 2.6.1 of Paraview, the file that we need to modify lies now in
 +
$HOME/OpenFOAM/linux/paraview-2.6.1/CMake/ParaViewCommon.cmake. The modifications are the same.
 +
 
 +
Here are the lines we need to modify; watch for the comments starting with ''OpenFOAM:'':
 +
<bash>
 +
# Setup install directories.
 +
IF(NOT PV_INSTALL_BIN_DIR)
 +
  SET(PV_INSTALL_BIN_DIR ${PV_INSTALL_ROOT}/bin)
 +
ENDIF(NOT PV_INSTALL_BIN_DIR)
 +
IF(NOT PV_INSTALL_INCLUDE_DIR)
 +
#
 +
# OpenFOAM: we need to modify this line
 +
#  SET(PV_INSTALL_INCLUDE_DIR ${PV_INSTALL_ROOT}/include/paraview-${PARAVIEW_VERSION})
 +
  SET(PV_INSTALL_INCLUDE_DIR ${PV_INSTALL_ROOT}/include)
 +
#
 +
# OpenFOAM: end of modification
 +
#
 +
ENDIF(NOT PV_INSTALL_INCLUDE_DIR)
 +
IF(NOT PV_INSTALL_LIB_DIR)
 +
  SET(PV_INSTALL_LIB_DIR ${PV_INSTALL_ROOT}/lib/paraview-${PARAVIEW_VERSION})
 +
ENDIF(NOT PV_INSTALL_LIB_DIR)
 +
IF(NOT PV_INSTALL_DATA_DIR)
 +
  SET(PV_INSTALL_DATA_DIR ${PV_INSTALL_ROOT}/share/paraview-${PARAVIEW_VERSION})
 +
ENDIF(NOT PV_INSTALL_DATA_DIR)
 +
 
 +
# Install no development files by default, but allow the user to get
 +
# them installed by setting PV_INSTALL_DEVELOPMENT to true. Disable
 +
# the option altogether if PV_INSTALL_NO_DEVELOPMENT is already set to
 +
# true.
 +
#
 +
# OpenFOAM: we need to add this line.
 +
#
 +
SET(PV_INSTALL_DEVELOPMENT 1)
 +
#
 +
# OpenFOAM: end of modification
 +
#
 +
IF(NOT PV_INSTALL_NO_DEVELOPMENT)
 +
  # Leave this option out until we write code to install paraview headers
 +
  # other than VTK.
 +
  #OPTION(PV_INSTALL_DEVELOPMENT "Install ParaView plugin development files."
 +
  #  OFF)
 +
  #MARK_AS_ADVANCED(PV_INSTALL_DEVELOPMENT)
 +
</bash>
 +
 
 +
=== Initial configuration using ''cmake'' ===
 +
Next, we use the default invocation of ''cmake'' to get the initial configuration of Paraview
 +
<bash>
 +
cd $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4
 +
cmake ../..
 +
</bash>
 +
 
 +
=== Adjusting the configuration ===
 +
Next, we need to adjust the initial ParaView configuration in order to get the proper settings for compiling with OpenFOAM.
 +
 
 +
For this, you need to edit the file ''$HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4/CMakeCache.txt'' using your favourite text editor. That file was automagically created by the prior invocation of ''cmake''.
 +
 
 +
Here are the lines and configuration variables that need to be modified. The default values previously generated by ''cmake'' are commented out.
 +
<bash>
 +
# BUILD_SHARED_LIBS:BOOL=OFF
 +
BUILD_SHARED_LIBS:BOOL=ON
 +
 
 +
# BUILD_TESTING:BOOL=ON
 +
BUILD_TESTING:BOOL=OFF
 +
 
 +
# CMAKE_INSTALL_PREFIX:PATH=/usr/local
 +
CMAKE_INSTALL_PREFIX:PATH=/home/whatever_your_login_is/OpenFOAM/linux/paraview-2.4.3
 +
 
 +
</bash>
 +
 
 +
For compiling ParaView for x86_64, we need to modify some other configuration variables. Here are the variables I had to modify for SuSE 9.1 x86_64. Adjust accordingly to your own specific 64-bit Operating System.
 +
 
 +
<bash>
 +
BUILD_SHARED_LIBS: ON
 +
CMAKE_BUILD_TYPE :
 +
CMAKE_CXX_COMPILER : /home/your_login_name/OpenFOAM/linuxAMD64/gcc-4.1.0/bin/g++
 +
CMAKE_CXX_FLAGS : -m64
 +
CMAKE_C_COMPILER : /home/your_login_name/OpenFOAM/linuxAMD64/gcc-4.1.0/bin/gcc
 +
CMAKE_C_FLAGS : -m64
 +
CMAKE_EXE_LINKER_FLAGS : -m64
 +
CMAKE_EXE_LINKER_FLAGS_RELEASE : -m64
 +
CCMAKE_MODULE_LINKER_FLAGS : -m64
 +
CMAKE_INSTALL_PREFIX : /home/your_login_name/OpenFOAM/linuxAMD64/paraview-2.4.3
 +
CMAKE_MODULE_LINKER_FLAGS : -m64
 +
CMAKE_MODULE_LINKER_FLAGS_RELEASE : -m64
 +
CMAKE_SHARED_LINKER_FLAGS : -m64
 +
CMAKE_SHARED_LINKER_FLAGS_RELEASE : -m64
 +
OPENGL_gl_LIBRARY : /usr/lib64/libGL.so
 +
OPENGL_glu_LIBRARY: /usr/X11R6/lib64/libGLU.a
 +
X11_X11_LIB : /usr/X11R6/lib64/libX11.so
 +
X11_Xext_LIB : /usr/X11R6/lib64/libXext.so
 +
CMAKE_X_LIBS : /usr/X11R6/lib64/libX11.so;/usr/X11R6/lib64/libXext.so;/usr/X11R6/lib64/libX11.so;/usr/X11R6/lib64/libXext.so
 +
X11_Xext_LIB: /usr/X11R6/lib64/libXext.so
 +
</bash>
 +
 
 +
I used OpenSUSE 10.1 x86_64 with Tcl/Tk-8.4.5, I found that if you want to compile paraview-2.4.3, you need to add the following parameters to CMakeCache.txt
 +
 
 +
<bash>
 +
TCL_LIBRARY:FILEPATH=/usr/lib64/tcl8.4.so
 +
TK_LIBRARY:FILEPATH=/usr/lib64/tk8.4.so
 +
</bash>
 +
 
 +
''Note: my recompiled 64 bit version of paraView 2.4.3 is crashing under SuSE 9.1. I had no such problem with paraview 2.2.1 (OpenFOAM 1.2). As soon as I find the source of the problem, I will document it here...''
 +
 
 +
=== Compiling and installing paraview ===
 +
At last, the moment of truth :)
 +
 
 +
<bash>
 +
cd $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4
 +
make
 +
make install
 +
</bash>
 +
 
 +
== Modifications for the compilation of PVFoamReader ==
 +
----
 +
{{VersionInfo}}{{Version1.3}}
 +
 
 +
In order to compile the module ''$HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader'',
 +
 
 +
we need to modify the file
 +
''$HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt''
 +
 
 +
for two reasons:
 +
# The position of the LINK_DIRECTORIES instruction in the file is important, and using a recent version of cmake (cmake-2.3.4-20060317), the linker search path specified in the Makefile will not be written correctly without the modifications.
 +
# You must include the directory $FOAM_USER_LIBBIN in the linker search path if you want the module ''PVFoamReader'' (and ''paraFoam'') to use your local ''${FOAM_USER_LIBBIN}/libfoamUser.so'' library (for your user-defined boundary condition code, etc,).
 +
 
 +
Otherwise,
 +
# Your library ''libPVFoamReader.so'' will fail to link against ''libOpenFOAM.so'' because it cannot find it.
 +
# ''paraFoam'' will fail to load your user-defined code because the library ''libPVFoamReader.so'' will be link against the default library ''${FOAM_LIBBIN}/libfoamUser.so'' instead of your local version ''${FOAM_USER_LIBBIN}/libfoamUser.so''.
 +
 
 +
Here is the modifications needed for the file ''$HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt''
 +
.
 +
 
 +
We only show a part of that file; look for the instructions preceded by a comment mentionning ''<b>cmake version 2.3.4-20060317</b>''
 +
 
 +
<bash>
 +
# Create the configuration header.
 +
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReaderConfigure.h.in
 +
              ${PROJECT_BINARY_DIR}/vtk${PROJECT_NAME}Configure.h
 +
              @ONLY IMMEDIATE)
 +
 
 +
# Create vtk client/server wrappers for the classes.
 +
VTK_WRAP_ClientServer(${PROJECT_NAME} PVFoamReaderCS_SRCS "${PVFoamReader_SRCS}")
 +
 
 +
# Must be defined before ADD_LIBRARY  for cmake version 2.3.4-20060317
 +
LINK_DIRECTORIES($ENV{FOAM_USER_LIBBIN})
 +
LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
 +
 
 +
# Build the package as a plugin for ParaView.
 +
ADD_LIBRARY(${PROJECT_NAME} MODULE ${PVFoamReader_SRCS} ${PVFoamReaderCS_SRCS})
 +
LINK_DIRECTORIES($ENV{ParaView_INST_DIR}/lib)
 +
TARGET_LINK_LIBRARIES(${PROJECT_NAME} vtkClientServer)
 +
FOREACH(c ${PVFoamReader_LIBS})
 +
  TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${c}CS)
 +
ENDFOREACH(c)
 +
 
 +
# Place the package configuration file into the build tree.
 +
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.xml.in
 +
              ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.xml @ONLY IMMEDIATE)
 +
 
 +
# Place the package configuration file into the build tree.
 +
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.pvsm.in
 +
              ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.pvsm @ONLY IMMEDIATE)
 +
 
 +
# Must be commented out for cmake version 2.3.4-20060317
 +
#LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
 +
TARGET_LINK_LIBRARIES(${PROJECT_NAME} OpenFOAM finiteVolume vtkFoam)
 +
 
 +
</bash>
 +
 
 +
 
 +
Once this modification made, the normal OpenFOAM 1.3 compilation scripts will take care of the rest.
 +
 
 +
 
 +
== Partial installation of GNU binutils (optional) ==
 +
----
 +
 
 +
With OpenFOAM 1.3, OpenCFD introduces a new, automatic stack trace on code abort. This new capability is based on the library ''libiberty'' from the package ''GNU binutils''. That library comes standard with most Linux-based OS. However, in order to recompile OpenFOAM, you also need to have a valid header file called ''/usr/include/demangle.h'', also provided by ''GNU binutils''.
 +
 
 +
That header file is present on SuSE OS, but not on RedHat/Fedora nor on Knoppix/Debian systems.
 +
 
 +
Looking at the scripts designed to construct the installation RPM of the binary package ''GNU binutils'', we can see that SuSE took an extra installation step in order to install under the directory ''/usr/include'' a few more header files from the ''GNU binutils'' package, including the ''demangle.h'' file.
 +
 
 +
This section gives a quick description on how to install the missing header files locally under the directory $HOME/OpenFOAM/linux.  
 +
 
 +
You first need to identify the version of ''GNU binutils'' installed on your system. For instance, on a RedHat WS 4, you can get that information  like this:  
 +
<bash>
 +
% rpm -qa | grep -i binutils
 +
binutils-2.15.92.0.2-15
 +
</bash>
 +
 
 +
Given that basic information, here the installation procedure:
 +
<bash>
 +
# First, create a temporary directory for extracting the GNU binutils source code
 +
mkdir -p $HOME/OpenFOAM/linux/binutils-2.15/src
 +
cd $HOME/OpenFOAM/linux/binutils-2.15/src
 +
 
 +
# Next, download the proper version on the GNU binutils source code
 +
 
 +
# Download from the Web site
 +
wget http://ftp.gnu.org/gnu/binutils/binutils-2.15.tar.gz
 +
tar -zxvf binutils-2.15.tar.gz
 +
cd binutils-2.15
 +
 
 +
# Or Download using CVS
 +
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
 +
  {enter "anoncvs" as the password}
 +
 
 +
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co -r binutils-2_15 binutils
 +
cd src
 +
 
 +
# Next, proceed with the configuration of the package
 +
./configure --prefix=$HOME/OpenFOAM/linux/binutils-2.15
 +
 
 +
# Next, execute a partial installation in order to get the missing header files
 +
make
 +
make target_header_dir=$HOME/OpenFOAM/linux/binutils-2.15/include -C libiberty install_to_libdir
 +
 
 +
# Finally, let's clean up
 +
rm -rf $HOME/OpenFOAM/linux/binutils-2.15/src
 +
</bash>
 +
 
 +
=== Configuring OpenFOAM for using binutils demangle.h ===
 +
<b>
 +
NB: If you already did a full installation of binutils, please make sure all the steps describe in that subsection are realized as well, but for binutils-2.16.1.
 +
</b>
 +
 
 +
We now have the needed header files installed locally under the directory $HOME/OpenFOAM/linux/binutils-2.15/include
 +
 
 +
We must now tell OpenFOAM where to find these new header files:
 +
 
 +
First, we create the new environment variable _BINUTILS_FOR_DEMANGLE_H.  
 +
 
 +
<font color=red>Warning: </font>
 +
Please make sure not to redefine the environment variable called '''BINUTILS_ROOT'''. This environment variable is a reserved variable for the compilation tools like the first stage compiler ''cc1'' from the gcc compiler. This redefinition will break the linker ''ld'' as well. An obvious symptom of such a redefinition of this variable will be the appearance of the error message
 +
<bash>
 +
/usr/bin/ld: crtbegin.o: No such file: No such file or directory
 +
</bash>
 +
when trying to link a simple executable program. 
 +
 
 +
 
 +
We will define this new variable _BINUTILS_FOR_DEMANGLE_H in the files ''$HOME/OpenFOAM/OpenFOAM-1.3/.bashrc'' and/or ''$HOME/OpenFOAM/OpenFOAM-1.3/.cshrc''.
 +
 
 +
Here is how to modify ''$HOME/OpenFOAM/OpenFOAM-1.3/.bashrc''
 +
<bash>
 +
# Binutils header files
 +
# Under Redhat, some header files like demangle.h are missing
 +
#
 +
# For now, we are using a local and partial installation of binutils in order
 +
# to provides only the missing header files.
 +
# The libraries are already provided by default by the OS (RedHat, SuSE, Knoppix, etc).
 +
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 +
#export _BINUTILS_FOR_DEMANGLE_H=/usr
 +
export _BINUTILS_FOR_DEMANGLE_H=$WM_PROJECT_INST_DIR/$WM_ARCH/binutils-2.15
 +
 
 +
# If you installed binutils-2.16.1 instead:
 +
export _BINUTILS_FOR_DEMANGLE_H=$WM_PROJECT_INST_DIR/$WM_ARCH/binutils-2.16.1
 +
 
 +
# If you did a full install for binutils, why not use the binary tools as well...
 +
AddPath $_BINUTILS_FOR_DEMANGLE_H/bin
 +
 
 +
</bash>
 +
 
 +
Then, we modify the file ''$HOME/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/Make/options'' for the compilation of the library libOpenFOAM:
 +
<bash>
 +
EXE_INC = \
 +
    -DWM_PROJECT_VERSION='"'$(WM_PROJECT_VERSION)'"' \
 +
    -I$(_BINUTILS_FOR_DEMANGLE_H)/include/ \
 +
    -I$(LIB_SRC)/zlib-1.2.1
 +
 
 +
LIB_LIBS = -L$(FOAM_LIBBIN)/dummy -lPstream -lfoamUser -lz
 +
</bash>
 +
 
 +
The library libOpenFOAM, and the rest of OpenFOAM 1.3 should now compile without a glitch with the new, automatic stack trace on code abort capabilities up and ready.
 +
 
 +
== Miscellaneous adjustments (optional) ==
 +
----
 +
Some OpenFOAM compilation script files either use ''gmake'', or ''make''.
 +
 
 +
Under Knoppix 5.0, ''gmake'' is absent, but ''make'' does exist.
 +
 
 +
To correct this problem, we simply need to create a symbolic link under ''/usr/local/bin''.
 +
 
 +
<bash>
 +
# Become root
 +
su
 +
 
 +
#Create the symlink
 +
ln -s `which make` /usr/local/bin/gmake
 +
</bash>
 +
 
 +
Of course, the directory ''/usr/local/bin'' needs to be in your path, so take the time to verify and to adjust your path if necessary.
 +
 
 +
<bash>
 +
% echo $PATH
 +
 
 +
# if /usr/local/bin/ is not in your PATH environment variable, simply do: (for example under bash)
 +
 
 +
% export PATH=/usr/local/bin:$PATH
 +
 
 +
# and/or adjust your $HOME/.bashrc accordingly.
 +
 
 +
</bash>
 +
 
 +
== Compiling OpenFOAM ==
 +
Now the easy stuff...
 +
 
 +
<bash>
 +
cd $HOME/OpenFOAM/OpenFOAM-1.3
 +
./Allwmake
 +
</bash>
 +
 
 +
Cheers!
 +
 
 +
== Building OpenFOAM on OpenSolaris x86_32 2/07 ==
 +
 
 +
Configure GCC as follows:
 +
 
 +
<bash>
 +
../configure --prefix=$HOME/OpenFOAM/linux/gcc-4.2.0 --exec-prefix=$HOME/OpenFOAM/linux/gcc-4.2.0 \
 +
  --with-ld=/usr/ccs/bin/ld --without-gnu-ld \
 +
  --enable-languages=c,c++ --enable-shared --disable-multilib
 +
</bash>
 +
 
 +
After that compile and install as described above.
 +
 
 +
You also need to download from http://flex.sourceforge.net/ and install the newest version of <code>flex</code> to use it instead of default for OpenSolaris v.2.5.4. 
 +
After installation add to local <code>.bashrc</code> the followings:
 +
 
 +
<bash>
 +
export PATH=PATH_TO_YOUR_NEW_FLEX_BIN:$PATH
 +
 
 +
alias flex++='flex -+'
 +
</bash>
 +
 
 +
Now configure and compile OpenFOAM as described above.
 +
 
 +
Due to the fact that command <code>find</code> on OpenSolaris does not support the option <code>-maxdepth</code>, the building the applications in <code><font color="blue">$WM_PROJECT_DIR</font>/applications</code> will fail.
 +
 
 +
To complete the building, create and execute the following script:
 +
 
 +
<perl>
 +
#!/usr/bin/perl
 +
 
 +
use File::Find;
 +
 
 +
chdir "$ENV{'WM_PROJECT_DIR'}/applications";
 +
 
 +
find(\&MakeIt, "./");
 +
 
 +
sub MakeIt
 +
{
 +
  -f and return;
 +
  if (-d "$_/Make") {
 +
      print "Building $File::Find::name ...\n";
 +
      $File::Find::prune = 1;
 +
      system "wmake $_";
 +
  }
 +
}
 +
</perl>
 +
 
 +
----
 +
 
 +
{{VersionInfo}}  {{Version1.3}} {{Version1.4}}
 +
 
 +
--[[User:MBeaudoin|MB]] 02:44, 13 Apr 2007 (CEST)

Revision as of 11:48, 2 July 2007

This document describes how to compile OpenFOAM on Unix from the source code provided by the nice folks at OpenCFD.

This document also describes how to download and compile some of the tools or packages needed for compiling OpenFOAM.

The process described in this document is based on the OpenFOAM README file, Section "4. Building from Sources (Optional)", but with more details.

The information presented here has been tested and validated by the author while compiling OpenFOAM 1.3, under SuSE 9.1 x86_64, RedHat/Centos 4 and Debian/Knoppix 5.0, and more recently with OpenFOAM 1.4 on the same RedHat system. Depending on your Operating System and/or your OS version, your milleage may vary...

Furthermore, the version numbers for the different packages involved in the recompilation of OpenFOAM are different for OpenFOAM version 1.3 and 1.4; please use the packages source code version associated with the binary package proposed by OpenCFD when upgrading and compiling a newer version of OpenFOAM. The current text is based on the packages version recommended for OpenFOAM 1.3.

This is work in progress; please don't hesitate to complement the information presented here.


1 Preamble

1.1 Basic stuff

This document describes the compilation and installation of OpenFOAM 1.3 in the default installation directory $HOME/OpenFOAM and $HOME/OpenFOAM/linux, as suggested in http://www.openfoam.org/download.html.


If not already available, you first need to create these directories:


For x86:

 
mkdir -p $HOME/OpenFOAM/linux


For x86_64:

 
mkdir -p $HOME/OpenFOAM/linuxAMD64


For the rest of this document, only the x86 installation procedure will be presented in detail. The specific information for the installation on x86_64 platforms will be presented only when significantly different from the x86 installation procedure.

1.2 Not so basic (but very useful) stuff

In the process of recompiling and installing OpenFOAM 1.3, you will have to modify some of the files provided by OpenCFD.

Before doing so, I highly recommend archiving the original version of the file under RCS first.

RCS stands for Revision Control System. It's a revision control system that is the ancestor of the well known CVS and Subversion revision systems. RCS comes standard with probably almost every modern flavors of Unix.

The nice thing about RCS is its simplicity, the fact that it stores the file revision archive locally, and most importantly, it's a system that will help you memorize every revisions of any given ASCII file, so you will always be able to return any modified file back to a known and valid version.

So, take the time to RTFM about RCS (eg: man rcs). It might save you some headaches later on.

1.3 Finally, a little advice

As a rule of thumb, do not install OpenFOAM as the user root on your workstation. Instead, use your own username, or simply create a new user openfoam. The super-user root should always be reserved for doing system administration tasks.


2 Compiling and installing GNU Gcc

2.1 The motivation for compiling GNU gcc

Compiling the GNU gcc/g++ compiler can be a daunting task for the non-initiated. Usually, the installation of the pre-compiled gcc/g++ binary package offered by OpenCFD with any new release of OpenFOAM should cover the need of most OpenFOAM developers.

As mentioned on the mailing list by Hrvoje Jasak, it is usually recommended to keep your OpenFOAM gcc/g++ compiler very up-to-date because a new gcc/g++ release usually means fewer compiler bugs and better performance; OpenFOAM will usually benefit from the newer compiler. So this is one very good reason to visit the GNU gcc compiler web site regularly, and recompile gcc/g++ from the source code.

However, another good reason for recompiling gcc/g++ is related to some compatibilities issues that can arise when deploying the OpenCFD pre-compiled gcc/g++ package on your platform.

One issue that I have encountered on a SuSE 9.1 platform with the pre-compiled gcc/g++ binary package was related to the interaction of the new g++ compiler and the system GNU linker ld. Both the gcc/g++ compiler and the ld linker are necessary when compiling applications on Unix. And of course, they both need to be compatible with one another.

To make a long story short, when configuring gcc/g++, the configure script will automagically explore the availability of the numerous runtime options of your system GNU linker ld, and compile gcc/g++ accordingly. On recent operating systems like SuSE 10, the version of system linker ld is newer, hence new runtime ld options are available, and, on that platform, gcc/g++ will be compiled to take advantage of them.

However, when the same pre-compiled gcc/g++ compiler is deployed with an older OS, your default system GNU linker ld will be older too, and there is a definite chance that the compatibility between gcc/g++ and ld will be broken. I know it did when I installed the pre-compiled gcc/g++ package from OpenFOAM 1.2 on my SuSE 9.1 workstation.

Some users also experienced the same kind of compatibility issues between gcc 4.1.0 and /usr/bin/ld on RedHat Enterprise AMD64 platforms.

In that situation, you have 3 options:

  1. You upgrade your Operating System to a newer version.
  2. You install a newer version of ld from GNU binutils for your spanking new gcc/g++ precompiled compiler.
  3. You recompile gcc/g++ in order for the configure script to discover the runtime options available from your system linker ld.


The rest of this section will describe options #2 and #3.

Other reasons would be: (NB: these 2 lines should go in a section like "Motivation for recompiling OpenFOAM")

  • You're developing a new utility or are looking for a bug in OpenFOAM: in that case you may want to have a version of OpenFOAM with debugging enabled
  • You don't have enough memory and precision isn't your primary concern. In that case you want to compile a single-precision version of OpenFOAM.

2.2 Selecting the right package to download

You should always download a GNU gcc/g++ source package with at least the same version, if not newer, as the version of the pre-compiled gcc/g++ compiler provided by OpenCFD, for the version of OpenFOAM you plan to use. The GNU gcc/g++ compiler source package is downloadable from the GCC GNU Web site, or from one of it's numerous mirrors.

Here is an example for OpenFOAM 1.3:

 
# create a temporary working directory
mkdir -p $HOME/OpenFOAM/linux/tmp
cd $HOME/OpenFOAM/linux/tmp
 
# download using standard ftp
ftp ftp.gnu.org
cd /gnu/gcc/gcc-4.1.0/
bin
get gcc-4.1.0.tar.bz2
exit

If you decide or need to install a local version of binutils, you can get it from the GNU Web site or GNU ftp site as well:

 
cd $HOME/OpenFOAM/linux/tmp
 
# download the latest version of binutils using standard ftp
ftp ftp.gnu.org
cd /gnu/binutils
bin
get binutils-2.16.1.tar.bz2
exit

2.3 Configuration, compilation and full installation of GNU binutils (optional)

This subsection describes the full installation of GNU binutils under $HOME/OpenFOAM/linux. You should only do a full install of GNU binutils if you are experiencing or suspecting compatibility problems between gcc 4.1.0 and your system's default linker "/usr/bin/ld".

You should also follow these installation steps prior to recompiling gcc 4.1.0; that way, the recompilation process of gcc will have access to the latest version of the linker "ld".

 
 
# extraction
cd $HOME/OpenFOAM/linux/tmp
bzcat binutils-2.16.1.tar.bz2 | tar -xvf - 
 
cd binutils-2.16.1 
 
# configuration for x86 platforms
./configure --prefix=$HOME/OpenFOAM/linux/binutils-2.16.1 
 
# configuration for x86_64 platforms
./configure --prefix=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1
 
# compilation
make
 
#installation
make install
 
# installation for the binutils header files for x86 platforms
# for more information, see the section about the partial installation of binutils
make target_header_dir=$HOME/OpenFOAM/linux/binutils-2.16.1/include -C libiberty install_to_libdir
 
# installation for the binutils header files for x86_64 platforms
make target_header_dir=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/include -C libiberty install_to_libdir
 
#cleanup
cd ..
rm -rf binutils-2.16.1
 
# Update your path (for bash)
export PATH=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/bin:$PATH
 
# Update your path (for csh)
setenv PATH $HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/bin:$PATH
 
# Final validation
# Should point to $HOME/OpenFOAM/linux/binutils-2.16.1/bin, or the AMD64 variant
which ld
 


Finally, make sure the configuration steps described further down in the section documenting the partial installation of binutils are followed as well. Those steps are important in order to compile the new, automatic stack trace on code abort capabilities of OpenFOAM 1.3.

2.4 Configuration, compilation and installation of GNU gcc

 
# extraction
cd $HOME/OpenFOAM/linux/tmp
 
bzcat gcc-4.1.0.tar.bz2 | tar -xvf - 
mkdir gcc-4.1.0/gcc-4.1.0-obj
cd gcc-4.1.0/gcc-4.1.0-obj 
 
# configuration for x86 platforms
../configure --prefix=$HOME/OpenFOAM/linux/gcc-4.1.0 --exec-prefix=$HOME/OpenFOAM/linux/gcc-4.1.0 \
    --enable-languages=c,c++ --enable-shared --disable-multilib
 
# configuration for x86_64 platforms
../configure --prefix=$HOME/OpenFOAM/linuxAMD64/gcc-4.1.0 --exec-prefix=$HOME/OpenFOAM/linuxAMD64/gcc-4.1.0 \
    --enable-languages=c,c++ --enable-shared --disable-multilib
 
# compilation
make bootstrap
 
#installation
make install
 
#cleanup
cd ../..
rm -rf gcc-4.1.0

3 Installing the Java JSDK

Nothing special to do here; simply download the default package from OpenCFD or SourceForge using your browser or a tool like wget, and install it under the right directory:

 
# download from a nearby SourceForge mirror
cd $HOME/OpenFOAM/linux/
wget http://umn.dl.sourceforge.net/sourceforge/foam/j2sdk1.4.2_05.linux.tgz
 
# extraction and installation
tar -zxvf j2sdk1.4.2_05.linux.tgz
 
# cleanup
rm j2sdk1.4.2_05.linux.tgz

4 Installing the OpenFOAM source code


4.1 Downloading and extracting the source code

It is now time to install the OpenFOAM source code, not because we are ready to compile it right away, but simply because we need to properly set some environment variables, and the OpenFOAM initialization scripts are exactly what is needed for such a job.

 
# download the OpenFOAM source code from OpenCFD or the closest SourceForge mirror
cd $HOME/OpenFOAM
wget http://umn.dl.sourceforge.net/sourceforge/foam/OpenFOAM-1.3.General.gtgz
 
# extract the source code
tar -zxvf OpenFOAM-1.3.General.gtgz

4.2 Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc (optional)

Next, we need to adjust some environment variables to reflect our compiler version if the version of gcc installed is newer than the default version available from OpenCFD.

This is specified in the file

$HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or
$HOME/OpenFOAM/OpenFOAM-1.3/.cshrc

For example, for the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc, we need to adjust the following line

 
# replace gcc-4.1.0 by gcc-4.xx.yy for the version 4.xx.yy of gcc
export WM_COMPILER_DIR=$WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH

For the file $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc, we need to adjust the following line

 
# replace gcc-4.1.0 by gcc-4.xx.yy for the version 4.xx.yy of gcc
setenv WM_COMPILER_DIR $WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH

4.3 Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc (optional)

Next, we need to specify if we want to compile and use OpenFOAM on a x86 or x86_64 system, or if we want our root directory for OpenFOAM under a different directory than $HOME/OpenFOAM.

For this, we need to modify the file

$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc or
$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc

For example, for the file $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc, we may want to adjust or add the following lines

 
# uncomment the following line on a AMD64 workstation 
#export WM_64=1
 
# uncomment the following line if your OpenFOAM root directory in under /opt	
#export WM_PROJECT_INST_DIR=/opt/$WM_PROJECT

For the file $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc, we may want to adjust or add the following lines

 
# uncomment the following line on a AMD64 workstation 
#setenv WM_64 1
 
# uncomment the following line if your OpenFOAM root directory in under /opt	
#setenv WM_PROJECT_INST_DIR /opt/$WM_PROJECT

4.3.1 Modifications for a Single-Precision version of OpenFOAM

This works only for versions after 1.3

If you want a single-precision version of OpenFOAM (instead of the usual double-precision) change the lines in $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc from

 
# export WM_PRECISION_OPTION=SP
export WM_PRECISION_OPTION=DP

to

 
export WM_PRECISION_OPTION=SP
# export WM_PRECISION_OPTION=DP

4.3.2 Modifications for a debug version of OpenFOAM

If you want a debug version of OpenFOAM (which is slower but does range checking on containers etc) change the lines in $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc from

 
export WM_COMPILE_OPTION=Opt
# export WM_COMPILE_OPTION=Debug
# export WM_COMPILE_OPTION=Prof

to

 
# export WM_COMPILE_OPTION=Opt
export WM_COMPILE_OPTION=Debug
# export WM_COMPILE_OPTION=Prof

(if you want a profiling-enabled version of OpenFOAM uncomment the third line)

4.4 Initializing the OpenFOAM environment variables

We can now initialize all the required environment variables and aliases for properly compiling and running OpenFOAM.

If your current shell is bash

 
. $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc

If your current shell is csh or a csh look-alike like tcsh

 
source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc

5 Compiling and installing cmake


Cmake is a cross-platform, open-source make system.

You need cmake for compiling ParaView.

Even though cmake is not supplied by OpenCFD as a companion tool for OpenFOAM, I find it useful to install cmake under the $HOME/OpenFOAM/linux directory, close to ParaView.

Here is the procedure for downloading, compiling and installing cmake:

 
# download the latest cmake source package from Kitware's ftp site:
mkdir $HOME/OpenFOAM/linux/tmp
cd $HOME/OpenFOAM/linux/tmp
 
ftp public.kitware.com
cd pub/cmake/v2.3
bin
get cmake-2.3.4-20060317.tar.gz
 
# extract the source code
tar -zxvf ./cmake-2.3.4-20060317.tar.gz
 
# configure cmake
cd cmake-2.3.4-20060317
./configure --prefix=$HOME/OpenFOAM/linux/cmake-2.3.4
make
make install
 
# cleanup
cd ../..
rm -rf ./tmp

Next, you need to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc in order to add cmake to your $PATH environment variable. I usually insert those modifications at the end of the files.

Here is how to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc.

 
#
# cmake
#
# Make sure cmake is accessible
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export CMAKE=cmake-2.3.4
export CMAKE_ARCH_PATH=$WM_PROJECT_INST_DIR/$WM_ARCH/$CMAKE
AddPath $CMAKE_ARCH_PATH/bin

Here is how to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc.

 
#
# cmake
#
# Make sure cmake is accessible
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setenv CMAKE cmake-2.3.4
setenv CMAKE_ARCH_PATH $WM_PROJECT_INST_DIR/$WM_ARCH/$CMAKE
AddPath $CMAKE_ARCH_PATH/bin

And of course, don't forget to reinitialize your environment:

If your current shell is bash

 
. $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc

If your current shell is csh or a csh look-alike like tcsh

 
source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc

6 Compiling and installing ParaView


ParaView is probably the trickiest package to recompile. Here is how.

6.1 Selecting the right version of ParaView

You first need to download the source code from Kitware's Web site.

But before doing so, please note the version number of the binary ParaView package provided by OpenCFD. You need to download the ParaView source package with the same version number, or very close to it if you like living on the bleeding edge. Otherwise, if your version is too different, you risk not being able to link in the modules needed for paraFoam.

For example, for OpenFOAM 1.3, OpenCFD ParaView binary package version is paraview-2.4.2; you should then download the same version for the source package from Kitware's Web site.

Note however that ParaView latest stable version is 2.4.3; since the version number is very close to 2.4.2, I have chosen to use this version instead.

6.2 Downloading and installing ParaView source code

 
cd $HOME/OpenFOAM/linux
wget http://www.paraview.org/files/v2.4/paraview-2.4.3.tar.gz
 
tar -zxvf ./paraview-2.4.3.tar.gz
mkdir -p paraview-2.4.3/lib/paraview-2.4


If you decide to install a newer version of ParaView, you need to adjust the files
$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/bashrc
and
$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/cshrc

For $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/bashrc, you need to modify this line

 
#export ParaView_VERSION=2.4.2
export ParaView_VERSION=2.4.3

For $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/cshrc, you need to modify this line

 
#setenv ParaView_VERSION 2.4.2
setenv ParaView_VERSION 2.4.3

6.3 Patching Tcl/TK (optional)

Valid versions: OF version 13.png


Next, you may need to correct a bug that is not yet corrected in the companion Tcl/Tk source package that comes with ParaView.

That bug is documented on the Tcl/Tk mailing list, and is only affecting systems running bash version 3.1 or later. I have stumbled on that bug when compiling OpenFOAM 1.3 under Knoppix 5.0.

For more information, please check out the following link

The correction is rather simple, there are two typos in the files paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix/tcl.m4 and paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix/tcl.m4.

Here is the first correction (the old code is commented out):

 
# starting on line 776 for both files:
 
# Bug fix: Remove the extra single quote close to .relid
#	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
#		system=MP-RAS-`awk '{print $3}' /etc/.relid'`
#	    fi
 
	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
		system=MP-RAS-`awk '{print $3}' /etc/.relid`
	    fi
 

The second correction is identical, only the line numbers are different:

 
# starting on line 2107 for the file paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix/tcl.m4:
# starting on line 2117 for the file paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix/tcl.m4:
 
# Bug fix: Remove the extra single quote close to .relid
#	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
#		system=MP-RAS-`awk '{print $3}' /etc/.relid'`
#	    fi
 
	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
		system=MP-RAS-`awk '{print $3}' /etc/.relid`
	    fi
 


Next, you need to regenerate the Automake files. The command autoreconf is part of the Automake package. You need this package for recompiling ParaView.

 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix
autoreconf
 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix
 
#This invocation of autoreconf will end with some error message about AC_LIBOBJ. 
#You can ignore this error message.
autoreconf

6.4 Modification to the file CMakeLists.txt

Before you do this, make sure you'v installed the develep package of tcl, tk, xorg/xfree. Next, we need to modify the file $HOME/OpenFOAM/linux/paraview-2.4.3/CMakeLists.txt in order to force the installation of the ParaView header files when we will invoke the command make install a little bit later.

With version 1.4 of OpenFOAM and version 2.6.1 of Paraview, the file that we need to modify lies now in $HOME/OpenFOAM/linux/paraview-2.6.1/CMake/ParaViewCommon.cmake. The modifications are the same.

Here are the lines we need to modify; watch for the comments starting with OpenFOAM::

 
# Setup install directories.
IF(NOT PV_INSTALL_BIN_DIR)
  SET(PV_INSTALL_BIN_DIR ${PV_INSTALL_ROOT}/bin)
ENDIF(NOT PV_INSTALL_BIN_DIR)
IF(NOT PV_INSTALL_INCLUDE_DIR)
#
# OpenFOAM: we need to modify this line
#  SET(PV_INSTALL_INCLUDE_DIR ${PV_INSTALL_ROOT}/include/paraview-${PARAVIEW_VERSION})
  SET(PV_INSTALL_INCLUDE_DIR ${PV_INSTALL_ROOT}/include)
#
# OpenFOAM: end of modification
#
ENDIF(NOT PV_INSTALL_INCLUDE_DIR)
IF(NOT PV_INSTALL_LIB_DIR)
  SET(PV_INSTALL_LIB_DIR ${PV_INSTALL_ROOT}/lib/paraview-${PARAVIEW_VERSION})
ENDIF(NOT PV_INSTALL_LIB_DIR)
IF(NOT PV_INSTALL_DATA_DIR)
  SET(PV_INSTALL_DATA_DIR ${PV_INSTALL_ROOT}/share/paraview-${PARAVIEW_VERSION})
ENDIF(NOT PV_INSTALL_DATA_DIR)
 
# Install no development files by default, but allow the user to get
# them installed by setting PV_INSTALL_DEVELOPMENT to true.  Disable
# the option altogether if PV_INSTALL_NO_DEVELOPMENT is already set to
# true.
#
# OpenFOAM: we need to add this line.
#
SET(PV_INSTALL_DEVELOPMENT 1)
#
# OpenFOAM: end of modification
#
IF(NOT PV_INSTALL_NO_DEVELOPMENT)
  # Leave this option out until we write code to install paraview headers
  # other than VTK.
  #OPTION(PV_INSTALL_DEVELOPMENT "Install ParaView plugin development files."
  #  OFF)
  #MARK_AS_ADVANCED(PV_INSTALL_DEVELOPMENT)

6.5 Initial configuration using cmake

Next, we use the default invocation of cmake to get the initial configuration of Paraview

 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4
cmake ../..

6.6 Adjusting the configuration

Next, we need to adjust the initial ParaView configuration in order to get the proper settings for compiling with OpenFOAM.

For this, you need to edit the file $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4/CMakeCache.txt using your favourite text editor. That file was automagically created by the prior invocation of cmake.

Here are the lines and configuration variables that need to be modified. The default values previously generated by cmake are commented out.

 
# BUILD_SHARED_LIBS:BOOL=OFF
BUILD_SHARED_LIBS:BOOL=ON
 
# BUILD_TESTING:BOOL=ON
BUILD_TESTING:BOOL=OFF
 
# CMAKE_INSTALL_PREFIX:PATH=/usr/local
CMAKE_INSTALL_PREFIX:PATH=/home/whatever_your_login_is/OpenFOAM/linux/paraview-2.4.3
 

For compiling ParaView for x86_64, we need to modify some other configuration variables. Here are the variables I had to modify for SuSE 9.1 x86_64. Adjust accordingly to your own specific 64-bit Operating System.

 
BUILD_SHARED_LIBS: ON
CMAKE_BUILD_TYPE : 
CMAKE_CXX_COMPILER : /home/your_login_name/OpenFOAM/linuxAMD64/gcc-4.1.0/bin/g++
CMAKE_CXX_FLAGS : -m64
CMAKE_C_COMPILER : /home/your_login_name/OpenFOAM/linuxAMD64/gcc-4.1.0/bin/gcc
CMAKE_C_FLAGS : -m64
CMAKE_EXE_LINKER_FLAGS : -m64
CMAKE_EXE_LINKER_FLAGS_RELEASE : -m64
CCMAKE_MODULE_LINKER_FLAGS : -m64
CMAKE_INSTALL_PREFIX : /home/your_login_name/OpenFOAM/linuxAMD64/paraview-2.4.3
CMAKE_MODULE_LINKER_FLAGS : -m64
CMAKE_MODULE_LINKER_FLAGS_RELEASE : -m64
CMAKE_SHARED_LINKER_FLAGS : -m64
CMAKE_SHARED_LINKER_FLAGS_RELEASE : -m64
OPENGL_gl_LIBRARY : /usr/lib64/libGL.so
OPENGL_glu_LIBRARY: /usr/X11R6/lib64/libGLU.a
X11_X11_LIB : /usr/X11R6/lib64/libX11.so
X11_Xext_LIB : /usr/X11R6/lib64/libXext.so 
CMAKE_X_LIBS : /usr/X11R6/lib64/libX11.so;/usr/X11R6/lib64/libXext.so;/usr/X11R6/lib64/libX11.so;/usr/X11R6/lib64/libXext.so
X11_Xext_LIB: /usr/X11R6/lib64/libXext.so

I used OpenSUSE 10.1 x86_64 with Tcl/Tk-8.4.5, I found that if you want to compile paraview-2.4.3, you need to add the following parameters to CMakeCache.txt

 
TCL_LIBRARY:FILEPATH=/usr/lib64/tcl8.4.so
TK_LIBRARY:FILEPATH=/usr/lib64/tk8.4.so

Note: my recompiled 64 bit version of paraView 2.4.3 is crashing under SuSE 9.1. I had no such problem with paraview 2.2.1 (OpenFOAM 1.2). As soon as I find the source of the problem, I will document it here...

6.7 Compiling and installing paraview

At last, the moment of truth :)

 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4
make
make install

7 Modifications for the compilation of PVFoamReader


Valid versions: OF version 13.png

In order to compile the module $HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader,

we need to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt

for two reasons:

  1. The position of the LINK_DIRECTORIES instruction in the file is important, and using a recent version of cmake (cmake-2.3.4-20060317), the linker search path specified in the Makefile will not be written correctly without the modifications.
  2. You must include the directory $FOAM_USER_LIBBIN in the linker search path if you want the module PVFoamReader (and paraFoam) to use your local ${FOAM_USER_LIBBIN}/libfoamUser.so library (for your user-defined boundary condition code, etc,).

Otherwise,

  1. Your library libPVFoamReader.so will fail to link against libOpenFOAM.so because it cannot find it.
  2. paraFoam will fail to load your user-defined code because the library libPVFoamReader.so will be link against the default library ${FOAM_LIBBIN}/libfoamUser.so instead of your local version ${FOAM_USER_LIBBIN}/libfoamUser.so.

Here is the modifications needed for the file $HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt .

We only show a part of that file; look for the instructions preceded by a comment mentionning cmake version 2.3.4-20060317

 
# Create the configuration header.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReaderConfigure.h.in
               ${PROJECT_BINARY_DIR}/vtk${PROJECT_NAME}Configure.h
               @ONLY IMMEDIATE)
 
# Create vtk client/server wrappers for the classes.
VTK_WRAP_ClientServer(${PROJECT_NAME} PVFoamReaderCS_SRCS "${PVFoamReader_SRCS}")
 
# Must be defined before ADD_LIBRARY  for cmake version 2.3.4-20060317
LINK_DIRECTORIES($ENV{FOAM_USER_LIBBIN})
LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
 
# Build the package as a plugin for ParaView.
ADD_LIBRARY(${PROJECT_NAME} MODULE ${PVFoamReader_SRCS} ${PVFoamReaderCS_SRCS})
LINK_DIRECTORIES($ENV{ParaView_INST_DIR}/lib)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} vtkClientServer)
FOREACH(c ${PVFoamReader_LIBS})
  TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${c}CS)
ENDFOREACH(c)
 
# Place the package configuration file into the build tree.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.xml.in
               ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.xml @ONLY IMMEDIATE)
 
# Place the package configuration file into the build tree.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.pvsm.in
               ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.pvsm @ONLY IMMEDIATE)
 
# Must be commented out for cmake version 2.3.4-20060317
#LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} OpenFOAM finiteVolume vtkFoam)
 


Once this modification made, the normal OpenFOAM 1.3 compilation scripts will take care of the rest.


8 Partial installation of GNU binutils (optional)


With OpenFOAM 1.3, OpenCFD introduces a new, automatic stack trace on code abort. This new capability is based on the library libiberty from the package GNU binutils. That library comes standard with most Linux-based OS. However, in order to recompile OpenFOAM, you also need to have a valid header file called /usr/include/demangle.h, also provided by GNU binutils.

That header file is present on SuSE OS, but not on RedHat/Fedora nor on Knoppix/Debian systems.

Looking at the scripts designed to construct the installation RPM of the binary package GNU binutils, we can see that SuSE took an extra installation step in order to install under the directory /usr/include a few more header files from the GNU binutils package, including the demangle.h file.

This section gives a quick description on how to install the missing header files locally under the directory $HOME/OpenFOAM/linux.

You first need to identify the version of GNU binutils installed on your system. For instance, on a RedHat WS 4, you can get that information like this:

 
% rpm -qa | grep -i binutils
binutils-2.15.92.0.2-15

Given that basic information, here the installation procedure:

 
# First, create a temporary directory for extracting the GNU binutils source code
mkdir -p $HOME/OpenFOAM/linux/binutils-2.15/src
cd $HOME/OpenFOAM/linux/binutils-2.15/src
 
# Next, download the proper version on the GNU binutils source code
 
# Download from the Web site
wget http://ftp.gnu.org/gnu/binutils/binutils-2.15.tar.gz
tar -zxvf binutils-2.15.tar.gz
cd binutils-2.15
 
# Or Download using CVS
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
  {enter "anoncvs" as the password}
 
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co -r binutils-2_15 binutils
cd src
 
# Next, proceed with the configuration of the package
./configure --prefix=$HOME/OpenFOAM/linux/binutils-2.15
 
# Next, execute a partial installation in order to get the missing header files
make
make target_header_dir=$HOME/OpenFOAM/linux/binutils-2.15/include -C libiberty install_to_libdir
 
# Finally, let's clean up
rm -rf $HOME/OpenFOAM/linux/binutils-2.15/src

8.1 Configuring OpenFOAM for using binutils demangle.h

NB: If you already did a full installation of binutils, please make sure all the steps describe in that subsection are realized as well, but for binutils-2.16.1.

We now have the needed header files installed locally under the directory $HOME/OpenFOAM/linux/binutils-2.15/include

We must now tell OpenFOAM where to find these new header files:

First, we create the new environment variable _BINUTILS_FOR_DEMANGLE_H.

Warning: Please make sure not to redefine the environment variable called BINUTILS_ROOT. This environment variable is a reserved variable for the compilation tools like the first stage compiler cc1 from the gcc compiler. This redefinition will break the linker ld as well. An obvious symptom of such a redefinition of this variable will be the appearance of the error message

 
/usr/bin/ld: crtbegin.o: No such file: No such file or directory

when trying to link a simple executable program.


We will define this new variable _BINUTILS_FOR_DEMANGLE_H in the files $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc and/or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc.

Here is how to modify $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc

 
# Binutils header files
# Under Redhat, some header files like demangle.h are missing
#
# For now, we are using a local and partial installation of binutils in order 
# to provides only the missing header files. 
# The libraries are already provided by default by the OS (RedHat, SuSE, Knoppix, etc).
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#export _BINUTILS_FOR_DEMANGLE_H=/usr
export _BINUTILS_FOR_DEMANGLE_H=$WM_PROJECT_INST_DIR/$WM_ARCH/binutils-2.15
 
# If you installed binutils-2.16.1 instead:
export _BINUTILS_FOR_DEMANGLE_H=$WM_PROJECT_INST_DIR/$WM_ARCH/binutils-2.16.1
 
# If you did a full install for binutils, why not use the binary tools as well...
AddPath $_BINUTILS_FOR_DEMANGLE_H/bin
 

Then, we modify the file $HOME/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/Make/options for the compilation of the library libOpenFOAM:

 
EXE_INC = \
    -DWM_PROJECT_VERSION='"'$(WM_PROJECT_VERSION)'"' \
    -I$(_BINUTILS_FOR_DEMANGLE_H)/include/ \
    -I$(LIB_SRC)/zlib-1.2.1
 
LIB_LIBS = -L$(FOAM_LIBBIN)/dummy -lPstream -lfoamUser -lz

The library libOpenFOAM, and the rest of OpenFOAM 1.3 should now compile without a glitch with the new, automatic stack trace on code abort capabilities up and ready.

9 Miscellaneous adjustments (optional)


Some OpenFOAM compilation script files either use gmake, or make.

Under Knoppix 5.0, gmake is absent, but make does exist.

To correct this problem, we simply need to create a symbolic link under /usr/local/bin.

 
# Become root
su
 
#Create the symlink
ln -s `which make` /usr/local/bin/gmake

Of course, the directory /usr/local/bin needs to be in your path, so take the time to verify and to adjust your path if necessary.

 
% echo $PATH
 
# if /usr/local/bin/ is not in your PATH environment variable, simply do: (for example under bash)
 
% export PATH=/usr/local/bin:$PATH
 
# and/or adjust your $HOME/.bashrc accordingly.
 

10 Compiling OpenFOAM

Now the easy stuff...

 
cd $HOME/OpenFOAM/OpenFOAM-1.3
./Allwmake

Cheers!

11 Building OpenFOAM on OpenSolaris x86_32 2/07

Configure GCC as follows:

 
../configure --prefix=$HOME/OpenFOAM/linux/gcc-4.2.0 --exec-prefix=$HOME/OpenFOAM/linux/gcc-4.2.0 \
   --with-ld=/usr/ccs/bin/ld --without-gnu-ld \
   --enable-languages=c,c++ --enable-shared --disable-multilib

After that compile and install as described above.

You also need to download from http://flex.sourceforge.net/ and install the newest version of flex to use it instead of default for OpenSolaris v.2.5.4. After installation add to local .bashrc the followings:

 
export PATH=PATH_TO_YOUR_NEW_FLEX_BIN:$PATH
 
alias flex++='flex -+'

Now configure and compile OpenFOAM as described above.

Due to the fact that command find on OpenSolaris does not support the option -maxdepth, the building the applications in $WM_PROJECT_DIR/applications will fail.

To complete the building, create and execute the following script:

 
#!/usr/bin/perl
 
use File::Find;
 
chdir "$ENV{'WM_PROJECT_DIR'}/applications";
 
find(\&MakeIt, "./");
 
sub MakeIt
{
   -f and return;
   if (-d "$_/Make") {
      print "Building $File::Find::name ...\n";
      $File::Find::prune = 1;
      system "wmake $_";
   }
}

Valid versions: OF version 13.png OF version 14.png

--MB 02:44, 13 Apr 2007 (CEST)