From 85b218c901b059b277ec1c48dc97c48d7ab4a9d5 Mon Sep 17 00:00:00 2001 From: Tammo van der Heide <vanderhe@uni-bremen.de> Date: Fri, 6 Dec 2024 11:38:43 +0100 Subject: [PATCH] Add support for libxc 7.x.x --- cmake/SkProgsUtils.cmake | 2 ++ common/include/common.fypp | 1 + sktwocnt/lib/twocnt.F90 | 7 +++++++ slateratom/lib/CMakeLists.txt | 4 ++-- .../lib/{xcfunctionals.f90 => xcfunctionals.F90} | 10 ++++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) rename slateratom/lib/{xcfunctionals.f90 => xcfunctionals.F90} (98%) diff --git a/cmake/SkProgsUtils.cmake b/cmake/SkProgsUtils.cmake index d9f5dfdf..4b442d46 100644 --- a/cmake/SkProgsUtils.cmake +++ b/cmake/SkProgsUtils.cmake @@ -55,6 +55,8 @@ function (skprogs_add_fypp_defines fyppflags) list(APPEND _fyppflags -DWITH_MPI) endif() + list(APPEND _fyppflags -DLIBXC_VERSION_MAJOR="${Libxc_VERSION_MAJOR}") + set(${fyppflags} ${_fyppflags} PARENT_SCOPE) endfunction() diff --git a/common/include/common.fypp b/common/include/common.fypp index 17ad7d6a..e5ccc492 100644 --- a/common/include/common.fypp +++ b/common/include/common.fypp @@ -15,6 +15,7 @@ #:set DEBUG = getvar('DEBUG', 0) #:set WITH_ASSERT = defined('WITH_ASSERT') or DEBUG > 0 #:set WITH_MPI = defined('WITH_MPI') +#:set LIBXC_VERSION_MAJOR = getvar('LIBXC_VERSION_MAJOR') #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/sktwocnt/lib/twocnt.F90 b/sktwocnt/lib/twocnt.F90 index 44f5c63a..754efe74 100644 --- a/sktwocnt/lib/twocnt.F90 +++ b/sktwocnt/lib/twocnt.F90 @@ -30,10 +30,17 @@ module twocnt use, intrinsic :: iso_c_binding, only : c_size_t +#:if LIBXC_VERSION_MAJOR == 6 use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_vxc,& & xc_f03_gga_vxc, XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_C_PBE,& & XC_GGA_X_B88, XC_GGA_C_LYP, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP,& & XC_HYB_GGA_XC_CAMY_B3LYP, XC_UNPOLARIZED, xc_f03_func_set_ext_params +#:elif LIBXC_VERSION_MAJOR == 7 + use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_vxc,& + & xc_f03_gga_vxc, xc_f03_func_set_ext_params, XC_UNPOLARIZED + use xc_f03_funcs_m, only : XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_C_PBE,& + & XC_GGA_X_B88, XC_GGA_C_LYP, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP, XC_HYB_GGA_XC_CAMY_B3LYP +#:endif implicit none private diff --git a/slateratom/lib/CMakeLists.txt b/slateratom/lib/CMakeLists.txt index 1c47c778..03df19ba 100644 --- a/slateratom/lib/CMakeLists.txt +++ b/slateratom/lib/CMakeLists.txt @@ -25,7 +25,6 @@ set(sources-f90 output.f90 total_energy.f90 utilities.f90 - xcfunctionals.f90 zora_routines.f90) set(sources-fpp @@ -34,7 +33,8 @@ set(sources-fpp confinement.F90 input.F90 lapackroutines.F90 - simplemixer.F90) + simplemixer.F90 + xcfunctionals.F90) skprogs_preprocess("${FYPP}" "${fypp_flags}" "F90" "f90" "${sources-fpp}" sources-f90-preproc) diff --git a/slateratom/lib/xcfunctionals.f90 b/slateratom/lib/xcfunctionals.F90 similarity index 98% rename from slateratom/lib/xcfunctionals.f90 rename to slateratom/lib/xcfunctionals.F90 index cb20cd34..7f4904f6 100644 --- a/slateratom/lib/xcfunctionals.f90 +++ b/slateratom/lib/xcfunctionals.F90 @@ -1,3 +1,5 @@ +#:include 'common.fypp' + !> Module related to supported xc-functionals of the slateratom code. module xcfunctionals @@ -5,10 +7,18 @@ module xcfunctionals use common_accuracy, only : dp use common_constants, only : rec4pi use utilities, only : zeroOutCpotOfEmptyDensitySpinChannels +#:if LIBXC_VERSION_MAJOR == 6 use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_exc_vxc,& & xc_f03_gga_exc_vxc, xc_f03_func_set_ext_params, XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW,& & XC_GGA_X_PBE, XC_GGA_X_B88, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP,& & XC_HYB_GGA_XC_CAMY_B3LYP, XC_GGA_C_PBE, XC_GGA_C_LYP, XC_POLARIZED +#:elif LIBXC_VERSION_MAJOR == 7 + use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_exc_vxc,& + & xc_f03_gga_exc_vxc, xc_f03_func_set_ext_params, XC_POLARIZED + use xc_f03_funcs_m, only : XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_X_B88,& + & XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP, XC_HYB_GGA_XC_CAMY_B3LYP, XC_GGA_C_PBE,& + & XC_GGA_C_LYP +#:endif implicit none private