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, type_requested, type_file, &
1010 filled, restart_file_present, iread, skip, lowest_missing)
1012 call states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1013 nst_max, filled, iread)
1016 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1017 call adios2_inquire_variable(var_indices, io,
'global_indices', ierr)
1018 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none, &
1019 "Problem loading ADIOS2 variable (global_indices).")
1020 safe_allocate(global_indices(mesh%np))
1021 call adios2_set_selection(var_indices, 1, &
1022 [int(mesh%pv%xlocal-1, int64)], &
1023 [int(mesh%np, int64)], ierr)
1024 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection (global_indices).")
1025 call adios2_get(engine, var_indices, global_indices, ierr)
1026 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (global_indices).")
1028 call adios2_end_step(engine, ierr)
1029 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 end_step.")
1030 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1031 do ik = st%d%kpt%start, st%d%kpt%end
1032 do ib = st%group%block_start, st%group%block_end
1040 safe_deallocate_a(global_indices)
1044 call adios2_close(engine, ierr)
1045 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
1046 call adios2_finalize(adios, ierr)
1047 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
1059 subroutine states_elec_adios2_read_state_by_state(st, mesh, engine, var, type_requested, type_file, &
1060 filled, restart_file_present, iread, skip, lowest_missing)
1062 class(
mesh_t),
intent(in) :: mesh
1063 type(adios2_engine),
intent(inout) :: engine
1064 type(adios2_variable),
intent(inout) :: var
1065 integer,
intent(in) :: type_requested
1066 integer,
intent(in) :: type_file
1067 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1068 logical,
intent(in) :: restart_file_present(:, :, :)
1069 integer,
intent(inout) :: iread
1070 logical,
optional,
intent(in) :: skip(:)
1071 integer,
optional,
intent(inout) :: lowest_missing(:, :)
1073 integer :: ik, ist, idim, ierr
1074 real(real64),
allocatable :: dpsi(:)
1075 complex(real64),
allocatable :: zpsi(:)
1077 push_sub(states_elec_adios2_read_state_by_state)
1079 if (type_requested == adios2_type_dp .and. type_file == adios2_type_complex_dp)
then
1080 message(1) =
"Error: calculation requested real states for restarting, but restart file has complex states."
1084 do ik = st%d%kpt%start, st%d%kpt%end
1087 if (type_file == adios2_type_dp)
then
1088 safe_allocate(dpsi(1:mesh%np))
1090 safe_allocate(zpsi(1:mesh%np))
1092 do ist = st%st_start, st%st_end
1093 if (
present(skip))
then
1094 if (skip(ist)) cycle
1097 do idim = 1, st%d%dim
1098 if (.not. restart_file_present(idim, ist, ik))
then
1099 if (
present(lowest_missing))
then
1100 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
1106 call adios2_set_selection(var, 3, &
1107 [int((ist-1)*st%d%dim+idim-1, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1108 [1_int64, int(mesh%np, int64), 1_int64], ierr)
1110 if (type_file == adios2_type_dp)
then
1111 call adios2_get(engine, var, dpsi, adios2_mode_sync, ierr)
1112 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get dpsi.")
1113 if (type_requested == adios2_type_complex_dp)
then
1120 call adios2_get(engine, var, zpsi, adios2_mode_sync, ierr)
1121 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get zpsi.")
1125 filled(idim, ist, ik) = .
true.
1129 safe_deallocate_a(dpsi)
1130 safe_deallocate_a(zpsi)
1133 pop_sub(states_elec_adios2_read_state_by_state)
1134 end subroutine states_elec_adios2_read_state_by_state
1138 subroutine states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1139 nst_max, filled, iread)
1141 class(
mesh_t),
intent(in) :: mesh
1142 type(adios2_engine),
intent(inout) :: engine
1143 type(adios2_variable),
intent(inout) :: var
1144 integer(int64),
intent(in) :: var_shape(:)
1145 integer,
intent(in) :: type_requested
1146 integer,
intent(in) :: type_file
1147 integer,
intent(in) :: nst_max
1148 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1149 integer,
intent(inout) :: iread
1151 integer :: ib, ik, ist, ip, adios2_mode, nst_linear, ierr
1153 real(real64),
allocatable :: dff_pack(:, :)
1155 push_sub(states_elec_adios2_read_batch_by_batch)
1157 do ik = st%d%kpt%start, st%d%kpt%end
1160 if (ik > var_shape(3)) cycle
1161 do ib = st%group%block_start, st%group%block_end
1162 select case (st%group%psib(ib, ik)%status())
1165 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.false.)
1167 adios2_mode = adios2_mode_sync
1169 psib => st%group%psib(ib, ik)
1173 adios2_mode = adios2_mode_sync
1176 call st%group%psib(ib, ik)%copy_to(psib)
1177 call psib%do_unpack(force=.
true., copy=.false.)
1180 adios2_mode = adios2_mode_sync
1185 nst_linear = st%group%psib(ib, ik)%nst_linear
1189 if (nst_linear <= 0)
then
1190 select case (st%group%psib(ib, ik)%status())
1193 safe_deallocate_p(psib)
1198 safe_deallocate_p(psib)
1206 call adios2_set_selection(var, 3, &
1207 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1208 [int(nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
1209 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection.")
1211 if (type_requested == adios2_type_dp .and. type_file == adios2_type_dp)
then
1213 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1214 [int(
size(psib%dff_pack, 1), int64), &
1215 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
1216 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading real).")
1218 call adios2_get(engine, var, psib%dff_pack, adios2_mode, ierr)
1219 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading real).")
1220 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_complex_dp)
then
1222 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1223 [int(
size(psib%zff_pack, 1), int64), &
1224 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1225 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex).")
1227 call adios2_get(engine, var, psib%zff_pack, adios2_mode, ierr)
1228 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex).")
1229 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_dp)
then
1231 safe_allocate(dff_pack(
size(psib%zff_pack, 1),
size(psib%zff_pack, 2)))
1233 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1234 [int(
size(psib%zff_pack, 1), int64), &
1235 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1236 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex from real).")
1239 call adios2_get(engine, var, dff_pack, adios2_mode_sync, ierr)
1240 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex from real).")
1244 do ist = 1, nst_linear
1245 psib%zff_pack(ist, ip) = cmplx(dff_pack(ist, ip),
m_zero, real64)
1248 safe_deallocate_a(dff_pack)
1250 message(1) =
"Error: requested to read complex states for restarting, but calculation has real states."
1254 iread = iread + nst_linear
1255 do ist = 1, nst_linear
1256 filled(st%group%psib(ib, ik)%linear_to_idim(ist), st%group%psib(ib, ik)%linear_to_ist(ist), ik) = .
true.
1259 select case (st%group%psib(ib, ik)%status())
1261 call psib%do_unpack()
1262 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1264 safe_deallocate_p(psib)
1269 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1271 safe_deallocate_p(psib)
1276 pop_sub(states_elec_adios2_read_batch_by_batch)
1277 end subroutine states_elec_adios2_read_batch_by_batch
1281 subroutine check_error(condition, error_message)
1282 logical,
intent(in) :: condition
1283 character(len=*),
intent(in) :: error_message
1288 end subroutine check_error
1294 class(
mesh_t),
intent(in) :: mesh
1295 integer,
intent(out) :: ierr
1296 integer,
optional,
intent(in) :: iter
1298 integer :: iunit, isp, err, err2(2)
1299 character(len=MAX_PATH_LEN) :: filename
1300 character(len=300) :: lines(2)
1306 if (restart%skip())
then
1311 message(1) =
"Debug: Writing density restart."
1317 iunit = restart%open(
'density')
1318 lines(1) =
'# #spin #nspin filename'
1319 lines(2) =
'%densities'
1320 call restart%write(iunit, lines, 2, err)
1321 if (err /= 0) ierr = ierr + 1
1324 do isp = 1, st%d%nspin
1326 write(lines(1),
'(i8,a,i8,a)') isp,
' | ', st%d%nspin,
' | "'//trim(adjustl(filename))//
'"'
1327 call restart%write(iunit, lines, 1, err)
1328 if (err /= 0) err2(1) = err2(1) + 1
1330 call restart%write_mesh_function(filename, mesh, st%rho(:,isp), err)
1331 if (err /= 0) err2(2) = err2(2) + 1
1334 if (err2(1) /= 0) ierr = ierr + 2
1335 if (err2(2) /= 0) ierr = ierr + 4
1338 call restart%write(iunit, lines, 1, err)
1339 if (err /= 0) ierr = ierr + 8
1340 if (
present(iter))
then
1341 write(lines(1),
'(a,i7)')
'Iter = ', iter
1342 call restart%write(iunit, lines, 1, err)
1343 if (err /= 0) ierr = ierr + 16
1345 call restart%close(iunit)
1349 message(1) =
"Debug: Writing density restart done."
1360 class(
mesh_t),
intent(in) :: mesh
1361 integer,
intent(out) :: ierr
1363 integer :: err, err2, isp
1364 character(len=MAX_PATH_LEN) :: filename
1370 if (restart%skip())
then
1376 message(1) =
"Debug: Reading density restart."
1387 do isp = 1, st%d%nspin
1392 call restart%read_mesh_function(filename, mesh, st%rho(:,isp), err)
1393 if (err /= 0) err2 = err2 + 1
1396 if (err2 /= 0) ierr = ierr + 1
1398 message(1) =
"Debug: Reading density restart done."
1406 class(
space_t),
intent(in) :: space
1408 class(
mesh_t),
intent(in) :: mesh
1409 integer,
intent(out) :: ierr
1411 integer :: isp, err, err2(2), idir
1412 character(len=MAX_PATH_LEN) :: filename
1418 assert(
allocated(st%frozen_rho))
1420 if (restart%skip())
then
1425 message(1) =
"Debug: Writing frozen densities restart."
1431 do isp = 1, st%d%nspin
1434 call restart%write_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1435 if (err /= 0) err2(2) = err2(2) + 1
1437 if (
allocated(st%frozen_tau))
then
1439 call restart%write_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1440 if (err /= 0) err2 = err2 + 1
1443 if (
allocated(st%frozen_gdens))
then
1444 do idir = 1, space%dim
1445 if (st%d%nspin == 1)
then
1446 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1448 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1450 call restart%write_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1451 if (err /= 0) err2 = err2 + 1
1455 if (
allocated(st%frozen_ldens))
then
1457 call restart%write_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1458 if (err /= 0) err2 = err2 + 1
1462 if (err2(1) /= 0) ierr = ierr + 2
1463 if (err2(2) /= 0) ierr = ierr + 4
1467 message(1) =
"Debug: Writing frozen densities restart done."
1477 class(
space_t),
intent(in) :: space
1479 class(
mesh_t),
intent(in) :: mesh
1480 integer,
intent(out) :: ierr
1482 integer :: err, err2, isp, idir
1483 character(len=MAX_PATH_LEN) :: filename
1487 assert(
allocated(st%frozen_rho))
1491 if (restart%skip())
then
1497 message(1) =
"Debug: Reading densities restart."
1501 do isp = 1, st%d%nspin
1503 call restart%read_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1504 if (err /= 0) err2 = err2 + 1
1506 if (
allocated(st%frozen_tau))
then
1508 call restart%read_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1509 if (err /= 0) err2 = err2 + 1
1512 if (
allocated(st%frozen_gdens))
then
1513 do idir = 1, space%dim
1514 if (st%d%nspin == 1)
then
1515 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1517 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1519 call restart%read_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1520 if (err /= 0) err2 = err2 + 1
1524 if (
allocated(st%frozen_ldens))
then
1526 call restart%read_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1527 if (err /= 0) err2 = err2 + 1
1531 if (err2 /= 0) ierr = ierr + 1
1533 message(1) =
"Debug: Reading frozen densities restart done."
1546 class(
space_t),
intent(in) :: space
1550 integer :: ip, id, is, ik, nstates, state_from, ierr, ncols
1551 integer :: ib, idim, inst, inik, normalize
1552 real(real64) :: xx(space%dim), rr, psi_re, psi_im
1553 character(len=150) :: filename
1554 complex(real64),
allocatable :: zpsi(:, :)
1556 integer,
parameter :: &
1557 state_from_formula = 1, &
1558 state_from_file = -10010, &
1559 normalize_yes = 1, &
1642 if (
parse_block(namespace,
'UserDefinedStates', blk) == 0)
then
1649 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
1655 if (ncols < 5 .or. ncols > 6)
then
1656 message(1) =
'Each line in the UserDefinedStates block must have'
1657 message(2) =
'five or six columns.'
1673 if (.not.(id == idim .and. is == inst .and. ik == inik )) cycle
1679 select case (state_from)
1680 case (state_from_formula)
1683 blk, ib - 1, 4, st%user_def_states(id, is, ik))
1685 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1686 write(
message(2),
'(2a)')
' with the expression:'
1687 write(
message(3),
'(2a)')
' ',trim(st%user_def_states(id, is, ik))
1693 case (state_from_file)
1699 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1700 write(
message(2),
'(2a)')
' with data from file:'
1701 write(
message(3),
'(2a)')
' ',trim(filename)
1707 if (.not.(st%st_start <= is .and. st%st_end >= is &
1708 .and. st%d%kpt%start <= ik .and. st%d%kpt%end >= ik)) cycle
1710 select case (state_from)
1712 case (state_from_formula)
1721 zpsi(ip, 1) = cmplx(psi_re, psi_im, real64)
1724 case (state_from_file)
1728 message(1) =
'Could not read the file!'
1729 write(
message(2),
'(a,i1)')
'Error code: ', ierr
1734 message(1) =
'Wrong entry in UserDefinedStates, column 4.'
1735 message(2) =
'You may state "formula" or "file" here.'
1745 select case (normalize)
1748 case (normalize_yes)
1749 assert(st%d%dim == 1)
1753 message(1) =
'The sixth column in UserDefinedStates may either be'
1754 message(2) =
'"normalize_yes" or "normalize_no"'
1764 safe_deallocate_a(zpsi)
1782 integer,
intent(out) :: ierr
1784 integer :: iunit_spin
1785 integer :: err, err2(2), ik, ist
1786 character(len=300) :: lines(3)
1792 if (restart%skip())
then
1801 iunit_spin = restart%open(
'spin')
1802 lines(1) =
'# #k-point #st #spin(x) spin(y) spin(z)'
1803 call restart%write(iunit_spin, lines, 1, err)
1804 if (err /= 0) ierr = ierr + 1
1809 write(lines(1),
'(i8,a,i8,3(a,f18.12))') ik,
' | ', ist,
' | ', &
1810 st%spin(1,ist,ik),
' | ', st%spin(2,ist,ik),
' | ', st%spin(3,ist,ik)
1811 call restart%write(iunit_spin, lines, 1, err)
1812 if (err /= 0) err2(1) = err2(1) + 1
1816 call restart%write(iunit_spin, lines, 1, err)
1817 if (err2(1) /= 0) ierr = ierr + 8
1818 if (err2(2) /= 0) ierr = ierr + 16
1820 call restart%close(iunit_spin)
1839 integer,
intent(out) :: ierr
1841 integer :: spin_file, err, ik, ist
1842 character(len=256) :: lines(3)
1843 real(real64) :: spin(3)
1844 character(len=1) :: char
1851 if (restart%skip())
then
1860 spin_file = restart%open(
'spin')
1862 call restart%read(spin_file, lines, 1, err)
1863 if (err /= 0) ierr = ierr - 2**7
1868 call restart%close(spin_file)
1878 call restart%read(spin_file, lines, 1, err)
1881 read(lines(1),
'(a)') char
1882 if (char ==
'%')
then
1886 read(lines(1), *) ik, char, ist, char, spin(1), char, spin(2), char, spin(3)
1889 st%spin(1:3, ist, ik) = spin(1:3)
1892 call restart%close(spin_file)
1902 class(
space_t),
intent(in) :: space
1903 type(
restart_t),
intent(inout) :: restart
1904 class(
mesh_t),
intent(in) :: mesh
1906 character(len=*),
optional,
intent(in) :: prefix
1910 complex(real64),
allocatable :: rotation_matrix(:,:), psi(:, :)
1911 integer :: ist, jst, ncols, iqn
1912 character(len=256) :: block_name
1945 if (
parse_block(namespace, trim(block_name), blk) == 0)
then
1946 if (st%parallel_in_states)
then
1950 message(1) =
"Number of rows in block " // trim(block_name) //
" must equal number of states in this calculation."
1957 safe_allocate(rotation_matrix(1:stin%nst, 1:stin%nst))
1958 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
1964 if (ncols /= stin%nst)
then
1965 write(
message(1),
'(a,i6,a,i6,3a,i6,a)')
"Number of columns (", ncols,
") in row ", ist,
" of block ", &
1966 trim(block_name),
" must equal number of states (", stin%nst,
") read from gs restart."
1969 do jst = 1, stin%nst
1976 do iqn = st%d%kpt%start, st%d%kpt%end
1983 do ist = st%st_start, st%st_end
1990 safe_deallocate_a(rotation_matrix)
1991 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