Compilation of Elmer on Linux

From Elmer Wiki
Revision as of 18:47, 24 June 2013 by Deric (talk | contribs) (removed "-" from chmod -u+x compile.sh & changed ~./bashrc to ~/.bashrc)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Detailed compilation instructions can be found from here.

Get the source via subversion:

$ svn checkout http://svn.code.sf.net/p/elmerfem/code/trunk elmerfem
$ cd elmerfem

Create the script compile.sh:

#!/bin/sh -f
#the compiler (here the gcc 4.X suite)
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
#the compiler flags
export CFLAGS=""
export FCFLAGS=""
export F77FLAGS=""
export FFLAGS=""
#linking
export LDFLAGS=""
#paths
export ELMER_HOME="/path/to/Elmerdir"
# modules
modules="matc umfpack mathlibs elmergrid meshgen2d eio hutiter fem post"
# configure and build
for m in $modules; do
   cd $m ; ./configure --prefix=$ELMER_HOME && make clean && make && make install && cd ..
done

If you compile on a 32-bit machine, you may want to play safe and add the switch "--with-64bits=no" to the configure command:

./configure --prefix=$ELMER_HOME --with-64bits=no

Run the script as follows:

$ chmod u+x compile.sh
$ ./compile.sh

Finally, we need to set up some environment variables and extend the path:

$ export ELMER_HOME="/path/to/Elmerdir"
$ export PATH=$PATH:$ELMER_HOME/bin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ELMER_HOME/lib

For bash users, a good place to put the above lines is in the end of ~/.bashrc.