LCOV - code coverage report
Current view: top level - src - libint_wrapper.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 97.4 % 195 190
Test Date: 2026-11-24 01:22:08 Functions: 89.5 % 38 34

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief Interface to the Libint-Library or a c++ wrapper.
      10              : !> \par History
      11              : !>      11.2007 created [Manuel Guidon]
      12              : !>      10.2009 refactored [Manuel Guidon]
      13              : !> \author Manuel Guidon
      14              : ! **************************************************************************************************
      15              : MODULE libint_wrapper
      16              : 
      17              : #if(__LIBINT)
      18              : #include <libint2/libint2_params.h>
      19              : #include <libint2/config.h>
      20              : ! Borrow the scalar kernel scratch for each group without per-record profiling or accumulation state.
      21              : #if LIBINT_CONTRACTED_INTS && LIBINT2_MAX_VECLEN == 1 && !LIBINT2_FLOP_COUNT && !defined(LIBINT_FLOP_COUNT)
      22              : #if !defined(LIBINT_PROFILE) && !defined(LIBINT2_PROFILE) && !defined(LIBINT_ACCUM_INTS) && !defined(LIBINT2_ACCUM_INTS)
      23              : #define CP2K_LIBINT_IMAGE_CONTRACTION 1
      24              : #endif
      25              : #endif
      26              : #endif
      27              : 
      28              : ! maximum angular momentum to be supported in CP2K-LIBINT interface
      29              :    #:set libint_max_am_supported = 8
      30              : 
      31              :    USE ISO_C_BINDING, ONLY: C_ASSOCIATED, &
      32              :                             C_F_POINTER, &
      33              :                             C_NULL_PTR, &
      34              :                             C_NULL_FUNPTR, &
      35              :                             C_FUNPTR
      36              :    USE kinds, ONLY: dp
      37              : #if(__LIBINT)
      38              :    USE libint_f, ONLY: &
      39              :       libint2_build_eri, libint2_build_eri1, libint2_cleanup_eri, &
      40              :       libint2_cleanup_eri1, libint2_init_eri, libint2_init_eri1, libint2_static_cleanup, &
      41              :       libint2_static_init, libint_t, libint2_max_am_eri, libint2_init_3eri, libint2_cleanup_3eri, &
      42              :       libint2_init_2eri, libint2_cleanup_2eri, &
      43              :       libint2_build_2eri, libint2_build_3eri, libint2_build_3eri1, libint2_cleanup_3eri1, libint2_init_3eri1, &
      44              :       libint2_build_2eri1, libint2_cleanup_2eri1, libint2_init_2eri1
      45              : #endif
      46              :    USE orbital_pointers, ONLY: nco
      47              : #include "./base/base_uses.f90"
      48              : 
      49              :    IMPLICIT NONE
      50              :    PRIVATE
      51              :    PUBLIC :: get_eri_permutation, reorder_eri_block
      52              :    PUBLIC :: libint_can_contract_images, cp_libint_image_workspace_type, &
      53              :              cp_libint_get_image_eris, cp_libint_get_image_derivs
      54              : 
      55              : #if CP2K_LIBINT_IMAGE_CONTRACTION
      56              :    LOGICAL, PARAMETER :: libint_can_contract_images = .TRUE.
      57              : #else
      58              :    LOGICAL, PARAMETER :: libint_can_contract_images = .FALSE.
      59              : #endif
      60              :    PUBLIC :: cp_libint_t, prim_data_f_size, &
      61              :              libint_max_am, cp_libint_get_eris, cp_libint_get_derivs, &
      62              :              cp_libint_init_eri, cp_libint_init_eri1, cp_libint_cleanup_eri, &
      63              :              cp_libint_cleanup_eri1, cp_libint_static_init, cp_libint_static_cleanup, &
      64              :              cp_libint_set_contrdepth, &
      65              :              cp_libint_set_params_eri, cp_libint_set_params_eri_deriv, &
      66              :              cp_libint_init_3eri, cp_libint_cleanup_3eri, cp_libint_get_3eris, &
      67              :              cp_libint_init_2eri, cp_libint_cleanup_2eri, cp_libint_get_2eris, &
      68              :              cp_libint_get_3eri_derivs, cp_libint_init_3eri1, cp_libint_cleanup_3eri1, &
      69              :              cp_libint_get_2eri_derivs, cp_libint_init_2eri1, cp_libint_cleanup_2eri1
      70              : 
      71              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'libint_wrapper'
      72              : 
      73              : #if(__LIBINT)
      74              :    INTEGER, PARAMETER :: libint_max_am = libint2_max_am_eri
      75              : #else
      76              :    INTEGER, PARAMETER :: libint_max_am = 0
      77              : #endif
      78              : 
      79              :    INTEGER, PARAMETER :: prim_data_f_size = 4*(libint_max_am) + 1
      80              : 
      81              : !> \brief Prepared primitive in original center order for the legacy Libint backend.
      82              : !> \note Zero exponents denote dummy centers. Fm contains orders zero through prepared_max_order.
      83              :    TYPE, PUBLIC :: eri_primitive_data_type
      84              :       INTEGER :: prepared_max_order = -1
      85              :       REAL(dp) :: centers(3, 4) = 0.0_dp, exponents(4) = 0.0_dp
      86              :       REAL(dp) :: P(3) = 0.0_dp, Q(3) = 0.0_dp, W(3) = 0.0_dp
      87              :       REAL(dp) :: ZetaInv = 0.0_dp, EtaInv = 0.0_dp, ZetapEtaInv = 0.0_dp, Rho = 0.0_dp
      88              :       REAL(dp) :: Fm(prim_data_f_size) = 0.0_dp
      89              :    END TYPE eri_primitive_data_type
      90              : 
      91              :    TYPE :: cp_libint_t
      92              :       PRIVATE
      93              : #if(__LIBINT)
      94              :       TYPE(libint_t), DIMENSION(1) :: prv
      95              : #else
      96              :       INTEGER :: unused = -1
      97              : #endif
      98              :    END TYPE cp_libint_t
      99              : 
     100              : !> \brief Storage for one group of native records. Its leading record borrows the kernel scratch.
     101              :    TYPE :: cp_libint_image_workspace_type
     102              :       PRIVATE
     103              : #if(__LIBINT)
     104              :       TYPE(libint_t), ALLOCATABLE :: records(:)
     105              : #else
     106              :       INTEGER :: unused = -1
     107              : #endif
     108              :    END TYPE cp_libint_image_workspace_type
     109              : 
     110              : #if(__LIBINT)
     111              :    INTERFACE
     112              :       ! Keep the indirect kernel call on the C side of the interoperability boundary.
     113              :       SUBROUTINE cp_libint_build(build, libint) BIND(C, NAME="cp2k_libint_build")
     114              :          IMPORT :: C_FUNPTR, libint_t
     115              :          TYPE(C_FUNPTR), VALUE :: build
     116              :          TYPE(libint_t), DIMENSION(*) :: libint
     117              :       END SUBROUTINE cp_libint_build
     118              :    END INTERFACE
     119              : 
     120              :    INTERFACE build_eri_kernel
     121              :       MODULE PROCEDURE build_eri_kernel_2c, build_eri_kernel_3c, build_eri_kernel_4c
     122              :    END INTERFACE build_eri_kernel
     123              : #endif
     124              : 
     125              : CONTAINS
     126              : 
     127              : ! **************************************************************************************************
     128              : !> \brief Select the canonical center order required by generated Libint kernels.
     129              : !> \param la original first-center angular momentum
     130              : !> \param lb original second-center angular momentum
     131              : !> \param lc original third-center angular momentum
     132              : !> \param ld original fourth-center angular momentum
     133              : !> \param permutation original center index for each canonical center
     134              : ! **************************************************************************************************
     135    298243064 :    PURE SUBROUTINE get_eri_permutation(la, lb, lc, ld, permutation)
     136              :       INTEGER, INTENT(IN)                                :: la, lb, lc, ld
     137              :       INTEGER, INTENT(OUT)                               :: permutation(4)
     138              : 
     139    298243064 :       permutation = [1, 2, 3, 4]
     140    473479580 :       IF (la < lb) permutation(1:2) = [2, 1]
     141    501686957 :       IF (lc < ld) permutation(3:4) = [4, 3]
     142    818248534 :       IF (la + lb > lc + ld) permutation = permutation([3, 4, 1, 2])
     143    298243064 :    END SUBROUTINE get_eri_permutation
     144              : 
     145              : ! **************************************************************************************************
     146              : !> \brief Restore original Cartesian axes and derivative center labels.
     147              : !> \param source canonical block with the fourth Cartesian index varying fastest
     148              : !> \param destination original block with the first Cartesian index varying fastest
     149              : !> \param ncart Cartesian shell sizes in original center order
     150              : !> \param permutation original center index for each canonical center
     151              : !> \param ncomponents one integral component or twelve center derivatives
     152              : !> \param nplanes number of independent planes
     153              : ! **************************************************************************************************
     154   1228600449 :    PURE SUBROUTINE reorder_eri_block(source, destination, ncart, permutation, ncomponents, nplanes)
     155              :       INTEGER, INTENT(IN)                                :: ncart(4), permutation(4), ncomponents, &
     156              :                                                             nplanes
     157              :       REAL(dp), INTENT(OUT) :: destination(PRODUCT(ncart), ncomponents, nplanes)
     158              :       REAL(dp), INTENT(IN) :: source(PRODUCT(ncart), ncomponents, nplanes)
     159              : 
     160              :       INTEGER                                            :: component, extent(4), i, isource, j, k, &
     161              :                                                             l, output_component, p1, p2, p3, p4, &
     162              :                                                             plane, stride(4)
     163              : 
     164    682555805 :       stride = [1, ncart(1), ncart(1)*ncart(2), ncart(1)*ncart(2)*ncart(3)]
     165   1365111610 :       stride = stride(permutation)
     166    682555805 :       extent = ncart(permutation)
     167              :       ! Read the Libint block contiguously and restore the original Fortran layout with strides.
     168    274892620 :       DO plane = 1, nplanes
     169    766913442 :          DO component = 1, ncomponents
     170    492020822 :             output_component = component
     171    492020822 :             IF (ncomponents == 12) THEN
     172    385788396 :                output_component = 3*(permutation((component - 1)/3 + 1) - 1) + MOD(component - 1, 3) + 1
     173              :             END IF
     174    492020822 :             isource = 0
     175    492020822 :             p1 = 1
     176   1457479364 :             DO i = 1, extent(1)
     177    827077083 :                p2 = p1
     178   1743288064 :                DO j = 1, extent(2)
     179    916210981 :                   p3 = p2
     180   4226618718 :                   DO k = 1, extent(3)
     181   3310407737 :                      p4 = p3
     182  10210765758 :                      DO l = 1, extent(4)
     183   6900358021 :                         isource = isource + 1
     184   6900358021 :                         destination(p4, output_component, plane) = source(isource, component, plane)
     185  10210765758 :                         p4 = p4 + stride(4)
     186              :                      END DO
     187   4226618718 :                      p3 = p3 + stride(3)
     188              :                   END DO
     189   1743288064 :                   p2 = p2 + stride(2)
     190              :                END DO
     191   1319097905 :                p1 = p1 + stride(1)
     192              :             END DO
     193              :          END DO
     194              :       END DO
     195    136511161 :    END SUBROUTINE reorder_eri_block
     196              : 
     197              : #if(__LIBINT)
     198              :    #:for rank in range(2, 5)
     199              : ! **************************************************************************************************
     200              : !> \brief Validate and invoke a generated Libint kernel without indexing outside its task table.
     201              : !> \param records native primitive records, starting with the one holding the scratch
     202              : !> \param kernels zero-based kernel table for this integral task and derivative order
     203              : !> \param angular_momenta indices in the table's own center order
     204              : !> \param kernel_name integral task used in diagnostics
     205              : ! **************************************************************************************************
     206    358802060 :       SUBROUTINE build_eri_kernel_${rank}$c(records, kernels, angular_momenta, kernel_name)
     207              :          TYPE(libint_t), INTENT(INOUT) :: records(*)
     208              :          TYPE(C_FUNPTR), INTENT(IN) :: kernels(${", ".join(["0:"]*rank)}$)
     209              :          INTEGER, INTENT(IN) :: angular_momenta(${rank}$)
     210              :          CHARACTER(LEN=*), INTENT(IN) :: kernel_name
     211              : 
     212              :          CHARACTER(LEN=160) :: error_msg
     213              :          TYPE(C_FUNPTR) :: build_funptr
     214              : 
     215    358802060 :          build_funptr = C_NULL_FUNPTR
     216   3408852432 :          IF (ALL(angular_momenta >= LBOUND(kernels)) .AND. ALL(angular_momenta <= UBOUND(kernels))) THEN
     217    358802060 :             build_funptr = kernels(${", ".join("angular_momenta(" + str(i) + ")" for i in range(1, rank + 1))}$)
     218              :          END IF
     219    358802060 :          IF (.NOT. C_ASSOCIATED(build_funptr)) THEN
     220              :             WRITE (error_msg, '(A,${rank}$(I0,1X))') &
     221            0 :                "LIBINT has no "//TRIM(kernel_name)//" kernel for angular momenta: ", angular_momenta
     222            0 :             CPABORT(TRIM(error_msg))
     223              :          END IF
     224    358802060 :          CALL cp_libint_build(build_funptr, records)
     225    358802060 :       END SUBROUTINE build_eri_kernel_${rank}$c
     226              : 
     227              :    #:endfor
     228              : #endif
     229              : 
     230              :    #! Emit the same primitive packing for the scalar setter and image groups.
     231              :    #:def pack_eri_fields(record, grouped)
     232              :       INTEGER :: pair_order(2)
     233              :       REAL(dp) :: product_centers(3, 2), inverse_exponents(2)
     234              : 
     235              :       CPASSERT(m_max <= params%prepared_max_order)
     236              : 
     237              :       pair_order = [1, 2]
     238              :       IF (permutation(1) > 2) pair_order = [2, 1]
     239              :       product_centers(:, 1) = params%P
     240              :       product_centers(:, 2) = params%Q
     241              :       inverse_exponents = [params%ZetaInv, params%EtaInv]
     242              : 
     243              :       ASSOCIATE (A => params%centers(:, permutation(1)), B => params%centers(:, permutation(2)), &
     244              :                  C => params%centers(:, permutation(3)), D => params%centers(:, permutation(4)), &
     245              :                  P => product_centers(:, pair_order(1)), Q => product_centers(:, pair_order(2)), &
     246              :                  W => params%W, ZetaInv => inverse_exponents(pair_order(1)), &
     247              :                  EtaInv => inverse_exponents(pair_order(2)), ZetapEtaInv => params%ZetapEtaInv, &
     248              :                  Rho => params%Rho, F => params%Fm)
     249              :          #:if grouped
     250              :             ${record}$%AB_x(1) = displacements(1, 1)
     251              :             ${record}$%AB_y(1) = displacements(2, 1)
     252              :             ${record}$%AB_z(1) = displacements(3, 1)
     253              :             ${record}$%CD_x(1) = displacements(1, 2)
     254              :             ${record}$%CD_y(1) = displacements(2, 2)
     255              :             ${record}$%CD_z(1) = displacements(3, 2)
     256              :          #:else
     257              :             ${record}$%AB_x(1) = A(1) - B(1)
     258              :             ${record}$%AB_y(1) = A(2) - B(2)
     259              :             ${record}$%AB_z(1) = A(3) - B(3)
     260              :             ${record}$%CD_x(1) = C(1) - D(1)
     261              :             ${record}$%CD_y(1) = C(2) - D(2)
     262              :             ${record}$%CD_z(1) = C(3) - D(3)
     263              :          #:endif
     264              : 
     265              :          ${record}$%PA_x(1) = P(1) - A(1)
     266              :          ${record}$%PA_y(1) = P(2) - A(2)
     267              :          ${record}$%PA_z(1) = P(3) - A(3)
     268              : 
     269              :          ${record}$%QC_x(1) = Q(1) - C(1)
     270              :          ${record}$%QC_y(1) = Q(2) - C(2)
     271              :          ${record}$%QC_z(1) = Q(3) - C(3)
     272              : 
     273              :          ${record}$%WP_x(1) = W(1) - P(1)
     274              :          ${record}$%WP_y(1) = W(2) - P(2)
     275              :          ${record}$%WP_z(1) = W(3) - P(3)
     276              : 
     277              :          ${record}$%WQ_x(1) = W(1) - Q(1)
     278              :          ${record}$%WQ_y(1) = W(2) - Q(2)
     279              :          ${record}$%WQ_z(1) = W(3) - Q(3)
     280              : 
     281              :          ${record}$%oo2z(1) = 0.5_dp*ZetaInv
     282              :          ${record}$%oo2e(1) = 0.5_dp*EtaInv
     283              :          ${record}$%oo2ze(1) = 0.5_dp*ZetapEtaInv
     284              :          ${record}$%roz(1) = Rho*ZetaInv
     285              :          ${record}$%roe(1) = Rho*EtaInv
     286              : 
     287              :          #:for m_max in range(0, 4*libint_max_am_supported)
     288              : #if 4*LIBINT2_MAX_AM_eri > ${m_max}$ - 1
     289              : 
     290              :             IF (${m_max}$ <= m_max) THEN
     291              :                ${record}$%f_aB_s___0__s___1___TwoPRep_s___0__s___1___Ab__up_${m_max}$ (1) &
     292              :                   = F(${m_max}$+1)
     293              :             END IF
     294              : #endif
     295              :          #:endfor
     296              : 
     297              :       END ASSOCIATE
     298              :    #:enddef
     299              : 
     300              : ! **************************************************************************************************
     301              : !> \brief Fill an ERI backend from one prepared primitive and a pair-symmetry permutation.
     302              : !> \param libint backend workspace
     303              : !> \param params primitive data in original center order
     304              : !> \param permutation original center index for each backend center; preserves the ERI pair structure
     305              : !> \param m_max requested radial order, not exceeding the prepared order
     306              : ! **************************************************************************************************
     307    282579299 :    SUBROUTINE cp_libint_set_params_eri(libint, params, permutation, m_max)
     308              :       TYPE(cp_libint_t), INTENT(INOUT) :: libint
     309              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params
     310              :       INTEGER, INTENT(IN) :: permutation(4), m_max
     311              : 
     312              : #if(__LIBINT)
     313   3108372289 :       $:pack_eri_fields("libint%prv(1)", False)
     314              : #else
     315              :       MARK_USED(libint)
     316              :       MARK_USED(params)
     317              :       MARK_USED(permutation)
     318              :       MARK_USED(m_max)
     319              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     320              : #endif
     321    282579299 :    END SUBROUTINE cp_libint_set_params_eri
     322              : 
     323              : #if CP2K_LIBINT_IMAGE_CONTRACTION
     324              : ! **************************************************************************************************
     325              : !> \brief Pack one primitive into a native Libint record.
     326              : !> \param record native primitive storage
     327              : !> \param params primitive data in original center order
     328              : !> \param permutation original center index for each backend center
     329              : !> \param m_max highest required radial order
     330              : !> \param displacements shared pair displacements in backend order
     331              : ! **************************************************************************************************
     332    300598103 :    SUBROUTINE set_eri_primitive(record, params, permutation, m_max, displacements)
     333              :       TYPE(libint_t), INTENT(INOUT) :: record
     334              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params
     335              :       INTEGER, INTENT(IN) :: permutation(4), m_max
     336              :       REAL(dp), INTENT(IN) :: displacements(3, 2)
     337              : 
     338   3306579133 :       $:pack_eri_fields("record", True)
     339    300598103 :    END SUBROUTINE set_eri_primitive
     340              : #endif
     341              : 
     342              : ! **************************************************************************************************
     343              : !> \brief Fill common ERI fields and the additional first-derivative recurrence fields.
     344              : !> \param libint backend workspace
     345              : !> \param params primitive data in original center order
     346              : !> \param permutation original center index for each backend center; preserves the ERI pair structure
     347              : !> \param m_max requested radial order, including the first-derivative increment
     348              : ! **************************************************************************************************
     349     60666782 :    SUBROUTINE cp_libint_set_params_eri_deriv(libint, params, permutation, m_max)
     350              :       TYPE(cp_libint_t), INTENT(INOUT) :: libint
     351              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params
     352              :       INTEGER, INTENT(IN) :: permutation(4), m_max
     353              : 
     354     60666782 :       CALL cp_libint_set_params_eri(libint, params, permutation, m_max)
     355              : #if(__LIBINT)
     356     60666782 :       CALL set_eri_derivative(libint%prv(1), params, permutation)
     357              : #endif
     358     60666782 :    END SUBROUTINE cp_libint_set_params_eri_deriv
     359              : 
     360              : #if(__LIBINT)
     361              : ! **************************************************************************************************
     362              : !> \brief Pack the remaining first-derivative recurrence fields.
     363              : !> \param record native primitive storage
     364              : !> \param params primitive data in original center order
     365              : !> \param permutation original center index for each backend center
     366              : ! **************************************************************************************************
     367    111287660 :    SUBROUTINE set_eri_derivative(record, params, permutation)
     368              :       TYPE(libint_t), INTENT(INOUT) :: record
     369              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params
     370              :       INTEGER, INTENT(IN) :: permutation(4)
     371              :       REAL(dp) :: P(3), exponents(4), gammap, gammaq, gammapq, rhop, rhoq
     372              : 
     373    445150640 :       P = params%P
     374    192954676 :       IF (permutation(1) > 2) P = params%Q
     375    556438300 :       exponents = params%exponents(permutation)
     376              :       ASSOCIATE (B => params%centers(:, permutation(2)), &
     377              :                  Zeta_A => exponents(1), Zeta_B => exponents(2), &
     378              :                  Zeta_C => exponents(3), Zeta_D => exponents(4))
     379    111287660 :          record%PB_x(1) = P(1) - B(1)
     380    111287660 :          record%PB_y(1) = P(2) - B(2)
     381    111287660 :          record%PB_z(1) = P(3) - B(3)
     382              : 
     383    111287660 :          record%two_alpha0_bra(1) = 2.0_dp*Zeta_A
     384    111287660 :          record%two_alpha0_ket(1) = 2.0_dp*Zeta_B
     385    111287660 :          record%two_alpha1_ket(1) = 2.0_dp*Zeta_D
     386              : 
     387    111287660 :          gammap = Zeta_A + Zeta_B
     388    111287660 :          gammaq = Zeta_C + Zeta_D
     389    111287660 :          gammapq = gammap*gammaq/(gammap + gammaq)
     390    111287660 :          record%alpha1_rho_over_zeta2(1) = Zeta_A*gammapq/(gammap*gammap)
     391    111287660 :          record%alpha2_rho_over_zeta2(1) = Zeta_B*gammapq/(gammap*gammap)
     392    111287660 :          record%alpha4_rho_over_eta2(1) = Zeta_D*gammapq/(gammaq*gammaq)
     393    111287660 :          record%alpha1_over_zetapluseta(1) = Zeta_A/(gammap + gammaq)
     394    111287660 :          record%alpha2_over_zetapluseta(1) = Zeta_B/(gammap + gammaq)
     395    111287660 :          record%alpha4_over_zetapluseta(1) = Zeta_D/(gammap + gammaq)
     396              : 
     397    111287660 :          rhop = Zeta_A*Zeta_B/gammap
     398    111287660 :          rhoq = Zeta_C*Zeta_D/gammaq
     399    111287660 :          record%rho12_over_alpha1(1) = rhop/Zeta_A
     400              : 
     401    111287660 :          record%rho34_over_alpha3(1) = rhoq/Zeta_C
     402              : 
     403              :       END ASSOCIATE
     404    111287660 :    END SUBROUTINE set_eri_derivative
     405              : #endif
     406              : ! **************************************************************************************************
     407              : !> \brief ...
     408              : !> \param n_d ...
     409              : !> \param n_c ...
     410              : !> \param n_b ...
     411              : !> \param n_a ...
     412              : !> \param lib ...
     413              : !> \param p_work ...
     414              : ! **************************************************************************************************
     415    194789313 :    SUBROUTINE cp_libint_get_eris(n_d, n_c, n_b, n_a, lib, p_work)
     416              :       INTEGER, INTENT(IN)                                :: n_d, n_c, n_b, n_a
     417              :       TYPE(cp_libint_t)                                  :: lib
     418              :       REAL(dp), DIMENSION(:), POINTER                    :: p_work
     419              : 
     420              : #if(__LIBINT)
     421    973946565 :       CALL build_eri_kernel(lib%prv, libint2_build_eri, [n_d, n_c, n_b, n_a], "4-center ERI")
     422              : 
     423    389578626 :       CALL C_F_POINTER(lib%prv(1)%targets(1), p_work, SHAPE=[nco(n_a)*nco(n_b)*nco(n_c)*nco(n_d)])
     424              : #else
     425              :       MARK_USED(n_d)
     426              :       MARK_USED(n_c)
     427              :       MARK_USED(n_b)
     428              :       MARK_USED(n_a)
     429              :       MARK_USED(lib)
     430              :       MARK_USED(p_work)
     431              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     432              : #endif
     433              : 
     434    194789313 :    END SUBROUTINE cp_libint_get_eris
     435              : 
     436              : ! **************************************************************************************************
     437              : !> \brief ...
     438              : !> \param n_c ...
     439              : !> \param n_b ...
     440              : !> \param n_a ...
     441              : !> \param lib ...
     442              : !> \param p_work ...
     443              : ! **************************************************************************************************
     444     50434992 :    SUBROUTINE cp_libint_get_3eris(n_c, n_b, n_a, lib, p_work)
     445              :       INTEGER, INTENT(IN)                                :: n_c, n_b, n_a
     446              :       TYPE(cp_libint_t)                                  :: lib
     447              :       REAL(dp), DIMENSION(:), POINTER                    :: p_work
     448              : 
     449              : #if(__LIBINT)
     450    201739968 :       CALL build_eri_kernel(lib%prv, libint2_build_3eri, [n_c, n_b, n_a], "3-center ERI")
     451              : 
     452    100869984 :       CALL C_F_POINTER(lib%prv(1)%targets(1), p_work, SHAPE=[nco(n_a)*nco(n_b)*nco(n_c)])
     453              : #else
     454              :       MARK_USED(n_c)
     455              :       MARK_USED(n_b)
     456              :       MARK_USED(n_a)
     457              :       MARK_USED(lib)
     458              :       MARK_USED(p_work)
     459              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     460              : #endif
     461              : 
     462     50434992 :    END SUBROUTINE cp_libint_get_3eris
     463              : 
     464              : ! **************************************************************************************************
     465              : !> \brief Copy independent 3-center derivatives into caller-owned compact scratch.
     466              : !> \param n_c ...
     467              : !> \param n_b ...
     468              : !> \param n_a ...
     469              : !> \param lib ...
     470              : !> \param p_work leading Cartesian block rows and 6 columns receive Cartesian derivative triplets
     471              : ! **************************************************************************************************
     472      4766024 :    SUBROUTINE cp_libint_get_3eri_derivs(n_c, n_b, n_a, lib, p_work)
     473              :       INTEGER, INTENT(IN)                                :: n_c, n_b, n_a
     474              :       TYPE(cp_libint_t)                                  :: lib
     475              :       REAL(dp), DIMENSION(:, :), INTENT(OUT)              :: p_work
     476              : 
     477              : #if(__LIBINT)
     478      4766024 :       REAL(dp), DIMENSION(:), POINTER                    :: p_work_tmp
     479              :       INTEGER :: i, ncart
     480              : 
     481      4766024 :       ncart = nco(n_a)*nco(n_b)*nco(n_c)
     482            0 :       CPASSERT(SIZE(p_work, 1) >= ncart)
     483      4766024 :       CPASSERT(SIZE(p_work, 2) >= 6)
     484              : 
     485     19064096 :       CALL build_eri_kernel(lib%prv, libint2_build_3eri1, [n_c, n_b, n_a], "3-center ERI derivative")
     486              : 
     487              :       !Derivatives 1-3 can be obtained using translational invariance
     488     33362168 :       DO i = 4, 9
     489     28596144 :          NULLIFY (p_work_tmp)
     490     57192288 :          CALL C_F_POINTER(lib%prv(1)%targets(i), p_work_tmp, SHAPE=[ncart])
     491    246081188 :          p_work(1:ncart, i - 3) = p_work_tmp
     492              :       END DO
     493              : #else
     494              :       MARK_USED(n_c)
     495              :       MARK_USED(n_b)
     496              :       MARK_USED(n_a)
     497              :       MARK_USED(lib)
     498              :       MARK_USED(p_work)
     499              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     500              : #endif
     501              : 
     502      4766024 :    END SUBROUTINE cp_libint_get_3eri_derivs
     503              : 
     504              : ! **************************************************************************************************
     505              : !> \brief Copy independent 2-center derivatives into caller-owned compact scratch.
     506              : !> \param n_b ...
     507              : !> \param n_a ...
     508              : !> \param lib ...
     509              : !> \param p_work leading Cartesian block rows and 3 columns receive Cartesian derivative triplets
     510              : ! **************************************************************************************************
     511      6171264 :    SUBROUTINE cp_libint_get_2eri_derivs(n_b, n_a, lib, p_work)
     512              :       INTEGER, INTENT(IN)                                :: n_b, n_a
     513              :       TYPE(cp_libint_t)                                  :: lib
     514              :       REAL(dp), DIMENSION(:, :), INTENT(OUT)              :: p_work
     515              : 
     516              : #if(__LIBINT)
     517      6171264 :       REAL(dp), DIMENSION(:), POINTER                    :: p_work_tmp
     518              :       INTEGER :: i, ncart
     519              : 
     520      6171264 :       ncart = nco(n_a)*nco(n_b)
     521            0 :       CPASSERT(SIZE(p_work, 1) >= ncart)
     522      6171264 :       CPASSERT(SIZE(p_work, 2) >= 3)
     523              : 
     524     18513792 :       CALL build_eri_kernel(lib%prv, libint2_build_2eri1, [n_b, n_a], "2-center ERI derivative")
     525              : 
     526              :       !Derivatives 1-3 can be obtained using translational invariance
     527     24685056 :       DO i = 4, 6
     528     18513792 :          NULLIFY (p_work_tmp)
     529     37027584 :          CALL C_F_POINTER(lib%prv(1)%targets(i), p_work_tmp, SHAPE=[ncart])
     530    163967796 :          p_work(1:ncart, i - 3) = p_work_tmp
     531              :       END DO
     532              : #else
     533              :       MARK_USED(n_b)
     534              :       MARK_USED(n_a)
     535              :       MARK_USED(lib)
     536              :       MARK_USED(p_work)
     537              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     538              : #endif
     539              : 
     540      6171264 :    END SUBROUTINE cp_libint_get_2eri_derivs
     541              : 
     542              : ! **************************************************************************************************
     543              : !> \brief ...
     544              : !> \param n_c ...
     545              : !> \param n_b ...
     546              : !> \param n_a ...
     547              : !> \param lib ...
     548              : !> \param p_work ...
     549              : ! **************************************************************************************************
     550     11020270 :    SUBROUTINE cp_libint_get_2eris(n_b, n_a, lib, p_work)
     551              :       INTEGER, INTENT(IN)                                :: n_b, n_a
     552              :       TYPE(cp_libint_t)                                  :: lib
     553              :       REAL(dp), DIMENSION(:), POINTER                    :: p_work
     554              : 
     555              : #if(__LIBINT)
     556     33060810 :       CALL build_eri_kernel(lib%prv, libint2_build_2eri, [n_b, n_a], "2-center ERI")
     557              : 
     558     22040540 :       CALL C_F_POINTER(lib%prv(1)%targets(1), p_work, SHAPE=[nco(n_a)*nco(n_b)])
     559              : #else
     560              :       MARK_USED(n_b)
     561              :       MARK_USED(n_a)
     562              :       MARK_USED(lib)
     563              :       MARK_USED(p_work)
     564              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     565              : #endif
     566              : 
     567     11020270 :    END SUBROUTINE cp_libint_get_2eris
     568              : 
     569              : ! **************************************************************************************************
     570              : !> \brief ...
     571              : !> \param n_d ...
     572              : !> \param n_c ...
     573              : !> \param n_b ...
     574              : !> \param n_a ...
     575              : !> \param lib ...
     576              : !> \param work_forces ...
     577              : ! **************************************************************************************************
     578     56035936 :    SUBROUTINE cp_libint_get_derivs(n_d, n_c, n_b, n_a, lib, work_forces)
     579              :       INTEGER, INTENT(IN)                                :: n_d, n_c, n_b, n_a
     580              :       TYPE(cp_libint_t)                                  :: lib
     581              :       REAL(dp), DIMENSION(nco(n_a)*nco(n_b)*nco(n_c)*nco &
     582              :                           (n_d), 12)                                      :: work_forces
     583              : 
     584              : #if(__LIBINT)
     585    280179680 :       CALL build_eri_kernel(lib%prv, libint2_build_eri1, [n_d, n_c, n_b, n_a], "4-center ERI derivative")
     586     56035936 :       CALL copy_eri_derivatives(lib%prv(1), SIZE(work_forces, 1), work_forces)
     587              : #else
     588              :       MARK_USED(n_d)
     589              :       MARK_USED(n_c)
     590              :       MARK_USED(n_b)
     591              :       MARK_USED(n_a)
     592              :       MARK_USED(lib)
     593              :       MARK_USED(work_forces)
     594              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     595              : #endif
     596              : 
     597     56035936 :    END SUBROUTINE cp_libint_get_derivs
     598              : 
     599              : #if(__LIBINT)
     600              : ! **************************************************************************************************
     601              : !> \brief Copy generated first derivatives and restore the omitted center.
     602              : !> \param record first native record of the evaluated batch
     603              : !> \param ncart number of Cartesian integrals for each component
     604              : !> \param work_forces derivative blocks in canonical center order
     605              : ! **************************************************************************************************
     606     65417458 :    SUBROUTINE copy_eri_derivatives(record, ncart, work_forces)
     607              :       TYPE(libint_t), INTENT(IN) :: record
     608              :       INTEGER, INTENT(IN) :: ncart
     609              :       REAL(dp), INTENT(OUT) :: work_forces(ncart, 12)
     610     65417458 :       REAL(dp), POINTER :: p_work(:)
     611              :       INTEGER :: i, k
     612              : 
     613    850426954 :       DO k = 1, 12
     614    785009496 :          IF (k == 4 .OR. k == 5 .OR. k == 6) CYCLE
     615   1177514244 :          CALL C_F_POINTER(record%targets(k), p_work, SHAPE=[ncart])
     616   6955876732 :          DO i = 1, ncart
     617   7086711648 :             work_forces(i, k) = p_work(i)
     618              :          END DO
     619              :       END DO
     620              :       ! Libint omits the canonical second-center derivatives; recover them by translation invariance.
     621    261669832 :       DO k = 4, 6
     622   2362237216 :          DO i = 1, ncart
     623              :             work_forces(i, k) = -1.0_dp*(work_forces(i, k - 3) + &
     624   2296819758 :                                          work_forces(i, k + 3) + work_forces(i, k + 6))
     625              :          END DO
     626              :       END DO
     627     65417458 :    END SUBROUTINE copy_eri_derivatives
     628              : #endif
     629              : 
     630              : ! **************************************************************************************************
     631              : !> \brief Sum a group of image quartets with common pair displacements.
     632              : !> \param lib workspace owning the generated kernel scratch
     633              : !> \param images reusable storage for the native records
     634              : !> \param angular_momenta shell angular momenta in backend order
     635              : !> \param params image-resolved primitives in original center order
     636              : !> \param permutation original center index for each backend center
     637              : !> \param displacements shared pair displacements in original center order
     638              : !> \param p_work grouped Cartesian integrals, valid until the workspace is reused
     639              : ! **************************************************************************************************
     640     26202739 :    SUBROUTINE cp_libint_get_image_eris(lib, images, angular_momenta, params, permutation, displacements, p_work)
     641              :       TYPE(cp_libint_t), INTENT(IN) :: lib
     642              :       TYPE(cp_libint_image_workspace_type), INTENT(INOUT) :: images
     643              :       INTEGER, INTENT(IN) :: angular_momenta(4), permutation(4)
     644              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params(:)
     645              :       REAL(dp), INTENT(IN) :: displacements(3, 2)
     646              :       REAL(dp), POINTER :: p_work(:)
     647              : 
     648              : #if CP2K_LIBINT_IMAGE_CONTRACTION
     649    131013695 :       CALL pack_image_group(lib, images, params, permutation, SUM(angular_momenta), displacements, .FALSE.)
     650    131013695 :       CALL build_eri_kernel(images%records, libint2_build_eri, angular_momenta(4:1:-1), "4-center ERI")
     651    157216434 :       CALL C_F_POINTER(images%records(1)%targets(1), p_work, SHAPE=[PRODUCT(nco(angular_momenta))])
     652              : #else
     653              :       MARK_USED(lib)
     654              :       MARK_USED(images)
     655              :       MARK_USED(angular_momenta)
     656              :       MARK_USED(params)
     657              :       MARK_USED(permutation)
     658              :       MARK_USED(displacements)
     659              :       MARK_USED(p_work)
     660              :       CPABORT("This Libint build does not support image contraction.")
     661              : #endif
     662     26202739 :    END SUBROUTINE cp_libint_get_image_eris
     663              : 
     664              : ! **************************************************************************************************
     665              : !> \brief Sum unweighted image derivatives with common pair displacements.
     666              : !> \param lib workspace owning the generated kernel scratch
     667              : !> \param images reusable storage for the native records
     668              : !> \param angular_momenta shell angular momenta in backend order
     669              : !> \param params image-resolved primitives in original center order
     670              : !> \param permutation original center index for each backend center
     671              : !> \param displacements shared pair displacements in original center order
     672              : !> \param work_forces grouped derivative blocks in canonical center order
     673              : ! **************************************************************************************************
     674     46907610 :    SUBROUTINE cp_libint_get_image_derivs(lib, images, angular_momenta, params, permutation, displacements, work_forces)
     675              :       TYPE(cp_libint_t), INTENT(IN) :: lib
     676              :       TYPE(cp_libint_image_workspace_type), INTENT(INOUT) :: images
     677              :       INTEGER, INTENT(IN) :: angular_momenta(4), permutation(4)
     678              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params(:)
     679              :       REAL(dp), INTENT(IN) :: displacements(3, 2)
     680              :       REAL(dp), INTENT(OUT) :: work_forces(PRODUCT(nco(angular_momenta)), 12)
     681              : 
     682              : #if CP2K_LIBINT_IMAGE_CONTRACTION
     683     46907610 :       CALL pack_image_group(lib, images, params, permutation, SUM(angular_momenta) + 1, displacements, .TRUE.)
     684     46907610 :       CALL build_eri_kernel(images%records, libint2_build_eri1, angular_momenta(4:1:-1), "4-center ERI derivative")
     685      9381522 :       CALL copy_eri_derivatives(images%records(1), SIZE(work_forces, 1), work_forces)
     686              : #else
     687              :       MARK_USED(lib)
     688              :       MARK_USED(images)
     689              :       MARK_USED(angular_momenta)
     690              :       MARK_USED(params)
     691              :       MARK_USED(permutation)
     692              :       MARK_USED(displacements)
     693              :       MARK_USED(work_forces)
     694              :       CPABORT("This Libint build does not support image contraction.")
     695              : #endif
     696      9381522 :    END SUBROUTINE cp_libint_get_image_derivs
     697              : 
     698              : #if CP2K_LIBINT_IMAGE_CONTRACTION
     699              : ! **************************************************************************************************
     700              : !> \brief Prepare the native records of a group without allocating another kernel stack.
     701              : !> \param lib existing Libint workspace
     702              : !> \param images reusable storage for the native records
     703              : !> \param params image-resolved primitives in original center order
     704              : !> \param permutation original center index for each backend center
     705              : !> \param m_max highest required radial order
     706              : !> \param displacements shared pair displacements in original center order
     707              : !> \param derivative whether to populate first-derivative fields
     708              : ! **************************************************************************************************
     709     35584261 :    SUBROUTINE pack_image_group(lib, images, params, permutation, m_max, displacements, derivative)
     710              :       TYPE(cp_libint_t), INTENT(IN) :: lib
     711              :       TYPE(cp_libint_image_workspace_type), INTENT(INOUT) :: images
     712              :       TYPE(eri_primitive_data_type), INTENT(IN) :: params(:)
     713              :       INTEGER, INTENT(IN) :: permutation(4), m_max
     714              :       REAL(dp), INTENT(IN) :: displacements(3, 2)
     715              :       LOGICAL, INTENT(IN) :: derivative
     716              : 
     717              :       INTEGER :: i, n
     718              :       REAL(dp) :: backend_displacements(3, 2)
     719              : 
     720     35584261 :       n = SIZE(params)
     721     35584261 :       IF (ALLOCATED(images%records)) THEN
     722     35584020 :          IF (SIZE(images%records) < n) DEALLOCATE (images%records)
     723              :       END IF
     724     35586849 :       IF (.NOT. ALLOCATED(images%records)) ALLOCATE (images%records(n))
     725    142337044 :       backend_displacements(:, 1) = displacements(:, (permutation(1) + 1)/2)
     726    142337044 :       backend_displacements(:, 2) = displacements(:, (permutation(3) + 1)/2)
     727     55671485 :       IF (permutation(1) > permutation(2)) backend_displacements(:, 1) = -backend_displacements(:, 1)
     728     73937689 :       IF (permutation(3) > permutation(4)) backend_displacements(:, 2) = -backend_displacements(:, 2)
     729    336182364 :       DO i = 1, n
     730    300598103 :          CALL set_eri_primitive(images%records(i), params(i), permutation, m_max, backend_displacements)
     731    336182364 :          IF (derivative) CALL set_eri_derivative(images%records(i), params(i), permutation)
     732              :       END DO
     733              :       ! Only the leading record uses the stack and owns the contraction depth.
     734     35584261 :       images%records(1)%stack = lib%prv(1)%stack
     735     35584261 :       images%records(1)%vstack = lib%prv(1)%vstack
     736     35584261 :       images%records(1)%contrdepth = n
     737     35584261 :    END SUBROUTINE pack_image_group
     738              : #endif
     739              : 
     740         1640 :    SUBROUTINE cp_libint_init_eri(lib, max_am)
     741              :       TYPE(cp_libint_t)               :: lib
     742              :       INTEGER                         :: max_am
     743              : #if(__LIBINT)
     744         1640 :       CALL libint2_init_eri(lib%prv, max_am, C_NULL_PTR)
     745              : #else
     746              :       MARK_USED(lib)
     747              :       MARK_USED(max_am)
     748              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     749              : #endif
     750         1640 :    END SUBROUTINE cp_libint_init_eri
     751              : 
     752        21281 :    SUBROUTINE cp_libint_set_contrdepth(lib, contrdepth)
     753              :       TYPE(cp_libint_t) :: lib
     754              :       INTEGER           :: contrdepth
     755              : #if(__LIBINT)
     756              : #if LIBINT_CONTRACTED_INTS
     757        21281 :       lib%prv(1)%contrdepth = contrdepth
     758              : #else
     759              :       MARK_USED(lib)
     760              :       MARK_USED(contrdepth)
     761              : #endif
     762              : #else
     763              :       MARK_USED(lib)
     764              :       MARK_USED(contrdepth)
     765              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     766              : #endif
     767              : 
     768        21281 :    END SUBROUTINE cp_libint_set_contrdepth
     769              : 
     770         1640 :    SUBROUTINE cp_libint_init_eri1(lib, max_am)
     771              :       TYPE(cp_libint_t)               :: lib
     772              :       INTEGER                         :: max_am
     773              : #if(__LIBINT)
     774         1640 :       CALL libint2_init_eri1(lib%prv, max_am, C_NULL_PTR)
     775              : #else
     776              :       MARK_USED(lib)
     777              :       MARK_USED(max_am)
     778              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     779              : #endif
     780         1640 :    END SUBROUTINE cp_libint_init_eri1
     781              : 
     782        14867 :    SUBROUTINE cp_libint_init_3eri(lib, max_am)
     783              :       TYPE(cp_libint_t)               :: lib
     784              :       INTEGER                         :: max_am
     785              : #if(__LIBINT)
     786        14867 :       CALL libint2_init_3eri(lib%prv, max_am, C_NULL_PTR)
     787              : #else
     788              :       MARK_USED(lib)
     789              :       MARK_USED(max_am)
     790              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     791              : #endif
     792        14867 :    END SUBROUTINE cp_libint_init_3eri
     793              : 
     794          606 :    SUBROUTINE cp_libint_init_3eri1(lib, max_am)
     795              :       TYPE(cp_libint_t)               :: lib
     796              :       INTEGER                         :: max_am
     797              : #if(__LIBINT)
     798          606 :       CALL libint2_init_3eri1(lib%prv, max_am, C_NULL_PTR)
     799              : #else
     800              :       MARK_USED(lib)
     801              :       MARK_USED(max_am)
     802              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     803              : #endif
     804          606 :    END SUBROUTINE cp_libint_init_3eri1
     805              : 
     806          412 :    SUBROUTINE cp_libint_init_2eri1(lib, max_am)
     807              :       TYPE(cp_libint_t)               :: lib
     808              :       INTEGER                         :: max_am
     809              : #if(__LIBINT)
     810          412 :       CALL libint2_init_2eri1(lib%prv, max_am, C_NULL_PTR)
     811              : #else
     812              :       MARK_USED(lib)
     813              :       MARK_USED(max_am)
     814              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     815              : #endif
     816          412 :    END SUBROUTINE cp_libint_init_2eri1
     817              : 
     818         2116 :    SUBROUTINE cp_libint_init_2eri(lib, max_am)
     819              :       TYPE(cp_libint_t)               :: lib
     820              :       INTEGER                         :: max_am
     821              : #if(__LIBINT)
     822         2116 :       CALL libint2_init_2eri(lib%prv, max_am, C_NULL_PTR)
     823              : #else
     824              :       MARK_USED(lib)
     825              :       MARK_USED(max_am)
     826              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     827              : #endif
     828         2116 :    END SUBROUTINE cp_libint_init_2eri
     829              : 
     830         1640 :    SUBROUTINE cp_libint_cleanup_eri(lib)
     831              :       TYPE(cp_libint_t)               :: lib
     832              : #if(__LIBINT)
     833         1640 :       CALL libint2_cleanup_eri(lib%prv)
     834              : #else
     835              :       MARK_USED(lib)
     836              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     837              : #endif
     838         1640 :    END SUBROUTINE cp_libint_cleanup_eri
     839              : 
     840         1640 :    SUBROUTINE cp_libint_cleanup_eri1(lib)
     841              :       TYPE(cp_libint_t)               :: lib
     842              : #if(__LIBINT)
     843         1640 :       CALL libint2_cleanup_eri1(lib%prv)
     844              : #else
     845              :       MARK_USED(lib)
     846              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     847              : #endif
     848         1640 :    END SUBROUTINE cp_libint_cleanup_eri1
     849              : 
     850        14867 :    SUBROUTINE cp_libint_cleanup_3eri(lib)
     851              :       TYPE(cp_libint_t)               :: lib
     852              : #if(__LIBINT)
     853        14867 :       CALL libint2_cleanup_3eri(lib%prv)
     854              : #else
     855              :       MARK_USED(lib)
     856              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     857              : #endif
     858        14867 :    END SUBROUTINE cp_libint_cleanup_3eri
     859              : 
     860          606 :    SUBROUTINE cp_libint_cleanup_3eri1(lib)
     861              :       TYPE(cp_libint_t)               :: lib
     862              : #if(__LIBINT)
     863          606 :       CALL libint2_cleanup_3eri1(lib%prv)
     864              : #else
     865              :       MARK_USED(lib)
     866              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     867              : #endif
     868          606 :    END SUBROUTINE cp_libint_cleanup_3eri1
     869              : 
     870          412 :    SUBROUTINE cp_libint_cleanup_2eri1(lib)
     871              :       TYPE(cp_libint_t)               :: lib
     872              : #if(__LIBINT)
     873          412 :       CALL libint2_cleanup_2eri1(lib%prv)
     874              : #else
     875              :       MARK_USED(lib)
     876              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     877              : #endif
     878          412 :    END SUBROUTINE cp_libint_cleanup_2eri1
     879              : 
     880         2116 :    SUBROUTINE cp_libint_cleanup_2eri(lib)
     881              :       TYPE(cp_libint_t)               :: lib
     882              : #if(__LIBINT)
     883         2116 :       CALL libint2_cleanup_2eri(lib%prv)
     884              : #else
     885              :       MARK_USED(lib)
     886              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     887              : #endif
     888         2116 :    END SUBROUTINE cp_libint_cleanup_2eri
     889              : 
     890         1492 :    SUBROUTINE cp_libint_static_init()
     891              : #if(__LIBINT)
     892         1492 :       CALL libint2_static_init()
     893              : #else
     894              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     895              : #endif
     896         1492 :    END SUBROUTINE cp_libint_static_init
     897              : 
     898         1492 :    SUBROUTINE cp_libint_static_cleanup()
     899              : #if(__LIBINT)
     900         1492 :       CALL libint2_static_cleanup()
     901              : #else
     902              :       CPABORT("This CP2K executable has not been linked against the required library libint.")
     903              : #endif
     904         1492 :    END SUBROUTINE cp_libint_static_cleanup
     905              : 
     906            0 : END MODULE libint_wrapper
        

Generated by: LCOV version 2.0-1