33 use cdenprop_defs,
only: civect, maxnuc
34 use const_gbl,
only: stdout
37 use mpi_gbl,
only: master, mpi_xermsg, mpi_mod_isend, mpi_mod_recv
38 use params,
only: ccidata, c8stars, cblank, cpoly
39 use scatci_routines,
only: movep, civio, movew
57 integer :: io_unit = 25
58 integer :: symmetry_type
59 integer :: num_eigenpairs
60 real(wp),
allocatable :: energy_shifts(:)
61 real(wp) :: core_energy
62 real(wp) :: energy_shift
63 integer,
allocatable ::
phase(:)
67 integer :: current_eigenvector = 0
68 integer :: print_all_eigs = 0
92 class(
options),
intent(in) :: opts
96 this % symmetry_type = opts % sym_group_flag
97 this % io_unit = opts % ci_output_unit
98 this % continuum_dimen = opts % seq_num_last_continuum_csf
99 this % vec_dimen = opts % contracted_mat_size
100 this % num_eigenpairs = opts % num_eigenpairs
101 this % vector_storage = opts % vector_storage_method
102 this % print_all_eigs = opts % print_flags(2)
104 if (.not.(
allocated(this % energy_shifts)))
then
105 allocate(this % energy_shifts(this % num_eigenpairs))
106 n = min(this % num_eigenpairs,
size(opts % energy_shifts))
107 this % energy_shifts = 0.0_wp
108 this % energy_shifts(1:n) = opts % energy_shifts(1:n)
124 if (
allocated(this % energy_shifts))
then
125 deallocate (this % energy_shifts)
128 if (
allocated(this % phase))
then
129 deallocate (this % phase)
132 call this % ci_vec % final_CV
148 class(
options),
intent(in) :: option
151 integer :: print_header
152 integer :: nnuc, nrec, i, buf(1), n = 1, tag = 0
153 integer :: ierror, nth, nhd(10)
156 this % core_energy = integrals % get_core_energy()
158 if (grid % grank /= master)
return
159 this % nciset = option % output_ci_set_number
160 if (option % output_ci_set_number < 0)
return
165 if (option % preceding_writer >= 0)
then
166 call mpi_mod_recv(option % preceding_writer, tag, buf, n)
169 this % size_phase = min(
size(option % phase_index), this % vec_dimen)
171 if (.not.(
allocated(this % phase)))
then
172 allocate(this % phase(this % vec_dimen))
174 this % phase(1:this % size_phase) = option % phase_index(1:this % size_phase)
177 nset = option % output_ci_set_number
180 print_header = option % print_dataset_heading
188 call movep(this % io_unit, nth, ierror, print_header, stdout)
190 if (ierror /= 0)
then
191 call mpi_xermsg(
'SolutionHandler_module',
'write_header_sol', &
192 ' ERROR POSITIONING FOR OUTPUT OF CI COEFFICIENTS', 1, 1)
196 nnuc = integrals % get_num_nuclei()
197 nrec = nnuc + this % num_eigenpairs + 1
199 write (this % io_unit) c8stars, cblank, cblank, ccidata
200 write (this % io_unit) nset, nrec, option % diag_name(1:120), nnuc, option % contracted_mat_size, &
201 this % num_eigenpairs, option % lambda, option % spin, option % spin_z, &
202 option % num_electrons, this % core_energy, option % num_target_sym, &
203 (option % lambda_continuum_orbitals_target(i), &
204 option % num_continuum_orbitals_target(i), i = 1, option % num_target_sym)
206 call integrals % write_geometries(this % io_unit)
211 call movew(this % io_unit, nth, ierror, print_header, stdout)
213 if (ierror /= 0)
then
214 call mpi_xermsg(
'SolutionHandler_module',
'write_header_sol', &
215 ' ERROR POSITIONING FOR OUTPUT OF CI COEFFICIENTS', 2, 1)
219 nhd( 2) = option % contracted_mat_size
220 nhd( 3) = this % num_eigenpairs
221 nhd( 4) = option % num_syms
222 nhd( 8) = option % contracted_mat_size
223 nhd( 9) = integrals % get_num_nuclei()
224 nhd(10) = merge(1, 0, this % num_eigenpairs < option % contracted_mat_size)
227 write (this % io_unit) nth, nhd, option % diag_name(1:120), integrals % NHE, integrals % DTNUC
231 write (stdout,
"(' CI data will be stored as set number',I3)") nset
247 class(
options),
intent(in) :: option
253 this % core_energy = integrals % get_core_energy()
254 this % size_phase = min(
size(option % phase_index), this % vec_dimen)
256 if (.not.(
allocated(this % phase)))
then
257 allocate(this % phase(this % vec_dimen), stat = err)
259 call mpi_xermsg(
'SolutionHandler_module',
'export_header_sol', &
260 'Error allocating internal phase array', 1, 1)
263 this % phase(1:this % size_phase) = option % phase_index(1:this % size_phase)
267 this % ci_vec % Nset = option % output_ci_set_number
268 this % ci_vec % nrec = integrals % get_num_nuclei() + this % num_eigenpairs + 1
269 this % ci_vec % name = option % diag_name
270 this % ci_vec % nnuc = integrals % get_num_nuclei()
271 this % ci_vec % nocsf = option % contracted_mat_size
272 this % ci_vec % nstat = this % num_eigenpairs
273 this % ci_vec % mgvn = option % lambda
274 this % ci_vec % s = option % spin
275 this % ci_vec % sz = option % spin_z
276 this % ci_vec % nelt = option % num_electrons
277 this % ci_vec % e0 = this % core_energy
279 if (this % ci_vec % nnuc > maxnuc)
then
280 call mpi_xermsg(
'SolutionHandler_module',
'export_header_sol', &
281 'Increase the value of maxnuc in cdenprop_defs and recompile', 2, 1)
284 select type (integrals)
286 this % ci_vec % cname (1:this % ci_vec % nnuc) = integrals % cname (1:this % ci_vec % nnuc)
287 this % ci_vec % charge(1:this % ci_vec % nnuc) = integrals % charge(1:this % ci_vec % nnuc)
288 this % ci_vec % xnuc (1:this % ci_vec % nnuc) = integrals % xnuc (1:this % ci_vec % nnuc)
289 this % ci_vec % ynuc (1:this % ci_vec % nnuc) = integrals % ynuc (1:this % ci_vec % nnuc)
290 this % ci_vec % znuc (1:this % ci_vec % nnuc) = integrals % znuc (1:this % ci_vec % nnuc)
292 this % ci_vec % cname (1:this % ci_vec % nnuc) = integrals % cname (1:this % ci_vec % nnuc)
293 this % ci_vec % charge(1:this % ci_vec % nnuc) = integrals % charge(1:this % ci_vec % nnuc)
294 this % ci_vec % xnuc (1:this % ci_vec % nnuc) = integrals % xnuc (1:this % ci_vec % nnuc)
295 this % ci_vec % ynuc (1:this % ci_vec % nnuc) = integrals % ynuc (1:this % ci_vec % nnuc)
296 this % ci_vec % znuc (1:this % ci_vec % nnuc) = integrals % znuc (1:this % ci_vec % nnuc)
298 call mpi_xermsg(
'SolutionHandler_module',
'export_header_sol', &
299 'Geometry export implemented only for UKRMOLIntegral, SWEDENIntegral', 3, 1)
302 write (stdout,
'(/,"CI VECTOR HEADER DATA:")')
303 write (stdout,
'("----------------------")')
304 write (stdout, *) this % ci_vec % nset, &
305 this % ci_vec % nrec, &
306 this % ci_vec % NAME, &
307 this % ci_vec % nnuc, &
308 this % ci_vec % nocsf, &
309 this % ci_vec % nstat, &
310 this % ci_vec % mgvn, &
312 this % ci_vec % sz, &
313 this % ci_vec % nelt, &
315 do i = 1, this % ci_vec % nnuc
316 write (stdout, *) this % ci_vec % cname(i), &
317 this % ci_vec % xnuc(i), &
318 this % ci_vec % ynuc(i), &
319 this % ci_vec % znuc(i), &
320 this % ci_vec % charge(i)
322 write (stdout,
'("----------------------")')
324 call mpi_xermsg(
'SolutionHandler_module',
'export_header_sol', &
325 'Output of ALCHEMY header not implemented yet', 4, 1)
328 write (stdout,
'(" CI data will be stored in memory for use in subsequent subroutines")')
343 integer,
intent(in) :: num_eigenpairs
344 real(wp),
intent(inout) :: output_eigenvalues(num_eigenpairs)
345 integer :: ido, jdo, neig
347 if (grid % grank /= master)
return
348 if (this % nciset < 0)
return
350 output_eigenvalues = output_eigenvalues + this % energy_shifts
352 neig = this % num_eigenpairs
353 if (this % print_all_eigs == 0)
then
354 neig = min(this % num_eigenpairs,
max_neig)
357 write (stdout,
'("ENERGY SHIFTS TO BE APPLIED")')
359 write (stdout,
"(5F20.10)") (this % energy_shifts(jdo), jdo = ido, min(ido + 4, neig))
375 integer,
intent(in) :: num_eigenpairs, vec_dimen
376 real(wp),
intent(in) :: eigenvalues(num_eigenpairs), diagonals(vec_dimen)
377 real(wp) :: output_eigenvalues(num_eigenpairs)
378 integer :: ido, jdo, neig
380 if (grid % grank /= master)
return
381 if (this % nciset < 0)
return
383 output_eigenvalues = eigenvalues
385 neig = this % num_eigenpairs
386 if (this % print_all_eigs == 0)
then
387 neig = min(this % num_eigenpairs,
max_neig)
390 if (sum(abs(this % energy_shifts)) .gt. 0_wp)
then
391 write (stdout,
'("ORIGINAL EIGEN-ENERGIES")')
393 write (stdout,
"(16X,5F20.10)") (output_eigenvalues(jdo) + this % core_energy, jdo = ido, min(ido + 4, neig))
395 call this % shift_eigenvalues(output_eigenvalues, num_eigenpairs)
398 write (stdout,
'("EIGEN-ENERGIES")')
400 write (stdout,
"(16X,5F20.10)") (output_eigenvalues(jdo) + this % core_energy, jdo = ido, min(ido + 4, neig))
402 write (this % io_unit) this % phase, output_eigenvalues, diagonals
417 integer,
intent(in) :: num_eigenpairs, vec_dimen
418 real(wp),
intent(in) :: eigenvalues(num_eigenpairs), diagonals(vec_dimen)
419 real(wp),
allocatable :: ei(:)
420 real(wp) :: output_eigenvalues(num_eigenpairs)
421 integer,
allocatable :: iphz(:)
422 integer :: ido, jdo, err
424 output_eigenvalues = eigenvalues
426 if (sum(abs(this % energy_shifts)) .gt. 0_wp)
then
427 call this % shift_eigenvalues(output_eigenvalues, num_eigenpairs)
430 if (
allocated(ei))
deallocate(ei)
431 allocate(ei, source = output_eigenvalues, stat = err)
433 call mpi_xermsg(
'SolutionHandler_module',
'export_eigenvalues',
'Error allocating ei',
size(output_eigenvalues), 1)
436 if (
allocated(iphz))
deallocate(iphz)
437 allocate(iphz, source = this % phase, stat = err)
439 call mpi_xermsg(
'SolutionHandler_module',
'export_eigenvalues',
'Error allocating iphz',
size(this % phase), 1)
455 integer,
intent(in) :: vec_dimen
456 real(wp),
intent(in) :: eigenvector(vec_dimen)
457 integer :: start_dimen, end_dimen, ido, j
459 if (grid % grank /= master)
return
460 if (this % nciset < 0)
return
462 this % current_eigenvector = this % current_eigenvector + 1
465 end_dimen = this % vec_dimen
468 end_dimen = this % continuum_dimen
471 start_dimen = this % continuum_dimen + 1
474 write (this % io_unit) this % current_eigenvector, (eigenvector(j), j = start_dimen, end_dimen)
490 class(
options),
intent(in) :: option
492 integer :: buf(1), tag = 0, n = 1
494 flush(this % io_unit)
495 close(this % io_unit)
497 if (option % following_writer >= 0)
then
498 call mpi_mod_isend(option % following_writer, buf, tag, n)