Compilie the Code
To compile the code, please follow the instructions step-by-step.
Fundamental Components
The following fundamental components are needed:
gcc
, version > 8.0;make
, version > 3.8;OpenMPI
, version > 3.0, if OpenMPI is enabled;nvcc
, version > 11.0, if CUDA is enabled;
Third-party Libraries
Boost
and Eigen
Boost
and Eigen
are two header-only libraries that do not need compilation. They can be obtained from:
Boost
: https://www.boost.org/Eigen
: https://eigen.tuxfamily.org/
After you download the source files, decompress them. You will find folders named boost
and Eigen
, respectively, in their top directories. Copy boost
and Eigen
to a suitable path, say /home/zhang/libs
. This will be value for $INCBOOST
and INCEIGEN
in the corresponding Makefile.
Of course, if your system has already installed Boost
and Eigen
somewhere, you can use those then.
libxc
libxc
is a density functional library. It can be obtained from https://www.tddft.org/programs/Libxc/. You can compile it using the following instructions:
$ tar -xzf libxc-x.x.x.tar.gz
cd libxc-x.x.x
$ mkdir bin
$ ./configure --prefix=/home/zhang/libs/libxc
$ make
$ make install $
Now, all libxc
files are available in /home/zhang/libs/libxc
.
Of course, if your system has already installed libxc
somewhere, you can use it then.
dftd3-lib
dftd3-lib
is a library for carrying out DFT-D3 calculations. It can be obtained from https://github.com/dftbplus/dftd3-lib. You can compile it using the following instructions:
$ unzip dftd3-lib-master.zip
cd dftd3-lib-master
$ make lib
$ cp lib /home/zhang/libs/dftd3-lib -r $
Of course, if your system has already installed dftd3-lib
somewhere, you can use it then.
Edit Makefile
After decompressing the source file archive, you can find several Makefiles:
Makefile-win-cpu |
Native Windows version, OpenMP parallelized. |
Makefile-linux-cpu |
Linux version, OpenMP parallelized. |
Makefile-linux-gpu |
Linux version, OpenMP parallelized, GPU enabled. |
Open the suitable one, say Makefile-linux-cpu
, you can find the following:
CODEINFO = -DCodeCommit="\"`git rev-parse HEAD`\"" \
-DCodeFlag="\"official version\"" \
-DCodeMajorVer=0 \
-DCodeMinorVer=1 \
-DCodeUser="\"`whoami | sed 's/\\\\/\\\\\\\\/g'`\"" \
-DCodeMachine="\"`hostname`\"" \
-DCodeCompiler="\"`$(CXX) --version | head -n 1`"\" \
-DCodeCompFlags="\"$(CXXFLAG)"\" \
-DCodeLibs="\"$(LIBS)"\" \
-DOSLinux \
-DNDEBUG
VERSION = linux-cpu
CXX = g++
CXXFLAG = -O2 -fno-exceptions --std=c++17 -fopenmp -ffast-math -fno-finite-math-only -fexpensive-optimizations -Wall -mavx -mavx2 -mavx512f -mfma
CC = gcc
CCFLAG = -O2 -fopenmp -Wall
FC = gfortran
FCFLAG = -O2 -fopenmp -Wall
NCC = nvcc
NCCFLAG = -O2 -use_fast_math -arch=compute_75 -code=sm_75
# Third-party library
LIBGNU = -lgfortran -lquadmath
LIBXC = /opt/libxc-5.1.5/lib/libxc.a
LIBDFTD = /opt/dftd3-lib-0.9/lib/libdftd3.a
LIBJSON =
LIBCUDA = /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudart_static.a -ldl -lrt
LIBSPONGE = /opt/lib/libSPONGE.so
LIBS = $(LIBXC) $(LIBDFTD) $(LIBJSON) $(LIBGNU)
# Third-party include
INCBOOST = -I/opt/lib/boost_1_76_0
INCEIGEN = -I/opt/lib/eigen-3.4-rc1
INCLIBXC = -I/opt/libxc-5.1.5/include
INCJSON =
INCCUDA = -I/usr/local/cuda-11.4/targets/x86_64-linux/include/
INCS = $(INCBOOST) $(INCEIGEN) $(INCLIBXC) $(INCJSON)
- You can modify the macro
CodeFlag
to give the code a unique identifier. - You can change
CXXFLAG
orNCCFLAG
to add suitable optimization options according to your systems. - You should change
LIBXC
,INCBOOST
, etc. to provide the correct paths of libraries and header files.
Compile
After editing your Makefile, say Makefile-linux-cpu
, just run the following command:
$ make -f Makefile-linux-cpu -j
After a long time, everything is ready in bin
. You can copy bin
to anywhere you like.