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=500) :: lines(3)
175 logical :: lr_wfns_are_associated, should_write, verbose_
176 real(real64) :: kpoint(space%dim)
177 real(real64),
allocatable :: dpsi(:)
178 complex(real64),
allocatable :: zpsi(:)
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))
240 safe_allocate(zpsi(1:mesh%np))
247 kpoint(1:space%dim) = &
248 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
251 do idim = 1, st%d%dim
253 write(filename,
'(i10.10)') itot
255 write(lines(1),
'(i8,a,i8,a,i8,3a)') ik,
' | ', ist,
' | ', idim,
' | "', trim(filename),
'"'
256 call restart%write(iunit_wfns, lines, 1, err)
257 if (err /= 0) err2(1) = err2(1) + 1
259 write(lines(1),
'(e23.16,a,e23.16)') st%occ(ist,ik),
' | ', st%eigenval(ist, ik)
260 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ',
m_zero
261 do idir = 1, space%dim
262 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ', kpoint(idir)
264 write(lines(1),
'(a,a,e23.16,a,i10.10,3(a,i8))') trim(lines(1)), &
265 ' | ', st%kweights(ik),
' | ', itot,
' | ', ik,
' | ', ist,
' | ', idim
266 call restart%write(iunit_occs, lines, 1, err)
267 if (err /= 0) err2(1) = err2(1) + 1
269 should_write = st%st_start <= ist .and. ist <= st%st_end
271 if (restart_file_format == option__restartfileformatstates__obf)
then
272 if (should_write)
then
273 if (st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
275 if (.not.
present(lr))
then
277 call restart%write_mesh_function(filename, mesh, dpsi, err, root = root)
279 call restart%write_mesh_function(filename, mesh, &
280 lr%ddl_psi(:, idim, ist, ik), err, root = root)
283 if (.not.
present(lr))
then
285 call restart%write_mesh_function(filename, mesh, zpsi, err, root = root)
287 call restart%write_mesh_function(filename, mesh, &
288 lr%zdl_psi(:, idim, ist, ik), err, root = root)
295 if (err /= 0) err2(2) = err2(2) + 1
302 if (err2(1) /= 0) ierr = ierr + 8
303 if (err2(2) /= 0) ierr = ierr + 16
305 safe_deallocate_a(dpsi)
306 safe_deallocate_a(zpsi)
308 if (restart_file_format == option__restartfileformatstates__adios2)
then
309 if (
present(lr))
then
317 call restart%write(iunit_occs, lines, 1, err)
318 if (err /= 0) ierr = ierr + 32
319 call restart%write(iunit_wfns, lines, 1, err)
320 if (err /= 0) ierr = ierr + 64
321 if (
present(iter))
then
322 write(lines(1),
'(a,i7)')
'Iter = ', iter
323 call restart%write(iunit_wfns, lines, 1, err)
324 if (err /= 0) ierr = ierr + 128
327 call restart%close(iunit_wfns)
328 call restart%close(iunit_occs)
331 message(1) =
"Info: Finished writing states."
345 class(
mesh_t),
intent(in) :: mesh
346 integer,
intent(out) :: ierr
349 type(adios2_adios) :: adios
350 type(adios2_io) :: io
351 type(adios2_variable) :: var, var_indices
352 type(adios2_attribute) :: attribute
353 type(adios2_engine) :: engine
354 integer :: adios2_type, ik, ib, ip, adios2_mode
355 integer(int64),
allocatable :: global_indices(:)
362 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
364 call adios2_init(adios, ierr)
366 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
367 call adios2_declare_io(io, adios,
"writer", ierr)
368 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
370 call adios2_set_parameter(io,
"StatsLevel",
"0", ierr)
371 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 parameter.")
373 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_write, ierr)
374 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
376 adios2_type = adios2_type_dp
378 adios2_type = adios2_type_complex_dp
381 call adios2_define_variable(var, io,
"wavefunctions", adios2_type, 3, &
382 [int(st%nst * st%d%dim, int64), int(mesh%np_global, int64), int(st%nik, int64)], &
383 [0_int64, 0_int64, 0_int64], &
384 [1_int64, 1_int64, 1_int64], &
385 adios2_variable_dims, ierr)
386 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (wavefunctions).")
388 call adios2_define_attribute(attribute, io,
"ParDomains", mesh%mpi_grp%size, ierr)
389 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 attribute (ParDomains).")
391 call adios2_define_variable(var_indices, io,
"global_indices", adios2_type_integer8, 1, &
392 [int(mesh%np_global, int64)], &
393 [int(mesh%pv%xlocal-1, int64)], &
394 [int(mesh%np, int64)], &
395 adios2_variable_dims, ierr)
396 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (global_indices).")
398 safe_allocate(global_indices(mesh%np))
403 call adios2_begin_step(engine, ierr)
404 call adios2_put(engine, var_indices, global_indices, ierr)
406 do ik = st%d%kpt%start, st%d%kpt%end
407 do ib = st%group%block_start, st%group%block_end
409 select case (st%group%psib(ib, ik)%status())
412 call st%group%psib(ib, ik)%copy_to(psib)
416 adios2_mode = adios2_mode_sync
418 psib => st%group%psib(ib, ik)
419 adios2_mode = adios2_mode_deferred
422 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.
true.)
424 call psib%do_unpack(force=.
true.)
428 adios2_mode = adios2_mode_sync
435 call adios2_set_selection(var, 3, &
436 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
437 [int(st%group%psib(ib, ik)%nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
440 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
441 [int(
size(psib%dff_pack, 1), int64), &
442 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
443 call adios2_put(engine, var, psib%dff_pack, adios2_mode, ierr)
445 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
446 [int(
size(psib%zff_pack, 1), int64), &
447 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
448 call adios2_put(engine, var, psib%zff_pack, adios2_mode, ierr)
450 select case (st%group%psib(ib, ik)%status())
453 safe_deallocate_p(psib)
459 call adios2_end_step(engine, ierr)
462 safe_deallocate_a(global_indices)
465 call adios2_close(engine, ierr)
466 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
467 call adios2_finalize(adios, ierr)
468 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
483 subroutine states_elec_load(restart, namespace, space, st, mesh, kpoints, ierr, iter, lr, lowest_missing, label, verbose, skip)
486 class(
space_t),
intent(in) :: space
488 class(
mesh_t),
intent(in) :: mesh
490 integer,
intent(out) :: ierr
491 integer,
optional,
intent(out) :: iter
492 type(
lr_t),
optional,
intent(inout) :: lr
493 integer,
optional,
intent(out) :: lowest_missing(:, :)
494 character(len=*),
optional,
intent(in) :: label
495 logical,
optional,
intent(in) :: verbose
496 logical,
optional,
intent(in) :: skip(:)
498 integer :: states_elec_file, wfns_file, occ_file, err, ik, ist, idir, idim
499 integer :: idone, iread, ntodo
500 character(len=12) :: filename
501 character(len=1) :: char
502 logical,
allocatable :: filled(:, :, :)
503 character(len=256) :: lines(3), label_
504 character(len=50) :: str
506 real(real64) :: my_occ, imev, my_kweight
507 logical :: read_occ, lr_allocated, verbose_
508 logical :: integral_occs
509 real(real64),
allocatable :: dpsi(:)
510 complex(real64),
allocatable :: zpsi(:)
511 character(len=256),
allocatable :: restart_file(:, :, :)
512 logical,
allocatable :: restart_file_present(:, :, :)
513 real(real64) :: kpoint(space%dim), read_kpoint(space%dim)
516 integer,
allocatable :: lowest_missing_tmp(:, :)
517 integer :: restart_file_format
524 if (
present(lowest_missing)) lowest_missing = 1
525 if (
present(iter)) iter = 0
527 if (
present(skip))
then
528 assert(ubound(skip, dim = 1) == st%nst)
531 if (restart%skip())
then
541 if (
present(label))
then
544 if (
present(lr))
then
545 label_ =
" for linear response"
551 message(1) =
'Info: Reading states'
552 if (len(trim(label_)) > 0)
then
558 if (.not.
present(lr))
then
559 st%fromScratch = .false.
565 integral_occs = .
true.
566 if (st%restart_fixed_occ)
then
568 st%fixed_occ = .
true.
570 read_occ = .not. st%fixed_occ
573 if (.not.
present(lr))
then
574 st%eigenval(:, :) =
m_zero
578 if (.not.
present(lr) .and. read_occ)
then
583 restart_file_format = restart%file_format_states
585 if (
present(lr))
then
586 lr_allocated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
590 restart_file_format = option__restartfileformatstates__obf
593 states_elec_file = restart%open(
'states')
598 call restart%read(states_elec_file, lines, 3, err)
602 read(lines(2), *) str, idim
603 read(lines(3), *) str, ik
604 if (idim == 2 .and. st%d%dim == 1)
then
605 write(
message(1),
'(a)')
'Incompatible restart information: saved calculation is spinors, this one is not.'
609 if (idim == 1 .and. st%d%dim == 2)
then
610 write(
message(1),
'(a)')
'Incompatible restart information: this calculation is spinors, saved one is not.'
614 if (ik < st%nik)
then
615 write(
message(1),
'(a)')
'Incompatible restart information: not enough k-points.'
616 write(
message(2),
'(2(a,i6))')
'Expected ', st%nik,
' > Read ', ik
621 call restart%close(states_elec_file)
625 wfns_file = restart%open(
'wfns')
626 occ_file = restart%open(
'occs')
627 call restart%read(wfns_file, lines, 2, err)
631 read(lines(2),
'(a)') str
632 if (str(2:8) ==
'Complex')
then
633 message(1) =
"Cannot read real states from complex wavefunctions."
636 else if (str(2:5) /=
'Real')
then
637 message(1) =
"Restart file 'wfns' does not specify real/complex; cannot check compatibility."
644 call restart%read(occ_file, lines, 2, err)
645 if (err /= 0) ierr = ierr - 2**7
650 call restart%close(wfns_file)
651 call restart%close(occ_file)
658 safe_allocate(dpsi(1:mesh%np))
660 safe_allocate(zpsi(1:mesh%np))
663 safe_allocate(restart_file(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
664 safe_allocate(restart_file_present(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
665 restart_file_present = .false.
671 call restart%read(wfns_file, lines, 1, err)
673 read(lines(1),
'(a)') char
674 if (char ==
'%')
then
678 read(lines(1), *) ik, char, ist, char, idim, char, filename
683 call restart%read(occ_file, lines, 1, err)
687 if (ist >= st%st_start .and. ist <= st%st_end .and. &
688 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
690 restart_file(idim, ist, ik) = trim(filename)
691 restart_file_present(idim, ist, ik) = .
true.
694 call restart%read(occ_file, lines, 1, err)
695 if (.not.
present(lr))
then
699 read(lines(1), *) my_occ, char, st%eigenval(ist, ik), char, imev, char, &
700 (read_kpoint(idir), char, idir = 1, space%dim), my_kweight
704 if (ist >= st%st_start .and. ist <= st%st_end .and. &
705 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
706 restart_file_present(idim, ist, ik) = .false.
711 kpoint(1:space%dim) = &
712 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
714 if (any(abs(kpoint(1:space%dim) - read_kpoint(1:space%dim)) > 1e-12_real64))
then
717 write(
message(1),
'(a,i6)')
'Incompatible restart information: k-point mismatch for ik ', ik
718 write(
message(2),
'(a,99f18.12)')
' Expected : ', kpoint(1:space%dim)
719 write(
message(3),
'(a,99f18.12)')
' Read : ', read_kpoint(1:space%dim)
722 if (ist >= st%st_start .and. ist <= st%st_end .and. &
723 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
724 restart_file_present(idim, ist, ik) = .false.
729 st%occ(ist, ik) = my_occ
730 integral_occs = integral_occs .and. &
731 abs((st%occ(ist, ik) - st%smear%el_per_state) * st%occ(ist, ik)) <=
m_epsilon
736 if (
present(iter))
then
737 call restart%read(wfns_file, lines, 1, err)
741 read(lines(1), *) filename, filename, iter
745 call restart%close(wfns_file)
746 call restart%close(occ_file)
750 if (restart_file_format == option__restartfileformatstates__adios2)
then
751 if (.not.
loct_dir_exists(trim(restart%dir())//
"/"//
"wavefunctions.bp"))
then
752 message(1) =
"ADIOS2 restart file not found, falling back to obf format."
754 restart_file_format = option__restartfileformatstates__obf
761 safe_allocate(filled(1:st%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
764 if (
present(lowest_missing)) lowest_missing = st%nst + 1
767 if (st%system_grp%is_root() .and. verbose_)
then
769 ntodo = st%lnst*st%d%kpt%nlocal*st%d%dim
772 if (restart_file_format == option__restartfileformatstates__obf)
then
773 do ik = st%d%kpt%start, st%d%kpt%end
774 do ist = st%st_start, st%st_end
775 if (
present(skip))
then
779 do idim = 1, st%d%dim
781 if (.not. restart_file_present(idim, ist, ik))
then
782 if (
present(lowest_missing))
then
783 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
789 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, dpsi, err)
790 if (.not.
present(lr))
then
793 call lalg_copy(mesh%np, dpsi, lr%ddl_psi(:, idim, ist, ik))
796 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, zpsi, err)
797 if (.not.
present(lr))
then
800 call lalg_copy(mesh%np, zpsi, lr%zdl_psi(:, idim, ist, ik))
805 filled(idim, ist, ik) = .
true.
807 else if (
present(lowest_missing))
then
808 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
811 if (st%system_grp%is_root() .and. verbose_)
then
819 else if (restart_file_format == option__restartfileformatstates__adios2)
then
820 if (
present(lr))
then
824 if (restart%has_map())
then
825 message(1) =
"ADIOS2 restart file format does not support restarting from a different grid."
826 message(2) =
"Please set RestartFileFormatStates = obf."
829 call states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
832 safe_deallocate_a(dpsi)
833 safe_deallocate_a(zpsi)
834 safe_deallocate_a(restart_file)
835 safe_deallocate_a(restart_file_present)
837 if (st%system_grp%is_root() .and. verbose_)
then
841 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
843 call st%st_kpt_mpi_grp%allreduce(iread_tmp, iread, 1, mpi_integer, mpi_sum)
846 if (st%d%kpt%parallel)
then
848 if (
present(lowest_missing))
then
849 safe_allocate(lowest_missing_tmp(1:st%d%dim, 1:st%nik))
850 lowest_missing_tmp = lowest_missing
851 call st%d%kpt%mpi_grp%allreduce(lowest_missing_tmp(1,1), lowest_missing(1,1), st%d%dim*st%nik, &
852 mpi_integer, mpi_min)
853 safe_deallocate_a(lowest_missing_tmp)
857 if (st%restart_fixed_occ .and. iread == st%nst * st%nik * st%d%dim)
then
860 call smear_init(st%smear, namespace, st%d%ispin, fixed_occ = .
true., integral_occs = integral_occs, kpoints = kpoints)
863 if (.not.
present(lr) .and. .not.
present(skip))
call fill_random()
866 safe_deallocate_a(filled)
868 if (ierr == 0 .and. iread /= st%nst * st%nik * st%d%dim)
then
876 if (.not.
present(lr))
then
877 write(str,
'(a,i5)')
'Reading states.'
879 write(str,
'(a,i5)')
'Reading states information for linear response.'
882 if (.not.
present(skip))
then
883 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
884 st%nst * st%nik * st%d%dim,
' could be read.'
886 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
887 st%nst * st%nik * st%d%dim,
' were loaded.'
894 message(1) =
'Info: States reading done.'
906 do ik = st%d%kpt%start, st%d%kpt%end
908 do ist = st%st_start, st%st_end
909 do idim = 1, st%d%dim
910 if (filled(idim, ist, ik)) cycle
922 logical function index_is_wrong() !< .
true. if the index (idim, ist, ik) is not present in st structure...
925 if (idim > st%d%dim .or. idim < 1 .or. &
926 ist > st%nst .or. ist < 1 .or. &
927 ik > st%nik .or. ik < 1)
then
939 subroutine states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
942 class(
mesh_t),
intent(in) :: mesh
943 integer,
intent(out) :: iread
944 logical,
intent(out) :: filled(1:, st%st_start:, st%d%kpt%start:)
945 logical,
intent(in) :: restart_file_present(:, :, :)
946 integer,
intent(out) :: ierr
947 logical,
optional,
intent(in) :: skip(:)
948 integer,
optional,
intent(inout) :: lowest_missing(:, :)
951 type(adios2_adios) :: adios
952 type(adios2_io) :: io
953 type(adios2_variable) :: var, var_indices
954 type(adios2_attribute) :: attribute
955 type(adios2_engine) :: engine
956 integer :: type_file, type_requested, ib, ik, ndims, pardomains
958 integer(int64),
allocatable :: var_shape(:)
959 integer(int64),
allocatable :: global_indices(:)
965 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
967 call adios2_init(adios, ierr)
969 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
970 call adios2_declare_io(io, adios,
"reader", ierr)
971 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
973 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_read, ierr)
974 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
976 call adios2_begin_step(engine, ierr)
978 call adios2_inquire_attribute(attribute, io,
"ParDomains", ierr)
979 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem inquiring ADIOS2 attribute.")
980 call adios2_attribute_data(pardomains, attribute, ierr)
982 type_requested = adios2_type_dp
984 type_requested = adios2_type_complex_dp
986 call adios2_inquire_variable(var, io,
'wavefunctions', ierr)
987 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem loading ADIOS2 variable (wavefunctions).")
989 call adios2_variable_type(type_file, var, ierr)
990 call adios2_variable_ndims(ndims, var, ierr)
991 call adios2_variable_shape(var_shape, ndims, var, ierr)
994 if (var_shape(1) < int(st%nst * st%d%dim, int64))
then
996 nst_max = int(var_shape(1), int32) / st%d%dim
998 if (var_shape(2) /= int(mesh%np_global, int64))
then
1000 message(1) =
"Error: trying to restart with a different number of grid points. Not supported with ADIOS2 format."
1003 if (
present(skip))
then
1006 call states_elec_adios2_read_state_by_state(st, mesh, engine, var, filled, restart_file_present, iread, skip, lowest_missing)
1008 call states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1009 nst_max, filled, iread)
1012 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1013 call adios2_inquire_variable(var_indices, io,
'global_indices', ierr)
1014 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none, &
1015 "Problem loading ADIOS2 variable (global_indices).")
1016 safe_allocate(global_indices(mesh%np))
1017 call adios2_set_selection(var_indices, 1, &
1018 [int(mesh%pv%xlocal-1, int64)], &
1019 [int(mesh%np, int64)], ierr)
1020 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection (global_indices).")
1021 call adios2_get(engine, var_indices, global_indices, ierr)
1022 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (global_indices).")
1024 call adios2_end_step(engine, ierr)
1025 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 end_step.")
1026 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1027 do ik = st%d%kpt%start, st%d%kpt%end
1028 do ib = st%group%block_start, st%group%block_end
1036 safe_deallocate_a(global_indices)
1040 call adios2_close(engine, ierr)
1041 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
1042 call adios2_finalize(adios, ierr)
1043 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
1055 subroutine states_elec_adios2_read_state_by_state(st, mesh, engine, var, filled, restart_file_present, &
1056 iread, skip, lowest_missing)
1058 class(
mesh_t),
intent(in) :: mesh
1059 type(adios2_engine),
intent(inout) :: engine
1060 type(adios2_variable),
intent(inout) :: var
1061 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1062 logical,
intent(in) :: restart_file_present(:, :, :)
1063 integer,
intent(inout) :: iread
1064 logical,
optional,
intent(in) :: skip(:)
1065 integer,
optional,
intent(inout) :: lowest_missing(:, :)
1067 integer :: ik, ist, idim, ierr
1068 real(real64),
allocatable :: dpsi(:)
1069 complex(real64),
allocatable :: zpsi(:)
1071 push_sub(states_elec_adios2_read_state_by_state)
1073 do ik = st%d%kpt%start, st%d%kpt%end
1075 safe_allocate(dpsi(1:mesh%np))
1077 safe_allocate(zpsi(1:mesh%np))
1079 do ist = st%st_start, st%st_end
1080 if (
present(skip))
then
1081 if (skip(ist)) cycle
1084 do idim = 1, st%d%dim
1085 if (.not. restart_file_present(idim, ist, ik))
then
1086 if (
present(lowest_missing))
then
1087 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
1093 call adios2_set_selection(var, 3, &
1094 [int((ist-1)*st%d%dim+idim-1, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1095 [1_int64, int(mesh%np, int64), 1_int64], ierr)
1098 call adios2_get(engine, var, dpsi, adios2_mode_sync, ierr)
1099 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get dpsi.")
1102 call adios2_get(engine, var, zpsi, adios2_mode_sync, ierr)
1103 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get zpsi.")
1107 filled(idim, ist, ik) = .
true.
1111 safe_deallocate_a(dpsi)
1112 safe_deallocate_a(zpsi)
1115 pop_sub(states_elec_adios2_read_state_by_state)
1116 end subroutine states_elec_adios2_read_state_by_state
1120 subroutine states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1121 nst_max, filled, iread)
1123 class(
mesh_t),
intent(in) :: mesh
1124 type(adios2_engine),
intent(inout) :: engine
1125 type(adios2_variable),
intent(inout) :: var
1126 integer(int64),
intent(in) :: var_shape(:)
1127 integer,
intent(in) :: type_requested
1128 integer,
intent(in) :: type_file
1129 integer,
intent(in) :: nst_max
1130 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1131 integer,
intent(inout) :: iread
1133 integer :: ib, ik, ist, ip, adios2_mode, nst_linear, ierr
1135 real(real64),
allocatable :: dff_pack(:, :)
1137 push_sub(states_elec_adios2_read_batch_by_batch)
1139 do ik = st%d%kpt%start, st%d%kpt%end
1142 if (ik > var_shape(3)) cycle
1143 do ib = st%group%block_start, st%group%block_end
1144 select case (st%group%psib(ib, ik)%status())
1147 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.false.)
1149 adios2_mode = adios2_mode_sync
1151 psib => st%group%psib(ib, ik)
1155 adios2_mode = adios2_mode_sync
1158 call st%group%psib(ib, ik)%copy_to(psib)
1159 call psib%do_unpack(force=.
true., copy=.false.)
1162 adios2_mode = adios2_mode_sync
1167 nst_linear = st%group%psib(ib, ik)%nst_linear
1171 if (nst_linear <= 0)
then
1172 select case (st%group%psib(ib, ik)%status())
1175 safe_deallocate_p(psib)
1180 safe_deallocate_p(psib)
1188 call adios2_set_selection(var, 3, &
1189 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1190 [int(nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
1191 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection.")
1193 if (type_requested == adios2_type_dp .and. type_file == adios2_type_dp)
then
1195 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1196 [int(
size(psib%dff_pack, 1), int64), &
1197 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
1198 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading real).")
1200 call adios2_get(engine, var, psib%dff_pack, adios2_mode, ierr)
1201 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading real).")
1202 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_complex_dp)
then
1204 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1205 [int(
size(psib%zff_pack, 1), int64), &
1206 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1207 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex).")
1209 call adios2_get(engine, var, psib%zff_pack, adios2_mode, ierr)
1210 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex).")
1211 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_dp)
then
1213 safe_allocate(dff_pack(
size(psib%zff_pack, 1),
size(psib%zff_pack, 2)))
1215 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1216 [int(
size(psib%zff_pack, 1), int64), &
1217 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1218 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex from real).")
1221 call adios2_get(engine, var, dff_pack, adios2_mode_sync, ierr)
1222 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex from real).")
1226 do ist = 1, nst_linear
1227 psib%zff_pack(ist, ip) = cmplx(dff_pack(ist, ip),
m_zero, real64)
1230 safe_deallocate_a(dff_pack)
1232 message(1) =
"Error: requested to read complex states for restarting, but calculation has real states."
1236 iread = iread + nst_linear
1237 do ist = 1, nst_linear
1238 filled(st%group%psib(ib, ik)%linear_to_idim(ist), st%group%psib(ib, ik)%linear_to_ist(ist), ik) = .
true.
1241 select case (st%group%psib(ib, ik)%status())
1243 call psib%do_unpack()
1244 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1246 safe_deallocate_p(psib)
1251 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1253 safe_deallocate_p(psib)
1258 pop_sub(states_elec_adios2_read_batch_by_batch)
1259 end subroutine states_elec_adios2_read_batch_by_batch
1263 subroutine check_error(condition, error_message)
1264 logical,
intent(in) :: condition
1265 character(len=*),
intent(in) :: error_message
1270 end subroutine check_error
1276 class(
mesh_t),
intent(in) :: mesh
1277 integer,
intent(out) :: ierr
1278 integer,
optional,
intent(in) :: iter
1280 integer :: iunit, isp, err, err2(2)
1281 character(len=MAX_PATH_LEN) :: filename
1282 character(len=300) :: lines(2)
1288 if (restart%skip())
then
1293 message(1) =
"Debug: Writing density restart."
1299 iunit = restart%open(
'density')
1300 lines(1) =
'# #spin #nspin filename'
1301 lines(2) =
'%densities'
1302 call restart%write(iunit, lines, 2, err)
1303 if (err /= 0) ierr = ierr + 1
1306 do isp = 1, st%d%nspin
1308 write(lines(1),
'(i8,a,i8,a)') isp,
' | ', st%d%nspin,
' | "'//trim(adjustl(filename))//
'"'
1309 call restart%write(iunit, lines, 1, err)
1310 if (err /= 0) err2(1) = err2(1) + 1
1312 call restart%write_mesh_function(filename, mesh, st%rho(:,isp), err)
1313 if (err /= 0) err2(2) = err2(2) + 1
1316 if (err2(1) /= 0) ierr = ierr + 2
1317 if (err2(2) /= 0) ierr = ierr + 4
1320 call restart%write(iunit, lines, 1, err)
1321 if (err /= 0) ierr = ierr + 8
1322 if (
present(iter))
then
1323 write(lines(1),
'(a,i7)')
'Iter = ', iter
1324 call restart%write(iunit, lines, 1, err)
1325 if (err /= 0) ierr = ierr + 16
1327 call restart%close(iunit)
1331 message(1) =
"Debug: Writing density restart done."
1342 class(
mesh_t),
intent(in) :: mesh
1343 integer,
intent(out) :: ierr
1345 integer :: err, err2, isp
1346 character(len=MAX_PATH_LEN) :: filename
1352 if (restart%skip())
then
1358 message(1) =
"Debug: Reading density restart."
1369 do isp = 1, st%d%nspin
1374 call restart%read_mesh_function(filename, mesh, st%rho(:,isp), err)
1375 if (err /= 0) err2 = err2 + 1
1378 if (err2 /= 0) ierr = ierr + 1
1380 message(1) =
"Debug: Reading density restart done."
1388 class(
space_t),
intent(in) :: space
1390 class(
mesh_t),
intent(in) :: mesh
1391 integer,
intent(out) :: ierr
1393 integer :: isp, err, err2(2), idir
1394 character(len=MAX_PATH_LEN) :: filename
1400 assert(
allocated(st%frozen_rho))
1402 if (restart%skip())
then
1407 message(1) =
"Debug: Writing frozen densities restart."
1413 do isp = 1, st%d%nspin
1416 call restart%write_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1417 if (err /= 0) err2(2) = err2(2) + 1
1419 if (
allocated(st%frozen_tau))
then
1421 call restart%write_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1422 if (err /= 0) err2 = err2 + 1
1425 if (
allocated(st%frozen_gdens))
then
1426 do idir = 1, space%dim
1427 if (st%d%nspin == 1)
then
1428 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1430 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1432 call restart%write_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1433 if (err /= 0) err2 = err2 + 1
1437 if (
allocated(st%frozen_ldens))
then
1439 call restart%write_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1440 if (err /= 0) err2 = err2 + 1
1444 if (err2(1) /= 0) ierr = ierr + 2
1445 if (err2(2) /= 0) ierr = ierr + 4
1449 message(1) =
"Debug: Writing frozen densities restart done."
1459 class(
space_t),
intent(in) :: space
1461 class(
mesh_t),
intent(in) :: mesh
1462 integer,
intent(out) :: ierr
1464 integer :: err, err2, isp, idir
1465 character(len=MAX_PATH_LEN) :: filename
1469 assert(
allocated(st%frozen_rho))
1473 if (restart%skip())
then
1479 message(1) =
"Debug: Reading densities restart."
1483 do isp = 1, st%d%nspin
1485 call restart%read_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1486 if (err /= 0) err2 = err2 + 1
1488 if (
allocated(st%frozen_tau))
then
1490 call restart%read_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1491 if (err /= 0) err2 = err2 + 1
1494 if (
allocated(st%frozen_gdens))
then
1495 do idir = 1, space%dim
1496 if (st%d%nspin == 1)
then
1497 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1499 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1501 call restart%read_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1502 if (err /= 0) err2 = err2 + 1
1506 if (
allocated(st%frozen_ldens))
then
1508 call restart%read_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1509 if (err /= 0) err2 = err2 + 1
1513 if (err2 /= 0) ierr = ierr + 1
1515 message(1) =
"Debug: Reading frozen densities restart done."
1526 class(
mesh_t),
intent(in) :: mesh
1528 class(
space_t),
intent(in) :: space
1532 integer :: ip, id, is, ik, nstates, state_from, ierr, ncols
1533 integer :: ib, idim, inst, inik, normalize
1534 real(real64) :: xx(space%dim), rr, psi_re, psi_im
1535 character(len=150) :: filename
1536 complex(real64),
allocatable :: zpsi(:, :)
1538 integer,
parameter :: &
1539 state_from_formula = 1, &
1540 state_from_file = -10010, &
1541 normalize_yes = 1, &
1624 if (
parse_block(namespace,
'UserDefinedStates', blk) == 0)
then
1631 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
1637 if (ncols < 5 .or. ncols > 6)
then
1638 message(1) =
'Each line in the UserDefinedStates block must have'
1639 message(2) =
'five or six columns.'
1655 if (.not.(id == idim .and. is == inst .and. ik == inik )) cycle
1661 select case (state_from)
1662 case (state_from_formula)
1665 blk, ib - 1, 4, st%user_def_states(id, is, ik))
1667 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1668 write(
message(2),
'(2a)')
' with the expression:'
1669 write(
message(3),
'(2a)')
' ',trim(st%user_def_states(id, is, ik))
1675 case (state_from_file)
1681 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1682 write(
message(2),
'(2a)')
' with data from file:'
1683 write(
message(3),
'(2a)')
' ',trim(filename)
1689 if (.not.(st%st_start <= is .and. st%st_end >= is &
1690 .and. st%d%kpt%start <= ik .and. st%d%kpt%end >= ik)) cycle
1692 select case (state_from)
1694 case (state_from_formula)
1703 zpsi(ip, 1) = cmplx(psi_re, psi_im, real64)
1706 case (state_from_file)
1710 message(1) =
'Could not read the file!'
1711 write(
message(2),
'(a,i1)')
'Error code: ', ierr
1716 message(1) =
'Wrong entry in UserDefinedStates, column 4.'
1717 message(2) =
'You may state "formula" or "file" here.'
1727 select case (normalize)
1730 case (normalize_yes)
1731 assert(st%d%dim == 1)
1735 message(1) =
'The sixth column in UserDefinedStates may either be'
1736 message(2) =
'"normalize_yes" or "normalize_no"'
1746 safe_deallocate_a(zpsi)
1764 integer,
intent(out) :: ierr
1766 integer :: iunit_spin
1767 integer :: err, err2(2), ik, ist
1768 character(len=300) :: lines(3)
1774 if (restart%skip())
then
1783 iunit_spin = restart%open(
'spin')
1784 lines(1) =
'# #k-point #st #spin(x) spin(y) spin(z)'
1785 call restart%write(iunit_spin, lines, 1, err)
1786 if (err /= 0) ierr = ierr + 1
1791 write(lines(1),
'(i8,a,i8,3(a,f18.12))') ik,
' | ', ist,
' | ', &
1792 st%spin(1,ist,ik),
' | ', st%spin(2,ist,ik),
' | ', st%spin(3,ist,ik)
1793 call restart%write(iunit_spin, lines, 1, err)
1794 if (err /= 0) err2(1) = err2(1) + 1
1798 call restart%write(iunit_spin, lines, 1, err)
1799 if (err2(1) /= 0) ierr = ierr + 8
1800 if (err2(2) /= 0) ierr = ierr + 16
1802 call restart%close(iunit_spin)
1821 integer,
intent(out) :: ierr
1823 integer :: spin_file, err, ik, ist
1824 character(len=256) :: lines(3)
1825 real(real64) :: spin(3)
1826 character(len=1) :: char
1833 if (restart%skip())
then
1842 spin_file = restart%open(
'spin')
1844 call restart%read(spin_file, lines, 1, err)
1845 if (err /= 0) ierr = ierr - 2**7
1850 call restart%close(spin_file)
1860 call restart%read(spin_file, lines, 1, err)
1863 read(lines(1),
'(a)') char
1864 if (char ==
'%')
then
1868 read(lines(1), *) ik, char, ist, char, spin(1), char, spin(2), char, spin(3)
1871 st%spin(1:3, ist, ik) = spin(1:3)
1874 call restart%close(spin_file)
1884 class(
space_t),
intent(in) :: space
1885 type(
restart_t),
intent(inout) :: restart
1886 class(
mesh_t),
intent(in) :: mesh
1888 character(len=*),
optional,
intent(in) :: prefix
1892 complex(real64),
allocatable :: rotation_matrix(:,:), psi(:, :)
1893 integer :: ist, jst, ncols, iqn
1894 character(len=256) :: block_name
1926 if (
parse_block(namespace, trim(block_name), blk) == 0)
then
1927 if (st%parallel_in_states)
then
1931 message(1) =
"Number of rows in block " // trim(block_name) //
" must equal number of states in this calculation."
1938 safe_allocate(rotation_matrix(1:stin%nst, 1:stin%nst))
1939 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
1945 if (ncols /= stin%nst)
then
1946 write(
message(1),
'(a,i6,a,i6,3a,i6,a)')
"Number of columns (", ncols,
") in row ", ist,
" of block ", &
1947 trim(block_name),
" must equal number of states (", stin%nst,
") read from gs restart."
1950 do jst = 1, stin%nst
1957 do iqn = st%d%kpt%start, st%d%kpt%end
1964 do ist = st%st_start, st%st_end
1971 safe_deallocate_a(rotation_matrix)
1972 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)
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