Compilation with Cmake


Elmer/Ice can be retrieved through the whole Elmer package via GitHub. From the shell of a system that has git installed, the command

 git clone git:// -b elmerice elmerice

creates a local copy of the repository, directly linking the local elmerice branch to the one of the repository on GitHub (this seems to be necessary in less recent git-versions). Mind that in some occasions you might have to use the https instead of the git protocol. Please, bear in mind that there are different branches in this repository. The Elmer development branch, devel, usually does not contain the latest Elmer/Ice developments. In order to be sure to have an Elmer/Ice development that doesn't interfere with the main Elmer branch development, we created a branch named elmerice. In order to check, which branch one is in, one can give the command

 git status

Or, for a more concise view of your current branch (starred) and other local branches you can run

 git branch -a

In order to change (if not already in) into the elmerice branch, one has to type

 git checkout elmerice

If you have made a bare clone (i.e., without the -b elmerice elmerice option), there is a chance this command may leave you in the default (devel) branch without returning an error, so make sure to check your branch again. If you are still not in the elmerice branch and you are familiar with git you can make a local branch tracking the remote elmerice branch

git checkout --track origin/elmerice

Building Elmer/Ice

Elmer/Ice - in contrary to the earlier autotools version - is best built alongside the main Elmer using cmake. Consequently, the prerequisites match those needed for building Elmer in the first instance:

  • A Fortran 90 compiler
  • (GNU) Make
  • cmake

In order to have Elmer/Ice automatically build alongside Elmer, add the following option to the cmake build command:


The following script can act as a guideline to compile Elmer with Elmer/Ice included:



# Installation directory (set these!)
TIMESTAMP=$(date +"%m-%d-%y")
# next line is optional

echo "Building Elmer from within " ${BUILDDIR}
echo "using following toolchain file " ${TOOLCHAIN}
echo "installation into " ${IDIR}
ls -ltr


# if you have a toolchain file declared
    -DCMAKE_C_COMPILER=/path/to/compiler/executable \
    -DCMAKE_Fortran_COMPILER=/path/to/compiler/executable \
    -DWITH_Mumps:BOOL=TRUE \
    -DWITH_Hypre:BOOL=TRUE \
    -DWITH_Trilinos:BOOL=FALSE \

# change the -j4 to the number of available cores on your system                              
make -j4 && sudo make install

# this automatically links /usr/local/Elmer-devel to your new built
sudo rm /usr/local/Elmer-devel
sudo ln -s $IDIR /usr/local/Elmer-devel

On standard Linux systems the CMAKE_C_COMPILER will be set to /usr/bin/gcc and CMAKE_Fortran_COMPILER to /usr/bin/gfortran.

Hint: if you need to use sudo-rights to install, sometimes the -E option is in order to redirect the current environment to the process.


To use the Elmer/Ice Solvers and User functions, simply modify your sif files to point on the ElmerIceSolvers and ElmerIceUSF object files:

Procedure =  File "ElmerIceSolvers" "NameSolver"

where NameSolver is the name of the solver you want to execute.


The complete tree elmerice is released under GPL 2 (or later), just like the rest of the code. The main difference of the elmerice subdirectory (in each branch) with respect to the rest of Elmer is that for Elmer/Ice the intellectual property lies not with CSC, but with the community. In short that means that no non-GPL branch can be derived from anyone (including CSC). This also means, that Elmer/Ice code has to stay within the elmerice tree.

compilation/compilationcmake.txt · Last modified: 2016/05/25 13:46 by tzwinger
CC Attribution-Share Alike 4.0 International Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0