Sources and compilation

When to compile?

Ready-compiled binaries exist for a few platforms. If these work with your system, there may be no reason to compile Elmer from the source codes. Even most of the code development may be done without compiling the main program as new solvers may be dynamically linked. However, local compilation usually gives the best performance and is often needed for non-standard systems. Also it is often useful to download the source code just for checking the functionalities of different solvers when the documentation is not completed.

These provide the basic instructions for compiling Elmer under cmake. In the wiki and discussion forum you may find more detailed instructions for particular platforms. 

Obtaining the source code

The source code of Elmer project is available at
https://github.com/elmercsc/elmerfem

# Create directory where to download things
$ mkdir elmer
$ cd elmer

# clone the git repository.
git clone git://www.github.com/ElmerCSC/elmerfem

Building the code

# create build directory
$ mkdir build
$ cd build

# let the cmake generate makefiles
$ cmake -DWITH_ELMERGUI:BOOL=FALSE -DWITH_MPI:BOOL=FALSE -DCMAKE_INSTALL_PREFIX=../install ../elmerfem

# Cmake configures things, if it does not find something (e.g., lapack), you can help it by 
$ cmake -DCMAKE_PREFIX_PATH=<path_to_lapack_installation> ../elmerfem

# Alternatively, you can tune the compilation parameters graphically with
$ ccmake .
# or
$ cmake-gui .

# If no errors are produced, compile:
$ make install
# or alternatively compile in parallel (4 procs) 
$ make -j4 install

Testing the installation

# finally you may test the newly compiled Elmer version
$ ctest -j4

Setting environmental variables

For convinience you may set some environmental variables in order to be able to run Elmer anywhere. The following definitions work for bash (and should be written to file ~/.bashrc).

export ELMER_HOME=$HOME/elmer/install/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ELMER_HOME/lib
export PATH=$PATH:$ELMER_HOME/bin