33 use,
intrinsic :: iso_fortran_env
82 type(restart_t),
intent(in) :: restart
83 type(namespace_t),
intent(in) :: namespace
84 class(space_t),
intent(in) :: space
85 type(states_elec_t),
target,
intent(inout) :: st
86 class(mesh_t),
intent(in) :: mesh
87 type(kpoints_t),
intent(in) :: kpoints
88 logical,
optional,
intent(in) :: is_complex
89 logical,
optional,
intent(in) :: packed
91 integer :: nkpt, dim, nst, ierr
92 real(real64),
allocatable :: new_occ(:,:)
99 message(1) =
"Unable to read states information."
103 if (st%parallel_in_states)
then
104 message(1) =
"Internal error: cannot use states_elec_look_and_load when parallel in states."
109 allocate(new_occ(1:nst, 1:st%nik))
111 new_occ(1:min(nst, st%nst),:) = st%occ(1:min(nst, st%nst),:)
112 safe_deallocate_a(st%occ)
113 call move_alloc(new_occ, st%occ)
123 safe_deallocate_a(st%node)
124 safe_allocate(st%node(1:st%nst))
127 safe_deallocate_a(st%eigenval)
128 safe_allocate(st%eigenval(1:st%nst, 1:st%nik))
129 st%eigenval = huge(st%eigenval)
131 if (
present(is_complex))
then
142 if (st%d%ispin ==
spinors)
then
143 safe_allocate(st%spin(1:3, 1:st%nst, 1:st%nik))
150 message(1) =
"Unable to read wavefunctions."
159 subroutine states_elec_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, verbose)
160 type(restart_t),
intent(in) :: restart
161 class(space_t),
intent(in) :: space
162 type(states_elec_t),
target,
intent(in) :: st
163 class(mesh_t),
intent(in) :: mesh
164 type(kpoints_t),
intent(in) :: kpoints
165 integer,
intent(out) :: ierr
166 integer,
optional,
intent(in) :: iter
167 type(lr_t),
optional,
intent(in) :: lr
168 logical,
optional,
intent(in) :: verbose
170 integer :: iunit_wfns, iunit_occs, iunit_states
171 integer :: err, err2(2), ik, idir, ist, idim, itot
172 integer :: root(1:P_STRATEGY_MAX)
173 character(len=MAX_PATH_LEN) :: filename
174 character(len=300) :: lines(3)
175 logical :: lr_wfns_are_associated, should_write, verbose_
176 real(real64) :: kpoint(space%dim)
177 real(real64),
allocatable :: dpsi(:), rff_global(:)
178 complex(real64),
allocatable :: zpsi(:), zff_global(:)
179 integer :: restart_file_format
187 if (restart%skip())
then
193 message(1) =
"Info: Writing states."
199 restart_file_format = restart%file_format_states
200 if (
present(lr))
then
201 lr_wfns_are_associated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
203 assert(lr_wfns_are_associated)
205 restart_file_format = option__restartfileformatstates__obf
210 iunit_states = restart%open(
'states')
211 write(lines(1),
'(a20,1i10)')
'nst= ', st%nst
212 write(lines(2),
'(a20,1i10)')
'dim= ', st%d%dim
213 write(lines(3),
'(a20,1i10)')
'nik= ', st%nik
214 call restart%write(iunit_states, lines, 3, err)
215 if (err /= 0) ierr = ierr + 1
216 call restart%close(iunit_states)
219 iunit_wfns = restart%open(
'wfns')
220 lines(1) =
'# #k-point #st #dim filename'
222 lines(2) =
'%Real_Wavefunctions'
224 lines(2) =
'%Complex_Wavefunctions'
226 call restart%write(iunit_wfns, lines, 2, err)
227 if (err /= 0) ierr = ierr + 2
230 iunit_occs = restart%open(
'occs')
231 lines(1) =
'# occupations | eigenvalue[a.u.] | Im(eigenvalue) [a.u.] | k-points | k-weights | filename | ik | ist | idim'
232 lines(2) =
'%Occupations_Eigenvalues_K-Points'
233 call restart%write(iunit_occs, lines, 2, err)
234 if (err /= 0) ierr = ierr + 4
238 safe_allocate(dpsi(1:mesh%np))
239 safe_allocate(rff_global(1:mesh%np_global))
241 safe_allocate(zpsi(1:mesh%np))
242 safe_allocate(zff_global(1:mesh%np_global))
249 kpoint(1:space%dim) = &
250 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
253 do idim = 1, st%d%dim
255 write(filename,
'(i10.10)') itot
257 write(lines(1),
'(i8,a,i8,a,i8,3a)') ik,
' | ', ist,
' | ', idim,
' | "', trim(filename),
'"'
258 call restart%write(iunit_wfns, lines, 1, err)
259 if (err /= 0) err2(1) = err2(1) + 1
261 write(lines(1),
'(e23.16,a,e23.16)') st%occ(ist,ik),
' | ', st%eigenval(ist, ik)
262 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ',
m_zero
263 do idir = 1, space%dim
264 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ', kpoint(idir)
266 write(lines(1),
'(a,a,e23.16,a,i10.10,3(a,i8))') trim(lines(1)), &
267 ' | ', st%kweights(ik),
' | ', itot,
' | ', ik,
' | ', ist,
' | ', idim
268 call restart%write(iunit_occs, lines, 1, err)
269 if (err /= 0) err2(1) = err2(1) + 1
271 should_write = st%st_start <= ist .and. ist <= st%st_end
273 if (restart_file_format == option__restartfileformatstates__obf)
then
274 if (should_write)
then
275 if (st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
277 if (.not.
present(lr))
then
279 call restart%write_mesh_function(filename, mesh, dpsi, err, root = root)
281 call restart%write_mesh_function(filename, mesh, &
282 lr%ddl_psi(:, idim, ist, ik), err, root = root)
285 if (.not.
present(lr))
then
287 call restart%write_mesh_function(filename, mesh, zpsi, err, root = root)
289 call restart%write_mesh_function(filename, mesh, &
290 lr%zdl_psi(:, idim, ist, ik), err, root = root)
297 if (err /= 0) err2(2) = err2(2) + 1
304 if (err2(1) /= 0) ierr = ierr + 8
305 if (err2(2) /= 0) ierr = ierr + 16
307 safe_deallocate_a(dpsi)
308 safe_deallocate_a(zpsi)
309 safe_deallocate_a(rff_global)
310 safe_deallocate_a(zff_global)
312 if (restart_file_format == option__restartfileformatstates__adios2)
then
313 if (
present(lr))
then
321 call restart%write(iunit_occs, lines, 1, err)
322 if (err /= 0) ierr = ierr + 32
323 call restart%write(iunit_wfns, lines, 1, err)
324 if (err /= 0) ierr = ierr + 64
325 if (
present(iter))
then
326 write(lines(1),
'(a,i7)')
'Iter = ', iter
327 call restart%write(iunit_wfns, lines, 1, err)
328 if (err /= 0) ierr = ierr + 128
331 call restart%close(iunit_wfns)
332 call restart%close(iunit_occs)
335 message(1) =
"Info: Finished writing states."
349 class(
mesh_t),
intent(in) :: mesh
350 integer,
intent(out) :: ierr
353 type(adios2_adios) :: adios
354 type(adios2_io) :: io
355 type(adios2_variable) :: var, var_indices
356 type(adios2_attribute) :: attribute
357 type(adios2_engine) :: engine
358 integer :: adios2_type, ik, ib, ip, adios2_mode
359 integer(int64),
allocatable :: global_indices(:)
366 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
368 call adios2_init(adios, ierr)
370 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
371 call adios2_declare_io(io, adios,
"writer", ierr)
372 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
374 call adios2_set_parameter(io,
"StatsLevel",
"0", ierr)
375 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 parameter.")
377 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_write, ierr)
378 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
380 adios2_type = adios2_type_dp
382 adios2_type = adios2_type_complex_dp
385 call adios2_define_variable(var, io,
"wavefunctions", adios2_type, 3, &
386 [int(st%nst * st%d%dim, int64), int(mesh%np_global, int64), int(st%nik, int64)], &
387 [0_int64, 0_int64, 0_int64], &
388 [1_int64, 1_int64, 1_int64], &
389 adios2_variable_dims, ierr)
390 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (wavefunctions).")
392 call adios2_define_attribute(attribute, io,
"ParDomains", mesh%mpi_grp%size, ierr)
393 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 attribute (ParDomains).")
395 call adios2_define_variable(var_indices, io,
"global_indices", adios2_type_integer8, 1, &
396 [int(mesh%np_global, int64)], &
397 [int(mesh%pv%xlocal-1, int64)], &
398 [int(mesh%np, int64)], &
399 adios2_variable_dims, ierr)
400 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (global_indices).")
402 safe_allocate(global_indices(mesh%np))
407 call adios2_begin_step(engine, ierr)
408 call adios2_put(engine, var_indices, global_indices, ierr)
410 do ik = st%d%kpt%start, st%d%kpt%end
411 do ib = st%group%block_start, st%group%block_end
413 select case (st%group%psib(ib, ik)%status())
416 call st%group%psib(ib, ik)%copy_to(psib)
420 adios2_mode = adios2_mode_sync
422 psib => st%group%psib(ib, ik)
423 adios2_mode = adios2_mode_deferred
426 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.
true.)
428 call psib%do_unpack(force=.
true.)
432 adios2_mode = adios2_mode_sync
439 call adios2_set_selection(var, 3, &
440 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
441 [int(st%group%psib(ib, ik)%nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
444 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
445 [int(
size(psib%dff_pack, 1), int64), &
446 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
447 call adios2_put(engine, var, psib%dff_pack, adios2_mode, ierr)
449 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
450 [int(
size(psib%zff_pack, 1), int64), &
451 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
452 call adios2_put(engine, var, psib%zff_pack, adios2_mode, ierr)
454 select case (st%group%psib(ib, ik)%status())
457 safe_deallocate_p(psib)
463 call adios2_end_step(engine, ierr)
466 safe_deallocate_a(global_indices)
469 call adios2_close(engine, ierr)
470 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
471 call adios2_finalize(adios, ierr)
472 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
487 subroutine states_elec_load(restart, namespace, space, st, mesh, kpoints, ierr, iter, lr, lowest_missing, label, verbose, skip)
490 class(
space_t),
intent(in) :: space
492 class(
mesh_t),
intent(in) :: mesh
494 integer,
intent(out) :: ierr
495 integer,
optional,
intent(out) :: iter
496 type(
lr_t),
optional,
intent(inout) :: lr
497 integer,
optional,
intent(out) :: lowest_missing(:, :)
498 character(len=*),
optional,
intent(in) :: label
499 logical,
optional,
intent(in) :: verbose
500 logical,
optional,
intent(in) :: skip(:)
502 integer :: states_elec_file, wfns_file, occ_file, err, ik, ist, idir, idim
503 integer :: idone, iread, ntodo
504 character(len=12) :: filename
505 character(len=1) :: char
506 logical,
allocatable :: filled(:, :, :)
507 character(len=256) :: lines(3), label_
508 character(len=50) :: str
510 real(real64) :: my_occ, imev, my_kweight
511 logical :: read_occ, lr_allocated, verbose_
512 logical :: integral_occs
513 real(real64),
allocatable :: dpsi(:)
514 complex(real64),
allocatable :: zpsi(:), zpsil(:)
515 character(len=256),
allocatable :: restart_file(:, :, :)
516 logical,
allocatable :: restart_file_present(:, :, :)
517 real(real64) :: kpoint(space%dim), read_kpoint(space%dim)
520 integer,
allocatable :: lowest_missing_tmp(:, :)
521 integer :: restart_file_format
528 if (
present(lowest_missing)) lowest_missing = 1
529 if (
present(iter)) iter = 0
531 if (
present(skip))
then
532 assert(ubound(skip, dim = 1) == st%nst)
535 if (restart%skip())
then
545 if (
present(label))
then
548 if (
present(lr))
then
549 label_ =
" for linear response"
555 message(1) =
'Info: Reading states'
556 if (len(trim(label_)) > 0)
then
562 if (.not.
present(lr))
then
563 st%fromScratch = .false.
569 integral_occs = .
true.
570 if (st%restart_fixed_occ)
then
572 st%fixed_occ = .
true.
574 read_occ = .not. st%fixed_occ
577 if (.not.
present(lr))
then
578 st%eigenval(:, :) =
m_zero
582 if (.not.
present(lr) .and. read_occ)
then
587 restart_file_format = restart%file_format_states
589 if (
present(lr))
then
590 lr_allocated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
594 restart_file_format = option__restartfileformatstates__obf
597 states_elec_file = restart%open(
'states')
602 call restart%read(states_elec_file, lines, 3, err)
606 read(lines(2), *) str, idim
607 read(lines(3), *) str, ik
608 if (idim == 2 .and. st%d%dim == 1)
then
609 write(
message(1),
'(a)')
'Incompatible restart information: saved calculation is spinors, this one is not.'
613 if (idim == 1 .and. st%d%dim == 2)
then
614 write(
message(1),
'(a)')
'Incompatible restart information: this calculation is spinors, saved one is not.'
618 if (ik < st%nik)
then
619 write(
message(1),
'(a)')
'Incompatible restart information: not enough k-points.'
620 write(
message(2),
'(2(a,i6))')
'Expected ', st%nik,
' > Read ', ik
625 call restart%close(states_elec_file)
629 wfns_file = restart%open(
'wfns')
630 occ_file = restart%open(
'occs')
631 call restart%read(wfns_file, lines, 2, err)
635 read(lines(2),
'(a)') str
636 if (str(2:8) ==
'Complex')
then
637 message(1) =
"Cannot read real states from complex wavefunctions."
640 else if (str(2:5) /=
'Real')
then
641 message(1) =
"Restart file 'wfns' does not specify real/complex; cannot check compatibility."
648 call restart%read(occ_file, lines, 2, err)
649 if (err /= 0) ierr = ierr - 2**7
654 call restart%close(wfns_file)
655 call restart%close(occ_file)
662 safe_allocate(dpsi(1:mesh%np))
664 safe_allocate(zpsi(1:mesh%np))
667 safe_allocate(restart_file(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
668 safe_allocate(restart_file_present(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
669 restart_file_present = .false.
675 call restart%read(wfns_file, lines, 1, err)
677 read(lines(1),
'(a)') char
678 if (char ==
'%')
then
682 read(lines(1), *) ik, char, ist, char, idim, char, filename
687 call restart%read(occ_file, lines, 1, err)
691 if (ist >= st%st_start .and. ist <= st%st_end .and. &
692 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
694 restart_file(idim, ist, ik) = trim(filename)
695 restart_file_present(idim, ist, ik) = .
true.
698 call restart%read(occ_file, lines, 1, err)
699 if (.not.
present(lr))
then
703 read(lines(1), *) my_occ, char, st%eigenval(ist, ik), char, imev, char, &
704 (read_kpoint(idir), char, idir = 1, space%dim), my_kweight
708 if (ist >= st%st_start .and. ist <= st%st_end .and. &
709 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
710 restart_file_present(idim, ist, ik) = .false.
715 kpoint(1:space%dim) = &
716 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
718 if (any(abs(kpoint(1:space%dim) - read_kpoint(1:space%dim)) > 1e-12_real64))
then
721 write(
message(1),
'(a,i6)')
'Incompatible restart information: k-point mismatch for ik ', ik
722 write(
message(2),
'(a,99f18.12)')
' Expected : ', kpoint(1:space%dim)
723 write(
message(3),
'(a,99f18.12)')
' Read : ', read_kpoint(1:space%dim)
726 if (ist >= st%st_start .and. ist <= st%st_end .and. &
727 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
728 restart_file_present(idim, ist, ik) = .false.
733 st%occ(ist, ik) = my_occ
734 integral_occs = integral_occs .and. &
735 abs((st%occ(ist, ik) - st%smear%el_per_state) * st%occ(ist, ik)) <=
m_epsilon
740 if (
present(iter))
then
741 call restart%read(wfns_file, lines, 1, err)
745 read(lines(1), *) filename, filename, iter
749 call restart%close(wfns_file)
750 call restart%close(occ_file)
754 if (restart_file_format == option__restartfileformatstates__adios2)
then
755 if (.not.
loct_dir_exists(trim(restart%dir())//
"/"//
"wavefunctions.bp"))
then
756 message(1) =
"ADIOS2 restart file not found, falling back to obf format."
758 restart_file_format = option__restartfileformatstates__obf
765 safe_allocate(filled(1:st%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
768 if (
present(lowest_missing)) lowest_missing = st%nst + 1
771 if (
mpi_world%is_root() .and. verbose_)
then
773 ntodo = st%lnst*st%d%kpt%nlocal*st%d%dim
776 if (restart_file_format == option__restartfileformatstates__obf)
then
777 do ik = st%d%kpt%start, st%d%kpt%end
778 do ist = st%st_start, st%st_end
779 if (
present(skip))
then
783 do idim = 1, st%d%dim
785 if (.not. restart_file_present(idim, ist, ik))
then
786 if (
present(lowest_missing))
then
787 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
793 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, dpsi, err)
794 if (.not.
present(lr))
then
797 call lalg_copy(mesh%np, dpsi, lr%ddl_psi(:, idim, ist, ik))
800 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, zpsi, err)
801 if (.not.
present(lr))
then
804 call lalg_copy(mesh%np, zpsi, lr%zdl_psi(:, idim, ist, ik))
809 filled(idim, ist, ik) = .
true.
811 else if (
present(lowest_missing))
then
812 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
815 if (
mpi_world%is_root() .and. verbose_)
then
823 else if (restart_file_format == option__restartfileformatstates__adios2)
then
824 if (
present(lr))
then
828 if (restart%has_map())
then
829 message(1) =
"ADIOS2 restart file format does not support restarting from a different grid."
830 message(2) =
"Please set RestartFileFormatStates = obf."
833 call states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
836 safe_deallocate_a(dpsi)
837 safe_deallocate_a(zpsi)
838 safe_deallocate_a(zpsil)
839 safe_deallocate_a(restart_file)
840 safe_deallocate_a(restart_file_present)
842 if (
mpi_world%is_root() .and. verbose_)
then
846 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
848 call st%st_kpt_mpi_grp%allreduce(iread_tmp, iread, 1, mpi_integer, mpi_sum)
851 if (st%d%kpt%parallel)
then
853 if (
present(lowest_missing))
then
854 safe_allocate(lowest_missing_tmp(1:st%d%dim, 1:st%nik))
855 lowest_missing_tmp = lowest_missing
856 call st%d%kpt%mpi_grp%allreduce(lowest_missing_tmp(1,1), lowest_missing(1,1), st%d%dim*st%nik, &
857 mpi_integer, mpi_min)
858 safe_deallocate_a(lowest_missing_tmp)
862 if (st%restart_fixed_occ .and. iread == st%nst * st%nik * st%d%dim)
then
865 call smear_init(st%smear, namespace, st%d%ispin, fixed_occ = .
true., integral_occs = integral_occs, kpoints = kpoints)
868 if (.not.
present(lr) .and. .not.
present(skip))
call fill_random()
871 safe_deallocate_a(filled)
873 if (ierr == 0 .and. iread /= st%nst * st%nik * st%d%dim)
then
881 if (.not.
present(lr))
then
882 write(str,
'(a,i5)')
'Reading states.'
884 write(str,
'(a,i5)')
'Reading states information for linear response.'
887 if (.not.
present(skip))
then
888 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
889 st%nst * st%nik * st%d%dim,
' could be read.'
891 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
892 st%nst * st%nik * st%d%dim,
' were loaded.'
899 message(1) =
'Info: States reading done.'
911 do ik = st%d%kpt%start, st%d%kpt%end
913 do ist = st%st_start, st%st_end
914 do idim = 1, st%d%dim
915 if (filled(idim, ist, ik)) cycle
927 logical function index_is_wrong() !< .
true. if the index (idim, ist, ik) is not present in st structure...
930 if (idim > st%d%dim .or. idim < 1 .or. &
931 ist > st%nst .or. ist < 1 .or. &
932 ik > st%nik .or. ik < 1)
then
944 subroutine states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
947 class(
mesh_t),
intent(in) :: mesh
948 integer,
intent(out) :: iread
949 logical,
intent(out) :: filled(1:, st%st_start:, st%d%kpt%start:)
950 logical,
intent(in) :: restart_file_present(:, :, :)
951 integer,
intent(out) :: ierr
952 logical,
optional,
intent(in) :: skip(:)
953 integer,
optional,
intent(inout) :: lowest_missing(:, :)
956 type(adios2_adios) :: adios
957 type(adios2_io) :: io
958 type(adios2_variable) :: var, var_indices
959 type(adios2_attribute) :: attribute
960 type(adios2_engine) :: engine
961 integer :: type_file, type_requested, ib, ik, ndims, pardomains
963 integer(int64),
allocatable :: var_shape(:)
964 integer(int64),
allocatable :: global_indices(:)
970 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
972 call adios2_init(adios, ierr)
974 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
975 call adios2_declare_io(io, adios,
"reader", ierr)
976 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
978 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_read, ierr)
979 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
981 call adios2_begin_step(engine, ierr)
983 call adios2_inquire_attribute(attribute, io,
"ParDomains", ierr)
984 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem inquiring ADIOS2 attribute.")
985 call adios2_attribute_data(pardomains, attribute, ierr)
987 type_requested = adios2_type_dp
989 type_requested = adios2_type_complex_dp
991 call adios2_inquire_variable(var, io,
'wavefunctions', ierr)
992 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem loading ADIOS2 variable (wavefunctions).")
994 call adios2_variable_type(type_file, var, ierr)
995 call adios2_variable_ndims(ndims, var, ierr)
996 call adios2_variable_shape(var_shape, ndims, var, ierr)
999 if (var_shape(1) < int(st%nst * st%d%dim, int64))
then
1001 nst_max = int(var_shape(1), int32) / st%d%dim
1003 if (var_shape(2) /= int(mesh%np_global, int64))
then
1005 message(1) =
"Error: trying to restart with a different number of grid points. Not supported with ADIOS2 format."
1008 if (
present(skip))
then
1011 call states_elec_adios2_read_state_by_state(st, mesh, engine, var, filled, restart_file_present, iread, skip, lowest_missing)
1013 call states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1014 nst_max, filled, iread)
1017 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1018 call adios2_inquire_variable(var_indices, io,
'global_indices', ierr)
1019 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none, &
1020 "Problem loading ADIOS2 variable (global_indices).")
1021 safe_allocate(global_indices(mesh%np))
1022 call adios2_set_selection(var_indices, 1, &
1023 [int(mesh%pv%xlocal-1, int64)], &
1024 [int(mesh%np, int64)], ierr)
1025 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection (global_indices).")
1026 call adios2_get(engine, var_indices, global_indices, ierr)
1027 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (global_indices).")
1029 call adios2_end_step(engine, ierr)
1030 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 end_step.")
1031 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1032 do ik = st%d%kpt%start, st%d%kpt%end
1033 do ib = st%group%block_start, st%group%block_end
1041 safe_deallocate_a(global_indices)
1045 call adios2_close(engine, ierr)
1046 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
1047 call adios2_finalize(adios, ierr)
1048 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
1060 subroutine states_elec_adios2_read_state_by_state(st, mesh, engine, var, filled, restart_file_present, &
1061 iread, skip, lowest_missing)
1063 class(
mesh_t),
intent(in) :: mesh
1064 type(adios2_engine),
intent(inout) :: engine
1065 type(adios2_variable),
intent(inout) :: var
1066 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1067 logical,
intent(in) :: restart_file_present(:, :, :)
1068 integer,
intent(inout) :: iread
1069 logical,
optional,
intent(in) :: skip(:)
1070 integer,
optional,
intent(inout) :: lowest_missing(:, :)
1072 integer :: ik, ist, idim, ierr
1073 real(real64),
allocatable :: dpsi(:)
1074 complex(real64),
allocatable :: zpsi(:)
1076 push_sub(states_elec_adios2_read_state_by_state)
1078 do ik = st%d%kpt%start, st%d%kpt%end
1080 safe_allocate(dpsi(1:mesh%np))
1082 safe_allocate(zpsi(1:mesh%np))
1084 do ist = st%st_start, st%st_end
1085 if (
present(skip))
then
1086 if (skip(ist)) cycle
1089 do idim = 1, st%d%dim
1090 if (.not. restart_file_present(idim, ist, ik))
then
1091 if (
present(lowest_missing))
then
1092 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
1098 call adios2_set_selection(var, 3, &
1099 [int((ist-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1100 [1_int64, int(mesh%np, int64), 1_int64], ierr)
1103 call adios2_get(engine, var, dpsi, adios2_mode_sync, ierr)
1104 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get dpsi.")
1107 call adios2_get(engine, var, zpsi, adios2_mode_sync, ierr)
1108 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get zpsi.")
1112 filled(idim, ist, ik) = .
true.
1116 safe_deallocate_a(dpsi)
1117 safe_deallocate_a(zpsi)
1120 pop_sub(states_elec_adios2_read_state_by_state)
1121 end subroutine states_elec_adios2_read_state_by_state
1125 subroutine states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1126 nst_max, filled, iread)
1128 class(
mesh_t),
intent(in) :: mesh
1129 type(adios2_engine),
intent(inout) :: engine
1130 type(adios2_variable),
intent(inout) :: var
1131 integer(int64),
intent(in) :: var_shape(:)
1132 integer,
intent(in) :: type_requested
1133 integer,
intent(in) :: type_file
1134 integer,
intent(in) :: nst_max
1135 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1136 integer,
intent(inout) :: iread
1138 integer :: ib, ik, ist, ip, adios2_mode, nst_linear, ierr
1140 real(real64),
allocatable :: dff_pack(:, :)
1142 push_sub(states_elec_adios2_read_batch_by_batch)
1144 do ik = st%d%kpt%start, st%d%kpt%end
1147 if (ik > var_shape(3)) cycle
1148 do ib = st%group%block_start, st%group%block_end
1149 select case (st%group%psib(ib, ik)%status())
1152 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.false.)
1154 adios2_mode = adios2_mode_sync
1156 psib => st%group%psib(ib, ik)
1160 adios2_mode = adios2_mode_sync
1163 call st%group%psib(ib, ik)%copy_to(psib)
1164 call psib%do_unpack(force=.
true., copy=.false.)
1167 adios2_mode = adios2_mode_sync
1172 nst_linear = st%group%psib(ib, ik)%nst_linear
1176 if (nst_linear <= 0) cycle
1181 call adios2_set_selection(var, 3, &
1182 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1183 [int(nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
1184 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection.")
1186 if (type_requested == adios2_type_dp .and. type_file == adios2_type_dp)
then
1188 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1189 [int(
size(psib%dff_pack, 1), int64), &
1190 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
1191 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading real).")
1193 call adios2_get(engine, var, psib%dff_pack, adios2_mode, ierr)
1194 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading real).")
1195 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_complex_dp)
then
1197 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1198 [int(
size(psib%zff_pack, 1), int64), &
1199 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1200 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex).")
1202 call adios2_get(engine, var, psib%zff_pack, adios2_mode, ierr)
1203 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex).")
1204 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_dp)
then
1206 safe_allocate(dff_pack(
size(psib%zff_pack, 1),
size(psib%zff_pack, 2)))
1208 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1209 [int(
size(psib%zff_pack, 1), int64), &
1210 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1211 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex from real).")
1214 call adios2_get(engine, var, dff_pack, adios2_mode_sync, ierr)
1215 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex from real).")
1219 do ist = 1, nst_linear
1220 psib%zff_pack(ist, ip) = cmplx(dff_pack(ist, ip),
m_zero, real64)
1223 safe_deallocate_a(dff_pack)
1225 message(1) =
"Error: requested to read complex states for restarting, but calculation has real states."
1229 iread = iread + nst_linear
1230 do ist = 1, nst_linear
1231 filled(st%group%psib(ib, ik)%linear_to_idim(ist), st%group%psib(ib, ik)%linear_to_ist(ist), ik) = .
true.
1234 select case (st%group%psib(ib, ik)%status())
1236 call psib%do_unpack()
1237 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1239 safe_deallocate_p(psib)
1244 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1246 safe_deallocate_p(psib)
1251 pop_sub(states_elec_adios2_read_batch_by_batch)
1252 end subroutine states_elec_adios2_read_batch_by_batch
1256 subroutine check_error(condition, error_message)
1257 logical,
intent(in) :: condition
1258 character(len=*),
intent(in) :: error_message
1263 end subroutine check_error
1269 class(
mesh_t),
intent(in) :: mesh
1270 integer,
intent(out) :: ierr
1271 integer,
optional,
intent(in) :: iter
1273 integer :: iunit, isp, err, err2(2)
1274 character(len=MAX_PATH_LEN) :: filename
1275 character(len=300) :: lines(2)
1281 if (restart%skip())
then
1286 message(1) =
"Debug: Writing density restart."
1292 iunit = restart%open(
'density')
1293 lines(1) =
'# #spin #nspin filename'
1294 lines(2) =
'%densities'
1295 call restart%write(iunit, lines, 2, err)
1296 if (err /= 0) ierr = ierr + 1
1299 do isp = 1, st%d%nspin
1301 write(lines(1),
'(i8,a,i8,a)') isp,
' | ', st%d%nspin,
' | "'//trim(adjustl(filename))//
'"'
1302 call restart%write(iunit, lines, 1, err)
1303 if (err /= 0) err2(1) = err2(1) + 1
1305 call restart%write_mesh_function(filename, mesh, st%rho(:,isp), err)
1306 if (err /= 0) err2(2) = err2(2) + 1
1309 if (err2(1) /= 0) ierr = ierr + 2
1310 if (err2(2) /= 0) ierr = ierr + 4
1313 call restart%write(iunit, lines, 1, err)
1314 if (err /= 0) ierr = ierr + 8
1315 if (
present(iter))
then
1316 write(lines(1),
'(a,i7)')
'Iter = ', iter
1317 call restart%write(iunit, lines, 1, err)
1318 if (err /= 0) ierr = ierr + 16
1320 call restart%close(iunit)
1324 message(1) =
"Debug: Writing density restart done."
1335 class(
mesh_t),
intent(in) :: mesh
1336 integer,
intent(out) :: ierr
1338 integer :: err, err2, isp
1339 character(len=MAX_PATH_LEN) :: filename
1345 if (restart%skip())
then
1351 message(1) =
"Debug: Reading density restart."
1362 do isp = 1, st%d%nspin
1367 call restart%read_mesh_function(filename, mesh, st%rho(:,isp), err)
1368 if (err /= 0) err2 = err2 + 1
1371 if (err2 /= 0) ierr = ierr + 1
1373 message(1) =
"Debug: Reading density restart done."
1381 class(
space_t),
intent(in) :: space
1383 class(
mesh_t),
intent(in) :: mesh
1384 integer,
intent(out) :: ierr
1386 integer :: isp, err, err2(2), idir
1387 character(len=MAX_PATH_LEN) :: filename
1393 assert(
allocated(st%frozen_rho))
1395 if (restart%skip())
then
1400 message(1) =
"Debug: Writing frozen densities restart."
1406 do isp = 1, st%d%nspin
1409 call restart%write_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1410 if (err /= 0) err2(2) = err2(2) + 1
1412 if (
allocated(st%frozen_tau))
then
1414 call restart%write_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1415 if (err /= 0) err2 = err2 + 1
1418 if (
allocated(st%frozen_gdens))
then
1419 do idir = 1, space%dim
1420 if (st%d%nspin == 1)
then
1421 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1423 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_tau-dir', idir,
'-', isp
1425 call restart%write_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1426 if (err /= 0) err2 = err2 + 1
1430 if (
allocated(st%frozen_ldens))
then
1432 call restart%write_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1433 if (err /= 0) err2 = err2 + 1
1437 if (err2(1) /= 0) ierr = ierr + 2
1438 if (err2(2) /= 0) ierr = ierr + 4
1442 message(1) =
"Debug: Writing frozen densities restart done."
1452 class(
space_t),
intent(in) :: space
1454 class(
mesh_t),
intent(in) :: mesh
1455 integer,
intent(out) :: ierr
1457 integer :: err, err2, isp, idir
1458 character(len=MAX_PATH_LEN) :: filename
1462 assert(
allocated(st%frozen_rho))
1466 if (restart%skip())
then
1472 message(1) =
"Debug: Reading densities restart."
1476 do isp = 1, st%d%nspin
1478 call restart%read_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1479 if (err /= 0) err2 = err2 + 1
1481 if (
allocated(st%frozen_tau))
then
1483 call restart%read_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1484 if (err /= 0) err2 = err2 + 1
1487 if (
allocated(st%frozen_gdens))
then
1488 do idir = 1, space%dim
1489 if (st%d%nspin == 1)
then
1490 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1492 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_tau-dir', idir,
'-', isp
1494 call restart%read_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1495 if (err /= 0) err2 = err2 + 1
1499 if (
allocated(st%frozen_ldens))
then
1501 call restart%read_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1502 if (err /= 0) err2 = err2 + 1
1506 if (err2 /= 0) ierr = ierr + 1
1508 message(1) =
"Debug: Reading frozen densities restart done."
1519 class(
mesh_t),
intent(in) :: mesh
1521 class(
space_t),
intent(in) :: space
1525 integer :: ip, id, is, ik, nstates, state_from, ierr, ncols
1526 integer :: ib, idim, inst, inik, normalize
1527 real(real64) :: xx(space%dim), rr, psi_re, psi_im
1528 character(len=150) :: filename
1529 complex(real64),
allocatable :: zpsi(:, :)
1531 integer,
parameter :: &
1532 state_from_formula = 1, &
1533 state_from_file = -10010, &
1534 normalize_yes = 1, &
1617 if (
parse_block(namespace,
'UserDefinedStates', blk) == 0)
then
1624 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
1630 if (ncols < 5 .or. ncols > 6)
then
1631 message(1) =
'Each line in the UserDefinedStates block must have'
1632 message(2) =
'five or six columns.'
1648 if (.not.(id == idim .and. is == inst .and. ik == inik )) cycle
1654 select case (state_from)
1655 case (state_from_formula)
1658 blk, ib - 1, 4, st%user_def_states(id, is, ik))
1660 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1661 write(
message(2),
'(2a)')
' with the expression:'
1662 write(
message(3),
'(2a)')
' ',trim(st%user_def_states(id, is, ik))
1668 case (state_from_file)
1674 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1675 write(
message(2),
'(2a)')
' with data from file:'
1676 write(
message(3),
'(2a)')
' ',trim(filename)
1682 if (.not.(st%st_start <= is .and. st%st_end >= is &
1683 .and. st%d%kpt%start <= ik .and. st%d%kpt%end >= ik)) cycle
1685 select case (state_from)
1687 case (state_from_formula)
1696 zpsi(ip, 1) = cmplx(psi_re, psi_im, real64)
1699 case (state_from_file)
1703 message(1) =
'Could not read the file!'
1704 write(
message(2),
'(a,i1)')
'Error code: ', ierr
1709 message(1) =
'Wrong entry in UserDefinedStates, column 4.'
1710 message(2) =
'You may state "formula" or "file" here.'
1720 select case (normalize)
1723 case (normalize_yes)
1724 assert(st%d%dim == 1)
1728 message(1) =
'The sixth column in UserDefinedStates may either be'
1729 message(2) =
'"normalize_yes" or "normalize_no"'
1739 safe_deallocate_a(zpsi)
1757 integer,
intent(out) :: ierr
1759 integer :: iunit_spin
1760 integer :: err, err2(2), ik, ist
1761 character(len=300) :: lines(3)
1767 if (restart%skip())
then
1776 iunit_spin = restart%open(
'spin')
1777 lines(1) =
'# #k-point #st #spin(x) spin(y) spin(z)'
1778 call restart%write(iunit_spin, lines, 1, err)
1779 if (err /= 0) ierr = ierr + 1
1784 write(lines(1),
'(i8,a,i8,3(a,f18.12))') ik,
' | ', ist,
' | ', &
1785 st%spin(1,ist,ik),
' | ', st%spin(2,ist,ik),
' | ', st%spin(3,ist,ik)
1786 call restart%write(iunit_spin, lines, 1, err)
1787 if (err /= 0) err2(1) = err2(1) + 1
1791 call restart%write(iunit_spin, lines, 1, err)
1792 if (err2(1) /= 0) ierr = ierr + 8
1793 if (err2(2) /= 0) ierr = ierr + 16
1795 call restart%close(iunit_spin)
1814 integer,
intent(out) :: ierr
1816 integer :: spin_file, err, ik, ist
1817 character(len=256) :: lines(3)
1818 real(real64) :: spin(3)
1819 character(len=1) :: char
1826 if (restart%skip())
then
1835 spin_file = restart%open(
'spin')
1837 call restart%read(spin_file, lines, 1, err)
1838 if (err /= 0) ierr = ierr - 2**7
1843 call restart%close(spin_file)
1853 call restart%read(spin_file, lines, 1, err)
1854 read(lines(1),
'(a)') char
1855 if (char ==
'%')
then
1859 read(lines(1), *) ik, char, ist, char, spin(1), char, spin(2), char, spin(3)
1864 st%spin(1:3, ist, ik) = spin(1:3)
1867 call restart%close(spin_file)
1877 class(
space_t),
intent(in) :: space
1878 type(
restart_t),
intent(inout) :: restart
1879 class(
mesh_t),
intent(in) :: mesh
1881 character(len=*),
optional,
intent(in) :: prefix
1885 complex(real64),
allocatable :: rotation_matrix(:,:), psi(:, :)
1886 integer :: ist, jst, ncols, iqn
1887 character(len=256) :: block_name
1919 if (
parse_block(namespace, trim(block_name), blk) == 0)
then
1920 if (st%parallel_in_states)
then
1924 message(1) =
"Number of rows in block " // trim(block_name) //
" must equal number of states in this calculation."
1931 safe_allocate(rotation_matrix(1:stin%nst, 1:stin%nst))
1932 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
1938 if (ncols /= stin%nst)
then
1939 write(
message(1),
'(a,i6,a,i6,3a,i6,a)')
"Number of columns (", ncols,
") in row ", ist,
" of block ", &
1940 trim(block_name),
" must equal number of states (", stin%nst,
") read from gs restart."
1943 do jst = 1, stin%nst
1950 do iqn = st%d%kpt%start, st%d%kpt%end
1957 do ist = st%st_start, st%st_end
1964 safe_deallocate_a(rotation_matrix)
1965 safe_deallocate_a(psi)
ssize_t read(int __fd, void *__buf, size_t __nbytes) __attribute__((__access__(__write_only__
Copies a vector x, to a vector y.
block signals while writing the restart files
unblock signals when writing restart is finished
This module implements batches of mesh functions.
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
This module handles the calculation mode.
integer, parameter, public p_strategy_domains
parallelization in domains
integer, parameter, public spinors
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
complex(real64), parameter, public m_z1
subroutine, public zio_function_input(filename, namespace, space, mesh, ff, ierr, map)
Reads a mesh function from file filename, and puts it into ff. If the map argument is passed,...
System information (time, memory, sysname)
subroutine, public loct_progress_bar(a, maxcount)
A wrapper around the progress bar, such that it can be silenced without needing to dress the call wit...
logical function, public loct_dir_exists(dirname)
This module is intended to contain "only mathematical" functions and procedures.
This module defines functions over batches of mesh functions.
subroutine, public zmesh_batch_exchange_points(mesh, aa, forward_map, backward_map)
This functions exchanges points of a mesh according to a certain map. Two possible maps can be given....
subroutine, public dmesh_batch_exchange_points(mesh, aa, forward_map, backward_map)
This functions exchanges points of a mesh according to a certain map. Two possible maps can be given....
This module defines various routines, operating on mesh functions.
subroutine, public zmf_normalize(mesh, dim, psi, norm)
Normalize a mesh function psi.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
subroutine, public messages_not_implemented(feature, namespace)
character(len=512), private msg
subroutine, public messages_variable_is_block(namespace, name)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public print_date(str)
subroutine, public messages_new_line()
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_grp_t), public mpi_world
This module handles the communicators for the various parallelization strategies.
this module contains the low-level part of the output system
character(len=max_path_len) function, public get_filename_with_spin(output, nspin, spin_index)
Returns the filame as output, or output-spX is spin polarized.
Some general things and nomenclature:
integer(int64) function, public par_vec_local2global(pv, ip)
Returns global index of local point ip.
logical function, public parse_is_defined(namespace, name)
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
subroutine, public smear_init(this, namespace, ispin, fixed_occ, integral_occs, kpoints)
pure logical function, public states_are_complex(st)
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
integer pure function, public states_elec_block_max(st, ib)
return index of last state in block ib
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
subroutine, public states_elec_generate_random(st, mesh, kpoints, ist_start_, ist_end_, ikpt_start_, ikpt_end_, normalized)
randomize states
integer pure function, public states_elec_block_min(st, ib)
return index of first state in block ib
subroutine, public states_elec_look(restart, nik, dim, nst, ierr)
Reads the 'states' file in the restart directory, and finds out the nik, dim, and nst contained in it...
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_read_user_def_orbitals(mesh, namespace, space, st)
the routine reads formulas for user-defined wavefunctions from the input file and fills the respectiv...
subroutine, public states_elec_load_frozen(restart, space, st, mesh, ierr)
subroutine, public states_elec_look_and_load(restart, namespace, space, st, mesh, kpoints, is_complex, packed)
subroutine states_elec_dump_adios2(restart, st, mesh, ierr)
subroutine, public states_elec_transform(st, namespace, space, restart, mesh, kpoints, prefix)
subroutine, public states_elec_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, verbose)
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public states_elec_load_spin(restart, st, ierr)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public states_elec_dump_frozen(restart, space, st, mesh, ierr)
subroutine states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
subroutine, public states_elec_load_rho(restart, st, mesh, ierr)
subroutine, public states_elec_dump_rho(restart, st, mesh, ierr, iter)
subroutine, public states_elec_dump_spin(restart, st, ierr)
subroutine, public conv_to_c_string(str)
converts to c string
type(type_t), public type_float
type(type_t), public type_cmplx
logical function index_is_wrong()
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
batches of electronic states