44 use const_gbl,
only: stdout
45 use global_utils,
only: print_ukrmol_header
46 use precisn,
only: wp, longint
47 use mpi_gbl,
only: mpi_mod_start, mpi_mod_finalize, master, myrank, mpi_mod_print_info
76 class(
basematrix),
pointer :: matrix_elements => null()
80 real(wp),
allocatable :: test_eig(:), test_vecs(:,:)
81 integer :: num_mat_elms, i, j
83 logical,
parameter :: sequential_diagonalizations = .true.
84 logical,
parameter :: master_writes_to_stdout = .true.
85 logical,
parameter :: allow_shared_memory = .true.
87 call mpi_mod_start(master_writes_to_stdout, allow_shared_memory)
89 if (myrank == master)
call print_ukrmol_header(stdout)
90 call mpi_mod_print_info(stdout)
96 call scatci_input % read
97 allocate (solutions(
size(scatci_input % opts)))
100 call process_grid % setup(
size(scatci_input % opts), sequential_diagonalizations)
102 if (.not.
process_grid % sequential)
call scatci_input % setup_write_order
105 symmetry_loop:
do i = 1,
size(scatci_input % opts)
111 call orbitals % initialize(scatci_input % opts(i) % tot_num_spin_orbitals, &
112 scatci_input % opts(i) % tot_num_orbitals, &
113 scatci_input % opts(i) % sym_group_flag, &
114 scatci_input % opts(i) % num_syms, &
115 scatci_input % opts(i) % positron_flag)
116 call orbitals % construct(scatci_input % opts(i) % num_orbitals_sym, &
117 scatci_input % opts(i) % num_target_orbitals_sym_dinf_congen, &
118 scatci_input % opts(i) % num_orbitals_sym, &
119 scatci_input % opts(i) % num_electronic_orbitals_sym, &
120 scatci_input % opts(i) % num_target_orbitals_sym_congen)
123 call orbitals % compute_electron_index(scatci_input % opts(i) % num_electrons, &
124 scatci_input % opts(i) % reference_dtrs)
127 call configuration_manager % initialize(scatci_input % opts(i), orbitals)
131 call configuration_manager % create_csfs(csfs, &
132 scatci_input % opts(i) % orbital_sequence_number, &
133 scatci_input % opts(i) % num_ci_target_sym, &
134 scatci_input % opts(i) % lambda_continuum_orbitals_target)
139 if (.not.
associated(integrals))
then
141 scatci_input % opts(i) % use_UKRMOL_integrals, &
143 call integrals % initialize(scatci_input % opts(i), &
144 orbitals % total_num_orbitals, &
145 orbitals % orbital_map)
146 call integrals % load_integrals(scatci_input % opts(i) % integral_unit)
150 write (stdout, *)
' Load CI target and construct matrix elements'
161 if (scatci_input % opts(i) % do_ci_contraction())
then
163 allocate(ci_rmat(scatci_input % opts(i) % num_target_sym))
164 do j = 1, scatci_input % opts(i) % num_target_sym
165 call ci_rmat(j) % initialize(j, &
166 scatci_input % opts(i) % num_target_state_sym(j), &
167 scatci_input % opts(i) % num_ci_target_sym(j), &
168 scatci_input % opts(i) % ci_phase(j), &
169 integrals % get_core_energy())
172 if (scatci_input % opts(i) % ci_target_switch > 0)
then
175 do j = 1, scatci_input % opts(i) % num_target_sym
178 scatci_input % opts(i) % force_serial, &
179 scatci_input % opts(i) % num_ci_target_sym(j), &
180 ci_rmat(j) % nstat, &
184 scatci_input % opts(i) % hamiltonian_unit)
187 call matrix_elements % set_options(scatci_input % opts(i))
189 call tgt_ci_hamiltonian % construct(scatci_input % opts(i), csfs, orbitals, integrals)
190 call tgt_ci_hamiltonian % initialize(j)
193 call tgt_ci_hamiltonian % build_hamiltonian(matrix_elements)
198 call diagonalizer % diagonalize(matrix_elements, ci_rmat(j) % nstat, ci_rmat(j), .true., &
199 scatci_input % opts(i), integrals)
202 call ci_rmat(j) % print
205 call matrix_elements % destroy
206 if (
process_grid % grank == master)
close (scatci_input % opts(i) % hamiltonian_unit)
207 deallocate(matrix_elements, diagonalizer)
208 deallocate(tgt_ci_hamiltonian)
215 scatci_input % opts(i) % force_serial, &
216 scatci_input % opts(i) % contracted_mat_size, &
217 scatci_input % opts(i) % num_eigenpairs, &
221 scatci_input % opts(i) % hamiltonian_unit)
223 call matrix_elements % set_options(scatci_input % opts(i))
225 call integrals % write_matrix_header(scatci_input % opts(i) % hamiltonian_unit, &
226 scatci_input % opts(i) % contracted_mat_size)
229 call matrix_elements % set_options(scatci_input % opts(i))
232 call matrix_elements % exclude_row_column(scatci_input % opts(i) % exclude_rowcolumn)
235 if (scatci_input % opts(i) % do_ci_contraction())
then
236 call enrgmx % construct(scatci_input % opts(i), csfs, orbitals, integrals)
237 call enrgmx % initialize(ci_rmat)
239 call enrgmx % build_hamiltonian(matrix_elements)
243 call enrgms % construct(scatci_input % opts(i), csfs, orbitals, integrals)
244 call master_timer % start_timer(
"Target-Hamiltonian Build")
245 call enrgms % build_hamiltonian(matrix_elements)
246 call master_timer % stop_timer(
"Target-Hamiltonian Build")
253 call configuration_manager % finalize
256 write (stdout,
"('Matrix N is ',i8)") matrix_elements % get_matrix_size()
257 write (stdout,
"('Num elements is ',i14)") matrix_elements % get_size()
261 scatci_input % opts(i) % num_eigenpairs = min(scatci_input % opts(i) % num_eigenpairs, &
262 matrix_elements % get_matrix_size())
263 call solutions(i) % construct(scatci_input % opts(i))
265 call diagonalizer % diagonalize(matrix_elements, &
266 scatci_input % opts(i) % num_eigenpairs, &
269 scatci_input % opts(i), &
273 write (stdout,
'(/,"Diagonalization not selected")')
274 num_mat_elms = matrix_elements % get_size()
282 write (stdout,
'(/,"Parameters written to: ham_data")')
285 if (
process_grid % grank == master)
close (scatci_input % opts(i) % hamiltonian_unit)
287 call matrix_elements % destroy
291 deallocate (diagonalizer)
292 deallocate (matrix_elements)
300 if (
associated(integrals))
then
301 call integrals % finalize
306 call mpi_mod_finalize