Compiling Elmer on Windows with gfortran

From Elmer Wiki
Jump to: navigation, search

Compilation instructions

The latest Windows installer for Elmer (since rev. 2992) provides a collection of compilers (gcc rev. 136212) which can be used to compile individual solvers, procedures, as well as the whole Elmer-suite for 32-bit Windows platforms.

Note: It is necessary to let the installer uncompress and extract its contents in the default localtion (currently C:\Elmer6.0). If you choose another location, the installation will work, but the compilers are not available.

Compiling procedures with ElmerGUI

Open ElmerGUI, choose Run -> Compiler... and select your subroutine to compile.

Compilation of procedures from CMD-prompt

Open a cmd-shell (start -> Run... -> Open: cmd) and go to the directory containing the solver or procedure you want to compile (for example mysolver.f90). Then type

> elmerf90 mysolver

This will create mysolver.dll, which can be accessed from a SIF-file as usual.

Compilation of procedures from MSYS-shell

Open a MSYS-shell and go to the directory containing the solver or procedure you wish to compile (for example mysolver.f90). Then type

$ elmerf90 mysolver.f90 -O -o mysolver.dll

This will create mysolver.dll, which can be accessed from a SIF-file as usual.

Compiling the Elmer suite from source

In order to compile the basic Elmer suite (all but ElmerGUI) from source code, you should have MinGW and MSYS installed on your system. These instructions assume that you have the Windows installer that comes with a built-in version of the gnu compilers with ending "-elmer". Normally these would be omitted.

Open the MSYS shell and get the latest Elmer source code from svn (if you don't have a command line svn client installed, you can use the "tortoise subversion client" instead):

$ cd /c
$ svn co https://elmerfem.svn.sourceforge.net/svnroot/elmerfem/trunk elmerfem
$ cd elmerfem

Create a text file called "compile.sh":

#!/bin/sh -f

export ELMER_HOME=/c/elmertest
export ELMER_POST_HOME=$ELMER_HOME/share/elmerpost
export ELMER_FRONT_HOME=$ELMER_HOME/share/elmerfront

export PATH=$ELMER_HOME/bin:$PATH

export CC=gcc-elmer
export CXX=g++-elmer
export FC=gfortran-elmer
export F77=gfortran-elmer
export CPP=cpp-elmer
export LDFLAGS="-L/c/Elmer5.4/lib/gcc/i686-pc-mingw32/4.4.0 -Xlinker --stack=1000000000 "

modules="matc umfpack mathlibs elmergrid meshgen2d eio hutiter fem post front"
for m in $modules; do
  cd $m
  ./configure --prefix=$ELMER_HOME
  make
  make install
  cd ..
done

Run the script as

$ . compile.sh

This will compile and install the basic Elmer suite in C:\elmertest (it should take about 30 minutes for the script to complete). If everything goes fine, you can test the installation by typing

$ ElmerPost
$ ElmerFront
$ ElmerSolver