Compilation with Cmake

Download

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://www.github.com/ElmerCSC/elmerfem -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:

-DWITH_ElmerIce:BOOL=TRUE

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

#!/bin/bash

CMAKE=cmake

# Installation directory (set these!)
TIMESTAMP=$(date +"%m-%d-%y")
ELMER_REV="Elmer_devel_${TIMESTAMP}"
ELMERSRC="/path/to/Elmer/Source/elmerice"
BUILDDIR="$ELMERSRC/builddir"
IDIR="/usr/local/$ELMER_REV"
# next line is optional
#TOOLCHAIN="/path/to/your/own/toolchainfile/yourtoolchainfile.cmake"

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

echo $CMAKE $ELMERSRC 

# you can add a -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN,
# if you have a toolchain file declared
$CMAKE $ELMERSRC  \
    -DCMAKE_INSTALL_PREFIX=$IDIR \
    -DCMAKE_C_COMPILER=/path/to/compiler/executable \
    -DCMAKE_Fortran_COMPILER=/path/to/compiler/executable \
    -DWITH_MPI:BOOL=TRUE \
    -DWITH_Mumps:BOOL=TRUE \
    -DWITH_Hypre:BOOL=TRUE \
    -DWITH_Trilinos:BOOL=FALSE \
    -DWITH_ELMERGUI:BOOL=FALSE \
    -DWITH_ElmerIce:BOOL=TRUE

# 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.

Usage

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.

License

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
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0