Installing Elmer in CentOs 6.5 using Cmake

Discussion about building and installing Elmer
Post Reply
xborras7
Posts: 37
Joined: 02 Sep 2013, 21:44
Antispam: Yes

Installing Elmer in CentOs 6.5 using Cmake

Post by xborras7 »

ElmerSolver for CentOs machines!

This post is a review of all the steps I followed to have the last version of ElmerSolver smoothly running in my CentOS machine. Thanks again to: Peter, Annier, Anil, Juhani, Zhang and Michal.

I will mainly followed the steps decribed here: viewtopic.php?f=2&t=3742

1) Create a directory to carry out the following steps:
$ mkdir elmer
$cd elmer

2) Download the last Elmer version using the following command:
Option A
$ git clone git://www.github.com/ElmerCSC/elmerfem
Option B
$ git clone https://www.github.com/ElmerCSC/elmerfem
The directory elmer/elmerfem has been generated and contains the files downloaded.

3) Create a directory in the /elmer directory named /build:
$ mkdir build
$ cd build

Now you have 2 directories in /elmer: /elmer/elmerfem and /elmer/build.

4)The next step generates "cmake" files. there are 2 alternatives: "cmake-gui" or "cmake".

Option A: Using cmake-gui to build elmer
$ cmake-gui
(check the link at the beginning of the file)
(*) I could manage to do it using cmake-gui too however I had to update some "qt" stuff and I had some troubles launching the make-gui. I found much easier to use Option B.

Option B: Using cmake command
a) Check the you have the compilers updated:
$ gcc -v
In my case it looked like this:

Code: Select all

[xavier@CE-CLYX01 V3(original_taper_ring_2boundaries)]$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
2012-03-13 Red hat 4.4.7-11 is too old!
Check the other compilers too:
$ gfortran -v
and
$ f95 -v
(I am not sure which compilers version are "updated" enough to compile Elmer)

I had to update the compilers using the following strategy:
(if your have an updated version you can skip this step)
I installed the "devtools-2" for CentOS (http://people.centos.org/tru/devtools-2/). the devtools-2 is fully self-contained so it will not mess your machine.
Lets do it:
a1) Download files:
$ cd /etc/yum.repos.d
$ wget http://people.centos.org/tru/devtools-2/devtools-2.repo

a2) Install the gcc, binutils, fortran, and C++ packages with:
$ yum install devtoolset-2-gcc
$ yum install devtoolset-2-binutils
$ yum install devtoolset-2-gcc-gfortran
$ yum install devtoolset-2-gcc-c++

Done!

a33)Use the “scl” command to activate the "devtools-2" within a terminal:
$ scl enable devtoolset-2 bash
If you repeat the following command you will see that you have now an updated version:

Code: Select all

[xavier@CE-CLYX01 V3(original_taper_ring_2boundaries)]$ scl enable devtoolset-2 bash
[xavier@CE-CLYX01 V3(original_taper_ring_2boundaries)]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/opt/rh/devtoolset-2/root/usr --mandir=/opt/rh/devtoolset-2/root/usr/share/man --infodir=/opt/rh/devtoolset-2/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --with-mpc=/dev/shm/home/centos/rpm/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
Compilers updated!

b) Run "cmake".
It is important to make sure that your elmer/build directory is empty before doing the following steps.
Sometimes the "cmake" was using the old compilers even having enabled the "devtoolset-2". Therefore I recommend to use the following sequence of commands although the 3 first commands should not be needed:
$ scl enable devtoolset-2 bash
$ export FC=gfortran
$ export CC=gcc
$ cmake -DWITH_ELMERGUI:BOOL=FALSE -DWITH_MPI:BOOL=FALSE -DCMAKE_INSTALL_PREFIX=../install ../elmerfem
Output message in my machine:

Code: Select all

[xavier@CE-CLYX01 build]$ cmake -DWITH_ELMERGUI:BOOL=FALSE -DWITH_MPI:BOOL=FALSE -DCMAKE_INSTALL_PREFIX=../install ../elmerfem
-- The Fortran compiler identification is GNU
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working Fortran compiler: /usr/bin/f95
-- Check for working Fortran compiler: /usr/bin/f95  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/f95 supports Fortran 90
-- Checking whether /usr/bin/f95 supports Fortran 90 -- yes
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- A library with BLAS API found.
-- A library with BLAS API found.
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- A library with LAPACK API found.
-- Checking whether /usr/bin/f95 supports CONTIGUOUS
-- Checking whether /usr/bin/f95 supports CONTIGUOUS -- no
-- Checking whether /usr/bin/f95 supports EXECUTE_COMMAND_LINE
-- Checking whether /usr/bin/f95 supports EXECUTE_COMMAND_LINE -- no
-- Looking for include file inttypes.h
-- Looking for include file inttypes.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long
-- Check size of long - done
-- ------------------------------------------------
--   BLAS library:   /usr/lib64/libblas.so
--   LAPACK library: /usr/lib64/liblapack.so;/usr/lib64/libblas.so
-- ------------------------------------------------
--   Fortran compiler:        /usr/bin/f95
--   Fortran flags:           
-- ------------------------------------------------
--   C compiler:              /usr/bin/cc
--   C flags:                 
-- ------------------------------------------------
--   Fortran compiler:  /usr/bin/f95
-- ------------------------------------------------
--   C compiler:        /usr/bin/cc
-- ------------------------------------------------
--   C++ compiler:      /usr/bin/c++
-- ------------------------------------------------
-- ------------------------------------------------
--   Package filename: elmerfem-7.0-501a8a3-20150213_Linux-x86_64 
--   Patch version: 7.0-501a8a3 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xavier/Downloads/Software/Elmer_CMAKE/build
It looks great! In case some error appears and you need to repeat this step; make sure you elmer/build directory is empty.

5) Compile using the generated Makefile:
$ make -j4 install
Do not forget to cross your fingers.

6) Test the newly Compiled Elmer Version:
$ ctest -j4
(Do not worry if some tests fail. The experts are working on it.)
7) Setting Enviroment variables:
$gedit ~/.bashrc

Add the following lines at the end of the file ~/.bashrc

Code: Select all

export ELMER_HOME=$HOME/elmer/install/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ELMER_HOME/lib
export PATH=$PATH:$ELMER_HOME/bin
Do not forget to refresh your terminal when you modify ~/.bashrc:
$ source ~/.basrc

Enjoy the latest version of Elmer! It took me a while to have it up and running but it was woth it.
Let me know if there is something no clear enough.

/Xavier Borras
raback
Site Admin
Posts: 4801
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Installing Elmer in CentOs 6.5 using Cmake

Post by raback »

HI Xavier,

Great work. I think many people will find this useful.

-Peter
Post Reply