subroutine w90_readwrite_read_explicit_kpath(settings, kpoint_path, ok, bands_plot, bohr, error, comm)
use w90_error, only: w90_error_type, set_error_input, set_error_alloc, set_error_dealloc
implicit none
logical, intent(in) :: bands_plot
type(kpoint_path_type), intent(inout) :: kpoint_path
logical, intent(out) :: ok
real(kind=dp), intent(in) :: bohr
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
integer :: ierr, bands_num_spec_points
logical :: found
bands_num_spec_points = 0
call w90_readwrite_get_block_length(settings, 'explicit_kpath_labels', found, bands_num_spec_points, error, comm)
if (allocated(error)) return
if (found) then
ok = .true.
kpoint_path%bands_kpt_explicit = .true.
! bands_num_spec_points = i_temp*2
if (allocated(kpoint_path%labels)) then
deallocate (kpoint_path%labels, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating kpoint_path%labels &
& in w90_readwrite_read_explicit_kpath', comm)
return
end if
end if
allocate (kpoint_path%labels(bands_num_spec_points), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating kpoint_path%labels &
& in w90_readwrite_read_explicit_kpath', comm)
return
end if
if (allocated(kpoint_path%points)) then
deallocate (kpoint_path%points, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating kpoint_path%points &
& in w90_readwrite_read_explicit_kpath', comm)
return
end if
end if
allocate (kpoint_path%points(3, bands_num_spec_points), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating kpoint_path%points &
& in w90_readwrite_read_explicit_kpath', comm)
return
end if
call w90_readwrite_get_keyword_explicit_kpath(settings, kpoint_path, error, comm)
if (allocated(error)) return
call w90_readwrite_read_explicit_kpath_points(settings, kpoint_path%bands_kpt_frac, bohr, &
error, comm)
if (allocated(error)) return
else
ok = .false.
end if
if (allocated(settings%entries)) then
! library mode: (3,n) special points and their n labels
call w90_readwrite_get_keyword_vector(settings, 'explicit_kpath_symbols', ok, 0, error, comm, &
c2_value=kpoint_path%labels)
if (allocated(error)) return
call w90_readwrite_get_keyword_vector(settings, 'explicit_kpath_labels', found, 0, error, comm, &
r2_value=kpoint_path%points)
if (allocated(error)) return
if (ok .neqv. found) then
call set_error_input(error, 'Error: Must specify both explicit_kpath_labels and explicit_kpath_symbols', comm)
return
end if
if (ok) then
if (size(kpoint_path%points, 1) /= 3 .or. size(kpoint_path%points, 2) /= size(kpoint_path%labels)) then
call set_error_input(error, 'Error: explicit_kpath_labels must have shape (3,n) for the n explicit_kpath_symbols', comm)
return
end if
kpoint_path%bands_kpt_explicit = .true.
call w90_readwrite_read_explicit_kpath_points(settings, kpoint_path%bands_kpt_frac, bohr, &
error, comm)
if (allocated(error)) return
end if
end if
! if (bands_plot) then
! if (kpoint_path%num_points_first_segment < 0) then
! call set_error_input(error, 'Error: bands_num_points must be positive', comm)
! return
! endif
! endif
end subroutine w90_readwrite_read_explicit_kpath