Skip to content

Instantly share code, notes, and snippets.

@TheIdealis
Last active October 11, 2023 15:26
Show Gist options
  • Save TheIdealis/9f9c48740ee610e6da00bf94eab91645 to your computer and use it in GitHub Desktop.
Save TheIdealis/9f9c48740ee610e6da00bf94eab91645 to your computer and use it in GitHub Desktop.
compile abinit and prerequisites

Abinit 9.0.3

This gist was inspired by https://gist.github.com/milancurcic/3a6c1a97a99d291f88cc61dae6621bdf but adjusted to the newer versions of the packages and the gcc compiler. Please note that some exports might vary sligthly.

Versions

  • gcc 8.1.0 (9.3.0-1)
  • openmpi-3.1.0 (4.0.3-1)
  • hdf5-1.10.6
  • netcdf-c-4.6.3
  • netcdf-fortran-4.5.2
  • libxc-4.2.3
  • fftw3-3.3.8

Dependencies

  • zlib (1.2.11-4 in my case)

Preparation

export CC=mpicc 
export CXX=mpicxx 
export FC=mpif90 
export F77=mpif77 
  • Please note, you cannot close your terminal before you finished all compilations, otherwise the environment variables will be lost.

Compile HDF5

cd hdf5-1.10.6
mkdir install
export HDF5=/path/to/hdf5-1.10.6/install
CFLAGS=-fPIC ./configure --enable-shared --enable-parallel --enable-fortran --enable-fortran2003 --prefix=$HDF5
make -j4
make install

Compile NETCDF

cd netcdf-c-4.6.3
mkdir install
export LD_LIBRARY_PATH=$HDF5/lib:$LD_LIBRARY_PATH
# WE might need this line, we dont know why
export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
export NETCDF=/path/to/netcdf-c-4.6.3/install
LDFLAGS=-L$HDF5/lib LIBS=-lhdf5 CPPFLAGS=-I$HDF5/include ./configure --prefix=$NETCDF
make -j4
make install

Compile NETCDF-FORTRAN

cd netcdf-fortran-4.5.2
mkdir install
# For gcc 10.x, so far
export FCFLAGS="-w -fallow-argument-mismatch -O2"
export FFLAGS="-w -fallow-argument-mismatch -O2"
######
LDFLAGS=-L$NETCDF/lib CPPFLAGS=-I$NETCDF/include LIBS=-lnetcdf ./configure --prefix=$NETCDF --enable-parallel-tests
make -j4
make install

Compile LIBXC

cd libxc-4.2.3
mkdir install
./configure --prefix=/path/to/libxc-4.2.3/install
make -j4
make install

Compile FFTW3

cd fftw-3.3.8
./configure --prefix=/path/to/fftw-3.3.8/install --enable-mpi
make -j4
make install
make clean
./configure --prefix=/path/to/fftw-3.3.8/install --enable-mpi --enable-float
make -j4
make install

Compile ABINIT

cd abinit-9.0.3
mkdir build-mpi

After that, you have to create a file named config-mpi.ac with the content

prefix="/path/to/abinit-9.0.3/build-mpi"

F77=mpif77
FC=mpif90
CC=mpicc
CXX=mpic++

with_mpi="yes"

with_hdf5=/path/to/hdf5-1.10.6/install
with_netcdf=/path/to/netcdf-c-4.6.3/install
with_netcdf_fortran=/path/to/netcdf-c-4.6.3/install
with_libxc=/path/to/libxc-4.2.3/install

and then

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/hdf5-1.10.6/install/lib:/path/to/netcdf-c-4.6.3/install/lib:/path/to/install/lib
./configure --with-config_file=config-mpi.ac
make -j4 
make install

Configure your system

  • set export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/hdf5-1.10.6/install/lib:/path/to/netcdf-c-4.6.3/install/lib:/path/to/install/lib before you execute abinit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment