subroutine w90_wannier90_readwrite_read_band_plot(settings, band_plot, num_wann, has_kpath, &
has_explicit_kpath, bands_plot, error, comm)
!================================================!
! Plotting
!================================================!
use w90_error, only: w90_error_type
implicit none
integer, intent(in) :: num_wann
logical, intent(in) :: bands_plot
logical, intent(in) :: has_kpath
logical, intent(in) :: has_explicit_kpath
type(band_plot_type), intent(inout) :: band_plot
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
integer :: ierr, num_project
logical :: found
call w90_readwrite_get_keyword(settings, 'bands_plot_format', found, error, comm, &
c_value=band_plot%format)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'bands_plot_mode', found, error, comm, c_value=band_plot%mode)
if (allocated(error)) return
num_project = 0
call w90_readwrite_get_range_vector(settings, 'bands_plot_project', found, num_project, .true., error, comm)
if (allocated(error)) return
if (found) then
if (num_project < 1) then
call set_error_input(error, 'Error: problem reading bands_plot_project', comm)
return
end if
if (allocated(band_plot%project)) then
deallocate (band_plot%project, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating bands_plot%project in &
& w90_wannier90_readwrite_read_band_plot', comm)
return
end if
end if
allocate (band_plot%project(num_project), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating bands_plot%project in w90_wannier90_readwrite_read_band_plot', comm)
return
end if
call w90_readwrite_get_range_vector(settings, 'bands_plot_project', found, &
num_project, .false., error, comm, band_plot%project)
if (allocated(error)) return
if (any(band_plot%project < 1) .or. any(band_plot%project > num_wann)) then
call set_error_input(error, 'Error: bands_plot_project asks for a non-valid wannier function to be projected', comm)
return
end if
end if
if ((.not. has_kpath) .and. (.not. has_explicit_kpath) .and. bands_plot) then
call set_error_input(error, &
'A bandstructure plot has been requested but there is no kpoint_path or explicit_kpath block', comm)
return
end if
! checks
if (bands_plot) then
if ((index(band_plot%format, 'gnu') .eq. 0) .and. &
(index(band_plot%format, 'xmgr') .eq. 0)) then
call set_error_input(error, 'Error: bands_plot_format not recognised', comm)
return
end if
if ((index(band_plot%mode, 's-k') .eq. 0) .and. (index(band_plot%mode, 'cut') .eq. 0)) then
call set_error_input(error, 'Error: bands_plot_mode not recognised', comm)
return
end if
end if
end subroutine w90_wannier90_readwrite_read_band_plot