Page 1 of 1

Compilation issues with Libxc and DFTD4

Posted: Sat Mar 23, 2024 5:33 pm
by shweta_choudhary
Dear Developers,

I am trying to compile VASP with Libxc (as I want to use meta-GGA functionals) and DFT-D4. I followed instructions from https://www.vasp.at/wiki/index.php/Makefile.include. Below is my makefile.include:

Code: Select all

# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxIFC\" \
              -DMPI -DMPI_BLOCK=8000 -Duse_collective \
              -DscaLAPACK \
              -DCACHE_SIZE=4000 \
              -Davoidalloc \
              -Dvasp6 \
              -Duse_bse_te \
              -Dtbdyn \
              -Dfock_dblbuf

CPP         = fpp -f_com=no -free -w0  $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)

FC          = mpiifort
FCL         = mpiifort

FREE        = -free -names lowercase

FFLAGS      = -assume byterecl -w

OFLAG       = -O3
OFLAG_IN    = $(OFLAG)
DEBUG       = -O0

OBJECTS     = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o

# For what used to be vasp.5.lib
CPP_LIB     = $(CPP)
FC_LIB      = $(FC)
CC_LIB      = icc
CFLAGS_LIB  = -O
FFLAGS_LIB  = -O1
FREE_LIB    = $(FREE)

OBJECTS_LIB = linpack_double.o

# For the parser library
CXX_PARS    = icpc
LLIBS       = -lstdc++

##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##

# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -xHOST
FFLAGS     += $(VASP_TARGET_CPU)
# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL        += -qmkl=sequential
MKLROOT    ?= /home/intel/oneapi/mkl/2022.0.2/
LLIBS      += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS        =-I$(MKLROOT)/include/fftw
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT  ?= /home/soft/vasp/hdf5/hdf5-1.14.3/hdf5/
LLIBS      += -L$(HDF5_ROOT)/lib/ -lhdf5_fortran
INCS       += -I$(HDF5_ROOT)/include/
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS    += -DVASP2WANNIER90
WANNIER90_ROOT ?= /home/soft/wannier/wannier90-3.1.0/
LLIBS          += -L$(WANNIER90_ROOT) -lwannier
#LIBXC
CPP_OPTIONS += -DUSELIBXC
LIBXC_ROOT  ?=/home/soft/vasp/libxc-6.2.2/build/
LLIBS       += -L$(LIBXC_ROOT)/lib64/ -lxcf03 -lxc
INCS        += -I$(LIBXC_ROOT)/include/
#Libbeef
CPP_OPTIONS  += -Dlibbeef
LIBBEEF_ROOT ?=/home/soft/vasp/libbeef
LLIBS        += -L$(LIBBEEF_ROOT)/lib/ -lbeef
#libMBD
CPP_OPTIONS += -DLIBMBD
LIBMBD_ROOT ?= /home/soft/vasp/libmbd
LLIBS       += -L$(LIBMBD_ROOT)/build/lib64/ -lmbd
INCS        += -I$(LIBMBD_ROOT)/build/include/modules/mbd/
#DFT-D4
CPP_OPTIONS += -DDFTD4
LLIBS       += $(shell pkg-config --libs dftd4)
INCS        += $(shell pkg-config --cflags dftd4)
The following error occurs:
with libxc:

Code: Select all

setex_struct.F(5): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [XC_F03_LIB_M]
      USE xc_f03_lib_m
----------^
setex_struct.F(114): error #6457: This derived type name has not been declared.   [XC_F03_FUNC_T]
      TYPE (xc_f03_func_t), SAVE :: LIBXC_FUNC_NSP(2),LIBXC_FUNC_SPN(2)
------------^
setex_struct.F(115): error #6457: This derived type name has not been declared.   [XC_F03_FUNC_INFO_T]
      TYPE (xc_f03_func_info_t), SAVE :: LIBXC_INFO_NSP(2),LIBXC_INFO_SPN(2)
------------^
compilation aborted for setex_struct.f90 (code 1)
make[2]: *** [setex_struct.o] Error 1
make[2]: Leaving directory `/home/soft/vasp/vasp.6.4.1/build/std'
cp: cannot stat ‘vasp’: No such file or directory
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/soft/vasp/vasp.6.4.1/build/std'
make: *** [std] Error 2
with dftd4:

Code: Select all

subdftd4.F(12): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [CLASS_SET]
   use class_set, only: dftd_options
-------^
subdftd4.F(13): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [CLASS_PARAM]
   use class_param, only: dftd_parameter
-------^
subdftd4.F(33): error #6457: This derived type name has not been declared.   [DFTD_OPTIONS]
      type(dftd_options) options
-----------^
subdftd4.F(34): error #6406: Conflicting attributes or multiple declaration of name.   [DFTD_PARAMETER]
      type(dftd_parameter) parameters
-----------^
subdftd4.F(61): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [CLASS_MOLECULE]
      use class_molecule, only: molecule
Could you please help?
Thanks!

Re: Compilation issues with Libxc and DFTD4

Posted: Sat Mar 23, 2024 10:14 pm
by andreas.singraber
Hello!

Looks like in both cases the compiler could not find the *.mod files of the DFT-D4 and Libxc libraries. Did you successfully compile the libraries before starting the VASP build process? I just tried this myself for the GNU compiler, for Libxc I used the instructions here, for DFT-D4 I used the CMake instructions listed here (you need to add -DWITH_API_V2=ON as listed further below on the github page).

If you compiled the libraries you should be able to find for both an include and lib directory. For DFT-D4 the contents are:

Code: Select all

lib:
drwxrwxr-x 6 andi andi    4096 Mar 23 22:11 cmake
-rw-r--r-- 1 andi andi 1536896 Mar 23 22:10 libdftd4.a
-rw-r--r-- 1 andi andi 1194106 Mar 23 22:10 libmctc-lib.a
-rw-r--r-- 1 andi andi 1360198 Mar 23 22:10 libmstore.a
-rw-r--r-- 1 andi andi  466424 Mar 23 22:10 libmulticharge.a
drwxrwxr-x 2 andi andi    4096 Mar 23 22:11 pkgconfig

include/dftd4/GNU-9.4.0:
-rw-r--r-- 1 andi andi 12680 Mar 23 22:10 class_molecule.mod
-rw-r--r-- 1 andi andi 12671 Mar 23 22:10 class_param.mod
-rw-r--r-- 1 andi andi 12690 Mar 23 22:10 class_results.mod
-rw-r--r-- 1 andi andi 12715 Mar 23 22:10 class_set.mod
-rw-r--r-- 1 andi andi 12642 Mar 23 22:10 class_wsc.mod
-rw-r--r-- 1 andi andi 13764 Mar 23 22:10 dftd4_api.mod
-rw-r--r-- 1 andi andi  2278 Mar 23 22:10 dftd4_blas.mod
-rw-r--r-- 1 andi andi  5365 Mar 23 22:10 dftd4_charge.mod
-rw-r--r-- 1 andi andi 13481 Mar 23 22:10 dftd4_compat.mod
-rw-r--r-- 1 andi andi  1908 Mar 23 22:10 dftd4_cutoff.mod
-rw-r--r-- 1 andi andi  5310 Mar 23 22:10 dftd4_damping_atm.mod
-rw-r--r-- 1 andi andi  5470 Mar 23 22:10 dftd4_damping.mod
-rw-r--r-- 1 andi andi  6491 Mar 23 22:10 dftd4_damping_rational.mod
-rw-r--r-- 1 andi andi  1861 Mar 23 22:10 dftd4_data_covrad.mod
-rw-r--r-- 1 andi andi  1416 Mar 23 22:10 dftd4_data_en.mod
-rw-r--r-- 1 andi andi  1407 Mar 23 22:10 dftd4_data_hardness.mod
-rw-r--r-- 1 andi andi  2335 Mar 23 22:10 dftd4_data.mod
-rw-r--r-- 1 andi andi  1858 Mar 23 22:10 dftd4_data_r4r2.mod
-rw-r--r-- 1 andi andi  1417 Mar 23 22:10 dftd4_data_zeff.mod
-rw-r--r-- 1 andi andi  9153 Mar 23 22:10 dftd4_disp.mod
-rw-r--r-- 1 andi andi 12760 Mar 23 22:10 dftd4.mod
-rw-r--r-- 1 andi andi  7040 Mar 23 22:10 dftd4_model.mod
-rw-r--r-- 1 andi andi  4368 Mar 23 22:10 dftd4_ncoord.mod
-rw-r--r-- 1 andi andi  8922 Mar 23 22:10 dftd4_numdiff.mod
-rw-r--r-- 1 andi andi  9754 Mar 23 22:10 dftd4_output.mod
-rw-r--r-- 1 andi andi  7165 Mar 23 22:10 dftd4_param.mod
-rw-r--r-- 1 andi andi  2493 Mar 23 22:10 dftd4_reference.mod
-rw-r--r-- 1 andi andi  2378 Mar 23 22:10 dftd4_utils.mod
-rw-r--r-- 1 andi andi   529 Mar 23 22:10 dftd4_version.mod
-rw-r--r-- 1 andi andi 12767 Mar 23 22:10 dfuncpar.mod
-rw-r--r-- 1 andi andi 12746 Mar 23 22:10 dispersion_calculator.mod
-rw-r--r-- 1 andi andi 12676 Mar 23 22:10 mctc_environment.mod
-rw-r--r-- 1 andi andi 12889 Mar 23 22:10 pbc_tools.mod
For Libxc I got:

Code: Select all

lib:
-rw-r--r--  1 andi andi 187255730 Mar 23 22:01 libxc.a
-rw-r--r--  1 andi andi     32744 Mar 23 22:01 libxcf03.a
-rwxr-xr-x  1 andi andi      1056 Mar 23 22:01 libxcf03.la
-rw-r--r--  1 andi andi     30904 Mar 23 22:01 libxcf90.a
-rwxr-xr-x  1 andi andi      1056 Mar 23 22:01 libxcf90.la
-rwxr-xr-x  1 andi andi       951 Mar 23 22:01 libxc.la
drwxrwxr-x  2 andi andi      4096 Mar 23 22:01 pkgconfig

include:
-rw-r--r--  1 andi andi 179889 Mar 23 22:01 libxc.bib
-rw-r--r--  1 andi andi  23394 Mar 23 22:01 xc_f03_lib_m.mod
-rw-r--r--  1 andi andi  23297 Mar 23 22:01 xc_f90_lib_m.mod
-rw-r--r--  1 andi andi  54529 Mar 23 22:01 xc_funcs.h
-rw-r--r--  1 andi andi   3614 Mar 23 22:01 xc_funcs_removed.h
-rw-r--r--  1 andi andi    107 Mar 23 22:01 xc_funcs_worker.h
-rw-r--r--  1 andi andi  28550 Mar 23 22:01 xc.h
-rw-r--r--  1 andi andi    495 Mar 23 22:01 xc_version.h
Can you verify that you got something similar for your compiler? If so, use the correct directories in the makefile.include lines with LLIBS and INCS and check if this improves the situation.

All the best,
Andreas Singraber

Re: Compilation issues with Libxc and DFTD4

Posted: Tue Mar 26, 2024 7:27 pm
by shweta_choudhary
Hi @Andreas Singraber,

Thanks for your reply. My libxc/lib and include contains all the above-mentioned files as yours. Still I am facing this following error:

Code: Select all

setex_struct.F(5): error #7013: This module file was not generated by any release of this compiler.   [XC_F03_LIB_M]
      USE xc_f03_lib_m
----------^
setex_struct.F(114): error #6457: This derived type name has not been declared.   [XC_F03_FUNC_T]
      TYPE (xc_f03_func_t), SAVE :: LIBXC_FUNC_NSP(2),LIBXC_FUNC_SPN(2)
------------^
setex_struct.F(115): error #6457: This derived type name has not been declared.   [XC_F03_FUNC_INFO_T]
      TYPE (xc_f03_func_info_t), SAVE :: LIBXC_INFO_NSP(2),LIBXC_INFO_SPN(2)
------------^
compilation aborted for setex_struct.f90 (code 1)
make[2]: *** [setex_struct.o] Error 1
make[2]: Leaving directory `/home/soft/vasp/vaspp/build/std'
cp: cannot stat ‘vasp’: No such file or directory
make[1]: *** [all] Error 1
make[1]: Leaving directory `/home/soft/vasp/vaspp/build/std'
make: *** [std] Error 2
libxc/lib:

Code: Select all

[user@login08 lib]$ ls
libxc.a  libxcf03.a  libxcf03.la  libxcf90.a  libxcf90.la  libxc.la  pkgconfig
libxc/include:

Code: Select all

[user@login08 include]$ ls
libxc.bib  xc_f03_lib_m.mod  xc_f90_lib_m.mod  xc_funcs.h  xc_funcs_removed.h  xc_funcs_worker.h  xc.h  xc_version.h
Thanks!

Re: Compilation issues with Libxc and DFTD4

Posted: Tue Mar 26, 2024 9:24 pm
by andreas.singraber
Hello!

Ok, I think we are one step closer to a successful build because now you are getting a different error:

Code: Select all

setex_struct.F(5): error #7013: This module file was not generated by any release of this compiler.   [XC_F03_LIB_M]
      USE xc_f03_lib_m
----------^
This means that the xc_f03_lib_m.mod was found but it was not created by the Intel compiler you are using for compiling VASP. Fortran *.mod files are unfortunately not compatible between different compilers, hence we need to compile every library that VASP links to with the same compiler. Please look up the documentations of Libxc and DFT-D4 on how to build them with the Intel compiler.

Best,
Andreas Singraber