LCOV - code coverage report
Current view: top level - src/hfxbase - hfx_contraction_methods.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 100.0 % 18 18
Test Date: 2026-11-24 01:22:08 Functions: 100.0 % 83 83

            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 Contains routines for contraction without dgemms.
      10              : !> \notes Contains specific routines for contraction. The compiler flag
      11              : !>        -D__MAX_CONTR defines the maximum angular momentum up to which
      12              : !>        specialized code will be used. Default setting is d-functions.
      13              : !>        Increasing -D__MAX_CONTR produces faster code but might overburden
      14              : !>        the optimization capabilities of some poor compilers.
      15              : !>        Templates are available up to l=10. The Fypp parameters lmax_specific
      16              : !>        and lmax_generic control the generated specialized routines and sparse
      17              : !>        cases in the generic routine; both default to 4 (g-functions).
      18              : !>        Fypp preserves compile-time dimensions and explicit sparse sums.
      19              : !> \par History
      20              : !>      07.2009 created [Manuel Guidon]
      21              : !> \author Manuel Guidon
      22              : ! **************************************************************************************************
      23              : 
      24              : MODULE hfx_contraction_methods
      25              : 
      26              : !** This defines the default behaviour
      27              : #ifndef __MAX_CONTR
      28              : #define __MAX_CONTR 2
      29              : #endif
      30              : 
      31              :    USE kinds, ONLY: dp
      32              : #include "../base/base_uses.f90"
      33              : 
      34              :    IMPLICIT NONE
      35              : 
      36              :    PRIVATE
      37              :    PUBLIC :: contract
      38              : 
      39              : CONTAINS
      40              : 
      41              :    #! Generation limits, independent of the compiler's __MAX_CONTR setting.
      42              :    #:set lmax_specific = 4
      43              :    #:set lmax_generic = 4
      44              : 
      45              :    #! Shell names and dimensions from the legacy generator, for l=0 through 10.
      46              :    #:set shells = 'spdfghijklm'
      47              :    #:set cartesian = [(l + 1)*(l + 2)//2 for l in range(len(shells))]
      48              :    #:set spherical = [2*l + 1 for l in range(len(shells))]
      49              :    #:assert 0 <= lmax_specific < len(shells)
      50              :    #:assert 0 <= lmax_generic < len(shells)
      51              :    #! Nonzero (Cartesian, spherical) indices, in the original accumulation order.
      52              :    #:set terms = [ &
      53              :       [(1, 1)], &
      54              :       [(1, 3), (2, 1), (3, 2)], &
      55              :       [(1, 3), (1, 5), (2, 1), (3, 4), (4, 3), (4, 5), (5, 2), (6, 3)], &
      56              :       [(1, 5), (1, 7), (2, 1), (2, 3), (3, 4), (3, 6), (4, 5), (4, 7), &
      57              :        (5, 2), (6, 5), (7, 1), (7, 3), (8, 4), (8, 6), (9, 3), (10, 4)], &
      58              :       [(1, 5), (1, 7), (1, 9), (2, 1), (2, 3), (3, 6), (3, 8), (4, 5), &
      59              :        (4, 9), (5, 2), (5, 4), (6, 5), (6, 7), (7, 1), (7, 3), (8, 6), &
      60              :        (8, 8), (9, 3), (10, 6), (11, 5), (11, 7), (11, 9), (12, 2), &
      61              :        (12, 4), (13, 5), (13, 7), (14, 4), (15, 5)], &
      62              :       [(1, 7), (1, 9), (1, 11), (2, 1), (2, 3), (2, 5), (3, 6), (3, 8), &
      63              :        (3, 10), (4, 7), (4, 9), (4, 11), (5, 2), (5, 4), (6, 7), (6, 9), &
      64              :        (7, 1), (7, 3), (7, 5), (8, 6), (8, 10), (9, 3), (9, 5), (10, 6), &
      65              :        (10, 8), (11, 7), (11, 9), (11, 11), (12, 2), (12, 4), (13, 7), (13, 9), &
      66              :        (14, 4), (15, 7), (16, 1), (16, 3), (16, 5), (17, 6), (17, 8), (17, 10), &
      67              :        (18, 3), (18, 5), (19, 6), (19, 8), (20, 5), (21, 6)], &
      68              :       [(1, 7), (1, 9), (1, 11), (1, 13), (2, 1), (2, 3), (2, 5), (3, 8), &
      69              :        (3, 10), (3, 12), (4, 7), (4, 9), (4, 11), (4, 13), (5, 2), (5, 4), &
      70              :        (5, 6), (6, 7), (6, 9), (6, 11), (7, 1), (7, 5), (8, 8), (8, 10), &
      71              :        (8, 12), (9, 3), (9, 5), (10, 8), (10, 10), (11, 7), (11, 9), (11, 11), &
      72              :        (11, 13), (12, 2), (12, 4), (12, 6), (13, 7), (13, 11), (14, 4), (14, 6), &
      73              :        (15, 7), (15, 9), (16, 1), (16, 3), (16, 5), (17, 8), (17, 10), (17, 12), &
      74              :        (18, 3), (18, 5), (19, 8), (19, 10), (20, 5), (21, 8), (22, 7), (22, 9), &
      75              :        (22, 11), (22, 13), (23, 2), (23, 4), (23, 6), (24, 7), (24, 9), (24, 11), &
      76              :        (25, 4), (25, 6), (26, 7), (26, 9), (27, 6), (28, 7)], &
      77              :       [(1, 9), (1, 11), (1, 13), (1, 15), (2, 1), (2, 3), (2, 5), (2, 7), &
      78              :        (3, 8), (3, 10), (3, 12), (3, 14), (4, 9), (4, 11), (4, 13), (4, 15), &
      79              :        (5, 2), (5, 4), (5, 6), (6, 9), (6, 11), (6, 13), (7, 1), (7, 3), &
      80              :        (7, 5), (7, 7), (8, 8), (8, 10), (8, 12), (8, 14), (9, 3), (9, 5), &
      81              :        (9, 7), (10, 8), (10, 10), (10, 12), (11, 9), (11, 11), (11, 13), (11, 15), &
      82              :        (12, 2), (12, 6), (13, 9), (13, 11), (13, 13), (14, 4), (14, 6), (15, 9), &
      83              :        (15, 11), (16, 1), (16, 3), (16, 5), (16, 7), (17, 8), (17, 10), (17, 12), &
      84              :        (17, 14), (18, 3), (18, 5), (18, 7), (19, 8), (19, 12), (20, 5), (20, 7), &
      85              :        (21, 8), (21, 10), (22, 9), (22, 11), (22, 13), (22, 15), (23, 2), (23, 4), &
      86              :        (23, 6), (24, 9), (24, 11), (24, 13), (25, 4), (25, 6), (26, 9), (26, 11), &
      87              :        (27, 6), (28, 9), (29, 1), (29, 3), (29, 5), (29, 7), (30, 8), (30, 10), &
      88              :        (30, 12), (30, 14), (31, 3), (31, 5), (31, 7), (32, 8), (32, 10), (32, 12), &
      89              :        (33, 5), (33, 7), (34, 8), (34, 10), (35, 7), (36, 8)], &
      90              :       [(1, 9), (1, 11), (1, 13), (1, 15), (1, 17), (2, 1), (2, 3), (2, 5), &
      91              :        (2, 7), (3, 10), (3, 12), (3, 14), (3, 16), (4, 9), (4, 11), (4, 13), &
      92              :        (4, 15), (4, 17), (5, 2), (5, 4), (5, 6), (5, 8), (6, 9), (6, 11), &
      93              :        (6, 13), (6, 15), (7, 1), (7, 3), (7, 5), (7, 7), (8, 10), (8, 12), &
      94              :        (8, 14), (8, 16), (9, 3), (9, 5), (9, 7), (10, 10), (10, 12), (10, 14), &
      95              :        (11, 9), (11, 13), (11, 17), (12, 2), (12, 4), (12, 6), (12, 8), (13, 9), &
      96              :        (13, 11), (13, 13), (13, 15), (14, 4), (14, 6), (14, 8), (15, 9), (15, 11), &
      97              :        (15, 13), (16, 1), (16, 3), (16, 5), (16, 7), (17, 10), (17, 12), (17, 14), &
      98              :        (17, 16), (18, 3), (18, 7), (19, 10), (19, 12), (19, 14), (20, 5), (20, 7), &
      99              :        (21, 10), (21, 12), (22, 9), (22, 11), (22, 13), (22, 15), (22, 17), (23, 2), &
     100              :        (23, 4), (23, 6), (23, 8), (24, 9), (24, 11), (24, 13), (24, 15), (25, 4), &
     101              :        (25, 6), (25, 8), (26, 9), (26, 13), (27, 6), (27, 8), (28, 9), (28, 11), &
     102              :        (29, 1), (29, 3), (29, 5), (29, 7), (30, 10), (30, 12), (30, 14), (30, 16), &
     103              :        (31, 3), (31, 5), (31, 7), (32, 10), (32, 12), (32, 14), (33, 5), (33, 7), &
     104              :        (34, 10), (34, 12), (35, 7), (36, 10), (37, 9), (37, 11), (37, 13), (37, 15), &
     105              :        (37, 17), (38, 2), (38, 4), (38, 6), (38, 8), (39, 9), (39, 11), (39, 13), &
     106              :        (39, 15), (40, 4), (40, 6), (40, 8), (41, 9), (41, 11), (41, 13), (42, 6), &
     107              :        (42, 8), (43, 9), (43, 11), (44, 8), (45, 9)], &
     108              :       [(1, 11), (1, 13), (1, 15), (1, 17), (1, 19), (2, 1), (2, 3), (2, 5), &
     109              :        (2, 7), (2, 9), (3, 10), (3, 12), (3, 14), (3, 16), (3, 18), (4, 11), &
     110              :        (4, 15), (4, 17), (4, 19), (5, 2), (5, 4), (5, 6), (5, 8), (6, 11), &
     111              :        (6, 13), (6, 15), (6, 17), (7, 1), (7, 3), (7, 7), (7, 9), (8, 10), &
     112              :        (8, 12), (8, 14), (8, 16), (8, 18), (9, 3), (9, 5), (9, 7), (9, 9), &
     113              :        (10, 10), (10, 12), (10, 14), (10, 16), (11, 11), (11, 13), (11, 15), (11, 17), &
     114              :        (11, 19), (12, 2), (12, 4), (12, 6), (12, 8), (13, 11), (13, 13), (13, 15), &
     115              :        (13, 17), (14, 4), (14, 6), (14, 8), (15, 11), (15, 13), (15, 15), (16, 1), &
     116              :        (16, 3), (16, 5), (16, 7), (16, 9), (17, 10), (17, 14), (17, 18), (18, 3), &
     117              :        (18, 5), (18, 7), (18, 9), (19, 10), (19, 12), (19, 14), (19, 16), (20, 5), &
     118              :        (20, 7), (20, 9), (21, 10), (21, 12), (21, 14), (22, 11), (22, 13), (22, 17), &
     119              :        (22, 19), (23, 2), (23, 4), (23, 6), (23, 8), (24, 11), (24, 13), (24, 15), &
     120              :        (24, 17), (25, 4), (25, 8), (26, 11), (26, 13), (26, 15), (27, 6), (27, 8), &
     121              :        (28, 11), (28, 13), (29, 1), (29, 3), (29, 5), (29, 9), (30, 10), (30, 12), &
     122              :        (30, 14), (30, 16), (30, 18), (31, 3), (31, 5), (31, 7), (31, 9), (32, 10), &
     123              :        (32, 12), (32, 14), (32, 16), (33, 5), (33, 7), (33, 9), (34, 10), (34, 14), &
     124              :        (35, 7), (35, 9), (36, 10), (36, 12), (37, 11), (37, 13), (37, 15), (37, 17), &
     125              :        (37, 19), (38, 2), (38, 4), (38, 6), (38, 8), (39, 11), (39, 13), (39, 15), &
     126              :        (39, 17), (40, 4), (40, 6), (40, 8), (41, 11), (41, 13), (41, 15), (42, 6), &
     127              :        (42, 8), (43, 11), (43, 13), (44, 8), (45, 11), (46, 1), (46, 3), (46, 5), &
     128              :        (46, 7), (46, 9), (47, 10), (47, 12), (47, 14), (47, 16), (47, 18), (48, 3), &
     129              :        (48, 5), (48, 7), (48, 9), (49, 10), (49, 12), (49, 14), (49, 16), (50, 5), &
     130              :        (50, 7), (50, 9), (51, 10), (51, 12), (51, 14), (52, 7), (52, 9), (53, 10), &
     131              :        (53, 12), (54, 9), (55, 10)], &
     132              :       [(1, 11), (1, 13), (1, 15), (1, 17), (1, 19), (1, 21), (2, 1), (2, 3), &
     133              :        (2, 5), (2, 7), (2, 9), (3, 12), (3, 14), (3, 16), (3, 18), (3, 20), &
     134              :        (4, 11), (4, 13), (4, 15), (4, 17), (4, 19), (4, 21), (5, 2), (5, 4), &
     135              :        (5, 6), (5, 8), (5, 10), (6, 11), (6, 13), (6, 15), (6, 17), (6, 19), &
     136              :        (7, 1), (7, 3), (7, 5), (7, 7), (7, 9), (8, 12), (8, 16), (8, 18), &
     137              :        (8, 20), (9, 3), (9, 5), (9, 7), (9, 9), (10, 12), (10, 14), (10, 16), &
     138              :        (10, 18), (11, 11), (11, 13), (11, 15), (11, 17), (11, 19), (11, 21), (12, 2), &
     139              :        (12, 4), (12, 8), (12, 10), (13, 11), (13, 13), (13, 15), (13, 17), (13, 19), &
     140              :        (14, 4), (14, 6), (14, 8), (14, 10), (15, 11), (15, 13), (15, 15), (15, 17), &
     141              :        (16, 1), (16, 5), (16, 9), (17, 12), (17, 14), (17, 16), (17, 18), (17, 20), &
     142              :        (18, 3), (18, 5), (18, 7), (18, 9), (19, 12), (19, 14), (19, 16), (19, 18), &
     143              :        (20, 5), (20, 7), (20, 9), (21, 12), (21, 14), (21, 16), (22, 11), (22, 13), &
     144              :        (22, 15), (22, 17), (22, 19), (22, 21), (23, 2), (23, 4), (23, 6), (23, 8), &
     145              :        (23, 10), (24, 11), (24, 15), (24, 19), (25, 4), (25, 6), (25, 8), (25, 10), &
     146              :        (26, 11), (26, 13), (26, 15), (26, 17), (27, 6), (27, 8), (27, 10), (28, 11), &
     147              :        (28, 13), (28, 15), (29, 1), (29, 3), (29, 5), (29, 7), (29, 9), (30, 12), &
     148              :        (30, 14), (30, 18), (30, 20), (31, 3), (31, 5), (31, 7), (31, 9), (32, 12), &
     149              :        (32, 14), (32, 16), (32, 18), (33, 5), (33, 9), (34, 12), (34, 14), (34, 16), &
     150              :        (35, 7), (35, 9), (36, 12), (36, 14), (37, 11), (37, 13), (37, 15), (37, 17), &
     151              :        (37, 19), (37, 21), (38, 2), (38, 4), (38, 6), (38, 10), (39, 11), (39, 13), &
     152              :        (39, 15), (39, 17), (39, 19), (40, 4), (40, 6), (40, 8), (40, 10), (41, 11), &
     153              :        (41, 13), (41, 15), (41, 17), (42, 6), (42, 8), (42, 10), (43, 11), (43, 15), &
     154              :        (44, 8), (44, 10), (45, 11), (45, 13), (46, 1), (46, 3), (46, 5), (46, 7), &
     155              :        (46, 9), (47, 12), (47, 14), (47, 16), (47, 18), (47, 20), (48, 3), (48, 5), &
     156              :        (48, 7), (48, 9), (49, 12), (49, 14), (49, 16), (49, 18), (50, 5), (50, 7), &
     157              :        (50, 9), (51, 12), (51, 14), (51, 16), (52, 7), (52, 9), (53, 12), (53, 14), &
     158              :        (54, 9), (55, 12), (56, 11), (56, 13), (56, 15), (56, 17), (56, 19), (56, 21), &
     159              :        (57, 2), (57, 4), (57, 6), (57, 8), (57, 10), (58, 11), (58, 13), (58, 15), &
     160              :        (58, 17), (58, 19), (59, 4), (59, 6), (59, 8), (59, 10), (60, 11), (60, 13), &
     161              :        (60, 15), (60, 17), (61, 6), (61, 8), (61, 10), (62, 11), (62, 13), (62, 15), &
     162              :        (63, 8), (63, 10), (64, 11), (64, 13), (65, 10), (66, 11)]]
     163              : 
     164              :    #:def call_generic()
     165              :       CALL contract_generic(ncoa, ncob, ncoc, ncod, nsoa, nsob, nsoc, nsod, &
     166              :                             work, nl_a, nl_b, nl_c, nl_d, &
     167              :                             angular_a, angular_b, angular_c, angular_d, &
     168              :                             weight_a, weight_b, weight_c, weight_d, nsgfa, nsgfb, nsgfc, primitives, buffer1, buffer2)
     169              :    #:enddef
     170              : 
     171              :    #:def transform(angular, source, target, tmat)
     172              :       #:set ncart = cartesian[angular]
     173              :       DO i = 1, imax
     174              :          #:for j in range(1, spherical[angular]+1)
     175              :             #:set summands = [f'{source}({k}+(i-1)*{ncart})*{tmat}({k},{j})' for k, m in terms[angular] if j == m]
     176              :             ${target}$ (i + imax*${j-1}$) = &
     177              :                ${' + &\n               '.join(summands) or '0.0_dp'}$
     178              :          #:endfor
     179              :       END DO
     180              :    #:enddef
     181              : 
     182              :    #! Share the loop structure between all specialized kernels and the fallback.
     183              :    #! Runtime dimensions and dense fallback loops are emitted only for generic.
     184              :    #:def contraction(angular=None)
     185              :       #:set generic = angular is None
     186              :       #:if generic
     187              :          #:set name = 'generic'
     188              :          #:set nc = ['nco' + axis for axis in 'abcd']
     189              :          #:set ns = ['nso' + axis for axis in 'abcd']
     190              :       #:else
     191              :          #:set name = ''.join(shells[l] for l in angular)
     192              :          #:set nc = [str(cartesian[l]) for l in angular]
     193              :          #:set ns = [str(spherical[l]) for l in angular]
     194              :          #:set max_contr = max(angular)
     195              : #if __MAX_CONTR >= ${max_contr}$
     196              :       #:endif
     197              : ! **************************************************************************************************
     198              : !> \brief Contract Cartesian integrals into spherical basis functions.
     199              :       #:if generic
     200              :          #:for axis in 'abcd'
     201              : !> \param nco${axis}$ Number of Cartesian functions on center ${axis}$
     202              :          #:endfor
     203              :          #:for axis in 'abcd'
     204              : !> \param nso${axis}$ Number of spherical functions on center ${axis}$
     205              :          #:endfor
     206              :       #:endif
     207              : !> \param work Cartesian integrals
     208              :       #:for axis in 'abcd'
     209              : !> \param nl_${axis}$ Number of contractions on center ${axis}$
     210              :       #:endfor
     211              :       #:for axis in 'abcd'
     212              : !> \param angular_${axis}$ Cartesian-to-spherical transformation
     213              :       #:endfor
     214              :       #:for axis in 'abcd'
     215              : !> \param weight_${axis}$ Radial weights for the current primitive
     216              :       #:endfor
     217              : !> \param nsgfa Leading dimension along center A in the full shell set
     218              : !> \param nsgfb Leading dimension along center B in the full shell set
     219              : !> \param nsgfc Leading dimension along center C in the full shell set
     220              : !> \param primitives Spherical integrals starting at the first element of the target block
     221              : !> \param buffer1 Work buffer
     222              : !> \param buffer2 Work buffer
     223              : ! **************************************************************************************************
     224              :       #:if generic
     225              :          SUBROUTINE contract_generic(ncoa, ncob, ncoc, ncod, nsoa, nsob, nsoc, nsod, &
     226              :                                      work, nl_a, nl_b, nl_c, nl_d, &
     227              :                                      angular_a, angular_b, angular_c, angular_d, &
     228              :                                      weight_a, weight_b, weight_c, weight_d, nsgfa, nsgfb, nsgfc, &
     229              :                                      primitives, buffer1, buffer2)
     230              : 
     231              :             INTEGER, INTENT(IN) :: ncoa, ncob, ncoc, ncod, nsoa, nsob, nsoc, nsod
     232              :             #:else
     233              :             SUBROUTINE contract_${name}$ (work, nl_a, nl_b, nl_c, nl_d, &
     234              :                                           angular_a, angular_b, angular_c, angular_d, &
     235              :                                           weight_a, weight_b, weight_c, weight_d, nsgfa, nsgfb, nsgfc, &
     236              :                                           primitives, buffer1, buffer2)
     237              : 
     238              :                #:endif
     239              :                REAL(dp), DIMENSION(${ '*'.join(nc) }$), INTENT(IN) :: work
     240              :                INTEGER :: nl_a, nl_b, nl_c, nl_d
     241              :                #:for axis, ncart, nsph in zip('abcd', nc, ns)
     242              :                   REAL(dp), DIMENSION(${ncart}$, ${nsph}$), INTENT(IN) :: angular_${axis}$
     243              :                #:endfor
     244              :                INTEGER, INTENT(IN) :: nsgfa, nsgfb, nsgfc
     245              :                REAL(dp), INTENT(INOUT) :: primitives(nsgfa, nsgfb, nsgfc, *)
     246              :                REAL(dp), DIMENSION(${ '*'.join(nc) }$) :: buffer1, buffer2
     247              :                REAL(dp), INTENT(IN) :: weight_a(nl_a), weight_b(nl_b), weight_c(nl_c), weight_d(nl_d)
     248              : 
     249              :                INTEGER :: i, ia, ib, ic, id, ma, mb, mc, md
     250              :                #:if generic or any(angular)
     251              :                   INTEGER :: imax
     252              :                #:endif
     253              :                #:if generic
     254              :                   INTEGER :: j, k, kmax
     255              :                #:endif
     256              :                INTEGER :: oa, ob, oc, od
     257              :                REAL(dp) :: weight, wcd, wbcd
     258              : 
     259              :                #! In a fixed kernel s axes are identities after extracting their scalar weights.
     260              :                #! Skipping their length-one transposes preserves the layout.
     261              :                #:if not generic
     262              :                   #:for axis, l in zip('abcd', angular)
     263              :                      #:if l == 0
     264              :                         MARK_USED(angular_${axis}$)
     265              :                      #:endif
     266              :                   #:endfor
     267              :                   #:if not any(angular)
     268              :                      MARK_USED(buffer1)
     269              :                   #:endif
     270              :                   #:if sum(l > 0 for l in angular) < 2
     271              :                      MARK_USED(buffer2)
     272              :                   #:endif
     273              :                #:endif
     274              :                ! Transform the primitive block once, alternating between the two buffers.
     275              :                #:set source = 'work'
     276              :                #:for stage, axis in enumerate('abcd')
     277              :                   #:if generic or angular[stage] > 0
     278              :                      #:set target = 'buffer2' if source == 'buffer1' else 'buffer1'
     279              :                      imax = ${'*'.join(ns[:stage] + nc[stage + 1:])}$
     280              :                      #:if generic
     281              :                         kmax = ${nc[stage]}$
     282              :                         SELECT CASE (kmax)
     283              :                            #:for l, ncart in enumerate(cartesian[:lmax_generic + 1])
     284              :                               CASE (${ncart}$)
     285              :                               $:transform(l, source, target, 'angular_' + axis)
     286              :                            #:endfor
     287              :                         CASE DEFAULT
     288              :                            DO j = 1, ${ns[stage]}$
     289              :                               DO i = 1, imax
     290              :                                  ${target}$ (i + imax*(j - 1)) = 0.0_dp
     291              :                                  DO k = 1, kmax
     292              :                                     ${target}$ (i + imax*(j - 1)) = ${target}$ (i + imax*(j - 1)) + &
     293              :                                                                     ${source}$ (k + (i - 1)*kmax)*angular_${axis}$ (k, j)
     294              :                                  END DO
     295              :                               END DO
     296              :                            END DO
     297              :                         END SELECT
     298              :                      #:else
     299              :                         $:transform(angular[stage], source, target, 'angular_' + axis)
     300              :                      #:endif
     301              :                      #:set source = target
     302              :                   #:endif
     303              :                #:endfor
     304              : 
     305              :                DO id = 1, nl_d
     306              :                   od = (id - 1)*${ns[3]}$
     307              :                   DO ic = 1, nl_c
     308              :                      oc = (ic - 1)*${ns[2]}$
     309              :                      wcd = weight_d(id)*weight_c(ic)
     310              :                      DO ib = 1, nl_b
     311              :                         ob = (ib - 1)*${ns[1]}$
     312              :                         wbcd = wcd*weight_b(ib)
     313              :                         DO ia = 1, nl_a
     314              :                            oa = (ia - 1)*${ns[0]}$
     315              :                            weight = wbcd*weight_a(ia)
     316              :                            i = 0
     317              :                            DO md = 1, ${ns[3]}$
     318              :                               DO mc = 1, ${ns[2]}$
     319              :                                  DO mb = 1, ${ns[1]}$
     320              :                                     DO ma = 1, ${ns[0]}$
     321              :                                        i = i + 1
     322              :                                        primitives(oa + ma, ob + mb, oc + mc, od + md) = &
     323              :                                           primitives(oa + ma, ob + mb, oc + mc, od + md) + weight*${source}$ (i)
     324              :                                     END DO
     325              :                                  END DO
     326              :                               END DO
     327              :                            END DO
     328              :                         END DO
     329              :                      END DO
     330              :                   END DO
     331              :                END DO
     332              :             END SUBROUTINE contract_${name}$
     333              :             #:if not generic
     334              : #endif
     335              :             #:endif
     336              :             #:enddef
     337              : 
     338              : ! **************************************************************************************************
     339              : !> \brief ...
     340              : !> \param ncoa ...
     341              : !> \param ncob ...
     342              : !> \param ncoc ...
     343              : !> \param ncod ...
     344              : !> \param nsoa ...
     345              : !> \param nsob ...
     346              : !> \param nsoc ...
     347              : !> \param nsod ...
     348              : !> \param n_a ...
     349              : !> \param n_b ...
     350              : !> \param n_c ...
     351              : !> \param n_d ...
     352              : !> \param nl_a ...
     353              : !> \param nl_b ...
     354              : !> \param nl_c ...
     355              : !> \param nl_d ...
     356              : !> \param work ...
     357              : !> \param angular_a ...
     358              : !> \param angular_b ...
     359              : !> \param angular_c ...
     360              : !> \param angular_d ...
     361              : !> \param weight_a ...
     362              : !> \param weight_b ...
     363              : !> \param weight_c ...
     364              : !> \param weight_d ...
     365              : !> \param nsgfa Leading dimension along center A in the full shell set
     366              : !> \param nsgfb Leading dimension along center B in the full shell set
     367              : !> \param nsgfc Leading dimension along center C in the full shell set
     368              : !> \param primitives Spherical integrals starting at the first element of the target block
     369              : !> \param buffer1 ...
     370              : !> \param buffer2 ...
     371              : ! **************************************************************************************************
     372    524503842 :             SUBROUTINE contract(ncoa, ncob, ncoc, ncod, nsoa, nsob, nsoc, nsod, &
     373    524503842 :                                 n_a, n_b, n_c, n_d, nl_a, nl_b, nl_c, nl_d, work, &
     374    524503842 :                                 angular_a, angular_b, angular_c, angular_d, weight_a, weight_b, weight_c, weight_d, &
     375    524503842 :                                 nsgfa, nsgfb, nsgfc, primitives, &
     376    524503842 :                                 buffer1, buffer2)
     377              : 
     378              :                INTEGER, INTENT(IN)         :: ncoa, ncob, ncoc, ncod, nsoa, nsob, nsoc, nsod, &
     379              :                                               n_a, n_b, n_c, n_d, nl_a, nl_b, nl_c, nl_d
     380              :                REAL(dp), DIMENSION(ncoa*ncob*ncoc*ncod), INTENT(IN) :: work
     381              :                REAL(dp), DIMENSION(ncoa, nsoa), INTENT(IN)   :: angular_a
     382              :                REAL(dp), DIMENSION(ncob, nsob), INTENT(IN)   :: angular_b
     383              :                REAL(dp), DIMENSION(ncoc, nsoc), INTENT(IN)   :: angular_c
     384              :                REAL(dp), DIMENSION(ncod, nsod), INTENT(IN)   :: angular_d
     385              : 
     386              :                INTEGER, INTENT(IN) :: nsgfa, nsgfb, nsgfc
     387              :                REAL(dp), INTENT(INOUT) :: primitives(nsgfa, nsgfb, nsgfc, *)
     388              :                REAL(dp), DIMENSION(ncoa*ncob*ncoc*ncod)  :: buffer1, buffer2
     389              :                REAL(dp), INTENT(IN) :: weight_a(nl_a), weight_b(nl_b), weight_c(nl_c), weight_d(nl_d)
     390              : 
     391              : #if !defined(__LIBINT)
     392              :                MARK_USED(ncoa)
     393              :                MARK_USED(ncob)
     394              :                MARK_USED(ncoc)
     395              :                MARK_USED(ncod)
     396              :                MARK_USED(nsoa)
     397              :                MARK_USED(nsob)
     398              :                MARK_USED(nsoc)
     399              :                MARK_USED(nsod)
     400              :                MARK_USED(n_a)
     401              :                MARK_USED(n_b)
     402              :                MARK_USED(n_c)
     403              :                MARK_USED(n_d)
     404              :                MARK_USED(nl_a)
     405              :                MARK_USED(nl_b)
     406              :                MARK_USED(nl_c)
     407              :                MARK_USED(nl_d)
     408              :                MARK_USED(angular_a)
     409              :                MARK_USED(angular_b)
     410              :                MARK_USED(angular_c)
     411              :                MARK_USED(angular_d)
     412              :                MARK_USED(weight_a)
     413              :                MARK_USED(weight_b)
     414              :                MARK_USED(weight_c)
     415              :                MARK_USED(weight_d)
     416              :                MARK_USED(work)
     417              :                MARK_USED(nsgfa)
     418              :                MARK_USED(nsgfb)
     419              :                MARK_USED(nsgfc)
     420              :                MARK_USED(primitives(1, 1, 1, 1))
     421              :                MARK_USED(buffer1)
     422              :                MARK_USED(buffer2)
     423              :                CPABORT("libint not compiled in")
     424              : #else
     425    873076449 :                SELECT CASE (n_a)
     426              :                   #:for a in range(lmax_specific + 1)
     427              :                      CASE (${a}$)
     428    947086401 :                      SELECT CASE (n_b)
     429              :                         #:for b in range(lmax_specific + 1)
     430              :                            CASE (${b}$)
     431    821116916 :                            SELECT CASE (n_c)
     432              :                               #:for c in range(lmax_specific + 1)
     433              :                                  CASE (${c}$)
     434    880318743 :                                  SELECT CASE (n_d)
     435              :                                     #:for d in range(lmax_specific + 1)
     436              :                                        CASE (${d}$)
     437              :                                        #:set max_contr = max(a, b, c, d)
     438              : #if __MAX_CONTR >= ${max_contr}$
     439              :                                        CALL contract_${''.join(shells[l] for l in (a, b, c, d))}$ (work, &
     440              :                                                                                                    nl_a, nl_b, nl_c, nl_d, &
     441              :                                                                                        angular_a, angular_b, angular_c, angular_d, &
     442              :                                                                                            weight_a, weight_b, weight_c, weight_d, &
     443    524083138 :                                                                                   nsgfa, nsgfb, nsgfc, primitives, buffer1, buffer2)
     444              : #else
     445       420704 :                                        $:call_generic()
     446              : #endif
     447              :                                     #:endfor
     448              :                                  CASE DEFAULT
     449    524503842 :                                     $:call_generic()
     450              :                                  END SELECT
     451              :                               #:endfor
     452              :                            CASE DEFAULT
     453    524503842 :                               $:call_generic()
     454              :                            END SELECT
     455              :                         #:endfor
     456              :                      CASE DEFAULT
     457    524503842 :                         $:call_generic()
     458              :                      END SELECT
     459              :                   #:endfor
     460              :                CASE DEFAULT
     461    524503842 :                   $:call_generic()
     462              :                END SELECT
     463              : #endif
     464    524503842 :             END SUBROUTINE contract
     465              : 
     466              : #if defined(__LIBINT)
     467              :             #:for a in range(lmax_specific + 1)
     468              :                #:for b in range(lmax_specific + 1)
     469              :                   #:for c in range(lmax_specific + 1)
     470              :                      #:for d in range(lmax_specific + 1)
     471  55376535232 :                         $:contraction((a, b, c, d))
     472              :                      #:endfor
     473              :                   #:endfor
     474              :                #:endfor
     475              :             #:endfor
     476              : 
     477     90725799 :             $:contraction()
     478              : #endif
     479              :             END MODULE hfx_contraction_methods
        

Generated by: LCOV version 2.0-1