Skip to content

Installation

Johannes Markert edited this page May 6, 2024 · 23 revisions

Here, we discuss how to install t8code from the GitHub repository on a Linux machine.

Build t8code with Autotools

Requirements

t8code uses Autotools and you will basically need

  • libsc (Included in t8code's git repository)
  • p4est (Included in t8code's git repository)
  • automake
  • libtool
  • make

Optional

  • The VTK library for advanced VTK output (basic VTK output is provided without linking against VTK)
  • The NetCFD library for NetCFD file output

Note: t8code has experimental support for building with cmake. For more details see Build t8code with CMake.

Installation

Clone the repository or download the latest release

To install t8code from GitHub on a Linux machine, first clone the repository or download the latest release, for example with

git clone git@github.com:DLR-AMR/t8code.git

or

git clone https://github.com/DLR-AMR/t8code

Notes for cloning from a newly created fork

(Release) tags are not automatically copied to a fork. But since the configure script determines the t8code version through the git tags, they have to be present. Otherwise, the configure and make step will fail. Therefore, it may be necessary to set the upsteam remote repository and to update the tags on the fork:

git fetch --tags upstream
git push --tags

By enabling the following option, tags get automatically pushed alongside with commits with git push. This way the tags will always be updated when the main branch of the fork is updated:

git config push.followTags true

To enable the option globally for all git repositories on the computer just add a --global.

git config --global push.followTags true

Initialize the submodules

t8code uses libsc and p4est as submodules. To download and initialize these, use

git submodule init
git submodule update

Bootstrap

Call the bootstrap script:

./bootstrap

Configure t8code

You now created a configure script ./configure in the t8code folder. Executing this script will create the t8code Makefiles.

Create a folder where you wish to build t8code into. Switch to it and execute the configure script. For the sake of this tutorial, we will choose ~/t8code_build and assume that the repository was cloned into ~/t8code.

mkdir t8code_build
cd ~/t8code_build
../t8code/configure [OPTIONS]

You can choose from various options to configure t8code. To see a list of possible configure options, call

 ./configure -h

For a more elaborate overview please see the Configure options wiki page.

The most common options are

Option Description
--enable-mpi enable MPI parallel code
--enable-debug enable debugging mode (Note: This will drastically reduce performance)
--with-LIB/--without-LIB (enable/disable linking with LIB)
--prefix=PATH Provide an installation prefix
CFLAGS= Provide C compiler flags
CXXFLAGS= Provide C++ compiler flags
CC= Set the C compiler
CXX= Set the C++ compiler

For a quick release mode configuration we recommend:

configure CFLAGS="-O3" CXXFLAGS="-O3" --enable-mpi CC=mpicc CXX=mpicxx

For a debugging mode configuration (mostly used by developers), you can use

configure CFLAGS="-Wall -O0 -g" CXXFLAGS="-Wall -O0 -g" --enable-mpi --enable-debug --enable-static --disable-shared CC=mpicc CXX=mpicxx

Note: enable-static and disable-shared allow you to properly use debugging tools such as gdb or valgrind.

Build t8code

The configure script should now have created the t8code Makefiles and you can build t8code.

make -j
make install -j

Checking

After a new installation you should run the t8code test programs. To do so, run

make check

or

make check -j

If any of the tests fail, something in the configuration or on your system does not work properly and you should not use t8code in this configuration.

If you cannot figure out, what causes the problem, feel free to contact the developers.

Linking against t8code

To use t8code as an external library and link against it, first you need to install it according to the above instructions or obtain an installation via another way. Your code must link against t8code, p4est, libsc, libz and libm. Usually p4est and libsc are shipped with t8code. If you did not obtain them with t8code you need to install them separately.

For the sake of the argument let's say the install folder is $HOME/t8code_install.

  1. Add the library folder to LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/t8code_install/lib
  1. Add these to your compile line
-I$HOME/t8code_install/include
-L$HOME/t8code_install/lib
-lt8 -lp4est -lsc -lm -lz

Build t8code with CMake

Disclaimer: The CMake build system in t8code is in early stages and subject to any changes. We encourage you to make code contributions if bugs have been found or if there are missing features.

tldr;

For building t8code with CMake the steps for cloning the repository and initializing the git sub-modules must be done as described above.

Afterwards create a build directory, call the configurator and run make:

mkdir build
cd build
cmake /path/to/t8code/repository -DCMAKE_INSTALL_PREFIX="/path/to/install/t8code/files" 
make -j
make -j install

This may take a while. To see all available configuration options you can call the interactive interface of CMake.

ccmake /path/to/t8code/repository

If you want to run all unit tests do

make -j test

The following sections provide more details regarding the usage of the CMake build system.

Requirements

  • libsc (Included in t8code's git repository)
  • p4est (Included in t8code's git repository)
  • CMake
  • make

Installing with CMake

  1. Clone the repository This is the same as for the autotools-based installation.
git clone git@github.com:DLR-AMR/t8code.git
cd t8code
git submodule init
git submodule update
  1. Create a build directory CMake builds are done out-of-tree in a dedicated build directory. This is traditionally achieved by creating a build directory at the root of the repository:
mkdir build
cd build
  1. Optional: specify the C and C++ compilers This step is not mandatory as CMake is usually able to infer this on its own, but we recommend exporting these variables prior to invoking CMake:
export CC="your favorite C compiler"
export CXX="your favorite C++ compiler"
  1. Invoke CMake Configure your build of CMake, and generate the corresponding Makefile:
cmake .. "append your build options here, see dedicated section"

A standard production build:

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="path/to/your/favorite/folder" -DT8CODE_BUILD_TUTORIALS=OFF -DT8CODE_BUILD_EXAMPLES=OFF
  1. Build and install t8code
make install

Build options

On top of the standard CMake options, we provide the following build options:

CMake option Description Default value
T8CODE_ENABLE_MPI Enable / disable MPI support ON
T8CODE_ENABLE_DYNAMIC_LINKAGE Install as a dynamic library (.so) / as a static library (.a) ON
T8CODE_BUILD_TESTS Build the automated test suite (required for make test) ON
T8CODE_BUILD_TUTORIALS Build the tutorials ON
T8CODE_BUILD_EXAMPLES Build the examples ON

Linking against t8code in your own CMake-based project

  1. Insert an add_subdirectory( path/to/t8code/sources ) instruction in your top level CMakeLists.txt file
  2. Add a target_link_libraries( your_target PRIVATE T8CODE::T8 ) instruction for each target depending on t8code
Clone this wiki locally