Compilation error under CentOS x86_64

Submitted by francescomarra on Thu, 05/05/2011 - 19:36

Dear CFDEM Community,

I have troubles in installing cfdem under CentOS x86_64 (ver 5.3 of Rocks Cluster).
Maybe the difficulty comes from the need to use the gcc-4.5.x compiler required to compile both the last versions of OpenFOAM and CFDEM. This is not the system gcc compiler. It cannot be upgraded in order to avoid compatibility issues with the Cluster functioning.

I am almost sure I have done everything needed to ensure that all components and libraries required have been compiled under the same gcc environment and adopting the needed compilation options (in particular –fPIC).

All goes fine for libraries (FFTW, LIGGGHTS, CFDEM_PARTICLE, OPENFOAM-1.7.x) but when compiling the cfdem solver I got the following message error (starting from the entire compilation command issued by wmake):


g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels/incompressible/turbulenceModel -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/transportModels -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/transportModels/incompressible/singlePhaseTransportModel -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/finiteVolume/lnInclude -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/lagrangian/cfdemParticle/lnInclude -IlnInclude -I. -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude -I/share/apps/OpenFOAM/OpenFOAM-1.7.x/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed Make/linux64GccDPOpt/cfdemSolverPiso.o -L/share/apps/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt \
-L/share/apps/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt -lincompressibleRASModels -lincompressibleLESModels -lincompressibleTransportModels -lfiniteVolume -llagrangianCFDEM_shared -lOpenFOAM -ldl -lm -o /share/apps/OpenFOAM/OpenFOAM-1.7.x/applications/bin/linux64GccDPOpt/cfdemSolverPiso_shared
/share/apps/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/liblagrangianCFDEM_shared.so: undefined reference to `fftw'
/share/apps/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/liblagrangianCFDEM_shared.so: undefined reference to `fftw_create_plan'
/share/apps/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/liblagrangianCFDEM_shared.so: undefined reference to `fftw_destroy_plan'
collect2: ld returned 1 exit status

I have used FFTW-2.5.1 instead of the newest FFTW-3.1.1 because it was impossible to compile with the newer version, being the file fftw.h missed in this last version.

The compiled FFTW-2.5.1 libraries seems perfectly compatible with the LIGGGHTS solver that I also created and ran on some example cases. Also the OpenFOAM applications and solvers run smoothly.

FFTW was the most difficult piece of code to compile, as it uses the configure and make compilation process. In order to get the right compiler detected by configure I had to set the following environment variables:

export LIBRARY_PATH=/share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1:/share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64/gcc-4.5.1/lib64
export C_INCLUDE_PATH=/share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/include:/share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64/gcc-4.5.1/lib/gcc/x86_64-unknown-linux-gnu/4.5.1/include-fixed

followed by the configure command:

./configure -prefix /export/apps/OpenFOAM/ThirdParty-1.7.x/FFTW-2.1.5 —with-gcc

Any hint will be so much gratefully appreciated.

Thank you in advance and best regards,

Franco

ckloss's picture

ckloss | Thu, 05/05/2011 - 21:02

Hi Franco,

if FFTW is the only problem, everything is fine - b/c you don't need FFTW
Edit the LIGGGHTS makefile of your choice and remove it

Cheers,
Christoph

francescomarra | Tue, 05/10/2011 - 19:13

Dear Christoph,

four days of umph, haarg! @#?, !##?, *&@, %##, etc. etc. ...

... EUREKA !!! Solved !

It seems that I got a working CFDEM solver !

Your suggestion opened the right way to the solution. It was a messed OpenFOAM, ld, Gcc installation. It is really incredible that any mechanism exists to ensure the consistency of all environment variables.
If you like I can post, after further testing, some detailed instructions of what I have done that could be of help for other people.

Just a further question. How much solver performance are affected by not having FFTW compiled and linked with ?

Thank you again. My best regards,

Franco

cgoniva's picture

cgoniva | Thu, 05/12/2011 - 10:27

Hi Franco,

FFTW should not be used so, performance should not be affected.

Of course it would be nice if you could post here how you installed CFDEM on CentOS.

Cheers,
Chris

francescomarra | Fri, 06/10/2011 - 18:40

Dear Chris,

sorry for my so late answer.

I had to face the problem due to the need of installing several versions of OpenFOAM and then ensure the selection, starting a new shell and without changing system libraries and compiler, the needed OpenFOAM version for the specific job.
In the following I explain all the steps I followed to reach a new and independent installation of the latest version of OpenFOAM and CFDEM. I have to advise that, being not a real expert system administrator, probably more effective setup could be obtained. I ask everyone reading these notes to suggest me any improvement or better alternative.
My cluster is based on the ClusterRocks distribution, essentially a specialized version of CentOS. To reduce the complexity of the installation steps, I started by installing precompiled binaries of OpenFOAM for CentOS x86_64 architecture
here available .
I choose to install the version 1.7.1 of precompiled binaries. This is easily done, after download, with the usual rpm commands. They install the OpenFOAM packages under the /opt dir. Then, to make OpenFOAM accessible from all computing nodes, I moved the installed OpenFOAM under /export/apps/OpenFOAM . This will be referenced as the FOAM_INST_DIR .
Under this directory I will have, therefore, two directories, OpenFoam-1.7.1 and Third-Party-1.7.1, eventually alongside with previously installed versions of OpenFOAM. The precompiled 1.7.1 release either does not contain the source files, nor is the last update of the OpenFOAM sources, being this available as 1.7.x from the official OpenFOAM git repository. Therefore I created a new directory named $FOAM_INST_DIR/OpenFOAM-1.7.x and made a symbolic link named Third-Party-1.7.x pointing to the Third-Party-1.7.1 (or just rename Third-Party-1.7.1 to Third-Party-1.7.x if you do not need any more a separate 1.7.1 version).
Depending upon your specific system, git could be not available, as it was the case for mine RocksCluster linux server. It can be properly installed after having resolved some dependencies. In my case I had to install:

  • xmlto, installed from sources;
  • Flex, available as rpm package from the official repository of CentOS;
  • mpfr, available from the mpfr official site;
  • asciidoc and git, both available as rpm packages from the Fedora-EPEL repository.

As explained in the official OpenFOAM site the command :
git clone git://github.com/OpenCFD/OpenFOAM-1.7.x.git
issued from the $FOAM_INST_DIR/Openfoam-1.7.x dir will provide to download all the last update of the source and configuration files. After the download, two configuration files are available, ./etc/bashrc and ./etc/settings.sh (as well as equivalent versions working with csh). A copy of these two files after the changes is here reported.
bashrc


#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see .
#
# File
# etc/bashrc
#
# Description
# Startup file for OpenFOAM
# Sourced from ~/.profile or ~/.bashrc
# Should be usable by any POSIX-compliant shell (eg, ksh)
#
#------------------------------------------------------------------------------
export WM_PROJECT=OpenFOAM
export WM_PROJECT_VERSION=1.7.x
################################################################################
# USER EDITABLE PART. Note changes made here may be lost with the next upgrade
#
# either set $FOAM_INST_DIR before sourcing this file or set
# $foamInstall below to where OpenFOAM is installed
#
# Location of the OpenFOAM installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# foamInstall=$HOME/$WM_PROJECT
# foamInstall=~$WM_PROJECT
# foamInstall=/usr/local/$WM_PROJECT
# foamInstall=/opt/$WM_PROJECT
foamInstall=/share/apps/$WM_PROJECT
#
# END OF (NORMAL) USER EDITABLE PART
################################################################################
# note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
# The old dirs to be cleaned from the various environment variables
# - remove anything under top-level directory.
# NB: the WM_PROJECT_INST_DIR might not be identical between versions
foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
then
foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
fi
# Location of site/user files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
# Location of third-party software
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
# Source files, possibly with some verbosity
_foamSource()
{
while [ $# -ge 1 ]
do
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
. $1
shift
done
}
# Add in preset user or site preferences:
foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` && _foamSource $foamPrefs
unset foamPrefs
# Evaluate command-line parameters
while [ $# -gt 0 ]
do
case "$1" in
*=)
# name= -> unset name
eval "unset ${1%=}"
;;
*=*)
# name=value -> export name=value
eval "export $1"
;;
esac
shift
done
# Operating System/Platform
# ~~~~~~~~~~~~~~~~~~~~~~~~~
# WM_OSTYPE = POSIX | ????
: ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
# Compiler: set to Gcc, Gcc43, Gcc44, or Icc (for Intel's icc)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# FRANCO changed to Gcc451 and added WM_COMPILERVER (see settings.sh)
: ${WM_COMPILER:=Gcc}; export WM_COMPILER
: ${WM_COMPILERVER:=Gcc451}; export WM_COMPILERVER
unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
# Compilation options (architecture, precision, optimised, debug or profiling)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# WM_ARCH_OPTION = 32 | 64
: ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION
# WM_PRECISION_OPTION = DP | SP
: ${WM_PRECISION_OPTION:=DP}; export WM_PRECISION_OPTION
# WM_COMPILE_OPTION = Opt | Debug | Prof
: ${WM_COMPILE_OPTION:=Opt}; export WM_COMPILE_OPTION
# WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | MPI | QSMPI
: ${WM_MPLIB:=OPENMPI}; export WM_MPLIB
# Run options (floating-point signal handling and memory initialisation)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export FOAM_SIGFPE=
# export FOAM_SETNAN=
# Detect system type and set environment variables appropriately
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export WM_ARCH=`uname -s`
case $WM_ARCH in
Linux)
WM_ARCH=linux
# compiler specifics
case `uname -m` in
i686)
;;
x86_64)
case $WM_ARCH_OPTION in
32)
export WM_COMPILER_ARCH='-64'
export WM_CC='gcc'
export WM_CXX='g++'
export WM_CFLAGS='-m32 -fPIC'
export WM_CXXFLAGS='-m32 -fPIC'
export WM_LDFLAGS='-m32'
;;
64)
WM_ARCH=linux64
export WM_COMPILER_LIB_ARCH=64
export WM_CC='gcc'
export WM_CXX='g++'
export WM_CFLAGS='-m64 -fPIC'
export WM_CXXFLAGS='-m64 -fPIC'
# FRANCO added linking with new binutils
export WM_LDFLAGS='-m64 -L/share/apps/OpenFOAM/linux/lib'
;;
*)
echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64"
;;
esac
;;
ia64)
WM_ARCH=linuxIA64
export WM_COMPILER=I64
;;
mips64)
WM_ARCH=SiCortex64
export WM_COMPILER_LIB_ARCH=64
export WM_CC='gcc'
export WM_CXX='g++'
export WM_CFLAGS='-mabi=64 -fPIC'
export WM_CXXFLAGS='-mabi=64 -fPIC'
export WM_LDFLAGS='-mabi=64 -G0'
export WM_MPLIB=MPI
;;
ppc64)
WM_ARCH=linuxPPC64
export WM_COMPILER_LIB_ARCH=64
export WM_CC='gcc'
export WM_CXX='g++'
export WM_CFLAGS='-m64 -fPIC'
export WM_CXXFLAGS='-m64 -fPIC'
export WM_LDFLAGS='-m64'
;;
*)
echo Unknown processor type `uname -m` for Linux
;;
esac
;;
SunOS)
WM_ARCH=SunOS64
export WM_COMPILER_LIB_ARCH=64
export WM_CC='gcc'
export WM_CXX='g++'
export WM_CFLAGS='-mabi=64 -fPIC'
export WM_CXXFLAGS='-mabi=64 -fPIC'
export WM_LDFLAGS='-mabi=64 -G0'
export WM_MPLIB=FJMPI
;;
*) # an unsupported operating system
cat <

settings.sh

#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see .
#
# File
# etc/settings.sh
#
# Description
# Startup file for OpenFOAM
# Sourced from OpenFOAM-??/etc/bashrc
#
#------------------------------------------------------------------------------
# prefix to PATH
_foamAddPath()
{
while [ $# -ge 1 ]
do
export PATH=$1:$PATH
shift
done
}
# prefix to LD_LIBRARY_PATH
_foamAddLib()
{
while [ $# -ge 1 ]
do
export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
shift
done
}
# prefix to MANPATH
_foamAddMan()
{
while [ $# -ge 1 ]
do
export MANPATH=$1:$MANPATH
shift
done
}
# location of the jobControl directory
export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl
# wmake configuration
export WM_DIR=$WM_PROJECT_DIR/wmake
export WM_LINK_LANGUAGE=c++
export WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
# base configuration
export FOAM_APP=$WM_PROJECT_DIR/applications
export FOAM_APPBIN=$WM_PROJECT_DIR/applications/bin/$WM_OPTIONS
export FOAM_LIB=$WM_PROJECT_DIR/lib
export FOAM_LIBBIN=$WM_PROJECT_DIR/lib/$WM_OPTIONS
export FOAM_SRC=$WM_PROJECT_DIR/src
# shared site configuration - similar naming convention as ~OpenFOAM expansion
export FOAM_SITE_APPBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/bin/$WM_OPTIONS
export FOAM_SITE_LIBBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/lib/$WM_OPTIONS
# user configuration
export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/applications/bin/$WM_OPTIONS
export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/lib/$WM_OPTIONS
# FRANCO new binutils and linux libraries
export BINUTILS_LIB=/share/apps/OpenFOAM/linux/lib
export BINUTILS_BIN=/share/apps/OpenFOAM/linux/bin
export TOGL_LIB=/share/apps/OpenFOAM/linux/lib/Togl2.0
# convenience
export FOAM_TUTORIALS=$WM_PROJECT_DIR/tutorials
export FOAM_UTILITIES=$FOAM_APP/utilities
export FOAM_SOLVERS=$FOAM_APP/solvers
export FOAM_RUN=$WM_PROJECT_USER_DIR/run
# add OpenFOAM scripts and wmake to the path
export PATH=$WM_DIR:$WM_PROJECT_DIR/bin:$BINUTILS_BIN:$PATH
_foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN
# Make sure to pick up dummy versions of external libraries last
# FRANCO Added BINUTILS_LIB and TOGL_LIB
_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$BINUTILS_LIB:$TOGL_LIB:$FOAM
_LIBBIN/dummy
# Compiler settings
# ~~~~~~~~~~~~~~~~~
unset gcc_version gmp_version mpfr_version mpc_version
unset MPFR_ARCH_PATH
# Select compiler installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# compilerInstall = OpenFOAM | system
# FRANCO: changed to OpenFOAM
: ${compilerInstall:=OpenFOAM}
case "${compilerInstall:-OpenFOAM}" in
OpenFOAM)
case "$WM_COMPILERVER" in
Gcc)
gcc_version=gcc-4.4.3
gmp_version=gmp-5.0.1
mpfr_version=mpfr-2.4.2
;;
Gcc45)
gcc_version=gcc-4.5.0
gmp_version=gmp-5.0.1
mpfr_version=mpfr-2.4.2
mpc_version=mpc-0.8.1
;;
Gcc451)
gcc_version=gcc-4.5.1
gmp_version=gmp-5.0.1
mpfr_version=mpfr-3.0.0
mpc_version=mpc-0.8.2
;;
Gcc44)
gcc_version=gcc-4.4.3
gmp_version=gmp-5.0.1
mpfr_version=mpfr-2.4.2
;;
Gcc43)
gcc_version=gcc-4.3.3
gmp_version=gmp-4.2.4
mpfr_version=mpfr-2.4.1
;;
*)
echo
echo "Warning in $WM_PROJECT_DIR/etc/settings.sh:"
echo " Unknown OpenFOAM compiler type '$WM_COMPILER'"
echo " Please check your settings"
echo
;;
esac
if [ -n "$gcc_version" ]
then
gccDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gcc_version
gmpDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version
mpfrDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version
mpcDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpc_version
# Check that the compiler directory can be found
[ -d "$gccDir" ] || {
echo
echo "Warning in $WM_PROJECT_DIR/etc/settings.sh:"
echo " Cannot find $gccDir installation."
echo " Please install this compiler version or if you wish to use the system
compiler,"
echo " change the 'compilerInstall' setting to 'system' in this file"
echo
}
_foamAddMan $gccDir/man
_foamAddPath $gccDir/bin
# 64-bit needs lib64, but 32-bit needs lib (not lib32)
if [ "$WM_ARCH_OPTION" = 64 ]
then
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH
else
_foamAddLib $gccDir/lib
fi
# add in gmp/mpfr libraries
_foamAddLib $gmpDir/lib
_foamAddLib $mpfrDir/lib
# add in mpc libraries (not need for older gcc)
if [ -n "$mpc_version" ]
then
_foamAddLib $mpcDir/lib
fi
# used by boost/CGAL:
export MPFR_ARCH_PATH=$mpfrDir
fi
unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
;;
esac
# boost and CGAL
# ~~~~~~~~~~~~~~
boost_version=boost_1_42_0
cgal_version=CGAL-3.5.1
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version
# enabled if CGAL is available
if [ -d "$CGAL_ARCH_PATH" ]
then
if [ -d "$BOOST_ARCH_PATH" ]
then
_foamAddLib $BOOST_ARCH_PATH/lib
else
unset BOOST_ARCH_PATH
fi
_foamAddLib $CGAL_ARCH_PATH/lib
else
unset BOOST_ARCH_PATH CGAL_ARCH_PATH MPFR_ARCH_PATH
fi
unset boost_version cgal_version
# Communications library
# ~~~~~~~~~~~~~~~~~~~~~~
unset MPI_ARCH_PATH MPI_HOME
case "$WM_MPLIB" in
OPENMPI)
mpi_version=openmpi-1.5
export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mpi_version
# Tell OpenMPI where to find its install directory
export OPAL_PREFIX=$MPI_ARCH_PATH
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib
_foamAddMan $MPI_ARCH_PATH/man
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
unset mpi_version
;;
SYSTEMOPENMPI)
# use the system installed openmpi, get library directory via mpicc
mpi_version=openmpi-system
# Set compilation flags here instead of in wmake/rules/../mplibSYSTEMOPENMPI
export PINC="`mpicc --showme:compile`"
export PLIBS="`mpicc --showme:link`"
libDir=`echo "$PLIBS" | sed -e 's/.*-L\([^ ]*\).*/\1/'`
# Bit of a hack: strip off 'lib' and hope this is the path to openmpi
# include files and libraries.
export MPI_ARCH_PATH="${libDir%/*}"
if [ "$FOAM_VERBOSE" -a "$PS1" ]
then
echo "Using system installed MPI:"
echo " compile flags : $PINC"
echo " link flags : $PLIBS"
echo " libmpi dir : $libDir"
fi
_foamAddLib $libDir
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
unset mpi_version libDir
;;
MPICH)
mpi_version=mpich2-1.1.1p1
export MPI_HOME=$WM_THIRD_PARTY_DIR/$mpi_version
export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mpi_version
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib
_foamAddMan $MPI_ARCH_PATH/share/man
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
unset mpi_version
;;
MPICH-GM)
export MPI_ARCH_PATH=/opt/mpi
export MPICH_PATH=$MPI_ARCH_PATH
export GM_LIB_PATH=/opt/gm/lib64
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib
_foamAddLib $GM_LIB_PATH
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/mpich-gm
;;
HPMPI)
export MPI_HOME=/opt/hpmpi
export MPI_ARCH_PATH=$MPI_HOME
_foamAddPath $MPI_ARCH_PATH/bin
case `uname -m` in
i686)
_foamAddLib $MPI_ARCH_PATH/lib/linux_ia32
;;
x86_64)
_foamAddLib $MPI_ARCH_PATH/lib/linux_amd64
;;
ia64)
_foamAddLib $MPI_ARCH_PATH/lib/linux_ia64
;;
*)
echo Unknown processor type `uname -m` for Linux
;;
esac
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/hpmpi
;;
MPI)
export MPI_ARCH_PATH=/opt/mpi
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/mpi
;;
FJMPI)
export MPI_ARCH_PATH=/opt/FJSVmpi2
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/mpi
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib/sparcv9
_foamAddLib /opt/FSUNf90/lib/sparcv9
_foamAddLib /opt/FJSVpnidt/lib
;;
QSMPI)
export MPI_ARCH_PATH=/usr/lib/mpi
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/qsmpi
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib
;;
*)
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/dummy
;;
esac
_foamAddLib $FOAM_MPI_LIBBIN
# Set the minimum MPI buffer size (used by all platforms except SGI MPI)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: ${minBufferSize:=20000000}
if [ "${MPI_BUFFER_SIZE:=$minBufferSize}" -lt $minBufferSize ]
then
MPI_BUFFER_SIZE=$minBufferSize
fi
export MPI_BUFFER_SIZE
# Enable the hoard memory allocator if available
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if [ -f $FOAM_LIBBIN/libhoard.so ]
#then
# export LD_PRELOAD=$FOAM_LIBBIN/libhoard.so:$LD_PRELOAD
#fi
# cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset _foamAddPath _foamAddLib _foamAddMan compilerInstall minBufferSize
# ----------------------------------------------------------------- end-of-file

To recognize the required changes, save these files in the same directory with a different name and then diffs them with the original versions. Please note especially the rows after comments starting with my name (FRANCO).
Then, it is very very important to remember that all further steps have to be executed from a new shell from where you have to preliminary source the new bashrc:

source $FOAM_INST_DIR/OpenFOAM-1.7.x/etc/bashrc

After that, issuing gcc --version, should give you the indication that the new gcc provided with OpenFOAM is in use.
Before to proceed to the compilation of the new OpenFOAM sources and all the libraries needed for LIGGGHTS and CFDEM, we need to setup a new compiling environment as described in the following section. To this aim, two new directories are created under $FOAM_INST_DIR, one named sources, where the sources of all new required linux packages are downloaded, and another named linux, where the compiled linux utilities will be provided . This is just my choice to avoid to mix packages relative to the linux system with packages and tools relevant to the OpenFOAM – CFDEM installation.
I found very useful the suggestions given in this post on cfd-online:
The following linux packages have to be upgraded.
Binutils
From the official GNU site, download the last stable versions, unpack into the $FOAM_INST_DIR/source directory. Then, to compile and install:

./configure --prefix=/share/apps/OpenFOAM/linux/binutils-2.21 --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror
make CFLAGS="-O2" LDFLAGS="-s"
make install

Readline
I am unable to remember when, but I got unresolved dependencies for the libreadline . From the GNU official site I downloaded the latest version (6.2), unpacked it into the $FOAM_INST_DIR/source directory, and installed it with the commands:

./configure --prefix=/share/apps/OpenFOAM/linux --disable-multilib --with-host-libstdcxx=-lstdc++ --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror
make
make install

Python
It is necessary to reinstall the python libraries to include the support to the libraries adopted by pizza.py . Tcl/Tk with support to Togl, have to be available before the building of python. Other libraries are python modules that can be installed after having build python. The required python modules are Imaging, numpy, Pmw, PyOpenGL.

Tcl
download sources from the official site (I used ver 8.5.9), unpack under the source dir, cd to tcl8.5.9/unix and compile and install with the sequence of commands:

./configure --prefix=/share/apps/OpenFOAM/linux --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror
make
make install

Tk
similarly download sources from the official site (I used ver 8.5.9), unpack under the source dir, cd to tk8.5.9/unix and compile and install with the sequence of commands:

./configure --prefix=/share/apps/OpenFOAM/linux --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror
make
make install

Togl
The support of this libraries make to compiling process a little bit more complicate. After download from the official site (ver 2.0) and unpack into the source directory, cd to Togl2.0 and compile and install with the sequence of commands:
./configure --prefix=/share/apps/OpenFOAM/linux --with-tcl=/share/apps/OpenFOAM/linux/lib --with-tk=/share/apps/OpenFOAM/linux/lib --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror
make
make install

Tcl
To obtain Tcl libraries with support to the Togl extensions with need to recompile them with the following commands.

cd $FOAM_INST_DIR/tcl8.5.9/unix
export LDFLAGS=-L/share/apps/OpenFOAM/linux/lib/Togl2.0
export LIBS=-lTogl
make distclean
./configure --prefix=/share/apps/OpenFOAM/linux --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror --with-Togl2
make
make install

Tk
similarly, with need to recompile them with the following commands:

make distclean
./configure --prefix=/share/apps/OpenFOAM/linux --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror --with-Togl2
make
make install

Python
It is now possible to install our new python to correctly use pizza.py . Download sources from the official site (I used ver 2.7.1), unpack into the source dir, cd in $FOAM_INST_DIR/source/Python-2.7.1 and compile and install with the commands:

make distclean
./configure --prefix=/share/apps/OpenFOAM/linux --disable-multilib --with-host-libstdcxx='-lstdc++' --with-gcc --with-gnu-as --with-gnu-ld --enable-shared --disable-rpath --disable-werror --with-Togl2
make
make install

Further python packages are necessary to use several features of pizza . It is useful to install the following python packages:

Imaging
Download sources from the official site (I used ver 1.1.7), unpack into the source dir, cd in $FOAM_INST_DIR/source/Imaging-1.1.7 and compile and install with the command:
python setup.py install
Pmw
Download sources from the official site (I used ver 1.3.2), unpack into the source dir, cd in $FOAM_INST_DIR/source/Pmw.1.3.2/src and compile and install with the command:
python setup.py install
PyOpenGL
Download sources from the official site (I used ver 3.0.1), unpack into the source dir, cd in $FOAM_INST_DIR/source/PyOpenGL-3.0.1 and compile and install with the command:
python setup.py install
Numpy
Download sources from the official site (I used ver 1.5.1), unpack into the source dir, cd in $FOAM_INST_DIR/source/numpy-1.5.1 and compile and install with the command:
python setup.py install

Building OpenFOAM
You should be now able to rebuild your OpenFOAM libraries. Follows the instructions given in the OpenFOAM official site. Essentially, you need to move into the $FOAM_INST_DIR/OpenFOAM-1.7.x dir and issue the command:

./Allwake

or better, just to save into a file all the messages from stdout and stderr in the file log.Allwmake :

./Allwake >& log.Allwmake &

In this case you can follow what is happening by typing

tail –f log.Allwmake

LIGGGHTS installation
As explained by Chris, FFTW is not strictly needed to correctly build and use CFDEM. Therefore, being especially interested to use CFDEM, I did not included the support to the FFTW libraries.
It is necessary to download the latest version (I used 1.2.9) . I chose to install LIGGGTHS inside the Third-Party-1.7.x directory. After having unpacked the sources, read the doc/Section_Start documentation file for detailed build instructions. Then enter the src/MAKE dir and copy the Makefile.serial to Makefile.CentOS_mpi . Then edit this file accordingly to the file here below to adapt it to your system.


# linux = RedHat Linux box, gcc, openmpi, No FFTW
SHELL = /bin/sh
# ---------------------------------------------------------------------
# compiler/linker settings
# specify flags and libraries needed for your compiler
CC = mpic++
CCFLAGS = -O2 \
-funroll-loops -fstrict-aliasing -Wall -W -Wno-uninitialized
DEPFLAGS = -M
LINK = mpic++
LINKFLAGS = -O
LIB = -lstdc++
ARCHIVE = ar
ARFLAGS = -rcsv
SIZE = size
# ---------------------------------------------------------------------
# LAMMPS-specific settings
# specify settings for LAMMPS features you will use
# LAMMPS ifdef options, see doc/Section_start.html
LMP_INC = -DLAMMPS_GZIP
# MPI library, can be src/STUBS dummy lib
# INC = path for mpi.h, MPI compiler settings
# PATH = path for MPI library
# LIB = name of MPI library
MPI_INC = -I /share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64Gcc/openmpi-1.5/include
MPI_PATH = -I /share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64Gcc/openmpi-1.5
MPI_LIB = -L/share/apps/OpenFOAM/ThirdParty-1.7.x/platforms/linux64Gcc/openmpi-1.5/lib
# FFT library, can be -DFFT_NONE if not using PPPM from KSPACE package
# INC = -DFFT_FFTW, -DFFT_INTEL, -DFFT_NONE, etc, FFT compiler settings
# PATH = path for FFT library
# LIB = name of FFT library
FFT_INC = -DFFT_NONE
FFT_PATH =
FFT_LIB =
# additional system libraries needed by LAMMPS package libraries
# these settings are IGNORED if the corresponding LAMMPS package
# (e.g. gpu, meam) is NOT included in the LAMMPS build
# SYSLIB = names of libraries
# SYSPATH = paths of libraries
gpu_SYSLIB = -lcudart
meam_SYSLIB = -lifcore -lsvml -lompstub -limf
reax_SYSLIB = -lifcore -lsvml -lompstub -limf
user-atc_SYSLIB = -lblas -llapack
gpu_SYSPATH = -L/usr/local/cuda/lib64
meam_SYSPATH = -L/opt/intel/fce/10.0.023/lib
reax_SYSPATH = -L/opt/intel/fce/10.0.023/lib
user-atc_SYSPATH =
# ---------------------------------------------------------------------
# build rules and dependencies
# no need to edit this section
include Makefile.package
EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC)
EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(PKG_SYSPATH)
EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(PKG_SYSLIB)
# Link target
$(EXE): $(OBJ)
$(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
$(SIZE) $(EXE)
# Library target
lib: $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
# Compilation rules
%.o:%.cpp
$(CC) $(CCFLAGS) $(EXTRA_INC) -c $<
%.d:%.cpp
$(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $< > $@
# Individual dependencies
DEPENDS = $(OBJ:.o=.d)
include $(DEPENDS)

To build the library to adopt with CFDEM, the required commands are:

make clean-CentOS_mpi
make makelib
make -f Makefile.lib CentOS_mpi

Now you have to cross your finger very strongly and close your eyes. If after a while everything has gone successfully, remember that it is unusual today to see people running around as just out of the bath and laughing Eureka !
With LIGGGTHS you got also the post processing utility of LAMMPS called pizza . To use it, you need to change the first line of the file $FOAM_INST_DIR//ThirdParty-1.7.x/pizza/src/pizza.py to point to your new python installation, in my case:

#!/share/apps/OpenFOAM/linux/bin/python -i

Swack4Foam
This additional libraries of OpenFOAM have to be downloaded through the svn command as here explained . After the download has been completed, it is possible to satisfies all dependencies upon utilities and tools not distributed with the standard release of OpenFOAM by adopting the script ./downloadSimpleFunctionObjects.sh . At this point it is possible to issue the command:

wmake all

to compile all the downloaded libraries and utilities. Note that this operation install the very useful groovyBC too.
Another script helps to install these libraries in the standard paths of OpenFOAM:

./copySwakFilesToGlobal.sh

CFDEM installation
Yes, we are finally few steps away to complete the installation ! Instructions given on the official website of CFDEM are clear and exhaustive. I will not repeat them here. There is only one step further required to conform the installation to our personal setup, that is performed by editing the file $FOAM_INST_DIR/OpenFOAM-1.7.x/src/lagrangian/cfdemParticle/etc/bashrc . Here is reported my bashrc to see the changes required.


#----------------------------------*-sh-*--------------------------------------
# CFDEM
# Christoph Goniva
# April 2011
# Modified by Franco Marra, May 2011
#------------------------------------------------------------------------------
#
# Script
# etc/bashrc
#
# Description
# Startup file for cfdem exporting environment variables
# Sourced ~/.bashrc
#
#------------------------------------------------------------------------------
#- LIGGGHTS source directory src
export CFDEM_LIGGGHTS_SRC_DIR=$WM_THIRD_PARTY_DIR/LIGGGHTS/src
#- LIGGGHTS lib name
export CFDEM_LIGGGHTS_LIB_NAME=lmp_CentOS_mpi
#- CFDEM coupling source directory src
export CFDEM_SRC_DIR=$FOAM_SRC/lagrangian/cfdemParticle

It can be useful to insert the following lines (check the paths for your installation) into your ~/.bashrc or into a script to be sourced any time you need to work with the newly installed OpenFOAM-CFDEM:


source /share/apps/OpenFOAM/OpenFOAM-1.7.x/etc/bashrc
#
# Setup for OpenFOAM - LIGGGHT - pizza - CFDEM
#
alias pizza="python -i /share/apps/OpenFOAM/ThirdParty-1.7.x/pizza/src/pizza.py"
source /share/apps/OpenFOAM/OpenFOAM-1.7.x/src/lagrangian/cfdemParticle/etc/bashrc

Your computer should be now ready to start computing very complex multiphase flows. I immediately discovered that I am not ready to instruct my computer to do this job. I will appreciate very much suggestion about starting points to know the exact physical models implemented in this solver and to properly setup them.

I hope somebody will find this guidelines useful, but especially I hope I did not made any big mistake that could lead you crazy: please accept these guide as is.

Regards,

Franco

PS. I had troubles with the code tag: lines inserted between code /code does not maintain exactly the same format of the original files. The best was to delete all empty lines, but spacing is lost making reading more difficult. Indentation is lost too.