subroutine w90_wannier90_readwrite_read_disentangle(settings, dis_control, dis_spheres, &
num_bands, num_wann, bohr, error, comm)
!================================================!
use w90_error, only: w90_error_type
implicit none
integer, intent(in) :: num_bands, num_wann
real(kind=dp), intent(in) :: bohr
type(dis_control_type), intent(inout) :: dis_control
type(dis_spheres_type), intent(inout) :: dis_spheres
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
integer :: nkp, ierr
logical :: found
call w90_readwrite_get_keyword(settings, 'dis_num_iter', found, error, comm, &
i_value=dis_control%num_iter)
if (allocated(error)) return
if (dis_control%num_iter < 0) then
call set_error_input(error, 'Error: dis_num_iter must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'dis_mix_ratio', found, error, comm, &
r_value=dis_control%mix_ratio)
if (allocated(error)) return
if (dis_control%mix_ratio <= 0.0_dp .or. dis_control%mix_ratio > 1.0_dp) then
call set_error_input(error, 'Error: dis_mix_ratio must be greater than 0.0 but not greater than 1.0', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'dis_conv_tol', found, error, comm, &
r_value=dis_control%conv_tol)
if (allocated(error)) return
if (dis_control%conv_tol < 0.0_dp) then
call set_error_input(error, 'Error: dis_conv_tol must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'dis_conv_window', found, error, comm, &
i_value=dis_control%conv_window)
if (allocated(error)) return
if (dis_control%conv_window < 0) then
call set_error_input(error, 'Error: dis_conv_window must be positive', comm)
return
end if
! GS-start
call w90_readwrite_get_keyword(settings, 'dis_spheres_first_wann', found, error, comm, &
i_value=dis_spheres%first_wann)
if (allocated(error)) return
if (dis_spheres%first_wann < 1) then
call set_error_input(error, 'Error: dis_spheres_first_wann must be greater than 0', comm)
return
end if
if (dis_spheres%first_wann > num_bands - num_wann + 1) then
call set_error_input(error, 'Error: dis_spheres_first_wann is larger than num_bands-num_wann+1', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'dis_spheres_num', found, error, comm, &
i_value=dis_spheres%num)
if (allocated(error)) return
if (dis_spheres%num < 0) then
call set_error_input(error, 'Error: dis_spheres_num cannot be negative', comm)
return
end if
if (dis_spheres%num > 0) then
allocate (dis_spheres%spheres(4, dis_spheres%num), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating dis_spheres in w90_wannier90_readwrite_read_disentangle', comm)
return
end if
call w90_readwrite_get_keyword_block(settings, 'dis_spheres', found, dis_spheres%num, 4, &
bohr, error, comm, r_value=dis_spheres%spheres)
if (allocated(error)) return
if (.not. found) then
call set_error_input(error, 'Error: Did not find dis_spheres in the input file', comm)
return
end if
do nkp = 1, dis_spheres%num
if (dis_spheres%spheres(4, nkp) < 1.0e-15_dp) then
call set_error_input(error, 'Error: radius for dis_spheres must be > 0', comm)
return
end if
end do
end if
! GS-end
end subroutine w90_wannier90_readwrite_read_disentangle