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,
intent(in) :: fixed_occ
89 logical,
optional,
intent(in) :: is_complex
90 logical,
optional,
intent(in) :: packed
92 integer :: nkpt, dim, nst, ierr
93 real(real64),
allocatable :: new_occ(:,:)
100 message(1) =
"Unable to read states information."
104 if (st%parallel_in_states)
then
105 message(1) =
"Internal error: cannot use states_elec_look_and_load when parallel in states."
110 allocate(new_occ(1:nst, 1:st%nik))
112 new_occ(1:min(nst, st%nst),:) = st%occ(1:min(nst, st%nst),:)
113 safe_deallocate_a(st%occ)
114 call move_alloc(new_occ, st%occ)
124 safe_deallocate_a(st%node)
125 safe_allocate(st%node(1:st%nst))
128 safe_deallocate_a(st%eigenval)
129 safe_allocate(st%eigenval(1:st%nst, 1:st%nik))
130 st%eigenval = huge(st%eigenval)
132 if (
present(is_complex))
then
143 if (st%d%ispin ==
spinors)
then
144 safe_allocate(st%spin(1:3, 1:st%nst, 1:st%nik))
149 call states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr)
151 message(1) =
"Unable to read wavefunctions."
160 subroutine states_elec_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, verbose)
161 type(restart_t),
intent(in) :: restart
162 class(space_t),
intent(in) :: space
163 type(states_elec_t),
target,
intent(in) :: st
164 class(mesh_t),
intent(in) :: mesh
165 type(kpoints_t),
intent(in) :: kpoints
166 integer,
intent(out) :: ierr
167 integer,
optional,
intent(in) :: iter
168 type(lr_t),
optional,
intent(in) :: lr
169 logical,
optional,
intent(in) :: verbose
171 integer :: iunit_wfns, iunit_occs, iunit_states
172 integer :: err, err2(2), ik, idir, ist, idim, itot
173 integer :: root(1:P_STRATEGY_MAX)
174 character(len=MAX_PATH_LEN) :: filename
175 character(len=500) :: lines(3)
176 logical :: lr_wfns_are_associated, should_write, verbose_
177 real(real64) :: kpoint(space%dim)
178 real(real64),
allocatable :: dpsi(:)
179 complex(real64),
allocatable :: zpsi(:)
180 integer :: restart_file_format
188 if (restart%skip())
then
194 message(1) =
"Info: Writing states."
200 restart_file_format = restart%file_format_states
201 if (
present(lr))
then
202 lr_wfns_are_associated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
204 assert(lr_wfns_are_associated)
206 restart_file_format = option__restartfileformatstates__obf
211 iunit_states = restart%open(
'states')
212 write(lines(1),
'(a20,1i10)')
'nst= ', st%nst
213 write(lines(2),
'(a20,1i10)')
'dim= ', st%d%dim
214 write(lines(3),
'(a20,1i10)')
'nik= ', st%nik
215 call restart%write(iunit_states, lines, 3, err)
216 if (err /= 0) ierr = ierr + 1
217 call restart%close(iunit_states)
220 iunit_wfns = restart%open(
'wfns')
221 lines(1) =
'# #k-point #st #dim filename'
223 lines(2) =
'%Real_Wavefunctions'
225 lines(2) =
'%Complex_Wavefunctions'
227 call restart%write(iunit_wfns, lines, 2, err)
228 if (err /= 0) ierr = ierr + 2
231 iunit_occs = restart%open(
'occs')
232 lines(1) =
'# occupations | eigenvalue[a.u.] | Im(eigenvalue) [a.u.] | k-points | k-weights | filename | ik | ist | idim'
233 lines(2) =
'%Occupations_Eigenvalues_K-Points'
234 call restart%write(iunit_occs, lines, 2, err)
235 if (err /= 0) ierr = ierr + 4
239 safe_allocate(dpsi(1:mesh%np))
241 safe_allocate(zpsi(1:mesh%np))
248 kpoint(1:space%dim) = &
249 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
252 do idim = 1, st%d%dim
254 write(filename,
'(i10.10)') itot
256 write(lines(1),
'(i8,a,i8,a,i8,3a)') ik,
' | ', ist,
' | ', idim,
' | "', trim(filename),
'"'
257 call restart%write(iunit_wfns, lines, 1, err)
258 if (err /= 0) err2(1) = err2(1) + 1
260 write(lines(1),
'(e23.16,a,e23.16)') st%occ(ist,ik),
' | ', st%eigenval(ist, ik)
261 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ',
m_zero
262 do idir = 1, space%dim
263 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ', kpoint(idir)
265 write(lines(1),
'(a,a,e23.16,a,i10.10,3(a,i8))') trim(lines(1)), &
266 ' | ', st%kweights(ik),
' | ', itot,
' | ', ik,
' | ', ist,
' | ', idim
267 call restart%write(iunit_occs, lines, 1, err)
268 if (err /= 0) err2(1) = err2(1) + 1
270 should_write = st%st_start <= ist .and. ist <= st%st_end
272 if (restart_file_format == option__restartfileformatstates__obf)
then
273 if (should_write)
then
274 if (st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
276 if (.not.
present(lr))
then
278 call restart%write_mesh_function(filename, mesh, dpsi, err, root = root)
280 call restart%write_mesh_function(filename, mesh, &
281 lr%ddl_psi(:, idim, ist, ik), err, root = root)
284 if (.not.
present(lr))
then
286 call restart%write_mesh_function(filename, mesh, zpsi, err, root = root)
288 call restart%write_mesh_function(filename, mesh, &
289 lr%zdl_psi(:, idim, ist, ik), err, root = root)
296 if (err /= 0) err2(2) = err2(2) + 1
303 if (err2(1) /= 0) ierr = ierr + 8
304 if (err2(2) /= 0) ierr = ierr + 16
306 safe_deallocate_a(dpsi)
307 safe_deallocate_a(zpsi)
309 if (restart_file_format == option__restartfileformatstates__adios2)
then
310 if (
present(lr))
then
318 call restart%write(iunit_occs, lines, 1, err)
319 if (err /= 0) ierr = ierr + 32
320 call restart%write(iunit_wfns, lines, 1, err)
321 if (err /= 0) ierr = ierr + 64
322 if (
present(iter))
then
323 write(lines(1),
'(a,i7)')
'Iter = ', iter
324 call restart%write(iunit_wfns, lines, 1, err)
325 if (err /= 0) ierr = ierr + 128
328 call restart%close(iunit_wfns)
329 call restart%close(iunit_occs)
332 message(1) =
"Info: Finished writing states."
346 class(
mesh_t),
intent(in) :: mesh
347 integer,
intent(out) :: ierr
350 type(adios2_adios) :: adios
351 type(adios2_io) :: io
352 type(adios2_variable) :: var, var_indices
353 type(adios2_attribute) :: attribute
354 type(adios2_engine) :: engine
355 integer :: adios2_type, ik, ib, ip, adios2_mode
356 integer(int64),
allocatable :: global_indices(:)
363 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
365 call adios2_init(adios, ierr)
367 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
368 call adios2_declare_io(io, adios,
"writer", ierr)
369 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
371 call adios2_set_parameter(io,
"StatsLevel",
"0", ierr)
372 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 parameter.")
374 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_write, ierr)
375 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
377 adios2_type = adios2_type_dp
379 adios2_type = adios2_type_complex_dp
382 call adios2_define_variable(var, io,
"wavefunctions", adios2_type, 3, &
383 [int(st%nst * st%d%dim, int64), int(mesh%np_global, int64), int(st%nik, int64)], &
384 [0_int64, 0_int64, 0_int64], &
385 [1_int64, 1_int64, 1_int64], &
386 adios2_variable_dims, ierr)
387 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (wavefunctions).")
389 call adios2_define_attribute(attribute, io,
"ParDomains", mesh%mpi_grp%size, ierr)
390 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 attribute (ParDomains).")
392 call adios2_define_variable(var_indices, io,
"global_indices", adios2_type_integer8, 1, &
393 [int(mesh%np_global, int64)], &
394 [int(mesh%pv%xlocal-1, int64)], &
395 [int(mesh%np, int64)], &
396 adios2_variable_dims, ierr)
397 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (global_indices).")
399 safe_allocate(global_indices(mesh%np))
404 call adios2_begin_step(engine, ierr)
405 call adios2_put(engine, var_indices, global_indices, ierr)
407 do ik = st%d%kpt%start, st%d%kpt%end
408 do ib = st%group%block_start, st%group%block_end
410 select case (st%group%psib(ib, ik)%status())
413 call st%group%psib(ib, ik)%copy_to(psib)
417 adios2_mode = adios2_mode_sync
419 psib => st%group%psib(ib, ik)
420 adios2_mode = adios2_mode_deferred
423 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.
true.)
425 call psib%do_unpack(force=.
true.)
429 adios2_mode = adios2_mode_sync
436 call adios2_set_selection(var, 3, &
437 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
438 [int(st%group%psib(ib, ik)%nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
441 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
442 [int(
size(psib%dff_pack, 1), int64), &
443 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
444 call adios2_put(engine, var, psib%dff_pack, adios2_mode, ierr)
446 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
447 [int(
size(psib%zff_pack, 1), int64), &
448 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
449 call adios2_put(engine, var, psib%zff_pack, adios2_mode, ierr)
451 select case (st%group%psib(ib, ik)%status())
454 safe_deallocate_p(psib)
460 call adios2_end_step(engine, ierr)
463 safe_deallocate_a(global_indices)
466 call adios2_close(engine, ierr)
467 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
468 call adios2_finalize(adios, ierr)
469 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
484 subroutine states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, &
485 ierr, iter, lr, lowest_missing, label, verbose, skip)
488 class(
space_t),
intent(in) :: space
490 class(
mesh_t),
intent(in) :: mesh
492 logical,
intent(in) :: fixed_occ
493 integer,
intent(out) :: ierr
494 integer,
optional,
intent(out) :: iter
495 type(
lr_t),
optional,
intent(inout) :: lr
496 integer,
optional,
intent(out) :: lowest_missing(:, :)
497 character(len=*),
optional,
intent(in) :: label
498 logical,
optional,
intent(in) :: verbose
499 logical,
optional,
intent(in) :: skip(:)
501 integer :: states_elec_file, wfns_file, occ_file, err, ik, ist, idir, idim
502 integer :: idone, iread, ntodo
503 character(len=12) :: filename
504 character(len=1) :: char
505 logical,
allocatable :: filled(:, :, :)
506 character(len=256) :: lines(3), label_
507 character(len=50) :: str
509 real(real64) :: my_occ, imev, my_kweight
510 logical :: read_occ, lr_allocated, verbose_
511 logical :: integral_occs
512 real(real64),
allocatable :: dpsi(:)
513 complex(real64),
allocatable :: zpsi(:)
514 character(len=256),
allocatable :: restart_file(:, :, :)
515 logical,
allocatable :: restart_file_present(:, :, :)
516 real(real64) :: kpoint(space%dim), read_kpoint(space%dim)
519 integer,
allocatable :: lowest_missing_tmp(:, :)
520 integer :: restart_file_format
527 if (
present(lowest_missing)) lowest_missing = 1
528 if (
present(iter)) iter = 0
530 if (
present(skip))
then
531 assert(ubound(skip, dim = 1) == st%nst)
534 if (restart%skip())
then
544 if (
present(label))
then
547 if (
present(lr))
then
548 label_ =
" for linear response"
554 message(1) =
'Info: Reading states'
555 if (len(trim(label_)) > 0)
then
561 if (.not.
present(lr))
then
562 st%fromScratch = .false.
568 integral_occs = .
true.
571 st%fixed_occ = .
true.
573 read_occ = .not. st%fixed_occ
576 if (.not.
present(lr))
then
577 st%eigenval(:, :) =
m_zero
581 if (.not.
present(lr) .and. read_occ)
then
586 restart_file_format = restart%file_format_states
588 if (
present(lr))
then
589 lr_allocated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
593 restart_file_format = option__restartfileformatstates__obf
596 states_elec_file = restart%open(
'states')
601 call restart%read(states_elec_file, lines, 3, err)
605 read(lines(2), *) str, idim
606 read(lines(3), *) str, ik
607 if (idim == 2 .and. st%d%dim == 1)
then
608 write(
message(1),
'(a)')
'Incompatible restart information: saved calculation is spinors, this one is not.'
612 if (idim == 1 .and. st%d%dim == 2)
then
613 write(
message(1),
'(a)')
'Incompatible restart information: this calculation is spinors, saved one is not.'
617 if (ik < st%nik)
then
618 write(
message(1),
'(a)')
'Incompatible restart information: not enough k-points.'
619 write(
message(2),
'(2(a,i6))')
'Expected ', st%nik,
' > Read ', ik
624 call restart%close(states_elec_file)
628 wfns_file = restart%open(
'wfns')
629 occ_file = restart%open(
'occs')
630 call restart%read(wfns_file, lines, 2, err)
634 read(lines(2),
'(a)') str
635 if (str(2:8) ==
'Complex')
then
636 message(1) =
"Cannot read real states from complex wavefunctions."
639 else if (str(2:5) /=
'Real')
then
640 message(1) =
"Restart file 'wfns' does not specify real/complex; cannot check compatibility."
647 call restart%read(occ_file, lines, 2, err)
648 if (err /= 0) ierr = ierr - 2**7
653 call restart%close(wfns_file)
654 call restart%close(occ_file)
661 safe_allocate(dpsi(1:mesh%np))
663 safe_allocate(zpsi(1:mesh%np))
666 safe_allocate(restart_file(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
667 safe_allocate(restart_file_present(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
668 restart_file_present = .false.
674 call restart%read(wfns_file, lines, 1, err)
676 read(lines(1),
'(a)') char
677 if (char ==
'%')
then
681 read(lines(1), *) ik, char, ist, char, idim, char, filename
686 call restart%read(occ_file, lines, 1, err)
690 if (ist >= st%st_start .and. ist <= st%st_end .and. &
691 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
693 restart_file(idim, ist, ik) = trim(filename)
694 restart_file_present(idim, ist, ik) = .
true.
697 call restart%read(occ_file, lines, 1, err)
698 if (.not.
present(lr))
then
702 read(lines(1), *) my_occ, char, st%eigenval(ist, ik), char, imev, char, &
703 (read_kpoint(idir), char, idir = 1, space%dim), my_kweight
707 if (ist >= st%st_start .and. ist <= st%st_end .and. &
708 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
709 restart_file_present(idim, ist, ik) = .false.
714 kpoint(1:space%dim) = &
715 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
717 if (any(abs(kpoint(1:space%dim) - read_kpoint(1:space%dim)) > 1e-12_real64))
then
720 write(
message(1),
'(a,i6)')
'Incompatible restart information: k-point mismatch for ik ', ik
721 write(
message(2),
'(a,99f18.12)')
' Expected : ', kpoint(1:space%dim)
722 write(
message(3),
'(a,99f18.12)')
' Read : ', read_kpoint(1:space%dim)
725 if (ist >= st%st_start .and. ist <= st%st_end .and. &
726 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
727 restart_file_present(idim, ist, ik) = .false.
732 st%occ(ist, ik) = my_occ
733 integral_occs = integral_occs .and. &
734 abs((st%occ(ist, ik) - st%smear%el_per_state) * st%occ(ist, ik)) <=
m_epsilon
739 if (
present(iter))
then
740 call restart%read(wfns_file, lines, 1, err)
744 read(lines(1), *) filename, filename, iter
748 call restart%close(wfns_file)
749 call restart%close(occ_file)
753 if (restart_file_format == option__restartfileformatstates__adios2)
then
754 if (.not.
loct_dir_exists(trim(restart%dir())//
"/"//
"wavefunctions.bp"))
then
755 message(1) =
"ADIOS2 restart file not found, falling back to obf format."
757 restart_file_format = option__restartfileformatstates__obf
764 safe_allocate(filled(1:st%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
767 if (
present(lowest_missing)) lowest_missing = st%nst + 1
770 if (st%system_grp%is_root() .and. verbose_)
then
772 ntodo = st%lnst*st%d%kpt%nlocal*st%d%dim
775 if (restart_file_format == option__restartfileformatstates__obf)
then
776 do ik = st%d%kpt%start, st%d%kpt%end
777 do ist = st%st_start, st%st_end
778 if (
present(skip))
then
782 do idim = 1, st%d%dim
784 if (.not. restart_file_present(idim, ist, ik))
then
785 if (
present(lowest_missing))
then
786 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
792 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, dpsi, err)
793 if (.not.
present(lr))
then
796 call lalg_copy(mesh%np, dpsi, lr%ddl_psi(:, idim, ist, ik))
799 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, zpsi, err)
800 if (.not.
present(lr))
then
803 call lalg_copy(mesh%np, zpsi, lr%zdl_psi(:, idim, ist, ik))
808 filled(idim, ist, ik) = .
true.
810 else if (
present(lowest_missing))
then
811 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
814 if (st%system_grp%is_root() .and. verbose_)
then
822 else if (restart_file_format == option__restartfileformatstates__adios2)
then
823 if (
present(lr))
then
827 if (restart%has_map())
then
828 message(1) =
"ADIOS2 restart file format does not support restarting from a different grid."
829 message(2) =
"Please set RestartFileFormatStates = obf."
832 call states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
835 safe_deallocate_a(dpsi)
836 safe_deallocate_a(zpsi)
837 safe_deallocate_a(restart_file)
838 safe_deallocate_a(restart_file_present)
840 if (st%system_grp%is_root() .and. verbose_)
then
844 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
846 call st%st_kpt_mpi_grp%allreduce(iread_tmp, iread, 1, mpi_integer, mpi_sum)
849 if (st%d%kpt%parallel)
then
851 if (
present(lowest_missing))
then
852 safe_allocate(lowest_missing_tmp(1:st%d%dim, 1:st%nik))
853 lowest_missing_tmp = lowest_missing
854 call st%d%kpt%mpi_grp%allreduce(lowest_missing_tmp(1,1), lowest_missing(1,1), st%d%dim*st%nik, &
855 mpi_integer, mpi_min)
856 safe_deallocate_a(lowest_missing_tmp)
860 if (fixed_occ .and. iread == st%nst * st%nik * st%d%dim)
then
863 call smear_init(st%smear, namespace, st%d%ispin, fixed_occ = .
true., integral_occs = integral_occs, kpoints = kpoints)
866 if (.not.
present(lr) .and. .not.
present(skip))
call fill_random()
869 safe_deallocate_a(filled)
871 if (ierr == 0 .and. iread /= st%nst * st%nik * st%d%dim)
then
879 if (.not.
present(lr))
then
880 write(str,
'(a,i5)')
'Reading states.'
882 write(str,
'(a,i5)')
'Reading states information for linear response.'
885 if (.not.
present(skip))
then
886 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
887 st%nst * st%nik * st%d%dim,
' could be read.'
889 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
890 st%nst * st%nik * st%d%dim,
' were loaded.'
897 message(1) =
'Info: States reading done.'
909 do ik = st%d%kpt%start, st%d%kpt%end
911 do ist = st%st_start, st%st_end
912 do idim = 1, st%d%dim
913 if (filled(idim, ist, ik)) cycle
925 logical function index_is_wrong() !< .
true. if the index (idim, ist, ik) is not present in st structure...
928 if (idim > st%d%dim .or. idim < 1 .or. &
929 ist > st%nst .or. ist < 1 .or. &
930 ik > st%nik .or. ik < 1)
then
942 subroutine states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
945 class(
mesh_t),
intent(in) :: mesh
946 integer,
intent(out) :: iread
947 logical,
intent(out) :: filled(1:, st%st_start:, st%d%kpt%start:)
948 logical,
intent(in) :: restart_file_present(:, :, :)
949 integer,
intent(out) :: ierr
950 logical,
optional,
intent(in) :: skip(:)
951 integer,
optional,
intent(inout) :: lowest_missing(:, :)
954 type(adios2_adios) :: adios
955 type(adios2_io) :: io
956 type(adios2_variable) :: var, var_indices
957 type(adios2_attribute) :: attribute
958 type(adios2_engine) :: engine
959 integer :: type_file, type_requested, ib, ik, ndims, pardomains
961 integer(int64),
allocatable :: var_shape(:)
962 integer(int64),
allocatable :: global_indices(:)
968 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
970 call adios2_init(adios, ierr)
972 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
973 call adios2_declare_io(io, adios,
"reader", ierr)
974 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
976 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_read, ierr)
977 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
979 call adios2_begin_step(engine, ierr)
981 call adios2_inquire_attribute(attribute, io,
"ParDomains", ierr)
982 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem inquiring ADIOS2 attribute.")
983 call adios2_attribute_data(pardomains, attribute, ierr)
985 type_requested = adios2_type_dp
987 type_requested = adios2_type_complex_dp
989 call adios2_inquire_variable(var, io,
'wavefunctions', ierr)
990 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem loading ADIOS2 variable (wavefunctions).")
992 call adios2_variable_type(type_file, var, ierr)
993 call adios2_variable_ndims(ndims, var, ierr)
994 call adios2_variable_shape(var_shape, ndims, var, ierr)
997 if (var_shape(1) < int(st%nst * st%d%dim, int64))
then
999 nst_max = int(var_shape(1), int32) / st%d%dim
1001 if (var_shape(2) /= int(mesh%np_global, int64))
then
1003 message(1) =
"Error: trying to restart with a different number of grid points. Not supported with ADIOS2 format."
1006 if (
present(skip))
then
1009 call states_elec_adios2_read_state_by_state(st, mesh, engine, var, filled, restart_file_present, iread, skip, lowest_missing)
1011 call states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1012 nst_max, filled, iread)
1015 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1016 call adios2_inquire_variable(var_indices, io,
'global_indices', ierr)
1017 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none, &
1018 "Problem loading ADIOS2 variable (global_indices).")
1019 safe_allocate(global_indices(mesh%np))
1020 call adios2_set_selection(var_indices, 1, &
1021 [int(mesh%pv%xlocal-1, int64)], &
1022 [int(mesh%np, int64)], ierr)
1023 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection (global_indices).")
1024 call adios2_get(engine, var_indices, global_indices, ierr)
1025 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (global_indices).")
1027 call adios2_end_step(engine, ierr)
1028 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 end_step.")
1029 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1030 do ik = st%d%kpt%start, st%d%kpt%end
1031 do ib = st%group%block_start, st%group%block_end
1039 safe_deallocate_a(global_indices)
1043 call adios2_close(engine, ierr)
1044 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
1045 call adios2_finalize(adios, ierr)
1046 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
1058 subroutine states_elec_adios2_read_state_by_state(st, mesh, engine, var, filled, restart_file_present, &
1059 iread, skip, lowest_missing)
1061 class(
mesh_t),
intent(in) :: mesh
1062 type(adios2_engine),
intent(inout) :: engine
1063 type(adios2_variable),
intent(inout) :: var
1064 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1065 logical,
intent(in) :: restart_file_present(:, :, :)
1066 integer,
intent(inout) :: iread
1067 logical,
optional,
intent(in) :: skip(:)
1068 integer,
optional,
intent(inout) :: lowest_missing(:, :)
1070 integer :: ik, ist, idim, ierr
1071 real(real64),
allocatable :: dpsi(:)
1072 complex(real64),
allocatable :: zpsi(:)
1074 push_sub(states_elec_adios2_read_state_by_state)
1076 do ik = st%d%kpt%start, st%d%kpt%end
1078 safe_allocate(dpsi(1:mesh%np))
1080 safe_allocate(zpsi(1:mesh%np))
1082 do ist = st%st_start, st%st_end
1083 if (
present(skip))
then
1084 if (skip(ist)) cycle
1087 do idim = 1, st%d%dim
1088 if (.not. restart_file_present(idim, ist, ik))
then
1089 if (
present(lowest_missing))
then
1090 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
1096 call adios2_set_selection(var, 3, &
1097 [int((ist-1)*st%d%dim+idim-1, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1098 [1_int64, int(mesh%np, int64), 1_int64], ierr)
1101 call adios2_get(engine, var, dpsi, adios2_mode_sync, ierr)
1102 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get dpsi.")
1105 call adios2_get(engine, var, zpsi, adios2_mode_sync, ierr)
1106 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get zpsi.")
1110 filled(idim, ist, ik) = .
true.
1114 safe_deallocate_a(dpsi)
1115 safe_deallocate_a(zpsi)
1118 pop_sub(states_elec_adios2_read_state_by_state)
1119 end subroutine states_elec_adios2_read_state_by_state
1123 subroutine states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1124 nst_max, filled, iread)
1126 class(
mesh_t),
intent(in) :: mesh
1127 type(adios2_engine),
intent(inout) :: engine
1128 type(adios2_variable),
intent(inout) :: var
1129 integer(int64),
intent(in) :: var_shape(:)
1130 integer,
intent(in) :: type_requested
1131 integer,
intent(in) :: type_file
1132 integer,
intent(in) :: nst_max
1133 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1134 integer,
intent(inout) :: iread
1136 integer :: ib, ik, ist, ip, adios2_mode, nst_linear, ierr
1138 real(real64),
allocatable :: dff_pack(:, :)
1140 push_sub(states_elec_adios2_read_batch_by_batch)
1142 do ik = st%d%kpt%start, st%d%kpt%end
1145 if (ik > var_shape(3)) cycle
1146 do ib = st%group%block_start, st%group%block_end
1147 select case (st%group%psib(ib, ik)%status())
1150 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.false.)
1152 adios2_mode = adios2_mode_sync
1154 psib => st%group%psib(ib, ik)
1158 adios2_mode = adios2_mode_sync
1161 call st%group%psib(ib, ik)%copy_to(psib)
1162 call psib%do_unpack(force=.
true., copy=.false.)
1165 adios2_mode = adios2_mode_sync
1170 nst_linear = st%group%psib(ib, ik)%nst_linear
1174 if (nst_linear <= 0)
then
1175 select case (st%group%psib(ib, ik)%status())
1178 safe_deallocate_p(psib)
1183 safe_deallocate_p(psib)
1191 call adios2_set_selection(var, 3, &
1192 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1193 [int(nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
1194 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection.")
1196 if (type_requested == adios2_type_dp .and. type_file == adios2_type_dp)
then
1198 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1199 [int(
size(psib%dff_pack, 1), int64), &
1200 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
1201 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading real).")
1203 call adios2_get(engine, var, psib%dff_pack, adios2_mode, ierr)
1204 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading real).")
1205 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_complex_dp)
then
1207 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1208 [int(
size(psib%zff_pack, 1), int64), &
1209 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1210 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex).")
1212 call adios2_get(engine, var, psib%zff_pack, adios2_mode, ierr)
1213 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex).")
1214 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_dp)
then
1216 safe_allocate(dff_pack(
size(psib%zff_pack, 1),
size(psib%zff_pack, 2)))
1218 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1219 [int(
size(psib%zff_pack, 1), int64), &
1220 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1221 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex from real).")
1224 call adios2_get(engine, var, dff_pack, adios2_mode_sync, ierr)
1225 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex from real).")
1229 do ist = 1, nst_linear
1230 psib%zff_pack(ist, ip) = cmplx(dff_pack(ist, ip),
m_zero, real64)
1233 safe_deallocate_a(dff_pack)
1235 message(1) =
"Error: requested to read complex states for restarting, but calculation has real states."
1239 iread = iread + nst_linear
1240 do ist = 1, nst_linear
1241 filled(st%group%psib(ib, ik)%linear_to_idim(ist), st%group%psib(ib, ik)%linear_to_ist(ist), ik) = .
true.
1244 select case (st%group%psib(ib, ik)%status())
1246 call psib%do_unpack()
1247 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1249 safe_deallocate_p(psib)
1254 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1256 safe_deallocate_p(psib)
1261 pop_sub(states_elec_adios2_read_batch_by_batch)
1262 end subroutine states_elec_adios2_read_batch_by_batch
1266 subroutine check_error(condition, error_message)
1267 logical,
intent(in) :: condition
1268 character(len=*),
intent(in) :: error_message
1273 end subroutine check_error
1279 class(
mesh_t),
intent(in) :: mesh
1280 integer,
intent(out) :: ierr
1281 integer,
optional,
intent(in) :: iter
1283 integer :: iunit, isp, err, err2(2)
1284 character(len=MAX_PATH_LEN) :: filename
1285 character(len=300) :: lines(2)
1291 if (restart%skip())
then
1296 message(1) =
"Debug: Writing density restart."
1302 iunit = restart%open(
'density')
1303 lines(1) =
'# #spin #nspin filename'
1304 lines(2) =
'%densities'
1305 call restart%write(iunit, lines, 2, err)
1306 if (err /= 0) ierr = ierr + 1
1309 do isp = 1, st%d%nspin
1311 write(lines(1),
'(i8,a,i8,a)') isp,
' | ', st%d%nspin,
' | "'//trim(adjustl(filename))//
'"'
1312 call restart%write(iunit, lines, 1, err)
1313 if (err /= 0) err2(1) = err2(1) + 1
1315 call restart%write_mesh_function(filename, mesh, st%rho(:,isp), err)
1316 if (err /= 0) err2(2) = err2(2) + 1
1319 if (err2(1) /= 0) ierr = ierr + 2
1320 if (err2(2) /= 0) ierr = ierr + 4
1323 call restart%write(iunit, lines, 1, err)
1324 if (err /= 0) ierr = ierr + 8
1325 if (
present(iter))
then
1326 write(lines(1),
'(a,i7)')
'Iter = ', iter
1327 call restart%write(iunit, lines, 1, err)
1328 if (err /= 0) ierr = ierr + 16
1330 call restart%close(iunit)
1334 message(1) =
"Debug: Writing density restart done."
1345 class(
mesh_t),
intent(in) :: mesh
1346 integer,
intent(out) :: ierr
1348 integer :: err, err2, isp
1349 character(len=MAX_PATH_LEN) :: filename
1355 if (restart%skip())
then
1361 message(1) =
"Debug: Reading density restart."
1372 do isp = 1, st%d%nspin
1377 call restart%read_mesh_function(filename, mesh, st%rho(:,isp), err)
1378 if (err /= 0) err2 = err2 + 1
1381 if (err2 /= 0) ierr = ierr + 1
1383 message(1) =
"Debug: Reading density restart done."
1391 class(
space_t),
intent(in) :: space
1393 class(
mesh_t),
intent(in) :: mesh
1394 integer,
intent(out) :: ierr
1396 integer :: isp, err, err2(2), idir
1397 character(len=MAX_PATH_LEN) :: filename
1403 assert(
allocated(st%frozen_rho))
1405 if (restart%skip())
then
1410 message(1) =
"Debug: Writing frozen densities restart."
1416 do isp = 1, st%d%nspin
1419 call restart%write_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1420 if (err /= 0) err2(2) = err2(2) + 1
1422 if (
allocated(st%frozen_tau))
then
1424 call restart%write_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1425 if (err /= 0) err2 = err2 + 1
1428 if (
allocated(st%frozen_gdens))
then
1429 do idir = 1, space%dim
1430 if (st%d%nspin == 1)
then
1431 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1433 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1435 call restart%write_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1436 if (err /= 0) err2 = err2 + 1
1440 if (
allocated(st%frozen_ldens))
then
1442 call restart%write_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1443 if (err /= 0) err2 = err2 + 1
1447 if (err2(1) /= 0) ierr = ierr + 2
1448 if (err2(2) /= 0) ierr = ierr + 4
1452 message(1) =
"Debug: Writing frozen densities restart done."
1462 class(
space_t),
intent(in) :: space
1464 class(
mesh_t),
intent(in) :: mesh
1465 integer,
intent(out) :: ierr
1467 integer :: err, err2, isp, idir
1468 character(len=MAX_PATH_LEN) :: filename
1472 assert(
allocated(st%frozen_rho))
1476 if (restart%skip())
then
1482 message(1) =
"Debug: Reading densities restart."
1486 do isp = 1, st%d%nspin
1488 call restart%read_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1489 if (err /= 0) err2 = err2 + 1
1491 if (
allocated(st%frozen_tau))
then
1493 call restart%read_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1494 if (err /= 0) err2 = err2 + 1
1497 if (
allocated(st%frozen_gdens))
then
1498 do idir = 1, space%dim
1499 if (st%d%nspin == 1)
then
1500 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1502 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1504 call restart%read_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1505 if (err /= 0) err2 = err2 + 1
1509 if (
allocated(st%frozen_ldens))
then
1511 call restart%read_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1512 if (err /= 0) err2 = err2 + 1
1516 if (err2 /= 0) ierr = ierr + 1
1518 message(1) =
"Debug: Reading frozen densities restart done."
1529 class(
mesh_t),
intent(in) :: mesh
1531 class(
space_t),
intent(in) :: space
1535 integer :: ip, id, is, ik, nstates, state_from, ierr, ncols
1536 integer :: ib, idim, inst, inik, normalize
1537 real(real64) :: xx(space%dim), rr, psi_re, psi_im
1538 character(len=150) :: filename
1539 complex(real64),
allocatable :: zpsi(:, :)
1541 integer,
parameter :: &
1542 state_from_formula = 1, &
1543 state_from_file = -10010, &
1544 normalize_yes = 1, &
1627 if (
parse_block(namespace,
'UserDefinedStates', blk) == 0)
then
1634 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
1640 if (ncols < 5 .or. ncols > 6)
then
1641 message(1) =
'Each line in the UserDefinedStates block must have'
1642 message(2) =
'five or six columns.'
1658 if (.not.(id == idim .and. is == inst .and. ik == inik )) cycle
1664 select case (state_from)
1665 case (state_from_formula)
1668 blk, ib - 1, 4, st%user_def_states(id, is, ik))
1670 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1671 write(
message(2),
'(2a)')
' with the expression:'
1672 write(
message(3),
'(2a)')
' ',trim(st%user_def_states(id, is, ik))
1678 case (state_from_file)
1684 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1685 write(
message(2),
'(2a)')
' with data from file:'
1686 write(
message(3),
'(2a)')
' ',trim(filename)
1692 if (.not.(st%st_start <= is .and. st%st_end >= is &
1693 .and. st%d%kpt%start <= ik .and. st%d%kpt%end >= ik)) cycle
1695 select case (state_from)
1697 case (state_from_formula)
1706 zpsi(ip, 1) = cmplx(psi_re, psi_im, real64)
1709 case (state_from_file)
1713 message(1) =
'Could not read the file!'
1714 write(
message(2),
'(a,i1)')
'Error code: ', ierr
1719 message(1) =
'Wrong entry in UserDefinedStates, column 4.'
1720 message(2) =
'You may state "formula" or "file" here.'
1730 select case (normalize)
1733 case (normalize_yes)
1734 assert(st%d%dim == 1)
1738 message(1) =
'The sixth column in UserDefinedStates may either be'
1739 message(2) =
'"normalize_yes" or "normalize_no"'
1749 safe_deallocate_a(zpsi)
1767 integer,
intent(out) :: ierr
1769 integer :: iunit_spin
1770 integer :: err, err2(2), ik, ist
1771 character(len=300) :: lines(3)
1777 if (restart%skip())
then
1786 iunit_spin = restart%open(
'spin')
1787 lines(1) =
'# #k-point #st #spin(x) spin(y) spin(z)'
1788 call restart%write(iunit_spin, lines, 1, err)
1789 if (err /= 0) ierr = ierr + 1
1794 write(lines(1),
'(i8,a,i8,3(a,f18.12))') ik,
' | ', ist,
' | ', &
1795 st%spin(1,ist,ik),
' | ', st%spin(2,ist,ik),
' | ', st%spin(3,ist,ik)
1796 call restart%write(iunit_spin, lines, 1, err)
1797 if (err /= 0) err2(1) = err2(1) + 1
1801 call restart%write(iunit_spin, lines, 1, err)
1802 if (err2(1) /= 0) ierr = ierr + 8
1803 if (err2(2) /= 0) ierr = ierr + 16
1805 call restart%close(iunit_spin)
1824 integer,
intent(out) :: ierr
1826 integer :: spin_file, err, ik, ist
1827 character(len=256) :: lines(3)
1828 real(real64) :: spin(3)
1829 character(len=1) :: char
1836 if (restart%skip())
then
1845 spin_file = restart%open(
'spin')
1847 call restart%read(spin_file, lines, 1, err)
1848 if (err /= 0) ierr = ierr - 2**7
1853 call restart%close(spin_file)
1863 call restart%read(spin_file, lines, 1, err)
1866 read(lines(1),
'(a)') char
1867 if (char ==
'%')
then
1871 read(lines(1), *) ik, char, ist, char, spin(1), char, spin(2), char, spin(3)
1874 st%spin(1:3, ist, ik) = spin(1:3)
1877 call restart%close(spin_file)
1887 class(
space_t),
intent(in) :: space
1888 type(
restart_t),
intent(inout) :: restart
1889 class(
mesh_t),
intent(in) :: mesh
1891 character(len=*),
optional,
intent(in) :: prefix
1895 complex(real64),
allocatable :: rotation_matrix(:,:), psi(:, :)
1896 integer :: ist, jst, ncols, iqn
1897 character(len=256) :: block_name
1930 if (
parse_block(namespace, trim(block_name), blk) == 0)
then
1931 if (st%parallel_in_states)
then
1935 message(1) =
"Number of rows in block " // trim(block_name) //
" must equal number of states in this calculation."
1942 safe_allocate(rotation_matrix(1:stin%nst, 1:stin%nst))
1943 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
1949 if (ncols /= stin%nst)
then
1950 write(
message(1),
'(a,i6,a,i6,3a,i6,a)')
"Number of columns (", ncols,
") in row ", ist,
" of block ", &
1951 trim(block_name),
" must equal number of states (", stin%nst,
") read from gs restart."
1954 do jst = 1, stin%nst
1961 do iqn = st%d%kpt%start, st%d%kpt%end
1968 do ist = st%st_start, st%st_end
1975 safe_deallocate_a(rotation_matrix)
1976 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, fixed_occ, 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_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, 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_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, verbose)
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), parameter, public type_cmplx
type(type_t), parameter, public type_float
logical function index_is_wrong()
Describes mesh distribution to nodes.
The states_elec_t class contains all electronic wave functions.
batches of electronic states