-
Notifications
You must be signed in to change notification settings - Fork 61
Failed to link targets when building VASP+DFTD4 #216
Copy link
Copy link
Closed
Labels
VASPRelated to VASPRelated to VASP
Description
Describe the bug
Failed to link targets when building VASP+DFTD4
To Reproduce
# 1. set environment
$ source /path/to/oneapi/setvars.sh
$ module load dft4_api
# 2. build vasp
$ cd /path/to/vasp
$ vim makefile.include
#
# CPP_OPTIONS += -DDFTD4
# DFTD4_ROOT ?= /path/to/dftd4/
# LLIBS += -L$(DFTD4_ROOT)/lib64 -ldftd4
# INCS += -I$(DFTD4_ROOT)/include -I$(DFTD4_ROOT)/include/dftd4/IntelLLVM-2023.1.0
#
# LLIBS and INCS are the result of:
# pkg-config --libs dftd4_api and pkg-config --cflag dftd4_api
# separately.
$ make veryclean
$ make DEPS=1 -j
#
# the below is the make output
#
mpiifort -qmkl=sequential # <-- here errors occurs when linking targets
-o vasp c2f_interface.o ... subdftd3.o subdftd4.o ... main.o
-Llib -ldmy -Lparser -lparser -lstdc++
-L/path/to/oneapi/mkl/2023.1.0/lib/intel64
-lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
-L/path/to/hdf5/latest/lib -lhdf5_fortran
-L/path/to/dftd4/lib64 -ldftd4
# error output:
/path/to/dftd4_api/lib64/libdftd4.a(compat.f90.o): In function `dftd4_compat_mp_d4_calculation_':
/path/to/dftd4_install/src/dftd4/compat.f90:111: undefined reference to `mctc_io_structure_mp_new_structure_num_'
/path/to/dftd4_install//3.6.0/src/dftd4/compat.f90:125: undefined reference to `mctc_io_math_mp_matinv_3x3_'
#
... # (Here I truncate the error output because too many 'undefined reference to')
#
/path/to/dftd4_api/lib64/libdftd4.a(charge.f90.o): In function `dftd4_charge_mp_get_charges_':
/path/to/dftd4_install/src/dftd4/charge.f90:57: undefined reference to `multicharge_param_mp_new_eeq2019_model_'
/path/to/dftd4_install//src/dftd4/charge.f90:58: undefined reference to `multicharge_cutoff_mp_get_lattice_points_cutoff_'
/path/to/dftd4_install//src/dftd4/charge.f90:65: undefined reference to /path/to/dftd4_install//src/dftd4/charge.f90:66: undefined reference to `multicharge_ncoord_mp_get_coordination_number_'
/path/to/dftd4_install//src/dftd4/charge.f90:68: undefined reference to `multicharge_model_mp_solve_'
/path/to/dftd4_install//lib64/libdftd4.a(charge.f90.o):(.data+0x10): undefined reference to `multicharge_model_mp_solve_'
make[2]: *** [makefile:132: vasp] Error 1Expected behaviour
The linker can work properly when building VASP+DFTD4
Additional context
Using:
- OneAPI 2023.1.0
- VASP 6.2.1
- DFTD4 3.6.0 (build from source with CMake 3.27.3)
I Googled and found some Q&A related to 'undefined reference to':
- https://stackoverflow.com/questions/16088892/fortran-compilation-error-undefined-reference
- https://stackoverflow.com/questions/29639760/error-in-fortran-undefined-reference-to-subroutine
According to IanH (a stackoverflow user), this may because:
- Forget to
USEmodule in main programdft4.f90 - the procedure in module is not
PUBLIC
So I checked the source code of dft4, and nothing peculiar found.
How I checked:
Take thecharge.f90:57: undefined reference to `multicharge_param_mp_new_eeq2019_model_' in the last In function `dftd4_charge_mp_get_charges_': as an example:
$ cd /path/to/dftd4_install
$ vim ./src/dftd4/charge.f90
#
# 18 module dftd4_charge
#
# 21 use multicharge, only : mchrg_model_type, new_eeq2019_model, &
#
# 27 public :: get_charges
#
# 34 subroutine get_charges(mol, qvec, dqdr, dqdL)
# 35 !DEC$ ATTRIBUTES DLLEXPORT :: get_charges
#
# 70 end subroutine get_charges
#
# 73 end module dftd4_charge
$ vim ./subprojects/multicharge/src/multicharge/param.f90
#
# 16 module multicharge_param
#
# 25 public :: new_eeq2019_model
#
# 29 subroutine new_eeq2019_model(mol, model)
#
# 44 end subroutine new_eeq2019_model
#
# 46 end module multicharge_paramThe USE and PUBLIC are properly used, hmmm, weird...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
VASPRelated to VASPRelated to VASP