subroutine w90_wannier90_readwrite_read_wann_plot(settings, wann_plot, num_wann, wannier_plot, &
error, comm)
!================================================!
! Plotting
!================================================!
use w90_error, only: w90_error_type
implicit none
integer, intent(in) :: num_wann
logical, intent(in) :: wannier_plot
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
type(wannier_plot_type), intent(inout) :: wann_plot
integer :: i, loop, ierr, wann_plot_num
logical :: found
found = .false.
call w90_readwrite_get_vector_length(settings, 'wannier_plot_supercell', found, i, error, comm)
if (allocated(error)) return
if (found) then
if (i .eq. 1) then
call w90_readwrite_get_keyword_vector(settings, 'wannier_plot_supercell', found, 1, error, comm, &
i_value=wann_plot%supercell)
if (allocated(error)) return
wann_plot%supercell(2) = wann_plot%supercell(1)
wann_plot%supercell(3) = wann_plot%supercell(1)
elseif (i .eq. 3) then
call w90_readwrite_get_keyword_vector(settings, 'wannier_plot_supercell', found, 3, error, comm, &
i_value=wann_plot%supercell)
if (allocated(error)) return
else
call set_error_input(error, 'Error: wannier_plot_supercell must be provided as either' &
//'one integer or a vector of three integers', comm)
return
end if
if (any(wann_plot%supercell <= 0)) then
call set_error_input(error, 'Error: wannier_plot_supercell elements must be greater than zero', comm)
return
end if
end if
call w90_readwrite_get_keyword(settings, 'wannier_plot_format', found, error, comm, c_value=wann_plot%format)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'wannier_plot_mode', found, error, comm, c_value=wann_plot%mode)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'wannier_plot_spinor_mode', found, error, comm, &
c_value=wann_plot%spinor_mode)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'wannier_plot_spinor_phase', found, error, comm, &
l_value=wann_plot%spinor_phase)
if (allocated(error)) return
wann_plot_num = 0
call w90_readwrite_get_range_vector(settings, 'wannier_plot_list', found, wann_plot_num, .true., error, comm)
if (allocated(error)) return
if (found) then
if (wann_plot_num < 1) then
call set_error_input(error, 'Error: problem reading wannier_plot_list', comm)
return
end if
if (allocated(wann_plot%list)) then
deallocate (wann_plot%list, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating wannier_plot%list in w90_wannier90_readwrite_read', comm)
return
end if
end if
allocate (wann_plot%list(wann_plot_num), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating wannier_plot%list in w90_wannier90_readwrite_read', comm)
return
end if
call w90_readwrite_get_range_vector(settings, 'wannier_plot_list', found, wann_plot_num, .false., &
error, comm, wann_plot%list)
if (allocated(error)) return
if (any(wann_plot%list < 1) .or. any(wann_plot%list > num_wann)) then
call set_error_input(error, 'Error: wannier_plot_list asks for a non-valid wannier function to be plotted', comm)
return
end if
else
! we plot all wannier functions
wann_plot_num = num_wann
if (allocated(wann_plot%list)) then
deallocate (wann_plot%list, stat=ierr)
if (ierr /= 0) then
call set_error_dealloc(error, 'Error deallocating wannier_plot%list &
& in w90_wannier90_readwrite_read_wann_plot', comm)
return
end if
end if
allocate (wann_plot%list(wann_plot_num), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating wannier_plot%list in w90_wannier90_readwrite_read_wann_plot', comm)
return
end if
do loop = 1, num_wann
wann_plot%list(loop) = loop
end do
end if
call w90_readwrite_get_keyword(settings, 'wannier_plot_radius', found, error, comm, r_value=wann_plot%radius)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'wannier_plot_scale', found, error, comm, r_value=wann_plot%scale)
if (allocated(error)) return
! checks
if (wannier_plot) then
if ((index(wann_plot%format, 'xcrys') .eq. 0) .and. (index(wann_plot%format, 'cub') .eq. 0)) then
call set_error_input(error, 'Error: wannier_plot_format not recognised', comm)
return
end if
if ((index(wann_plot%mode, 'crys') .eq. 0) .and. (index(wann_plot%mode, 'mol') .eq. 0)) then
call set_error_input(error, 'Error: wannier_plot_mode not recognised', comm)
return
end if
if ((index(wann_plot%spinor_mode, 'total') .eq. 0) &
.and. (index(wann_plot%spinor_mode, 'up') .eq. 0) &
.and. (index(wann_plot%spinor_mode, 'down') .eq. 0)) then
call set_error_input(error, 'Error: wannier_plot_spinor_mode not recognised', comm)
return
end if
if (wann_plot%radius < 0.0_dp) then
call set_error_input(error, 'Error: wannier_plot_radius must be positive', comm)
return
end if
if (wann_plot%scale < 0.0_dp) then
call set_error_input(error, 'Error: wannier_plot_scale must be positive', comm)
return
end if
end if
end subroutine w90_wannier90_readwrite_read_wann_plot