Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Some utility functions for the calculation of integrals
10 : !> \par History
11 : !> JGH: initial version
12 : !> \author JGH (10.07.2014)
13 : ! **************************************************************************************************
14 : MODULE qs_integral_utils
15 :
16 : USE basis_set_types, ONLY: gto_basis_set_p_type,&
17 : gto_basis_set_type
18 : USE orbital_pointers, ONLY: init_orbital_pointers
19 : USE qs_kind_types, ONLY: get_qs_kind,&
20 : get_qs_kind_set,&
21 : qs_kind_type
22 : #include "./base/base_uses.f90"
23 :
24 : IMPLICIT NONE
25 :
26 : PRIVATE
27 :
28 : ! *** Global parameters ***
29 :
30 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_integral_utils'
31 :
32 : ! *** Interfaces ***
33 :
34 : INTERFACE get_memory_usage
35 : MODULE PROCEDURE get_memory_usage_a, get_memory_usage_ab, &
36 : get_memory_usage_abc, get_memory_usage_abcd
37 : END INTERFACE
38 :
39 : ! *** Public subroutines ***
40 :
41 : PUBLIC :: get_memory_usage, basis_set_list_setup
42 :
43 : CONTAINS
44 :
45 : ! **************************************************************************************************
46 : !> \brief Return the maximum memory usage in integral calculations
47 : !> \param qs_kind_set The info for all atomic kinds
48 : !> \param basis_type_a Type of basis
49 : !> \return Result
50 : ! **************************************************************************************************
51 2965667 : FUNCTION get_memory_usage_a(qs_kind_set, basis_type_a) RESULT(ldmem)
52 :
53 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
54 : CHARACTER(LEN=*), INTENT(IN) :: basis_type_a
55 : INTEGER :: ldmem
56 :
57 : INTEGER :: maxc, maxl, maxs
58 :
59 : CALL get_qs_kind_set(qs_kind_set=qs_kind_set, &
60 : maxco=maxc, maxlgto=maxl, maxsgf=maxs, &
61 2965667 : basis_type=basis_type_a)
62 2965667 : ldmem = MAX(maxc, maxs)
63 :
64 2965667 : CALL init_orbital_pointers(maxl + 2)
65 :
66 2965667 : END FUNCTION get_memory_usage_a
67 :
68 : ! **************************************************************************************************
69 : !> \brief Return the maximum memory usage in integral calculations
70 : !> \param qs_kind_set The info for all atomic kinds
71 : !> \param basis_type_a Type of basis
72 : !> \param basis_type_b Type of basis
73 : !> \return Result
74 : ! **************************************************************************************************
75 1472385 : FUNCTION get_memory_usage_ab(qs_kind_set, basis_type_a, basis_type_b) RESULT(ldmem)
76 :
77 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
78 : CHARACTER(LEN=*), INTENT(IN) :: basis_type_a, basis_type_b
79 : INTEGER :: ldmem
80 :
81 : INTEGER :: lda, ldb
82 :
83 1472385 : lda = get_memory_usage_a(qs_kind_set, basis_type_a)
84 1472385 : ldb = get_memory_usage_a(qs_kind_set, basis_type_b)
85 1472385 : ldmem = MAX(lda, ldb)
86 :
87 1472385 : END FUNCTION get_memory_usage_ab
88 :
89 : ! **************************************************************************************************
90 : !> \brief Return the maximum memory usage in integral calculations
91 : !> \param qs_kind_set The info for all atomic kinds
92 : !> \param basis_type_a Type of basis
93 : !> \param basis_type_b Type of basis
94 : !> \param basis_type_c Type of basis
95 : !> \return Result
96 : ! **************************************************************************************************
97 0 : FUNCTION get_memory_usage_abc(qs_kind_set, basis_type_a, &
98 : basis_type_b, basis_type_c) RESULT(ldmem)
99 :
100 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
101 : CHARACTER(LEN=*), INTENT(IN) :: basis_type_a, basis_type_b, basis_type_c
102 : INTEGER :: ldmem
103 :
104 : INTEGER :: lda, ldb, ldc
105 :
106 0 : lda = get_memory_usage_a(qs_kind_set, basis_type_a)
107 0 : ldb = get_memory_usage_a(qs_kind_set, basis_type_b)
108 0 : ldc = get_memory_usage_a(qs_kind_set, basis_type_c)
109 0 : ldmem = MAX(lda, ldb, ldc)
110 :
111 0 : END FUNCTION get_memory_usage_abc
112 :
113 : ! **************************************************************************************************
114 : !> \brief Return the maximum memory usage in integral calculations
115 : !> \param qs_kind_set The info for all atomic kinds
116 : !> \param basis_type_a Type of basis
117 : !> \param basis_type_b Type of basis
118 : !> \param basis_type_c Type of basis
119 : !> \param basis_type_d Type of basis
120 : !> \return Result
121 : ! **************************************************************************************************
122 0 : FUNCTION get_memory_usage_abcd(qs_kind_set, basis_type_a, &
123 : basis_type_b, basis_type_c, basis_type_d) RESULT(ldmem)
124 :
125 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
126 : CHARACTER(LEN=*), INTENT(IN) :: basis_type_a, basis_type_b, &
127 : basis_type_c, basis_type_d
128 : INTEGER :: ldmem
129 :
130 : INTEGER :: lda, ldb, ldc, ldd
131 :
132 0 : lda = get_memory_usage_a(qs_kind_set, basis_type_a)
133 0 : ldb = get_memory_usage_a(qs_kind_set, basis_type_b)
134 0 : ldc = get_memory_usage_a(qs_kind_set, basis_type_c)
135 0 : ldd = get_memory_usage_a(qs_kind_set, basis_type_d)
136 0 : ldmem = MAX(lda, ldb, ldc, ldd)
137 :
138 0 : END FUNCTION get_memory_usage_abcd
139 :
140 : ! **************************************************************************************************
141 :
142 : ! **************************************************************************************************
143 : !> \brief Set up an easy accessible list of the basis sets for all kinds
144 : !> \param basis_set_list The basis set list
145 : !> \param basis_type ...
146 : !> \param qs_kind_set Kind information, the basis is used
147 : ! **************************************************************************************************
148 116045 : SUBROUTINE basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
149 :
150 : TYPE(gto_basis_set_p_type), DIMENSION(:) :: basis_set_list
151 : CHARACTER(len=*), INTENT(IN) :: basis_type
152 : TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
153 :
154 : INTEGER :: ikind
155 : TYPE(gto_basis_set_type), POINTER :: basis_set
156 : TYPE(qs_kind_type), POINTER :: qs_kind
157 :
158 : ! set up basis sets
159 333453 : DO ikind = 1, SIZE(qs_kind_set)
160 217408 : qs_kind => qs_kind_set(ikind)
161 : CALL get_qs_kind(qs_kind=qs_kind, basis_set=basis_set, &
162 217408 : basis_type=basis_type)
163 217408 : NULLIFY (basis_set_list(ikind)%gto_basis_set)
164 333453 : IF (ASSOCIATED(basis_set)) basis_set_list(ikind)%gto_basis_set => basis_set
165 : END DO
166 :
167 116045 : END SUBROUTINE basis_set_list_setup
168 :
169 : ! **************************************************************************************************
170 :
171 : END MODULE qs_integral_utils
172 :
|