How to install ABINIT on Ubuntu¶
This file describes how to install ABINIT on Ubuntu. The procedure for other Linux-based systems is similar, but the package manager and the location of the libraries may differ. Explicit testing was done with Ubuntu 19.10.
This page discusses how to install ABINIT with two different approaches:
- Using the apt package manager to install a precompiled version of abinit
- Compiling abinit from source using external libraries installed via apt.
Other possibilities (such as installation using the binary files provided by conda) are not discussed.
To install a precompiled version of ABINIT, just type:
sudo apt install abinit
then enter your user password and ABINIT should install smoothly with all its dependencies.
This version of ABINIT is most likely an old one.
abinit -v to print the version number.
Compiling from source under Ubuntu¶
The source code of the latest stable release is available at https://www.abinit.org/packages. Compiling from source enables one to optimize the build, activate MPI parallelism, customize linear algebra libraries etc. All the required packages are available via apt and can be installed with the syntax:
sudo apt install [package]
Use the commands
apt search and
apt show to search for a package or to get info about a particular package.
Ubuntu packages install their executables in the bin folder (e.g. /usr/bin).
The location of the executable can be found via the unix
will show the location of the gfortran executable provided the binary is in $PATH.
Other packages of interest when compiling code from source
are the so-called develop packages (denoted by the
-dev suffix) that contain among others:
- header files (extension
.h) providing the declaration of prototypes and named constants. These files are usually installed in an include folder (e.g. /usr/include).
- shared library files (extension
.so). that are usually installed in a lib folder (e.g. /usr/lib).
To obtain the location of such files, use the command
dpkg -L [package]
from the dpkg package
The prerequisites are first discussed qualitatively, because the installation may depend on the linux distribution. Then we discuss how to compile the source code.
A possible list of prerequisites (tested for Ubuntu 19.10) is:
Ubuntu or similar Ubuntu-based distributions
A Fortran compiler. Possible options:
- gfortran, the GNU compiler. It is open source and available via e.g. apt (gfortran package).
- ifort, the intel compiler. This is a commercial compiler, slightly more complicated to use but more optimized for intel architecture.
A MPI library installed (If you want to benefit from parallelism; recommended). Possible options:
- Open MPI from apt (
libopenmpi-devpackage) or http://www.open-mpi.org
- MPICH from apt (
libmpich-devpackage) or http://www.mpich.org
Depending on your distribution, you might need to manually add the
mpi-default-devpackage, a metapackage for both MPI libraries.
- Open MPI from apt (
A Linear Algebra library installed. A fallback (see next point) is available inside ABINIT (basic version of lapack), but you might want to install a math library yourself, especially for parallel computations: You can choose among:
mklfrom Intel (or you might try the libmkl-full-dev package).
Some mandatory libraries:
HDF5, NetCDF and NetCDF-Fortran, libraries to write/read binary files in netcdf4 format. These libraries are available via the
libnetcdff-devpackages from apt. For parallel IO, the
LIBXC, a library containing exchange-correlation potentials, from the
Note that it is also possible to generate these libraries via the ABINIT fallbacks:
cd fallbacks ./build-abinit-fallbacks.sh
In the latter case, the ABINIT configuration file (see later) should contain
These are the commands required to install the required packages from apt assuming a relatively simple ABINIT build with MPI support. The list of commands may change depending on your linux distribution, the exact ABINIT version you want to compile and the libraries you want to use.
# 1 # compiler sudo apt install gfortran # 2 # MPI libraries - choice for Open MPI sudo apt install mpi-default-dev libopenmpi-dev # 3 # math libraries - choice for lapack and blas sudo apt install liblapack-dev libblas-dev # 4 # mandatory libraries sudo apt install libhdf5-dev libnetcdf-dev libnetcdff-dev libpnetcdf-dev libxc-dev
For normal users it is advised to download the latest stable version from our website (replace 9.0.4 by the newest version available).
wget https://www.abinit.org/sites/default/files/packages/abinit-9.0.4.tar.gz tar xzf abinit-9.0.4.tar.gz cd abinit-9.0.4
Create a working directory:
mkdir build && cd build
To configure, use:
where ‘my_config_file.ac9’ is a configuration file that is discussed in more details in the next section.
The configuration file¶
The configure script accepts variables and flags to customize the configuration. For example
../configure FC=mpifort --with-mpi="yes"
tells ABINIT to configure for a MPI build with the mpifort MPI wrapper. To obtain the documentation for the different variables and flags, use:
Most configuration options are detected automatically by configure.
For example, if
with_mpi is set to ‘yes’, configure will try to use the parallel fortran compiler (mpifort)
and automatically detect the MPI installation with libraries (.so) and header (.h) files.
When you install the Open MPI package via apt, these directories can be printed to terminal
dpkg -L 'libopenmpi-dev'.
When a lot of options must be passed to configure, it is advised to use an external configuration file with the syntax:
An example of configuration file to build abinit with MPI, lapack and blas and automatic detection for libxc, hdf5, and netcdf:
# MPI settings with_mpi="yes" enable_mpi_io="yes" # linear algebra settings with_linalg_flavor="netlib" LINALG_LIBS="-L/usr/lib/x86_64-linux-gnu -llapack -lblas" # mandatory libraries with_libxc="yes" with_hdf5="yes" with_netcdf="yes" with_netcdf_fortran="yes"
one uses ‘-‘ when typing a flag but ‘_’ inside the config file, e.g.
the LINALG_LIBS variable was explicitly set for this linux distrubution. The directory was extracted via
dpkg -L liblapack-devand
dpkg -L libblas-dev.
when fine tuning variables and flags for a particular linux distribution, it is advised to take a look at the template file
~abinit/doc/build/config-template.ac9. For example, the setting of
LINALG_LIBSin this template file is given by the line
#LINALG_LIBS="-L/usr/local/lib -llapack -lblas".
More specialized libraries might be harder to detect.
For example, the following section was added to the config file to detect customized FFT and XML libraries.
These libraries are available via apt (
The directories for the corresponding library and header files can be found by using
dpkg -L [package]
and other flags can be extracted from the
# fast fourier settings with_fft_flavor="fftw3" FFTW3_CPPFLAGS="-I/usr/include" FFTW3_FCFLAGS="-I/usr/include" FFTW3_LIBS="-L/usr/lib/x86_64-linux-gnu -lfftw3 -lfftw3f" # XML2 library (used by multibinit) with_libxml2="yes" LIBXML2_FCFLAGS="-I/usr/lib/x86_64-linux-gnu/" LIBXML2_LIBS="-L/usr/include/libxml2/libxml/ -lxmlf90"