Installation

This package is written mainly in fortran, with parts in c, c++, and python. The minimum requirements are

  • fortran compiler. Tested with gcc 5+, ifort 14+. Several f2003/2008 features are extensively used, so the compiler needs to be rather new.
  • MPI
  • fftw
  • hdf5
  • python

In addition, to make use of all features you might want to install

  • gnuplot, tested with 4+ on OSX with aquaterm
  • this documentation is generated with FORD.

Download

Dependencies

MPI

Nothing special is required by the MPI installation, except that it needs to support MPI_IN_PLACE. I have never had any issues with specific MPI implementations.

hdf5

It is likely that the cluster you use already has hdf5 installed. If not, compiling is a breeze (except on Cray systems) usually, I use

./configure FC=XX CC=XX --with-fortran --with-fortran2003 --prefix=XX
make
make install

Note that the fortran compiler needs to be exactly the same as the one used to compile TDEP later on.

Compiling

The build system is a little unorthodox, but straightforward. You need to create a file called important_settings, and put it in the root directory of tdep. Several examples are provided, start with the one that seems closest to what you have. An example follows here, for OSX:

#!/bin/bash
# A central place to put all the important paths. You probably have to modify this to make things work.

# the fortran compiler
FORTRAN_COMPILER="gfortran-7"
# optimization stuff. Go all in.
OPTIMIZATION_LEVEL="-Ofast"
# the flag that sets the default real to a double.
DOUBLE_FLAG="-fdefault-real-8"
# The flag that tells the compiler where to put .o and .mod files.
MODULE_FLAG="-J"

# the header to put in python scripts.
PYTHONHEADER="#!/usr/bin/python"

# Which gnuplot terminal to use by default.
GNUPLOTTERMINAL="aqua"  # nice on OSX, needs aquaterm installed and gnuplot compiled with support for it.

# Precompiler flags. Selecting default gnuplot terminal, and make the progressbars work.
PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar"
#PRECOMPILER_FLAGS="-DGP${GNUPLOTTERMINAL} -Dgfortranprogressbar -DAGRESSIVE_SANITY"

# these are the flags that are needed for gfortran
FCFLAGS="-Wl,-commons,use_dylibs -ffree-line-length-none -std=f2008 -fall-intrinsics -cpp -fopenmp"

# These are the BLAS/LAPACK libraries. On OSX with gfortran, use the built-in 'framework accelerate'
PATH_TO_BLASLAPACK_LIB=" "
PATH_TO_BLASLAPACK_INC=" "
BLASLAPACK_LIBS="-framework accelerate" 

# I use fftw for Fourier transforms.
PATH_TO_FFTW_LIB="-L/usr/local/lib"
PATH_TO_FFTW_INC="-I/usr/local/include"
FFTW_LIBS="-lfftw3"

# Also need MPI
PATH_TO_MPI_LIB="-L/usr/local/lib"
PATH_TO_MPI_INC="-I/usr/local/include"
MPI_LIBS="-lmpi_mpifh -lmpi"

# I also use HDF5 every now and then
PATH_TO_HDF5_LIB="-L/usr/local/lib"
PATH_TO_HDF5_INC="-I/usr/local/include"
HDF5_LIBS="-lhdf5 -lhdf5_fortran"

# We also need a C-compiler
C_COMPILER="gcc-7"

# Things below this line is strictly optional, and not really needed except for testing purposes.
# If you want to try and use CGAL. Not recommended for people who do not like to sort out compiler errors. 
USECGAL="no"

# CGAL is written in c++. I have wrapper functions in C, that I call from Fortran.
CPP_COMPILER="gcc-7"
CPP_FLAGS="--std=c++0x -frounding-math -O3 -Dusecgal -DCGAL_USE_GMP -DCGAL_USE_MPFR -DCGAL_EIGEN3_ENABLED -DNDEBUG -DBOOST_PARAMETER_MAX_ARITY=12 -Wno-deprecated-declarations"
CGALLINKLINE="-lstdc++ -lCGAL -lmpfr -lgmp -lboost_system -lboost_thread-mt"

# It's important at least a majority of these libraries are compiled with the same c++ compiler 
# as above. You can get strange, strange errors otherwise. As I said, getting this up and running
# is not easy.
PATH_TO_CGAL_LIB="-L/Users/olle/software/CGAL-4.9/build/lib -L/usr/local/lib"
PATH_TO_CGAL_INC="-I/Users/olle/software/CGAL-4.9/build/include -I/usr/local/include -I/usr/local/include/eigen3"

# If I want to link with AIMS, I have to specify where it is
PATH_TO_AIMS_LIB="-L/Users/olle/software/aims/lib"
PATH_TO_AIMS_INC="-I/Users/olle/software/aims/src"
AIMS_LIBS="-laims.170824.mpi"

once that is set up, run

./build_things.sh

And things should start compiling. It will stop at any error, you probably have to install some library or adjust some path in important_settings.

Setting paths

once build_things.sh has finished, it should have printed a bashrc_tdep file. The rest of the usage guides assumes you put this in your .bashrc or equivalent. It sets the path, manpath and a few minor things, contains the following lines:

MANPATH=$MANPATH:/Users/olle/tdep-devel/man
PATH=$PATH:/Users/olle/tdep-devel/bin
export MANPATH
export PATH
alias gnuplot='gnuplot -persist'

If this is set up, you are good to go.

Complicated dependencies

CGAL

You might have noticed that there is an optional dependency on CGAL in the provided important_settings. I wrote a Fortran interface to (a very small subset of) CGAL that can be used to generate meshes, triangulations and other things. The reason it is not enabled by default is that making CGAL and Fortran talk to each other is not straightforward. I can only describe how I got it to work. I don't know if all of these steps are necessary, or if there is some other thing I did that got it to work. This is all for OSX 10.11.4

  • get the latest CGAL source, I used 4.11, and read the manual installation.
  • when configuring cgal with cmake, specify C and c++ compilers manually to gcc-7 and g++-7, installed via homebrew. (I never got it working with clang, my guess is that linking becomes easier if the fortran, C and c++ compilers are all gcc.)
  • configure cgal to produce static libraries (untick the box that says BUILD_SHARED_LIBS)
  • add -DBOOST_PARAMETER_MAX_ARITY=12 to the compile line

If this made no sense whatsoever, you probably do not want to try and enable this.