13#include "../base/base_uses.f90"
17 USE dlaf_fortran,
ONLY: dlaf_pdpotrf, &
27 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_fm_dlaf_api'
48 CHARACTER,
INTENT(IN) :: uplo
49 INTEGER,
INTENT(IN) :: n
50 REAL(kind=
dp),
DIMENSION(:, :),
TARGET :: a
51 INTEGER,
INTENT(IN) :: ia, ja
52 INTEGER,
DIMENSION(9) :: desca
53 INTEGER,
TARGET :: info
55 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pdpotrf_dlaf'
59 CALL timeset(routinen, handle)
61 CALL dlaf_pdpotrf(uplo, n, a, ia, ja, desca, info)
70 cpabort(
"CP2K compiled without the DLA-Future library.")
87 CHARACTER,
INTENT(IN) :: uplo
88 INTEGER,
INTENT(IN) :: n
89 REAL(kind=
dp),
DIMENSION(:, :),
TARGET :: a
90 INTEGER,
INTENT(IN) :: ia, ja
91 INTEGER,
DIMENSION(9) :: desca
92 INTEGER,
TARGET :: info
94 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pdpotri_dlaf'
98 CALL timeset(routinen, handle)
100 CALL dlaf_pdpotri(uplo, n, a, ia, ja, desca, info)
109 cpabort(
"CP2K compiled without the DLA-Future library.")
111 CALL timestop(handle)
122 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
123 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
125 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_dlaf'
127 INTEGER :: handle, n, nmo
128 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
130 CALL timeset(routinen, handle)
132 n = matrix%matrix_struct%nrow_global
135 CALL cp_fm_diag_dlaf_base(matrix, eigenvectors, eig)
137 nmo =
SIZE(eigenvalues, 1)
139 eigenvalues(1:n) = eig(1:n)
141 eigenvalues(1:nmo) = eig(1:nmo)
146 CALL timestop(handle)
157 SUBROUTINE cp_fm_diag_dlaf_base(matrix, eigenvectors, eigenvalues)
158 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
159 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
161 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', routinen =
'cp_fm_diag_dlaf_base'
162 CHARACTER,
PARAMETER :: uplo =
'L'
164 CHARACTER(LEN=100) :: message
165 INTEGER :: blacs_context, dlaf_handle, handle, n
166 INTEGER,
DIMENSION(9) :: desca, descz
167 INTEGER,
TARGET :: info
168 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, z
170 CALL timeset(routinen, handle)
178 blacs_context = matrix%matrix_struct%context%get_handle()
181 n = matrix%matrix_struct%nrow_global
183 a => matrix%local_data
184 z => eigenvectors%local_data
186 desca(:) = matrix%matrix_struct%descriptor(:)
187 descz(:) = eigenvectors%matrix_struct%descriptor(:)
190 CALL timeset(dlaf_name, dlaf_handle)
191 CALL dlaf_pdsyevd(uplo, n, a, 1, 1, desca, eigenvalues, z, 1, 1, descz, info)
192 CALL timestop(dlaf_handle)
195 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYEVD: Eigensolver failed (INFO = ", info,
")"
196 cpabort(trim(message))
204 mark_used(eigenvectors)
205 mark_used(eigenvalues)
209 mark_used(dlaf_handle)
212 mark_used(blacs_context)
213 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
216 CALL timestop(handle)
218 END SUBROUTINE cp_fm_diag_dlaf_base
230 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
231 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
233 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_gen_dlaf'
235 INTEGER :: handle, n, nmo
236 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
238 CALL timeset(routinen, handle)
240 n = a_matrix%matrix_struct%nrow_global
243 CALL cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eig)
245 nmo =
SIZE(eigenvalues, 1)
247 eigenvalues(1:n) = eig(1:n)
249 eigenvalues(1:nmo) = eig(1:nmo)
254 CALL timestop(handle)
266 SUBROUTINE cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eigenvalues)
267 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
268 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
270 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsygvd_dlaf', &
271 routinen =
'cp_fm_diag_gen_dlaf_base'
272 CHARACTER,
PARAMETER :: uplo =
'L'
274 CHARACTER(LEN=100) :: message
275 INTEGER :: blacs_context, dlaf_handle, handle, n
276 INTEGER,
DIMENSION(9) :: desca, descb, descz
277 INTEGER,
TARGET :: info
278 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, b, z
280 CALL timeset(routinen, handle)
289 blacs_context = a_matrix%matrix_struct%context%get_handle()
292 n = a_matrix%matrix_struct%nrow_global
294 a => a_matrix%local_data
295 b => b_matrix%local_data
296 z => eigenvectors%local_data
298 desca(:) = a_matrix%matrix_struct%descriptor(:)
299 descb(:) = b_matrix%matrix_struct%descriptor(:)
300 descz(:) = eigenvectors%matrix_struct%descriptor(:)
303 CALL timeset(dlaf_name, dlaf_handle)
304 CALL dlaf_pdsygvd(uplo, n, a, 1, 1, desca, b, 1, 1, descb, eigenvalues, z, 1, 1, descz, info)
305 CALL timestop(dlaf_handle)
308 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYGVD: Generalized Eigensolver failed (INFO = ", info,
")"
309 cpabort(trim(message))
320 mark_used(eigenvectors)
321 mark_used(eigenvalues)
325 mark_used(blacs_context)
326 mark_used(dlaf_handle)
329 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
332 CALL timestop(handle)
334 END SUBROUTINE cp_fm_diag_gen_dlaf_base
subroutine, public cp_dlaf_create_grid(blacs_context)
Create DLA-Future grid from BLACS context.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, computes the corresponding full matrix
subroutine, public cp_pdpotrf_dlaf(uplo, n, a, ia, ja, desca, info)
Cholesky factorization using DLA-Future.
subroutine, public cp_pdpotri_dlaf(uplo, n, a, ia, ja, desca, info)
Inverse from Cholesky factorization using DLA-Future.
subroutine, public cp_fm_diag_dlaf(matrix, eigenvectors, eigenvalues)
...
subroutine, public cp_fm_diag_gen_dlaf(a_matrix, b_matrix, eigenvectors, eigenvalues)
...
represent a full matrix distributed on many processors
Defines the basic variable types.
integer, parameter, public dp