From 1ff4b5af0f38e7bf212166b0515261951b07f8a2 Mon Sep 17 00:00:00 2001 From: Frederick Stein <43850145+fstein93@users.noreply.github.com> Date: Tue, 25 Jan 2022 12:54:45 +0100 Subject: [PATCH] Bump LibXC to version 5.2.0 (#1899) * Bump LibXC to version 8.2.0 * Fix redefined i_ref The behavior of the underlying routine changed such that xc_f03_func_info_get_references does not increase the counter if the next reference is not found. Before, this routine returned -1 instead. * Use LDA_X_ERF correctly Before LibXC 5.2, there was a misleading description of the functional. Because these tests implement range-separated MP2, we should adjust the regtests according to the revised documentation of LDA_X_ERF. --- src/xc/xc_libxc.F | 8 +++++++- src/xc/xc_libxc_wrap.F | 19 +++++++++++++------ tests/QS/regtest-rs-dhft/CH3-rsLDAlrMP2.inp | 5 ++--- tests/QS/regtest-rs-dhft/H2O-rsLDAlrMP2.inp | 5 ++--- tests/QS/regtest-rs-dhft/TEST_FILES | 4 ++-- .../toolchain/scripts/stage3/install_libxc.sh | 4 ++-- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/xc/xc_libxc.F b/src/xc/xc_libxc.F index ab5e6b7b44..b6255510f0 100644 --- a/src/xc/xc_libxc.F +++ b/src/xc/xc_libxc.F @@ -158,11 +158,15 @@ CONTAINS INTEGER :: length #if defined (__LIBXC) + CHARACTER(len=*), PARAMETER :: routineN = 'libxc_get_reference_length' + CHARACTER(LEN=default_string_length) :: func_name - INTEGER :: func_id + INTEGER :: func_id, handle TYPE(xc_f03_func_t) :: xc_func TYPE(xc_f03_func_info_t) :: xc_info + CALL timeset(routineN, handle) + func_name = libxc_params%section%name IF (func_name == "LIBXC" .OR. func_name == "KE_LIBXC") THEN CALL section_vals_val_get(libxc_params, "functional", c_val=func_name) @@ -182,6 +186,8 @@ CONTAINS length = xc_libxc_get_reference_length(xc_info) CALL xc_f03_func_end(xc_func) + + CALL timestop(handle) #else MARK_USED(libxc_params) MARK_USED(lsd) diff --git a/src/xc/xc_libxc_wrap.F b/src/xc/xc_libxc_wrap.F index d7254d7694..578a4a6552 100644 --- a/src/xc/xc_libxc_wrap.F +++ b/src/xc/xc_libxc_wrap.F @@ -159,18 +159,21 @@ CONTAINS TYPE(xc_f03_func_info_t), INTENT(IN) :: xc_info INTEGER :: length + CHARACTER(LEN=*), PARAMETER :: routineN = 'xc_libxc_get_reference_length' INTEGER, PARAMETER :: maxlen = 67 CHARACTER(LEN=128) :: descr_string CHARACTER(LEN=1024) :: doi_string, ref_string - INTEGER :: i, i_ref, idx, n_params + INTEGER :: i, i_ref, i_ref_old, n_params, handle TYPE(xc_f03_func_reference_t) :: xc_ref + CALL timeset(routineN, handle) + ! We are counting the number of necessary lines by carrying out a dry run of xc_libxc_wrap_info_refs i_ref = 0 - idx = 1 + i_ref_old = -1 length = 0 - DO WHILE (i_ref >= 0) + DO WHILE (i_ref >= 0 .AND. i_ref /= i_ref_old) ! information about functional references xc_ref = xc_f03_func_info_get_references(xc_info, i_ref) ref_string = xc_f03_func_reference_get_ref(xc_ref) @@ -187,11 +190,13 @@ CONTAINS length = length + LEN_TRIM(descr_string) + 3 IF (MOD(length, maxlen) /= 0) length = length + maxlen - MOD(length, maxlen) END DO - idx = idx + 1 + i_ref_old = i_ref END DO ! two additional lines for spin polarization, scaling factor and buffer length = length + 2*maxlen + CALL timestop(handle) + END FUNCTION xc_libxc_get_reference_length ! ************************************************************************************************** @@ -216,16 +221,17 @@ CONTAINS CHARACTER(LEN=1028) :: doi_string, ref_string ! conservative estimate of the necessary length: 2*1028+11=2067 CHARACTER(LEN=2067) :: tmp_string - INTEGER :: empty, first, handle, i, i_ref, idx, & + INTEGER :: empty, first, handle, i, i_ref, i_ref_old, idx, & last, n_params TYPE(xc_f03_func_reference_t) :: xc_ref CALL timeset(routineN, handle) i_ref = 0 + i_ref_old = -1 idx = 1 first = 1 - DO WHILE (i_ref >= 0) + DO WHILE (i_ref >= 0 .AND. i_ref /= i_ref_old) ! information about functional references xc_ref = xc_f03_func_info_get_references(xc_info, i_ref) ref_string = xc_f03_func_reference_get_ref(xc_ref) @@ -261,6 +267,7 @@ CONTAINS END IF END DO idx = idx + 1 + i_ref_old = i_ref END DO SELECT CASE (polarized) CASE (XC_UNPOLARIZED) diff --git a/tests/QS/regtest-rs-dhft/CH3-rsLDAlrMP2.inp b/tests/QS/regtest-rs-dhft/CH3-rsLDAlrMP2.inp index a1d58ef025..4f7de040f8 100644 --- a/tests/QS/regtest-rs-dhft/CH3-rsLDAlrMP2.inp +++ b/tests/QS/regtest-rs-dhft/CH3-rsLDAlrMP2.inp @@ -32,11 +32,10 @@ &END SCF &XC &XC_FUNCTIONAL - &LDA_X - &END LDA_X + # LDA_X_ERF is the short-range part of the functional &LDA_X_ERF _OMEGA ${MY_OMEGA} - SCALE -1.0 + SCALE 1.0 &END &LDA_C_PMGB06 SCALE -1.0 diff --git a/tests/QS/regtest-rs-dhft/H2O-rsLDAlrMP2.inp b/tests/QS/regtest-rs-dhft/H2O-rsLDAlrMP2.inp index 5730529a9b..81422f1545 100644 --- a/tests/QS/regtest-rs-dhft/H2O-rsLDAlrMP2.inp +++ b/tests/QS/regtest-rs-dhft/H2O-rsLDAlrMP2.inp @@ -33,11 +33,10 @@ &END SCF &XC &XC_FUNCTIONAL - &LDA_X - &END LDA_X + # LDA_X_ERF is the short-range part of the functional &LDA_X_ERF _OMEGA ${MY_OMEGA} - SCALE -1.0 + SCALE 1.0 &END &LDA_C_PMGB06 SCALE -1.0 diff --git a/tests/QS/regtest-rs-dhft/TEST_FILES b/tests/QS/regtest-rs-dhft/TEST_FILES index 0675c407d8..5d95ea9233 100644 --- a/tests/QS/regtest-rs-dhft/TEST_FILES +++ b/tests/QS/regtest-rs-dhft/TEST_FILES @@ -1,4 +1,4 @@ -CH3-rsLDAlrMP2.inp 11 1e-8 -7.724767496356234 -H2O-rsLDAlrMP2.inp 11 1e-8 -16.899255585036251 +CH3-rsLDAlrMP2.inp 11 1e-8 -7.337744306690559 +H2O-rsLDAlrMP2.inp 11 1e-8 -17.138844102419636 H2O-B2P3LYP.inp 11 1e-8 -17.030982292980237 #EOF diff --git a/tools/toolchain/scripts/stage3/install_libxc.sh b/tools/toolchain/scripts/stage3/install_libxc.sh index 338a69b940..0a2ba19761 100755 --- a/tools/toolchain/scripts/stage3/install_libxc.sh +++ b/tools/toolchain/scripts/stage3/install_libxc.sh @@ -9,8 +9,8 @@ [ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0 SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)" -libxc_ver="5.1.7" -libxc_sha256="1a818fdfe5c5f74270bc8ef0c59064e8feebcd66b8f642c08aecc1e7d125be34" +libxc_ver="5.2.0" +libxc_sha256="b6fee9abea24a0ecbdd7a69aba19bb78d546043217e8465f5d878aac0636a27e" source "${SCRIPT_DIR}"/common_vars.sh source "${SCRIPT_DIR}"/tool_kit.sh source "${SCRIPT_DIR}"/signal_trap.sh