13#include "../base/base_uses.f90"
17 USE dlaf_fortran,
ONLY: dlaf_pdpotrf, &
29 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_fm_dlaf_api'
51 CHARACTER,
INTENT(IN) :: uplo
52 INTEGER,
INTENT(IN) :: n
53 REAL(kind=
dp),
DIMENSION(:, :),
TARGET :: a
54 INTEGER,
INTENT(IN) :: ia, ja
55 INTEGER,
DIMENSION(9) :: desca
56 INTEGER,
TARGET :: info
58 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pdpotrf_dlaf'
62 CALL timeset(routinen, handle)
64 CALL dlaf_pdpotrf(uplo, n, a, ia, ja, desca, info)
73 cpabort(
"CP2K compiled without the DLA-Future library.")
92 CHARACTER,
INTENT(IN) :: uplo
93 INTEGER,
INTENT(IN) :: n
94 REAL,
DIMENSION(:, :),
TARGET :: a
95 INTEGER,
INTENT(IN) :: ia, ja
96 INTEGER,
DIMENSION(9) :: desca
97 INTEGER,
TARGET :: info
99 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pspotrf_dlaf'
103 CALL timeset(routinen, handle)
106 CALL dlaf_pspotrf(uplo, n, a, ia, ja, desca, info)
115 cpabort(
"CP2K compiled without the DLA-Future library.")
117 CALL timestop(handle)
132 CHARACTER,
INTENT(IN) :: uplo
133 INTEGER,
INTENT(IN) :: n
134 REAL(kind=
dp),
DIMENSION(:, :),
TARGET :: a
135 INTEGER,
INTENT(IN) :: ia, ja
136 INTEGER,
DIMENSION(9) :: desca
137 INTEGER,
TARGET :: info
139 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pdpotri_dlaf'
143 CALL timeset(routinen, handle)
145 CALL dlaf_pdpotri(uplo, n, a, ia, ja, desca, info)
154 cpabort(
"CP2K compiled without the DLA-Future library.")
156 CALL timestop(handle)
171 CHARACTER,
INTENT(IN) :: uplo
172 INTEGER,
INTENT(IN) :: n
173 REAL,
DIMENSION(:, :),
TARGET :: a
174 INTEGER,
INTENT(IN) :: ia, ja
175 INTEGER,
DIMENSION(9) :: desca
176 INTEGER,
TARGET :: info
178 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pspotri_dlaf'
182 CALL timeset(routinen, handle)
185 CALL dlaf_pspotri(uplo, n, a, ia, ja, desca, info)
194 cpabort(
"CP2K compiled without the DLA-Future library.")
196 CALL timestop(handle)
207 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
208 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
210 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_dlaf'
212 INTEGER :: handle, n, nmo
213 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
215 CALL timeset(routinen, handle)
217 n = matrix%matrix_struct%nrow_global
220 CALL cp_fm_diag_dlaf_base(matrix, eigenvectors, eig)
222 nmo =
SIZE(eigenvalues, 1)
224 eigenvalues(1:n) = eig(1:n)
226 eigenvalues(1:nmo) = eig(1:nmo)
231 CALL timestop(handle)
242 SUBROUTINE cp_fm_diag_dlaf_base(matrix, eigenvectors, eigenvalues)
243 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
244 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
246 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', routinen =
'cp_fm_diag_dlaf_base'
247 CHARACTER,
PARAMETER :: uplo =
'L'
249 CHARACTER(LEN=100) :: message
250 INTEGER :: dlaf_handle, handle, n
251 INTEGER,
DIMENSION(9) :: desca, descz
252 INTEGER,
TARGET :: info
253 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, z
255 CALL timeset(routinen, handle)
265 n = matrix%matrix_struct%nrow_global
267 a => matrix%local_data
268 z => eigenvectors%local_data
270 desca(:) = matrix%matrix_struct%descriptor(:)
271 descz(:) = eigenvectors%matrix_struct%descriptor(:)
274 CALL timeset(dlaf_name, dlaf_handle)
276 CALL dlaf_pdsyevd(uplo, n, a, 1, 1, desca, eigenvalues, z, 1, 1, descz, info)
278 CALL timestop(dlaf_handle)
281 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYEVD: Eigensolver failed (INFO = ", info,
")"
282 cpabort(trim(message))
290 mark_used(eigenvectors)
291 mark_used(eigenvalues)
295 mark_used(dlaf_handle)
298 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
301 CALL timestop(handle)
303 END SUBROUTINE cp_fm_diag_dlaf_base
315 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
316 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
318 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_gen_dlaf'
320 INTEGER :: handle, n, nmo
321 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
323 CALL timeset(routinen, handle)
325 n = a_matrix%matrix_struct%nrow_global
328 CALL cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eig)
330 nmo =
SIZE(eigenvalues, 1)
332 eigenvalues(1:n) = eig(1:n)
334 eigenvalues(1:nmo) = eig(1:nmo)
339 CALL timestop(handle)
351 SUBROUTINE cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eigenvalues)
352 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
353 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
355 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', &
356 routinen =
'cp_fm_diag_gen_dlaf_base'
357 CHARACTER,
PARAMETER :: uplo =
'L'
359 CHARACTER(LEN=100) :: message
360 INTEGER :: dlaf_handle, handle, n
361 INTEGER,
DIMENSION(9) :: desca, descb, descz
362 INTEGER,
TARGET :: info
363 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, b, z
365 CALL timeset(routinen, handle)
376 n = a_matrix%matrix_struct%nrow_global
378 a => a_matrix%local_data
379 b => b_matrix%local_data
380 z => eigenvectors%local_data
382 desca(:) = a_matrix%matrix_struct%descriptor(:)
383 descb(:) = b_matrix%matrix_struct%descriptor(:)
384 descz(:) = eigenvectors%matrix_struct%descriptor(:)
387 CALL timeset(dlaf_name, dlaf_handle)
388 CALL dlaf_pdsygvd(uplo, n, a, 1, 1, desca, b, 1, 1, descb, eigenvalues, z, 1, 1, descz, info)
389 CALL timestop(dlaf_handle)
392 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYGVD: Generalized Eigensolver failed (INFO = ", info,
")"
393 cpabort(trim(message))
404 mark_used(eigenvectors)
405 mark_used(eigenvalues)
409 mark_used(dlaf_handle)
412 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
415 CALL timestop(handle)
417 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_pspotri_dlaf(uplo, n, a, ia, ja, desca, info)
Inverse from Cholesky factorization using DLA-Future.
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_pspotrf_dlaf(uplo, n, a, ia, ja, desca, info)
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
integer, parameter, public sp