28#include "../base/base_uses.f90"
59 nval_request, nrestarts, generalized_ev, iram)
64 INTEGER :: selection_crit, nval_request, nrestarts
65 LOGICAL :: generalized_ev, iram
67 CALL setup_arnoldi_control(arnoldi_env, matrix, max_iter, threshold, selection_crit, &
68 nval_request, nrestarts, generalized_ev, iram)
70 CALL setup_arnoldi_data(arnoldi_env, matrix, max_iter)
80 SUBROUTINE setup_arnoldi_data(arnoldi_env, matrix, max_iter)
89 CALL dbcsr_get_info(matrix=matrix(1)%matrix, nfullrows_local=nrow_local)
90 ALLOCATE (ar_data%f_vec(nrow_local))
91 ALLOCATE (ar_data%x_vec(nrow_local))
92 ALLOCATE (ar_data%Hessenberg(max_iter + 1, max_iter))
93 ALLOCATE (ar_data%local_history(nrow_local, max_iter))
95 ALLOCATE (ar_data%evals(max_iter))
96 ALLOCATE (ar_data%revec(max_iter, max_iter))
100 END SUBROUTINE setup_arnoldi_data
114 SUBROUTINE setup_arnoldi_control(arnoldi_env, matrix, max_iter, threshold, selection_crit, &
115 nval_request, nrestarts, generalized_ev, iram)
119 REAL(
dp) :: threshold
120 INTEGER :: selection_crit, nval_request, nrestarts
121 LOGICAL :: generalized_ev, iram
123 INTEGER :: group_handle, pcol_handle
124 LOGICAL :: subgroups_defined
133 group=group_handle, &
134 mynode=control%myproc, &
135 subgroups_defined=subgroups_defined, &
136 pcol_group=pcol_handle)
138 CALL control%mp_group%set_handle(group_handle)
139 CALL control%pcol_group%set_handle(pcol_handle)
141 IF (.NOT. subgroups_defined)
THEN
142 cpabort(
"arnoldi only with subgroups")
145 control%symmetric = .false.
147 IF (
SIZE(matrix) == 1)
THEN
152 control%max_iter = max_iter
153 control%current_step = 0
154 control%selection_crit = selection_crit
155 control%nval_req = nval_request
156 control%threshold = threshold
157 control%converged = .false.
158 control%has_initial_vector = .false.
160 control%nrestart = nrestarts
161 control%generalized_ev = generalized_ev
163 IF (control%nval_req > 1 .AND. control%nrestart > 0 .AND. .NOT. control%iram)
THEN
164 CALL cp_abort(__location__,
'with more than one eigenvalue requested '// &
165 'internal restarting with a previous EVEC is a bad idea, set IRAM or nrestsart=0')
169 IF (control%generalized_ev .AND. selection_crit == 1)
THEN
170 CALL cp_abort(__location__, &
171 'generalized ev can only highest OR lowest EV')
173 IF (control%generalized_ev .AND. nval_request /= 1)
THEN
174 CALL cp_abort(__location__, &
175 'generalized ev can only compute one EV at the time')
177 IF (control%generalized_ev .AND. control%nrestart == 0)
THEN
178 CALL cp_abort(__location__, &
179 'outer loops are mandatory for generalized EV, set nrestart appropriatly')
181 IF (
SIZE(matrix) /= 2 .AND. control%generalized_ev)
THEN
182 CALL cp_abort(__location__, &
183 'generalized ev needs exactly two matrices as input (2nd is the metric)')
186 ALLOCATE (control%selected_ind(max_iter))
189 END SUBROUTINE setup_arnoldi_control
203 COMPLEX(dp),
ALLOCATABLE,
DIMENSION(:) :: ritz_v
204 INTEGER :: i, myind, sspace_size, vsize
205 INTEGER,
DIMENSION(:),
POINTER :: selected_ind
206 REAL(kind=
dp),
DIMENSION(:),
POINTER :: data_vec
213 sspace_size = get_subsp_size(arnoldi_env)
214 vsize =
SIZE(ar_data%f_vec)
215 myind = selected_ind(ind)
216 ALLOCATE (ritz_v(vsize))
217 ritz_v = cmplx(0.0, 0.0,
dp)
221 IF (control%local_comp)
THEN
222 DO i = 1, sspace_size
223 ritz_v(:) = ritz_v(:) + ar_data%local_history(:, i)*ar_data%revec(i, myind)
228 data_vec(1:vsize) = real(ritz_v(1:vsize), kind=
dp)
246 IF (
ASSOCIATED(ar_data%f_vec))
DEALLOCATE (ar_data%f_vec)
247 IF (
ASSOCIATED(ar_data%x_vec))
DEALLOCATE (ar_data%x_vec)
248 IF (
ASSOCIATED(ar_data%Hessenberg))
DEALLOCATE (ar_data%Hessenberg)
249 IF (
ASSOCIATED(ar_data%local_history))
DEALLOCATE (ar_data%local_history)
250 IF (
ASSOCIATED(ar_data%evals))
DEALLOCATE (ar_data%evals)
251 IF (
ASSOCIATED(ar_data%revec))
DEALLOCATE (ar_data%revec)
255 DEALLOCATE (control%selected_ind)
267 INTEGER :: i, last_el, my_crit, my_ind
268 REAL(
dp) :: convergence
275 last_el = control%current_step
276 convergence = real(0.0,
dp)
277 my_crit = control%selection_crit
278 control%nval_out = min(control%nval_req, control%current_step)
279 SELECT CASE (my_crit)
282 CALL index_min_max_real_eval(ar_data%evals, control%current_step, control%selected_ind, control%nval_out)
285 CALL index_nmax_real_eval(ar_data%evals, control%current_step, control%selected_ind, control%nval_out)
288 CALL index_nmin_real_eval(ar_data%evals, control%current_step, control%selected_ind, control%nval_out)
290 cpabort(
"unknown selection index")
293 DO i = 1, control%nval_out
294 my_ind = control%selected_ind(i)
295 convergence = max(convergence, &
296 abs(ar_data%revec(last_el, my_ind)*ar_data%Hessenberg(last_el + 1, last_el)))
298 control%converged = convergence < control%threshold
307 SUBROUTINE set_eval_selection(arnoldi_env, itype)
314 control%selection_crit = itype
315 END SUBROUTINE set_eval_selection
329 nrestart = control%nrestart
338 FUNCTION get_nval_out(arnoldi_env)
RESULT(nval_out)
345 nval_out = control%nval_out
347 END FUNCTION get_nval_out
354 FUNCTION get_subsp_size(arnoldi_env)
RESULT(current_step)
356 INTEGER :: current_step
361 current_step = control%current_step
363 END FUNCTION get_subsp_size
377 converged = control%converged
390 COMPLEX(dp) :: eval_out
392 COMPLEX(dp),
DIMENSION(:),
POINTER :: evals
394 INTEGER,
DIMENSION(:),
POINTER :: selected_ind
396 IF (ind > get_nval_out(arnoldi_env))
THEN
397 cpabort(
'outside range of indexed evals')
401 ev_ind = selected_ind(ind)
403 eval_out = evals(ev_ind)
413 SUBROUTINE get_all_selected_ritz_val(arnoldi_env, eval_out)
415 COMPLEX(dp),
DIMENSION(:) :: eval_out
417 COMPLEX(dp),
DIMENSION(:),
POINTER :: evals
418 INTEGER :: ev_ind, ind
419 INTEGER,
DIMENSION(:),
POINTER :: selected_ind
422 IF (
SIZE(eval_out) < get_nval_out(arnoldi_env))
THEN
423 cpabort(
'array for eval output too small')
429 DO ind = 1, get_nval_out(arnoldi_env)
430 ev_ind = selected_ind(ind)
431 eval_out(ind) = evals(ev_ind)
434 END SUBROUTINE get_all_selected_ritz_val
445 INTEGER :: ncol_local, nrow_local
446 REAL(kind=
dp),
DIMENSION(:),
POINTER :: data_vec
451 control%has_initial_vector = .true.
454 CALL dbcsr_get_info(matrix=vector, nfullrows_local=nrow_local, nfullcols_local=ncol_local)
456 IF (nrow_local*ncol_local > 0) ar_data%f_vec(1:nrow_local) = data_vec(1:nrow_local)
471 SUBROUTINE index_min_max_real_eval(evals, current_step, selected_ind, neval)
472 COMPLEX(dp),
DIMENSION(:) :: evals
473 INTEGER,
INTENT(IN) :: current_step
474 INTEGER,
DIMENSION(:) :: selected_ind
478 INTEGER,
DIMENSION(current_step) :: indexing
479 REAL(
dp),
DIMENSION(current_step) :: tmp_array
483 tmp_array(1:current_step) = real(evals(1:current_step),
dp)
484 CALL sort(tmp_array, current_step, indexing)
485 DO i = 1, current_step
486 IF (abs(aimag(evals(indexing(i)))) < epsilon(0.0_dp))
THEN
487 selected_ind(1) = indexing(i)
492 DO i = current_step, 1, -1
493 IF (abs(aimag(evals(indexing(i)))) < epsilon(0.0_dp))
THEN
494 selected_ind(2) = indexing(i)
500 END SUBROUTINE index_min_max_real_eval
509 SUBROUTINE index_nmax_real_eval(evals, current_step, selected_ind, neval)
510 COMPLEX(dp),
DIMENSION(:) :: evals
511 INTEGER,
INTENT(IN) :: current_step
512 INTEGER,
DIMENSION(:) :: selected_ind
516 INTEGER,
DIMENSION(current_step) :: indexing
517 REAL(
dp),
DIMENSION(current_step) :: tmp_array
519 nlimit = neval; neval = 0
521 tmp_array(1:current_step) = real(evals(1:current_step),
dp)
522 CALL sort(tmp_array, current_step, indexing)
523 DO i = 1, current_step
524 IF (abs(aimag(evals(indexing(current_step + 1 - i)))) < epsilon(0.0_dp))
THEN
525 selected_ind(i) = indexing(current_step + 1 - i)
527 IF (neval == nlimit)
EXIT
531 END SUBROUTINE index_nmax_real_eval
540 SUBROUTINE index_nmin_real_eval(evals, current_step, selected_ind, neval)
541 COMPLEX(dp),
DIMENSION(:) :: evals
542 INTEGER,
INTENT(IN) :: current_step
543 INTEGER,
DIMENSION(:) :: selected_ind
547 INTEGER,
DIMENSION(current_step) :: indexing
548 REAL(
dp),
DIMENSION(current_step) :: tmp_array
550 nlimit = neval; neval = 0
552 tmp_array(1:current_step) = real(evals(1:current_step),
dp)
553 CALL sort(tmp_array, current_step, indexing)
554 DO i = 1, current_step
555 IF (abs(aimag(evals(indexing(i)))) < epsilon(0.0_dp))
THEN
556 selected_ind(i) = indexing(i)
558 IF (neval == nlimit)
EXIT
562 END SUBROUTINE index_nmin_real_eval
The methods which allow to analyze and manipulate the arnoldi procedure The main routine and this sho...
subroutine, public deallocate_arnoldi_env(arnoldi_env)
Deallocate the data in arnoldi_env.
integer function, public get_nrestart(arnoldi_env)
returns the number of restarts allowed for arnoldi
logical function, public arnoldi_is_converged(arnoldi_env)
Find out whether the method with the current search criterion is converged.
subroutine, public get_selected_ritz_vector(arnoldi_env, ind, matrix, vector)
...
subroutine, public select_evals(arnoldi_env)
perform the selection of eigenvalues, fills the selected_ind array
subroutine, public setup_arnoldi_env(arnoldi_env, matrix, max_iter, threshold, selection_crit, nval_request, nrestarts, generalized_ev, iram)
This routine sets the environment for the arnoldi iteration and the krylov subspace creation....
subroutine, public set_arnoldi_initial_vector(arnoldi_env, vector)
...
complex(dp) function, public get_selected_ritz_val(arnoldi_env, ind)
get a single specific Ritz value from the set of selected
collection of types used in arnoldi
complex(dp) function, dimension(:), pointer, public get_evals(arnoldi_env)
...
type(arnoldi_data_type) function, pointer, public get_data(arnoldi_env)
...
type(arnoldi_control_type) function, pointer, public get_control(arnoldi_env)
...
subroutine, public set_control(arnoldi_env, control)
...
subroutine, public set_data(arnoldi_env, ar_data)
...
integer function, dimension(:), pointer, public get_sel_ind(arnoldi_env)
...
operations for skinny matrices/vectors expressed in dbcsr form
subroutine, public create_col_vec_from_matrix(dbcsr_vec, matrix, ncol)
creates a dbcsr col vector like object which lives on proc_col 0 and has the same row dist as the tem...
character function, public dbcsr_get_matrix_type(matrix)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
real(kind=dp) function, dimension(:), pointer, public dbcsr_get_data_p(matrix, lb, ub)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_mp_grid_setup(dist)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
Defines the basic variable types.
integer, parameter, public dp
All kind of helpful little routines.