subroutine w90_wannier90_readwrite_read_gyrotropic(settings, pw90_gyrotropic, num_wann, &
smr_fixed_en_width, smr_index, error, comm)
!================================================!
use w90_error, only: w90_error_type
use w90_comms, only: w90_comm_type
implicit none
type(pw90_gyrotropic_type), intent(out) :: pw90_gyrotropic
integer, intent(in) :: num_wann
real(kind=dp), intent(in) :: smr_fixed_en_width
integer, intent(in) :: smr_index
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm
type(settings_type), intent(inout) :: settings
real(kind=dp) :: smr_max_arg
real(kind=dp) :: gyrotropic_box_tmp(3)
integer :: i, ierr, loop
logical :: found
character(len=maxlen) :: ctmp
! Stepan
call w90_readwrite_get_keyword(settings, 'gyrotropic_task', found, error, comm, &
c_value=pw90_gyrotropic%task)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'gyrotropic_degen_thresh', found, error, comm, &
r_value=pw90_gyrotropic%degen_thresh)
if (allocated(error)) return
do i = 1, 3
pw90_gyrotropic%box(i, i) = 1.0_dp
gyrotropic_box_tmp(:) = 0.0_dp
call w90_readwrite_get_keyword_vector(settings, 'gyrotropic_box_b'//achar(48 + i), found, &
3, error, comm, r_value=gyrotropic_box_tmp)
if (allocated(error)) return
if (found) pw90_gyrotropic%box(i, :) = gyrotropic_box_tmp(:)
end do
call w90_readwrite_get_keyword_vector(settings, 'gyrotropic_box_center', found, 3, error, &
comm, r_value=gyrotropic_box_tmp)
if (allocated(error)) return
if (found) pw90_gyrotropic%box_corner(:) = &
gyrotropic_box_tmp(:) - 0.5*(pw90_gyrotropic%box(1, :) + pw90_gyrotropic%box(2, :) + &
pw90_gyrotropic%box(3, :))
call w90_readwrite_get_range_vector(settings, 'gyrotropic_band_list', found, &
pw90_gyrotropic%num_bands, .true., error, comm)
if (allocated(error)) return
if (found) then
if (pw90_gyrotropic%num_bands < 1) then
call set_error_input(error, 'Error: problem reading gyrotropic_band_list', comm)
return
end if
if (allocated(pw90_gyrotropic%band_list)) deallocate (pw90_gyrotropic%band_list)
allocate (pw90_gyrotropic%band_list(pw90_gyrotropic%num_bands), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating gyrotropic_band_list in w90_wannier90_readwrite_read', comm)
return
end if
call w90_readwrite_get_range_vector(settings, 'gyrotropic_band_list', found, &
pw90_gyrotropic%num_bands, .false., error, comm, &
pw90_gyrotropic%band_list)
if (allocated(error)) return
if (any(pw90_gyrotropic%band_list < 1) .or. any(pw90_gyrotropic%band_list > num_wann)) then
call set_error_input(error, 'Error: gyrotropic_band_list asks for a non-valid bands', comm)
return
end if
else
! include all bands in the calculation
pw90_gyrotropic%num_bands = num_wann
if (allocated(pw90_gyrotropic%band_list)) deallocate (pw90_gyrotropic%band_list)
allocate (pw90_gyrotropic%band_list(pw90_gyrotropic%num_bands), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating gyrotropic_band_list in w90_wannier90_readwrite_read', comm)
return
end if
do loop = 1, num_wann
pw90_gyrotropic%band_list(loop) = loop
end do
end if
pw90_gyrotropic%smearing%use_adaptive = .false.
smr_max_arg = 5.0
call w90_readwrite_get_keyword(settings, 'smr_max_arg', found, error, comm, r_value=smr_max_arg)
if (allocated(error)) return
if (found .and. (smr_max_arg <= 0._dp)) then
call set_error_input(error, 'Error: smr_max_arg must be greater than zero', comm)
return
end if
pw90_gyrotropic%smearing%max_arg = smr_max_arg
call w90_readwrite_get_keyword(settings, 'gyrotropic_smr_max_arg', found, error, comm, &
r_value=pw90_gyrotropic%smearing%max_arg)
if (allocated(error)) return
if (found .and. (pw90_gyrotropic%smearing%max_arg <= 0._dp)) then
call set_error_input(error, 'Error: gyrotropic_smr_max_arg must be greater than zero', comm)
return
end if
pw90_gyrotropic%smearing%fixed_width = smr_fixed_en_width
call w90_readwrite_get_keyword(settings, 'gyrotropic_smr_fixed_en_width', found, error, comm, &
r_value=pw90_gyrotropic%smearing%fixed_width)
if (allocated(error)) return
if (found .and. (pw90_gyrotropic%smearing%fixed_width < 0._dp)) then
call set_error_input(error, 'Error: gyrotropic_smr_fixed_en_width must be greater than or equal to zero', comm)
return
end if
! By default: use the "global" smearing index
pw90_gyrotropic%smearing%type_index = smr_index
call w90_readwrite_get_keyword(settings, 'gyrotropic_smr_type', found, error, comm, &
c_value=ctmp)
if (allocated(error)) return
if (found) then
pw90_gyrotropic%smearing%type_index = w90_readwrite_get_smearing_index(ctmp, &
'gyrotropic_smr_type', &
error, comm)
if (allocated(error)) return
end if
end subroutine w90_wannier90_readwrite_read_gyrotropic