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.")
89 CHARACTER,
INTENT(IN) :: uplo
90 INTEGER,
INTENT(IN) :: n
91 REAL,
DIMENSION(:, :),
TARGET :: a
92 INTEGER,
INTENT(IN) :: ia, ja
93 INTEGER,
DIMENSION(9) :: desca
94 INTEGER,
TARGET :: info
96 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_pspotrf_dlaf'
100 CALL timeset(routinen, handle)
103 CALL dlaf_pspotrf(uplo, n, a, ia, ja, desca, info)
112 cpabort(
"CP2K compiled without the DLA-Future library.")
114 CALL timestop(handle)
125 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
126 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
128 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_dlaf'
130 INTEGER :: handle, n, nmo
131 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
133 CALL timeset(routinen, handle)
135 n = matrix%matrix_struct%nrow_global
138 CALL cp_fm_diag_dlaf_base(matrix, eigenvectors, eig)
140 nmo =
SIZE(eigenvalues, 1)
142 eigenvalues(1:n) = eig(1:n)
144 eigenvalues(1:nmo) = eig(1:nmo)
149 CALL timestop(handle)
160 SUBROUTINE cp_fm_diag_dlaf_base(matrix, eigenvectors, eigenvalues)
161 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
162 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
164 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', routinen =
'cp_fm_diag_dlaf_base'
165 CHARACTER,
PARAMETER :: uplo =
'L'
167 CHARACTER(LEN=100) :: message
168 INTEGER :: dlaf_handle, handle, n
169 INTEGER,
DIMENSION(9) :: desca, descz
170 INTEGER,
TARGET :: info
171 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, z
173 CALL timeset(routinen, handle)
183 n = matrix%matrix_struct%nrow_global
185 a => matrix%local_data
186 z => eigenvectors%local_data
188 desca(:) = matrix%matrix_struct%descriptor(:)
189 descz(:) = eigenvectors%matrix_struct%descriptor(:)
192 CALL timeset(dlaf_name, dlaf_handle)
194 CALL dlaf_pdsyevd(uplo, n, a, 1, 1, desca, eigenvalues, z, 1, 1, descz, info)
196 CALL timestop(dlaf_handle)
199 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYEVD: Eigensolver failed (INFO = ", info,
")"
200 cpabort(trim(message))
208 mark_used(eigenvectors)
209 mark_used(eigenvalues)
213 mark_used(dlaf_handle)
216 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
219 CALL timestop(handle)
221 END SUBROUTINE cp_fm_diag_dlaf_base
233 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
234 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
236 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_gen_dlaf'
238 INTEGER :: handle, n, nmo
239 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: eig
241 CALL timeset(routinen, handle)
243 n = a_matrix%matrix_struct%nrow_global
246 CALL cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eig)
248 nmo =
SIZE(eigenvalues, 1)
250 eigenvalues(1:n) = eig(1:n)
252 eigenvalues(1:nmo) = eig(1:nmo)
257 CALL timestop(handle)
269 SUBROUTINE cp_fm_diag_gen_dlaf_base(a_matrix, b_matrix, eigenvectors, eigenvalues)
270 TYPE(
cp_fm_type),
INTENT(IN) :: a_matrix, b_matrix, eigenvectors
271 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT),
TARGET :: eigenvalues
273 CHARACTER(len=*),
PARAMETER :: dlaf_name =
'pdsyevd_dlaf', &
274 routinen =
'cp_fm_diag_gen_dlaf_base'
275 CHARACTER,
PARAMETER :: uplo =
'L'
277 CHARACTER(LEN=100) :: message
278 INTEGER :: dlaf_handle, handle, n
279 INTEGER,
DIMENSION(9) :: desca, descb, descz
280 INTEGER,
TARGET :: info
281 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, b, z
283 CALL timeset(routinen, handle)
294 n = a_matrix%matrix_struct%nrow_global
296 a => a_matrix%local_data
297 b => b_matrix%local_data
298 z => eigenvectors%local_data
300 desca(:) = a_matrix%matrix_struct%descriptor(:)
301 descb(:) = b_matrix%matrix_struct%descriptor(:)
302 descz(:) = eigenvectors%matrix_struct%descriptor(:)
305 CALL timeset(dlaf_name, dlaf_handle)
306 CALL dlaf_pdsygvd(uplo, n, a, 1, 1, desca, b, 1, 1, descb, eigenvalues, z, 1, 1, descz, info)
307 CALL timestop(dlaf_handle)
310 WRITE (message,
"(A,I0,A)")
"ERROR in DLAF_PDSYGVD: Generalized Eigensolver failed (INFO = ", info,
")"
311 cpabort(trim(message))
322 mark_used(eigenvectors)
323 mark_used(eigenvalues)
327 mark_used(dlaf_handle)
330 cpabort(
"CP2K compiled without DLA-Future-Fortran library.")
333 CALL timestop(handle)
335 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_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