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)
105 CALL dlaf_pspotrf(uplo, n, a, ia, ja, desca, info)
114 cpabort(
"CP2K compiled without the DLA-Future library.")
116 CALL timestop(handle)
131 CHARACTER,
INTENT(IN) :: uplo
132 INTEGER,
INTENT(IN) :: n
133 REAL(kind=
dp),
DIMENSION(:, :),
TARGET :: a
134 INTEGER,
INTENT(IN) :: ia, ja
135 INTEGER,
DIMENSION(9) :: desca
136 INTEGER,
TARGET :: info
138 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pdpotri_dlaf'
142 CALL timeset(routinen, handle)
144 CALL dlaf_pdpotri(uplo, n, a, ia, ja, desca, info)
153 cpabort(
"CP2K compiled without the DLA-Future library.")
155 CALL timestop(handle)
170 CHARACTER,
INTENT(IN) :: uplo
171 INTEGER,
INTENT(IN) :: n
172 REAL,
DIMENSION(:, :),
TARGET :: a
173 INTEGER,
INTENT(IN) :: ia, ja
174 INTEGER,
DIMENSION(9) :: desca
175 INTEGER,
TARGET :: info
177 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pspotri_dlaf'
181 CALL timeset(routinen, handle)
184 CALL dlaf_pspotri(uplo, n, a, ia, ja, desca, info)
193 cpabort(
"CP2K compiled without the DLA-Future library.")
195 CALL timestop(handle)
206 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
207 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
209 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_dlaf'
211 INTEGER :: handle, n, nmo
212 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
214 CALL timeset(routinen, handle)
216 n = matrix%matrix_struct%nrow_global
219 CALL cp_fm_diag_dlaf_base(matrix, eigenvectors, eig)
221 nmo =
SIZE(eigenvalues, 1)
223 eigenvalues(1:n) = eig(1:n)
225 eigenvalues(1:nmo) = eig(1:nmo)
230 CALL timestop(handle)
241 SUBROUTINE cp_fm_diag_dlaf_base(matrix, eigenvectors, eigenvalues)
242 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
243 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
245 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', routinen =
'cp_fm_diag_dlaf_base'
246 CHARACTER,
PARAMETER :: uplo =
'L'
248 CHARACTER(LEN=100) :: message
249 INTEGER :: blacs_context, dlaf_handle, handle, n
250 INTEGER,
DIMENSION(9) :: desca, descz
251 INTEGER,
TARGET :: info
252 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, z
254 CALL timeset(routinen, handle)
262 blacs_context = matrix%matrix_struct%context%get_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)
275 CALL dlaf_pdsyevd(uplo, n, a, 1, 1, desca, eigenvalues, z, 1, 1, descz, info)
276 CALL timestop(dlaf_handle)
279 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYEVD: Eigensolver failed (INFO = ", info,
")"
280 cpabort(trim(message))
288 mark_used(eigenvectors)
289 mark_used(eigenvalues)
293 mark_used(dlaf_handle)
296 mark_used(blacs_context)
297 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
300 CALL timestop(handle)
302 END SUBROUTINE cp_fm_diag_dlaf_base
314 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
315 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
317 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_gen_dlaf'
319 INTEGER :: handle, n, nmo
320 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
322 CALL timeset(routinen, handle)
324 n = a_matrix%matrix_struct%nrow_global
327 CALL cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eig)
329 nmo =
SIZE(eigenvalues, 1)
331 eigenvalues(1:n) = eig(1:n)
333 eigenvalues(1:nmo) = eig(1:nmo)
338 CALL timestop(handle)
350 SUBROUTINE cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eigenvalues)
351 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
352 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
354 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', &
355 routinen =
'cp_fm_diag_gen_dlaf_base'
356 CHARACTER,
PARAMETER :: uplo =
'L'
358 CHARACTER(LEN=100) :: message
359 INTEGER :: blacs_context, dlaf_handle, handle, n
360 INTEGER,
DIMENSION(9) :: desca, descb, descz
361 INTEGER,
TARGET :: info
362 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, b, z
364 CALL timeset(routinen, handle)
373 blacs_context = a_matrix%matrix_struct%context%get_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(blacs_context)
410 mark_used(dlaf_handle)
413 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
416 CALL timestop(handle)
418 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