Compiling from Source
Table of contents
Choice of Compiler
In order to compile CREST from source you will need a Fortran and C compiler. We recommend either the Intel ifx/icx or GNU gfortran/gcc compilers. Both compilers can be obtained free-of-charge, but you’ll only need one of them. A quick reference on where to obtain either one is provided in the following.
1. GNU compilers
Installing the gfortran and gcc compilers on Unix systems is fairly straightforward. The installation can be done directly via the commandline, e.g., with
sudo apt-get install gfortran
Check the installation and gfortran version with
gfortran --version
The gcc compiler is included in the build-essential package and there is a good chance you have installed this on your Linux system already. If not, try installing it via
sudo apt update
sudo apt-get install build-essential
and check the gcc version with
gcc --version
If you decided on the GNU compilers, set them as your defaults:
export FC=gfortran CC=gcc
In case you are going for the GNU compilers, it also makes sense to install openBLAS as a linear algebra backend, for example on Ubuntu via
sudo apt-get install libopenblas-dev
2. Intel compilers via oneAPI
The ifx and icx compilers are available free-of-charge through Intel’s oneAPI initiative . You will need to first install the Intel oneAPI Base Toolkit and afterwards the Intel oneAPI HPC Toolkit . Follow the instructions and check the installation via
ifx --version
If this gives you a version number, set these compilers as your defaults:
export FC=ifx CC=icx
Install via CMake
CMake is one of the most widely used multiplatform build systems. Starting with CREST 3.0, we will focus primarily on this build, although the Meson build may still be used.
It can be used with Ninja or the regular make as a backend. CMake can be installed in different ways. For example from the official website, or via pip
pip install cmake
For the next steps you will need to have chosen a compiler (ifx/icx or gfortran/gcc) and exported the FC and CC variables as described above . To start building CREST, navigate to the source (a file called CMakeLists.txt should be present here) and setup a _build directory with
cmake -B _build
Further arguments can be added to this command if you wish to customize the build. Information about the subprojects is given on the programs repository page .
Optional feature flags (add to the cmake -B _build command):
| Flag | Effect |
|---|---|
-DWITH_GXTB=ON | Enable g-xTB via tblite (also requires -DWITH_TBLITE=ON) |
-DWITH_FMLIP_RELAY=ON | Enable ML potential interface via fmlip-relay |
Then build the project with
make -C _build
If you wish to use Ninja as a backend (instead of make), add the -GNinja option to the CMake setup command.
Unit tests can be run via
make test -C _build
mctc-lib, mstore, multicharge, s-dftd3). After cloning or pulling, run git submodule update --init --recursive to ensure all dependencies are present.Install via Meson
Meson is an open source multiplatform build system. The main development project can be found on Meson’s GitHub page . Meson is used in combination with the Ninja build system (version > 1.8) as a backend. Both can be installed from the command line via pip (Python version > 3.7).
python3 -m pip install meson ninja
OR via
sudo apt install meson ninja-build
Check their installation with
meson --version ; ninja --version
Instructions for building CREST with Meson are read from the meson.build file. As before, you must have exported FC and CC variables to set the compilers. To start building the program, navigate to the directory in which you have saved CREST and set up the build with
meson setup _build
This will prepare the directory _build in which the program will be compiled.
-Dlapack=<option> keyword to the setup command. Available options are auto (default), openblas, mkl, netlib, and custom. For example, add -Dlapack=mkl to use the shared MKL library.-Dstatic=true to the Meson setup command. This attempts to link OpenMP and LAPACK runtimes statically and is useful for deployment on clusters without matching system libraries.The optional features listed for the CMake build have Meson counterparts (add to the meson setup _build command):
| Flag | Effect |
|---|---|
-Dgxtb=true | Enable g-xTB via tblite (also requires -Dtblite=enabled) |
-Dfmlip-relay=enabled | Enable ML potential interface via fmlip-relay |
If the setup was successful, initiate the build (still in the same directory) with
ninja -C _build