13#include "../base/base_uses.f90"
16 USE dlaf_fortran,
ONLY: dlaf_pdpotrf, &
26 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_fm_dlaf_api'
47 CHARACTER,
INTENT(IN) :: uplo
48 INTEGER,
INTENT(IN) :: n
49 REAL(kind=
dp),
DIMENSION(:, :),
TARGET :: a
50 INTEGER,
INTENT(IN) :: ia, ja
51 INTEGER,
DIMENSION(9) :: desca
52 INTEGER,
TARGET :: info
54 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pdpotrf_dlaf'
58 CALL timeset(routinen, handle)
60 CALL dlaf_pdpotrf(uplo, n, a, ia, ja, desca, info)
69 cpabort(
"CP2K compiled without the DLA-Future library.")
88 CHARACTER,
INTENT(IN) :: uplo
89 INTEGER,
INTENT(IN) :: n
90 REAL,
DIMENSION(:, :),
TARGET :: a
91 INTEGER,
INTENT(IN) :: ia, ja
92 INTEGER,
DIMENSION(9) :: desca
93 INTEGER,
TARGET :: info
95 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pspotrf_dlaf'
99 CALL timeset(routinen, handle)
102 CALL dlaf_pspotrf(uplo, n, a, ia, ja, desca, info)
111 cpabort(
"CP2K compiled without the DLA-Future library.")
113 CALL timestop(handle)
124 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
125 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
127 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_dlaf'
129 INTEGER :: handle, n, nmo
130 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
132 CALL timeset(routinen, handle)
134 n = matrix%matrix_struct%nrow_global
137 CALL cp_fm_diag_dlaf_base(matrix, eigenvectors, eig)
139 nmo =
SIZE(eigenvalues, 1)
141 eigenvalues(1:n) = eig(1:n)
143 eigenvalues(1:nmo) = eig(1:nmo)
148 CALL timestop(handle)
159 SUBROUTINE cp_fm_diag_dlaf_base(matrix, eigenvectors, eigenvalues)
160 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
161 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
163 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', routinen =
'cp_fm_diag_dlaf_base'
164 CHARACTER,
PARAMETER :: uplo =
'L'
166 CHARACTER(LEN=100) :: message
167 INTEGER :: dlaf_handle, handle, n
168 INTEGER,
DIMENSION(9) :: desca, descz
169 INTEGER,
TARGET :: info
170 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, z
172 CALL timeset(routinen, handle)
179 n = matrix%matrix_struct%nrow_global
181 a => matrix%local_data
182 z => eigenvectors%local_data
184 desca(:) = matrix%matrix_struct%descriptor(:)
185 descz(:) = eigenvectors%matrix_struct%descriptor(:)
188 CALL timeset(dlaf_name, dlaf_handle)
190 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 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
215 CALL timestop(handle)
217 END SUBROUTINE cp_fm_diag_dlaf_base
229 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
230 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
232 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_gen_dlaf'
234 INTEGER :: handle, n, nmo
235 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
237 CALL timeset(routinen, handle)
239 n = a_matrix%matrix_struct%nrow_global
242 CALL cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eig)
244 nmo =
SIZE(eigenvalues, 1)
246 eigenvalues(1:n) = eig(1:n)
248 eigenvalues(1:nmo) = eig(1:nmo)
253 CALL timestop(handle)
265 SUBROUTINE cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eigenvalues)
266 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
267 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
269 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', &
270 routinen =
'cp_fm_diag_gen_dlaf_base'
271 CHARACTER,
PARAMETER :: uplo =
'L'
273 CHARACTER(LEN=100) :: message
274 INTEGER :: dlaf_handle, handle, n
275 INTEGER,
DIMENSION(9) :: desca, descb, descz
276 INTEGER,
TARGET :: info
277 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, b, z
279 CALL timeset(routinen, handle)
287 n = a_matrix%matrix_struct%nrow_global
289 a => a_matrix%local_data
290 b => b_matrix%local_data
291 z => eigenvectors%local_data
293 desca(:) = a_matrix%matrix_struct%descriptor(:)
294 descb(:) = b_matrix%matrix_struct%descriptor(:)
295 descz(:) = eigenvectors%matrix_struct%descriptor(:)
298 CALL timeset(dlaf_name, dlaf_handle)
300 CALL dlaf_pdsygvd(uplo, n, a, 1, 1, desca, b, 1, 1, descb, eigenvalues, z, 1, 1, descz, info)
302 CALL timestop(dlaf_handle)
305 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYGVD: Generalized Eigensolver failed (INFO = ", info,
")"
306 cpabort(trim(message))
317 mark_used(eigenvectors)
318 mark_used(eigenvalues)
322 mark_used(dlaf_handle)
325 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
328 CALL timestop(handle)
330 END SUBROUTINE cp_fm_diag_gen_dlaf_base
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_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