subroutine w90_wannier90_readwrite_read_global_kmesh(settings, global_kmesh_set, kmesh, &
recip_lattice, error, comm)
!================================================!
use w90_error, only: w90_error_type
use w90_comms, only: w90_comm_type
implicit none
type(kmesh_spacing_type), intent(out) :: kmesh
logical, intent(inout) :: global_kmesh_set
real(kind=dp), intent(in) :: recip_lattice(3, 3)
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
integer :: i
logical :: found
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! k meshes
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! [GP-begin, Apr13, 2012]
! Global interpolation k-mesh; this is overridden by "local" meshes of a given submodule
! This bit of code must appear *before* all other codes for the local interpolation meshes,
! BUT *after* having calculated the reciprocal-space vectors.
global_kmesh_set = .false.
kmesh%spacing = -1._dp
kmesh%mesh = 0
call w90_readwrite_get_keyword(settings, 'kmesh_spacing', found, error, comm, &
r_value=kmesh%spacing)
if (allocated(error)) return
if (found) then
if (kmesh%spacing .le. 0._dp) then
call set_error_input(error, 'Error: kmesh_spacing must be greater than zero', comm)
return
end if
global_kmesh_set = .true.
call w90_readwrite_set_kmesh(kmesh%spacing, recip_lattice, kmesh%mesh)
end if
call w90_readwrite_get_vector_length(settings, 'kmesh', found, i, error, comm)
if (allocated(error)) return
if (found) then
if (global_kmesh_set) then
call set_error_input(error, 'Error: cannot set both kmesh and kmesh_spacing', comm)
return
end if
if (i .eq. 1) then
global_kmesh_set = .true.
call w90_readwrite_get_keyword_vector(settings, 'kmesh', found, 1, error, comm, &
i_value=kmesh%mesh)
if (allocated(error)) return
kmesh%mesh(2) = kmesh%mesh(1)
kmesh%mesh(3) = kmesh%mesh(1)
elseif (i .eq. 3) then
global_kmesh_set = .true.
call w90_readwrite_get_keyword_vector(settings, 'kmesh', found, 3, error, comm, &
i_value=kmesh%mesh)
if (allocated(error)) return
else
call set_error_input(error, 'Error: kmesh must be provided as either one integer or a vector of three integers', comm)
return
end if
if (any(kmesh%mesh <= 0)) then
call set_error_input(error, 'Error: kmesh elements must be greater than zero', comm)
return
end if
end if
! [GP-end]
end subroutine w90_wannier90_readwrite_read_global_kmesh