34 use,
intrinsic :: iso_fortran_env
83 type(restart_t),
intent(in) :: restart
84 type(namespace_t),
intent(in) :: namespace
85 class(space_t),
intent(in) :: space
86 type(states_elec_t),
target,
intent(inout) :: st
87 class(mesh_t),
intent(in) :: mesh
88 type(kpoints_t),
intent(in) :: kpoints
89 logical,
intent(in) :: fixed_occ
90 logical,
optional,
intent(in) :: is_complex
91 logical,
optional,
intent(in) :: packed
93 integer :: nkpt, dim, nst, ierr
94 real(real64),
allocatable :: new_occ(:,:)
101 message(1) =
"Unable to read states information."
105 if (st%parallel_in_states)
then
106 message(1) =
"Internal error: cannot use states_elec_look_and_load when parallel in states."
111 allocate(new_occ(1:nst, 1:st%nik))
113 new_occ(1:min(nst, st%nst),:) = st%occ(1:min(nst, st%nst),:)
114 safe_deallocate_a(st%occ)
115 call move_alloc(new_occ, st%occ)
125 safe_deallocate_a(st%node)
126 safe_allocate(st%node(1:st%nst))
129 safe_deallocate_a(st%eigenval)
130 safe_allocate(st%eigenval(1:st%nst, 1:st%nik))
131 st%eigenval = huge(st%eigenval)
133 if (
present(is_complex))
then
144 if (st%d%ispin ==
spinors)
then
145 safe_allocate(st%spin(1:3, 1:st%nst, 1:st%nik))
150 call states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr)
152 message(1) =
"Unable to read wavefunctions."
161 subroutine states_elec_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, verbose)
163 class(
space_t),
intent(in) :: space
165 class(
mesh_t),
intent(in) :: mesh
167 integer,
intent(out) :: ierr
168 integer,
optional,
intent(in) :: iter
169 type(
lr_t),
optional,
intent(in) :: lr
170 logical,
optional,
intent(in) :: verbose
172 integer :: iunit_wfns, iunit_occs, iunit_states
173 integer :: err, err2(2), ik, idir, ist, idim, itot
175 character(len=MAX_PATH_LEN) :: filename
176 character(len=500) :: lines(3)
177 logical :: lr_wfns_are_associated, should_write, verbose_
178 real(real64) :: kpoint(space%dim)
179 real(real64),
allocatable :: dpsi(:)
180 complex(real64),
allocatable :: zpsi(:)
181 integer :: restart_file_format
189 if (restart%skip())
then
195 message(1) =
"Info: Writing states."
201 restart_file_format = restart%file_format_states
202 if (
present(lr))
then
203 lr_wfns_are_associated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
205 assert(lr_wfns_are_associated)
207 restart_file_format = option__restartfileformatstates__obf
212 iunit_states = restart%open(
'states')
213 write(lines(1),
'(a20,1i10)')
'nst= ', st%nst
214 write(lines(2),
'(a20,1i10)')
'dim= ', st%d%dim
215 write(lines(3),
'(a20,1i10)')
'nik= ', st%nik
216 call restart%write(iunit_states, lines, 3, err)
217 if (err /= 0) ierr = ierr + 1
218 call restart%close(iunit_states)
221 iunit_wfns = restart%open(
'wfns')
222 lines(1) =
'# #k-point #st #dim filename'
224 lines(2) =
'%Real_Wavefunctions'
226 lines(2) =
'%Complex_Wavefunctions'
228 call restart%write(iunit_wfns, lines, 2, err)
229 if (err /= 0) ierr = ierr + 2
232 iunit_occs = restart%open(
'occs')
233 lines(1) =
'# occupations | eigenvalue[a.u.] | Im(eigenvalue) [a.u.] | k-points | k-weights | filename | ik | ist | idim'
234 lines(2) =
'%Occupations_Eigenvalues_K-Points'
235 call restart%write(iunit_occs, lines, 2, err)
236 if (err /= 0) ierr = ierr + 4
240 safe_allocate(dpsi(1:mesh%np))
242 safe_allocate(zpsi(1:mesh%np))
249 kpoint(1:space%dim) = &
250 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
253 do idim = 1, st%d%dim
255 write(filename,
'(i10.10)') itot
257 write(lines(1),
'(i8,a,i8,a,i8,3a)') ik,
' | ', ist,
' | ', idim,
' | "', trim(filename),
'"'
258 call restart%write(iunit_wfns, lines, 1, err)
259 if (err /= 0) err2(1) = err2(1) + 1
261 write(lines(1),
'(e23.16,a,e23.16)') st%occ(ist,ik),
' | ', st%eigenval(ist, ik)
262 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ',
m_zero
263 do idir = 1, space%dim
264 write(lines(1),
'(a,a,e23.16)') trim(lines(1)),
' | ', kpoint(idir)
266 write(lines(1),
'(a,a,e23.16,a,i10.10,3(a,i8))') trim(lines(1)), &
267 ' | ', st%kweights(ik),
' | ', itot,
' | ', ik,
' | ', ist,
' | ', idim
268 call restart%write(iunit_occs, lines, 1, err)
269 if (err /= 0) err2(1) = err2(1) + 1
271 should_write = st%st_start <= ist .and. ist <= st%st_end
273 if (restart_file_format == option__restartfileformatstates__obf)
then
274 if (should_write)
then
275 if (st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
277 if (.not.
present(lr))
then
279 call restart%write_mesh_function(filename, mesh, dpsi, err, root = root)
281 call restart%write_mesh_function(filename, mesh, &
282 lr%ddl_psi(:, idim, ist, ik), err, root = root)
285 if (.not.
present(lr))
then
287 call restart%write_mesh_function(filename, mesh, zpsi, err, root = root)
289 call restart%write_mesh_function(filename, mesh, &
290 lr%zdl_psi(:, idim, ist, ik), err, root = root)
297 if (err /= 0) err2(2) = err2(2) + 1
304 if (err2(1) /= 0) ierr = ierr + 8
305 if (err2(2) /= 0) ierr = ierr + 16
307 safe_deallocate_a(dpsi)
308 safe_deallocate_a(zpsi)
310 if (restart_file_format == option__restartfileformatstates__adios2)
then
311 if (
present(lr))
then
319 call restart%write(iunit_occs, lines, 1, err)
320 if (err /= 0) ierr = ierr + 32
321 call restart%write(iunit_wfns, lines, 1, err)
322 if (err /= 0) ierr = ierr + 64
323 if (
present(iter))
then
324 write(lines(1),
'(a,i7)')
'Iter = ', iter
325 call restart%write(iunit_wfns, lines, 1, err)
326 if (err /= 0) ierr = ierr + 128
329 call restart%close(iunit_wfns)
330 call restart%close(iunit_occs)
333 message(1) =
"Info: Finished writing states."
347 class(
mesh_t),
intent(in) :: mesh
348 integer,
intent(out) :: ierr
351 type(adios2_adios) :: adios
352 type(adios2_io) :: io
353 type(adios2_variable) :: var, var_indices
354 type(adios2_attribute) :: attribute
355 type(adios2_engine) :: engine
356 integer :: adios2_type, ik, ib, ip, adios2_mode
357 integer(int64),
allocatable :: global_indices(:)
364 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
366 call adios2_init(adios, ierr)
368 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
369 call adios2_declare_io(io, adios,
"writer", ierr)
370 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
372 call adios2_set_parameter(io,
"StatsLevel",
"0", ierr)
373 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 parameter.")
375 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_write, ierr)
376 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
378 adios2_type = adios2_type_dp
380 adios2_type = adios2_type_complex_dp
383 call adios2_define_variable(var, io,
"wavefunctions", adios2_type, 3, &
384 [int(st%nst * st%d%dim, int64), int(mesh%np_global, int64), int(st%nik, int64)], &
385 [0_int64, 0_int64, 0_int64], &
386 [1_int64, 1_int64, 1_int64], &
387 adios2_variable_dims, ierr)
388 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (wavefunctions).")
390 call adios2_define_attribute(attribute, io,
"ParDomains", mesh%mpi_grp%size, ierr)
391 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 attribute (ParDomains).")
393 call adios2_define_variable(var_indices, io,
"global_indices", adios2_type_integer8, 1, &
394 [int(mesh%np_global, int64)], &
395 [int(mesh%pv%xlocal-1, int64)], &
396 [int(mesh%np, int64)], &
397 adios2_variable_dims, ierr)
398 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none,
"Problem creating ADIOS2 variable (global_indices).")
400 safe_allocate(global_indices(mesh%np))
405 call adios2_begin_step(engine, ierr)
406 call adios2_put(engine, var_indices, global_indices, ierr)
408 do ik = st%d%kpt%start, st%d%kpt%end
409 do ib = st%group%block_start, st%group%block_end
411 select case (st%group%psib(ib, ik)%status())
414 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.
true.)
418 adios2_mode = adios2_mode_sync
420 psib => st%group%psib(ib, ik)
421 adios2_mode = adios2_mode_deferred
424 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.
true.)
426 call psib%do_unpack(force=.
true.)
430 adios2_mode = adios2_mode_sync
437 call adios2_set_selection(var, 3, &
438 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
439 [int(st%group%psib(ib, ik)%nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
442 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
443 [int(
size(psib%dff_pack, 1), int64), &
444 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
445 call adios2_put(engine, var, psib%dff_pack, adios2_mode, ierr)
447 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
448 [int(
size(psib%zff_pack, 1), int64), &
449 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
450 call adios2_put(engine, var, psib%zff_pack, adios2_mode, ierr)
452 select case (st%group%psib(ib, ik)%status())
455 safe_deallocate_p(psib)
461 call adios2_end_step(engine, ierr)
464 safe_deallocate_a(global_indices)
467 call adios2_close(engine, ierr)
468 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
469 call adios2_finalize(adios, ierr)
470 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
485 subroutine states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, &
486 ierr, iter, lr, lowest_missing, label, verbose, skip)
489 class(
space_t),
intent(in) :: space
491 class(
mesh_t),
intent(in) :: mesh
493 logical,
intent(in) :: fixed_occ
494 integer,
intent(out) :: ierr
495 integer,
optional,
intent(out) :: iter
496 type(
lr_t),
optional,
intent(inout) :: lr
497 integer,
contiguous,
optional,
intent(out) :: lowest_missing(:, :)
498 character(len=*),
optional,
intent(in) :: label
499 logical,
optional,
intent(in) :: verbose
500 logical,
contiguous,
optional,
intent(in) :: skip(:)
502 integer :: states_elec_file, wfns_file, occ_file, err, ik, ist, idir, idim
503 integer :: idone, iread, ntodo
504 character(len=12) :: filename
505 character(len=1) :: char
506 logical,
allocatable :: filled(:, :, :)
507 character(len=256) :: lines(3), label_
508 character(len=50) :: str
510 real(real64) :: my_occ, imev, my_kweight
511 logical :: read_occ, lr_allocated, verbose_
512 logical :: integral_occs
513 real(real64),
allocatable :: dpsi(:)
514 complex(real64),
allocatable :: zpsi(:)
515 character(len=256),
allocatable :: restart_file(:, :, :)
516 logical,
allocatable :: restart_file_present(:, :, :)
517 real(real64) :: kpoint(space%dim), read_kpoint(space%dim)
520 integer,
allocatable :: lowest_missing_tmp(:, :)
521 integer :: restart_file_format
528 if (
present(lowest_missing)) lowest_missing = 1
529 if (
present(iter)) iter = 0
531 if (
present(skip))
then
532 assert(ubound(skip, dim = 1) == st%nst)
535 if (restart%skip())
then
545 if (
present(label))
then
548 if (
present(lr))
then
549 label_ =
" for linear response"
555 message(1) =
'Info: Reading states'
556 if (len(trim(label_)) > 0)
then
562 if (.not.
present(lr))
then
563 st%fromScratch = .false.
569 integral_occs = .
true.
572 st%fixed_occ = .
true.
574 read_occ = .not. st%fixed_occ
577 if (.not.
present(lr))
then
578 st%eigenval(:, :) =
m_zero
582 if (.not.
present(lr) .and. read_occ)
then
587 restart_file_format = restart%file_format_states
589 if (
present(lr))
then
590 lr_allocated = (
allocated(lr%ddl_psi) .and.
states_are_real(st)) .or. &
594 restart_file_format = option__restartfileformatstates__obf
597 states_elec_file = restart%open(
'states')
602 call restart%read(states_elec_file, lines, 3, err)
606 read(lines(2), *) str, idim
607 read(lines(3), *) str, ik
608 if (idim == 2 .and. st%d%dim == 1)
then
609 write(
message(1),
'(a)')
'Incompatible restart information: saved calculation is spinors, this one is not.'
613 if (idim == 1 .and. st%d%dim == 2)
then
614 write(
message(1),
'(a)')
'Incompatible restart information: this calculation is spinors, saved one is not.'
618 if (ik < st%nik)
then
619 write(
message(1),
'(a)')
'Incompatible restart information: not enough k-points.'
620 write(
message(2),
'(2(a,i6))')
'Expected ', st%nik,
' > Read ', ik
625 call restart%close(states_elec_file)
629 wfns_file = restart%open(
'wfns')
630 occ_file = restart%open(
'occs')
631 call restart%read(wfns_file, lines, 2, err)
635 read(lines(2),
'(a)') str
636 if (str(2:8) ==
'Complex')
then
637 message(1) =
"Cannot read real states from complex wavefunctions."
640 else if (str(2:5) /=
'Real')
then
641 message(1) =
"Restart file 'wfns' does not specify real/complex; cannot check compatibility."
648 call restart%read(occ_file, lines, 2, err)
649 if (err /= 0) ierr = ierr - 2**7
654 call restart%close(wfns_file)
655 call restart%close(occ_file)
662 safe_allocate(dpsi(1:mesh%np))
664 safe_allocate(zpsi(1:mesh%np))
667 safe_allocate(restart_file(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
668 safe_allocate(restart_file_present(1:st%d%dim, st%st_start:st%st_end, 1:st%nik))
669 restart_file_present = .false.
675 call restart%read(wfns_file, lines, 1, err)
677 read(lines(1),
'(a)') char
678 if (char ==
'%')
then
682 read(lines(1), *) ik, char, ist, char, idim, char, filename
687 call restart%read(occ_file, lines, 1, err)
691 if (ist >= st%st_start .and. ist <= st%st_end .and. &
692 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
694 restart_file(idim, ist, ik) = trim(filename)
695 restart_file_present(idim, ist, ik) = .
true.
698 call restart%read(occ_file, lines, 1, err)
699 if (.not.
present(lr))
then
703 read(lines(1), *) my_occ, char, st%eigenval(ist, ik), char, imev, char, &
704 (read_kpoint(idir), char, idir = 1, space%dim), my_kweight
708 if (ist >= st%st_start .and. ist <= st%st_end .and. &
709 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
710 restart_file_present(idim, ist, ik) = .false.
715 kpoint(1:space%dim) = &
716 kpoints%get_point(st%d%get_kpoint_index(ik), absolute_coordinates = .
true.)
718 if (any(abs(kpoint(1:space%dim) - read_kpoint(1:space%dim)) > 1e-12_real64))
then
721 write(
message(1),
'(a,i6)')
'Incompatible restart information: k-point mismatch for ik ', ik
722 write(
message(2),
'(a,99f18.12)')
' Expected : ', kpoint(1:space%dim)
723 write(
message(3),
'(a,99f18.12)')
' Read : ', read_kpoint(1:space%dim)
726 if (ist >= st%st_start .and. ist <= st%st_end .and. &
727 ik >= st%d%kpt%start .and. ik <= st%d%kpt%end)
then
728 restart_file_present(idim, ist, ik) = .false.
733 st%occ(ist, ik) = my_occ
734 integral_occs = integral_occs .and. &
735 abs((st%occ(ist, ik) - st%smear%el_per_state) * st%occ(ist, ik)) <=
m_epsilon
740 if (
present(iter))
then
741 call restart%read(wfns_file, lines, 1, err)
745 read(lines(1), *) filename, filename, iter
749 call restart%close(wfns_file)
750 call restart%close(occ_file)
754 if (restart_file_format == option__restartfileformatstates__adios2)
then
755 if (.not.
loct_dir_exists(trim(restart%dir())//
"/"//
"wavefunctions.bp"))
then
756 message(1) =
"ADIOS2 restart file not found, falling back to obf format."
758 restart_file_format = option__restartfileformatstates__obf
765 safe_allocate(filled(1:st%d%dim, st%st_start:st%st_end, st%d%kpt%start:st%d%kpt%end))
768 if (
present(lowest_missing)) lowest_missing = st%nst + 1
771 if (st%system_grp%is_root() .and. verbose_)
then
773 ntodo = st%lnst*st%d%kpt%nlocal()*st%d%dim
776 if (restart_file_format == option__restartfileformatstates__obf)
then
777 do ik = st%d%kpt%start, st%d%kpt%end
778 do ist = st%st_start, st%st_end
779 if (
present(skip))
then
783 do idim = 1, st%d%dim
785 if (.not. restart_file_present(idim, ist, ik))
then
786 if (
present(lowest_missing))
then
787 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
793 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, dpsi, err)
794 if (.not.
present(lr))
then
797 call lalg_copy(mesh%np, dpsi, lr%ddl_psi(:, idim, ist, ik))
800 call restart%read_mesh_function(restart_file(idim, ist, ik), mesh, zpsi, err)
801 if (.not.
present(lr))
then
804 call lalg_copy(mesh%np, zpsi, lr%zdl_psi(:, idim, ist, ik))
809 filled(idim, ist, ik) = .
true.
811 else if (
present(lowest_missing))
then
812 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
815 if (st%system_grp%is_root() .and. verbose_)
then
823 else if (restart_file_format == option__restartfileformatstates__adios2)
then
824 if (
present(lr))
then
828 if (restart%has_map())
then
829 message(1) =
"ADIOS2 restart file format does not support restarting from a different grid."
830 message(2) =
"Please set RestartFileFormatStates = obf."
833 call states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
836 safe_deallocate_a(dpsi)
837 safe_deallocate_a(zpsi)
838 safe_deallocate_a(restart_file)
839 safe_deallocate_a(restart_file_present)
841 if (st%system_grp%is_root() .and. verbose_)
then
845 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
847 call st%st_kpt_mpi_grp%allreduce(iread_tmp, iread, 1, mpi_integer, mpi_sum)
850 if (st%d%kpt%parallel)
then
852 if (
present(lowest_missing))
then
853 safe_allocate(lowest_missing_tmp(1:st%d%dim, 1:st%nik))
854 lowest_missing_tmp = lowest_missing
855 call st%d%kpt%mpi_grp%allreduce(lowest_missing_tmp(1,1), lowest_missing(1,1), st%d%dim*st%nik, &
856 mpi_integer, mpi_min)
857 safe_deallocate_a(lowest_missing_tmp)
861 if (fixed_occ .and. iread == st%nst * st%nik * st%d%dim)
then
864 call smear_init(st%smear, namespace, st%d%ispin, fixed_occ = .
true., integral_occs = integral_occs, kpoints = kpoints)
867 if (.not.
present(lr) .and. .not.
present(skip) .and. iread /= st%nst * st%nik * st%d%dim)
then
872 safe_deallocate_a(filled)
874 if (ierr == 0 .and. iread /= st%nst * st%nik * st%d%dim)
then
882 if (.not.
present(lr))
then
883 write(str,
'(a,i5)')
'Reading states.'
885 write(str,
'(a,i5)')
'Reading states information for linear response.'
888 if (.not.
present(skip))
then
889 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
890 st%nst * st%nik * st%d%dim,
' could be read.'
892 write(
message(1),
'(a,i6,a,i6,a)')
'Only ', iread,
' files out of ', &
893 st%nst * st%nik * st%d%dim,
' were loaded.'
900 message(1) =
'Info: States reading done.'
910 logical function index_is_wrong() !< .
true. if the index (idim, ist, ik) is not present in st structure...
913 if (idim > st%d%dim .or. idim < 1 .or. &
914 ist > st%nst .or. ist < 1 .or. &
915 ik > st%nik .or. ik < 1)
then
933 class(
mesh_t),
intent(in) :: mesh
935 logical,
intent(in) :: filled(1:, st%st_start:, st%d%kpt%start:)
937 integer :: jdim, jst, jk
938 integer,
allocatable :: needs_fill(:, :, :)
942 safe_allocate(needs_fill(1:st%d%dim, 1:st%nst, 1:st%nik))
945 do jk = st%d%kpt%start, st%d%kpt%end
946 do jst = st%st_start, st%st_end
947 do jdim = 1, st%d%dim
948 if (.not. filled(jdim, jst, jk)) needs_fill(jdim, jst, jk) = 1
957 do jdim = 1, st%d%dim
958 if (needs_fill(jdim, jst, jk) == 0) cycle
964 safe_deallocate_a(needs_fill)
970 subroutine states_elec_load_adios2(restart, st, mesh, iread, filled, restart_file_present, ierr, skip, lowest_missing)
973 class(
mesh_t),
intent(in) :: mesh
974 integer,
intent(out) :: iread
975 logical,
intent(out) :: filled(1:, st%st_start:, st%d%kpt%start:)
976 logical,
contiguous,
intent(in) :: restart_file_present(:, :, :)
977 integer,
intent(out) :: ierr
978 logical,
contiguous,
optional,
intent(in) :: skip(:)
979 integer,
contiguous,
optional,
intent(inout) :: lowest_missing(:, :)
982 type(adios2_adios) :: adios
983 type(adios2_io) :: io
984 type(adios2_variable) :: var, var_indices
985 type(adios2_attribute) :: attribute
986 type(adios2_engine) :: engine
987 integer :: type_file, type_requested, ib, ik, ndims, pardomains
989 integer(int64),
allocatable :: var_shape(:)
990 integer(int64),
allocatable :: global_indices(:)
996 call adios2_init(adios, restart%mpi_grp%comm%MPI_VAL, ierr)
998 call adios2_init(adios, ierr)
1000 call check_error(.not. adios%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
1001 call adios2_declare_io(io, adios,
"reader", ierr)
1002 call check_error(.not. io%valid .or. ierr /= adios2_error_none,
"Problem initializing ADIOS2.")
1004 call adios2_open(engine, io, trim(restart%dir())//
"/"//
"wavefunctions.bp", adios2_mode_read, ierr)
1005 call check_error(.not. engine%valid .or. ierr /= adios2_error_none,
"Problem opening ADIOS2 restart file.")
1007 call adios2_begin_step(engine, ierr)
1009 call adios2_inquire_attribute(attribute, io,
"ParDomains", ierr)
1010 call check_error(.not. attribute%valid .or. ierr /= adios2_error_none,
"Problem inquiring ADIOS2 attribute.")
1011 call adios2_attribute_data(pardomains, attribute, ierr)
1013 type_requested = adios2_type_dp
1015 type_requested = adios2_type_complex_dp
1017 call adios2_inquire_variable(var, io,
'wavefunctions', ierr)
1018 call check_error(.not. var%valid .or. ierr /= adios2_error_none,
"Problem loading ADIOS2 variable (wavefunctions).")
1020 call adios2_variable_type(type_file, var, ierr)
1021 call adios2_variable_ndims(ndims, var, ierr)
1022 call adios2_variable_shape(var_shape, ndims, var, ierr)
1025 if (var_shape(1) < int(st%nst * st%d%dim, int64))
then
1027 nst_max = int(var_shape(1), int32) / st%d%dim
1029 if (var_shape(2) /= int(mesh%np_global, int64))
then
1031 message(1) =
"Error: trying to restart with a different number of grid points. Not supported with ADIOS2 format."
1034 if (
present(skip))
then
1037 call states_elec_adios2_read_state_by_state(st, mesh, engine, var, type_requested, type_file, &
1038 filled, restart_file_present, iread, skip, lowest_missing)
1040 call states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1041 nst_max, filled, iread)
1044 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1045 call adios2_inquire_variable(var_indices, io,
'global_indices', ierr)
1046 call check_error(.not. var_indices%valid .or. ierr /= adios2_error_none, &
1047 "Problem loading ADIOS2 variable (global_indices).")
1048 safe_allocate(global_indices(mesh%np))
1049 call adios2_set_selection(var_indices, 1, &
1050 [int(mesh%pv%xlocal-1, int64)], &
1051 [int(mesh%np, int64)], ierr)
1052 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection (global_indices).")
1053 call adios2_get(engine, var_indices, global_indices, ierr)
1054 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (global_indices).")
1056 call adios2_end_step(engine, ierr)
1057 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 end_step.")
1058 if (mesh%mpi_grp%size > 1 .or. pardomains > 1)
then
1059 do ik = st%d%kpt%start, st%d%kpt%end
1060 do ib = st%group%block_start, st%group%block_end
1068 safe_deallocate_a(global_indices)
1072 call adios2_close(engine, ierr)
1073 call check_error(ierr /= adios2_error_none,
"Problem closing ADIOS2 engine.")
1074 call adios2_finalize(adios, ierr)
1075 call check_error(ierr /= adios2_error_none,
"Problem finalizing ADIOS2.")
1087 subroutine states_elec_adios2_read_state_by_state(st, mesh, engine, var, type_requested, type_file, &
1088 filled, restart_file_present, iread, skip, lowest_missing)
1090 class(
mesh_t),
intent(in) :: mesh
1091 type(adios2_engine),
intent(inout) :: engine
1092 type(adios2_variable),
intent(inout) :: var
1093 integer,
intent(in) :: type_requested
1094 integer,
intent(in) :: type_file
1095 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1096 logical,
contiguous,
intent(in) :: restart_file_present(:, :, :)
1097 integer,
intent(inout) :: iread
1098 logical,
contiguous,
optional,
intent(in) :: skip(:)
1099 integer,
contiguous,
optional,
intent(inout) :: lowest_missing(:, :)
1101 integer :: ik, ist, idim, ierr
1102 real(real64),
allocatable :: dpsi(:)
1103 complex(real64),
allocatable :: zpsi(:)
1105 push_sub(states_elec_adios2_read_state_by_state)
1107 if (type_requested == adios2_type_dp .and. type_file == adios2_type_complex_dp)
then
1108 message(1) =
"Error: calculation requested real states for restarting, but restart file has complex states."
1112 do ik = st%d%kpt%start, st%d%kpt%end
1115 if (type_file == adios2_type_dp)
then
1116 safe_allocate(dpsi(1:mesh%np))
1118 safe_allocate(zpsi(1:mesh%np))
1120 do ist = st%st_start, st%st_end
1121 if (
present(skip))
then
1122 if (skip(ist)) cycle
1125 do idim = 1, st%d%dim
1126 if (.not. restart_file_present(idim, ist, ik))
then
1127 if (
present(lowest_missing))
then
1128 lowest_missing(idim, ik) = min(lowest_missing(idim, ik), ist)
1134 call adios2_set_selection(var, 3, &
1135 [int((ist-1)*st%d%dim+idim-1, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1136 [1_int64, int(mesh%np, int64), 1_int64], ierr)
1138 if (type_file == adios2_type_dp)
then
1139 call adios2_get(engine, var, dpsi, adios2_mode_sync, ierr)
1140 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get dpsi.")
1141 if (type_requested == adios2_type_complex_dp)
then
1148 call adios2_get(engine, var, zpsi, adios2_mode_sync, ierr)
1149 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get zpsi.")
1153 filled(idim, ist, ik) = .
true.
1157 safe_deallocate_a(dpsi)
1158 safe_deallocate_a(zpsi)
1161 pop_sub(states_elec_adios2_read_state_by_state)
1162 end subroutine states_elec_adios2_read_state_by_state
1166 subroutine states_elec_adios2_read_batch_by_batch(st, mesh, engine, var, var_shape, type_requested, type_file, &
1167 nst_max, filled, iread)
1169 class(
mesh_t),
intent(in) :: mesh
1170 type(adios2_engine),
intent(inout) :: engine
1171 type(adios2_variable),
intent(inout) :: var
1172 integer(int64),
contiguous,
intent(in) :: var_shape(:)
1173 integer,
intent(in) :: type_requested
1174 integer,
intent(in) :: type_file
1175 integer,
intent(in) :: nst_max
1176 logical,
intent(inout) :: filled(1:, st%st_start:, st%d%kpt%start:)
1177 integer,
intent(inout) :: iread
1179 integer :: ib, ik, ist, ip, adios2_mode, nst_linear, ierr
1181 real(real64),
allocatable :: dff_pack(:, :)
1183 push_sub(states_elec_adios2_read_batch_by_batch)
1185 do ik = st%d%kpt%start, st%d%kpt%end
1188 if (ik > var_shape(3)) cycle
1189 do ib = st%group%block_start, st%group%block_end
1190 select case (st%group%psib(ib, ik)%status())
1193 call st%group%psib(ib, ik)%copy_to(psib, copy_data=.false.)
1195 adios2_mode = adios2_mode_sync
1197 psib => st%group%psib(ib, ik)
1201 adios2_mode = adios2_mode_sync
1204 call st%group%psib(ib, ik)%copy_to(psib)
1205 call psib%do_unpack(force=.
true., copy=.false.)
1208 adios2_mode = adios2_mode_sync
1213 nst_linear = st%group%psib(ib, ik)%nst_linear
1217 if (nst_linear <= 0)
then
1218 select case (st%group%psib(ib, ik)%status())
1221 safe_deallocate_p(psib)
1226 safe_deallocate_p(psib)
1234 call adios2_set_selection(var, 3, &
1235 [int((
states_elec_block_min(st, ib)-1)*st%d%dim, int64), int(mesh%pv%xlocal-1, int64), int(ik-1, int64)], &
1236 [int(nst_linear, int64), int(mesh%np, int64), 1_int64], ierr)
1237 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 selection.")
1239 if (type_requested == adios2_type_dp .and. type_file == adios2_type_dp)
then
1241 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1242 [int(
size(psib%dff_pack, 1), int64), &
1243 int(
size(psib%dff_pack, 2), int64), 1_int64], ierr)
1244 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading real).")
1246 call adios2_get(engine, var, psib%dff_pack, adios2_mode, ierr)
1247 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading real).")
1248 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_complex_dp)
then
1250 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1251 [int(
size(psib%zff_pack, 1), int64), &
1252 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1253 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex).")
1255 call adios2_get(engine, var, psib%zff_pack, adios2_mode, ierr)
1256 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex).")
1257 else if (type_requested == adios2_type_complex_dp .and. type_file == adios2_type_dp)
then
1259 safe_allocate(dff_pack(
size(psib%zff_pack, 1),
size(psib%zff_pack, 2)))
1261 call adios2_set_memory_selection(var, 3, [0_int64, 0_int64, 0_int64], &
1262 [int(
size(psib%zff_pack, 1), int64), &
1263 int(
size(psib%zff_pack, 2), int64), 1_int64], ierr)
1264 call check_error(ierr /= adios2_error_none,
"Problem setting ADIOS2 memory selection (reading complex from real).")
1267 call adios2_get(engine, var, dff_pack, adios2_mode_sync, ierr)
1268 call check_error(ierr /= adios2_error_none,
"Problem in ADIOS2 get (reading complex from real).")
1272 do ist = 1, nst_linear
1273 psib%zff_pack(ist, ip) = cmplx(dff_pack(ist, ip),
m_zero, real64)
1276 safe_deallocate_a(dff_pack)
1278 message(1) =
"Error: requested to read complex states for restarting, but calculation has real states."
1282 iread = iread + nst_linear
1283 do ist = 1, nst_linear
1284 filled(st%group%psib(ib, ik)%linear_to_idim(ist), st%group%psib(ib, ik)%linear_to_ist(ist), ik) = .
true.
1287 select case (st%group%psib(ib, ik)%status())
1289 call psib%do_unpack()
1290 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1292 safe_deallocate_p(psib)
1297 call psib%copy_data_to(mesh%np, st%group%psib(ib, ik))
1299 safe_deallocate_p(psib)
1304 pop_sub(states_elec_adios2_read_batch_by_batch)
1305 end subroutine states_elec_adios2_read_batch_by_batch
1309 subroutine check_error(condition, error_message)
1310 logical,
intent(in) :: condition
1311 character(len=*),
intent(in) :: error_message
1316 end subroutine check_error
1322 class(
mesh_t),
intent(in) :: mesh
1323 integer,
intent(out) :: ierr
1324 integer,
optional,
intent(in) :: iter
1326 integer :: iunit, isp, err, err2(2)
1327 character(len=MAX_PATH_LEN) :: filename
1328 character(len=300) :: lines(2)
1334 if (restart%skip())
then
1339 message(1) =
"Debug: Writing density restart."
1345 iunit = restart%open(
'density')
1346 lines(1) =
'# #spin #nspin filename'
1347 lines(2) =
'%densities'
1348 call restart%write(iunit, lines, 2, err)
1349 if (err /= 0) ierr = ierr + 1
1352 do isp = 1, st%d%nspin
1354 write(lines(1),
'(i8,a,i8,a)') isp,
' | ', st%d%nspin,
' | "'//trim(adjustl(filename))//
'"'
1355 call restart%write(iunit, lines, 1, err)
1356 if (err /= 0) err2(1) = err2(1) + 1
1358 call restart%write_mesh_function(filename, mesh, st%rho(:,isp), err)
1359 if (err /= 0) err2(2) = err2(2) + 1
1362 if (err2(1) /= 0) ierr = ierr + 2
1363 if (err2(2) /= 0) ierr = ierr + 4
1366 call restart%write(iunit, lines, 1, err)
1367 if (err /= 0) ierr = ierr + 8
1368 if (
present(iter))
then
1369 write(lines(1),
'(a,i7)')
'Iter = ', iter
1370 call restart%write(iunit, lines, 1, err)
1371 if (err /= 0) ierr = ierr + 16
1373 call restart%close(iunit)
1377 message(1) =
"Debug: Writing density restart done."
1388 class(
mesh_t),
intent(in) :: mesh
1389 integer,
intent(out) :: ierr
1391 integer :: err, err2, isp
1392 character(len=MAX_PATH_LEN) :: filename
1398 if (restart%skip())
then
1404 message(1) =
"Debug: Reading density restart."
1415 do isp = 1, st%d%nspin
1420 call restart%read_mesh_function(filename, mesh, st%rho(:,isp), err)
1421 if (err /= 0) err2 = err2 + 1
1424 if (err2 /= 0) ierr = ierr + 1
1426 message(1) =
"Debug: Reading density restart done."
1434 class(
space_t),
intent(in) :: space
1436 class(
mesh_t),
intent(in) :: mesh
1437 integer,
intent(out) :: ierr
1439 integer :: isp, err, err2(2), idir
1440 character(len=MAX_PATH_LEN) :: filename
1446 assert(
allocated(st%frozen_rho))
1448 if (restart%skip())
then
1453 message(1) =
"Debug: Writing frozen densities restart."
1459 do isp = 1, st%d%nspin
1462 call restart%write_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1463 if (err /= 0) err2(2) = err2(2) + 1
1465 if (
allocated(st%frozen_tau))
then
1467 call restart%write_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1468 if (err /= 0) err2 = err2 + 1
1471 if (
allocated(st%frozen_gdens))
then
1472 do idir = 1, space%dim
1473 if (st%d%nspin == 1)
then
1474 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1476 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1478 call restart%write_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1479 if (err /= 0) err2 = err2 + 1
1483 if (
allocated(st%frozen_ldens))
then
1485 call restart%write_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1486 if (err /= 0) err2 = err2 + 1
1490 if (err2(1) /= 0) ierr = ierr + 2
1491 if (err2(2) /= 0) ierr = ierr + 4
1495 message(1) =
"Debug: Writing frozen densities restart done."
1505 class(
space_t),
intent(in) :: space
1507 class(
mesh_t),
intent(in) :: mesh
1508 integer,
intent(out) :: ierr
1510 integer :: err, err2, isp, idir
1511 character(len=MAX_PATH_LEN) :: filename
1515 assert(
allocated(st%frozen_rho))
1519 if (restart%skip())
then
1525 message(1) =
"Debug: Reading densities restart."
1529 do isp = 1, st%d%nspin
1531 call restart%read_mesh_function(filename, mesh, st%frozen_rho(:,isp), err)
1532 if (err /= 0) err2 = err2 + 1
1534 if (
allocated(st%frozen_tau))
then
1536 call restart%read_mesh_function(filename, mesh, st%frozen_tau(:,isp), err)
1537 if (err /= 0) err2 = err2 + 1
1540 if (
allocated(st%frozen_gdens))
then
1541 do idir = 1, space%dim
1542 if (st%d%nspin == 1)
then
1543 write(filename, fmt=
'(a,i1)')
'frozen_gdens-dir', idir
1545 write(filename, fmt=
'(a,i1,a,i1)')
'frozen_gdens-dir', idir,
'-', isp
1547 call restart%read_mesh_function(filename, mesh, st%frozen_gdens(:,idir,isp), err)
1548 if (err /= 0) err2 = err2 + 1
1552 if (
allocated(st%frozen_ldens))
then
1554 call restart%read_mesh_function(filename, mesh, st%frozen_ldens(:,isp), err)
1555 if (err /= 0) err2 = err2 + 1
1559 if (err2 /= 0) ierr = ierr + 1
1561 message(1) =
"Debug: Reading frozen densities restart done."
1572 class(
mesh_t),
intent(in) :: mesh
1574 class(
space_t),
intent(in) :: space
1578 integer :: ip, id, is, ik, nstates, state_from, ierr, ncols
1579 integer :: ib, idim, inst, inik, normalize
1580 real(real64) :: xx(space%dim), rr, psi_re, psi_im
1581 character(len=150) :: filename
1582 complex(real64),
allocatable :: zpsi(:, :)
1584 integer,
parameter :: &
1585 state_from_formula = 1, &
1586 state_from_file = -10010, &
1587 normalize_yes = 1, &
1670 if (
parse_block(namespace,
'UserDefinedStates', blk) == 0)
then
1677 safe_allocate(zpsi(1:mesh%np, 1:st%d%dim))
1683 if (ncols < 5 .or. ncols > 6)
then
1684 message(1) =
'Each line in the UserDefinedStates block must have'
1685 message(2) =
'five or six columns.'
1701 if (.not.(id == idim .and. is == inst .and. ik == inik )) cycle
1707 select case (state_from)
1708 case (state_from_formula)
1711 blk, ib - 1, 4, st%user_def_states(id, is, ik))
1713 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1714 write(
message(2),
'(2a)')
' with the expression:'
1715 write(
message(3),
'(2a)')
' ',trim(st%user_def_states(id, is, ik))
1721 case (state_from_file)
1727 write(
message(1),
'(a,3i5)')
'Substituting state of orbital with k, ist, dim = ', ik, is, id
1728 write(
message(2),
'(2a)')
' with data from file:'
1729 write(
message(3),
'(2a)')
' ',trim(filename)
1735 if (.not.(st%st_start <= is .and. st%st_end >= is &
1736 .and. st%d%kpt%start <= ik .and. st%d%kpt%end >= ik)) cycle
1738 select case (state_from)
1740 case (state_from_formula)
1749 zpsi(ip, 1) = cmplx(psi_re, psi_im, real64)
1752 case (state_from_file)
1756 message(1) =
'Could not read the file!'
1757 write(
message(2),
'(a,i1)')
'Error code: ', ierr
1762 message(1) =
'Wrong entry in UserDefinedStates, column 4.'
1763 message(2) =
'You may state "formula" or "file" here.'
1773 select case (normalize)
1776 case (normalize_yes)
1777 assert(st%d%dim == 1)
1781 message(1) =
'The sixth column in UserDefinedStates may either be'
1782 message(2) =
'"normalize_yes" or "normalize_no"'
1792 safe_deallocate_a(zpsi)
1810 integer,
intent(out) :: ierr
1812 integer :: iunit_spin
1813 integer :: err, err2(2), ik, ist
1814 character(len=300) :: lines(3)
1820 if (restart%skip())
then
1829 iunit_spin = restart%open(
'spin')
1830 lines(1) =
'# #k-point #st #spin(x) spin(y) spin(z)'
1831 call restart%write(iunit_spin, lines, 1, err)
1832 if (err /= 0) ierr = ierr + 1
1837 write(lines(1),
'(i8,a,i8,3(a,f18.12))') ik,
' | ', ist,
' | ', &
1838 st%spin(1,ist,ik),
' | ', st%spin(2,ist,ik),
' | ', st%spin(3,ist,ik)
1839 call restart%write(iunit_spin, lines, 1, err)
1840 if (err /= 0) err2(1) = err2(1) + 1
1844 call restart%write(iunit_spin, lines, 1, err)
1845 if (err2(1) /= 0) ierr = ierr + 8
1846 if (err2(2) /= 0) ierr = ierr + 16
1848 call restart%close(iunit_spin)
1867 integer,
intent(out) :: ierr
1869 integer :: spin_file, err, ik, ist
1870 character(len=256) :: lines(3)
1871 real(real64) :: spin(3)
1872 character(len=1) :: char
1879 if (restart%skip())
then
1888 spin_file = restart%open(
'spin')
1890 call restart%read(spin_file, lines, 1, err)
1891 if (err /= 0) ierr = ierr - 2**7
1896 call restart%close(spin_file)
1906 call restart%read(spin_file, lines, 1, err)
1909 read(lines(1),
'(a)') char
1910 if (char ==
'%')
then
1914 read(lines(1), *) ik, char, ist, char, spin(1), char, spin(2), char, spin(3)
1917 st%spin(1:3, ist, ik) = spin(1:3)
1920 call restart%close(spin_file)
1930 class(
space_t),
intent(in) :: space
1931 type(
restart_t),
intent(inout) :: restart
1932 class(
mesh_t),
intent(in) :: mesh
1934 character(len=*),
optional,
intent(in) :: prefix
1938 complex(real64),
allocatable :: rotation_matrix(:,:), psi(:, :)
1939 integer :: ist, jst, ncols, iqn
1940 character(len=256) :: block_name
1973 if (
parse_block(namespace, trim(block_name), blk) == 0)
then
1974 if (st%parallel_in_states)
then
1978 message(1) =
"Number of rows in block " // trim(block_name) //
" must equal number of states in this calculation."
1985 safe_allocate(rotation_matrix(1:stin%nst, 1:stin%nst))
1986 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
1992 if (ncols /= stin%nst)
then
1993 write(
message(1),
'(a,i6,a,i6,3a,i6,a)')
"Number of columns (", ncols,
") in row ", ist,
" of block ", &
1994 trim(block_name),
" must equal number of states (", stin%nst,
") read from gs restart."
1997 do jst = 1, stin%nst
2004 do iqn = st%d%kpt%start, st%d%kpt%end
2011 do ist = st%st_start, st%st_end
2018 safe_deallocate_a(rotation_matrix)
2019 safe_deallocate_a(psi)
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_max
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_)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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, dest_type, copy_data)
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 states_elec_fill_random(st, mesh, kpoints, filled)
Put random functions in orbitals that could not be read.
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