33 use precisn,
only: longint, wp
34 use const_gbl,
only: stdout
41 use mpi_gbl,
only: myrank, master, mpi_xermsg
42 use m_4_mkarp,
only: mkarp
55 subroutine diagonalize_arpack (this, matrix_elements, num_eigenpair, dresult, all_procs, option, integrals)
58 class(
basematrix),
intent(in) :: matrix_elements
60 type(
options),
intent(in) :: option
61 integer,
intent(in) :: num_eigenpair
62 logical,
intent(in) :: all_procs
64 integer :: max_iterations
65 real(wp) :: max_tolerance
68 if (myrank /= master)
return
71 call mpi_xermsg(
'ARPACKDiagonalizer_module',
'diagonalize_ARPACK', &
72 'PASS_TO_CDENPROP not implemented for Arpack', 1, 1)
75 max_iterations = option % max_iterations
76 max_tolerance = option % max_tolerance
78 if (max_iterations < 0)
then
79 max_iterations = max(num_eigenpair * 50, 500)
82 select type(matrix_elements)
84 call this % diagonalize_writermatrix(matrix_elements, num_eigenpair, dresult, max_iterations, max_tolerance, &
87 call mpi_xermsg(
'ARPACKDiagonalizer_module',
'diagonalize_ARPACK', &
88 'Only WriterMatrix format can use Arpack', 1, 1)
100 type(
options),
intent(in) :: option
101 integer,
intent(in) :: num_eigenpair
102 integer,
intent(in) :: max_iterations
103 real(wp),
intent(in) :: max_tolerance
107 integer :: matrix_unit
108 integer :: matrix_size
111 integer :: arpack_numeig
112 integer :: arpack_maxit
113 real(wp) :: arpack_maxtol
114 integer :: num_matrix_elements_per_record, num_elems
116 real(wp),
allocatable :: eigenvalues(:), eigenvector(:)
118 write (stdout,
"('Diagonalization done with ARPACK')")
119 write (stdout,
"('Parameters:')")
120 write (stdout,
"('N: ',i8)") matrix_elements % get_matrix_size()
121 write (stdout,
"('Requested # of eigenpairs',i8)") num_eigenpair
123 arpack_numeig = num_eigenpair
124 arpack_maxit = max_iterations
125 arpack_maxtol = max_tolerance
126 matrix_size = matrix_elements % get_matrix_size()
127 num_elems = matrix_elements % get_size()
128 matrix_unit = matrix_elements % get_matrix_unit()
130 allocate(eigenvalues(num_eigenpair), eigenvector(matrix_size))
132 call mkarp(matrix_size, arpack_numeig, arpack_maxit, arpack_maxtol, matrix_unit)
138 open (unit = 11, file =
"___tmp_eigensys", status =
"old", action =
"read", form =
"unformatted")
142 do i1 = 1, num_eigenpair
143 read (unit = 11) eigenvalues(i1)
147 call dresult % export_header(option, integrals)
149 call dresult % write_header(option, integrals)
150 call dresult % handle_eigenvalues(eigenvalues, matrix_elements % diagonal, num_eigenpair, matrix_size)
154 do i1 = 1, num_eigenpair
155 do i2 = 1, matrix_size
156 read (unit = 11) eigenvector(i2)
158 call dresult % handle_eigenvector(eigenvector, matrix_size)
165 close (unit = 11, status =
"delete")
167 deallocate(eigenvalues, eigenvector)