subroutine w90_wannier90_readwrite_read_wannierise(settings, wann_control, num_wann, &
stdout, iprint, error, comm)
!================================================!
! Wannierise
!================================================!
use w90_error, only: w90_error_type
implicit none
! arguments
integer, intent(in) :: num_wann
integer, intent(in) :: stdout
integer, intent(in) :: iprint
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
type(wann_control_type), intent(inout) :: wann_control
! local variables
integer :: ierr
logical :: found
call w90_readwrite_get_keyword(settings, 'num_dump_cycles', found, error, comm, &
i_value=wann_control%num_dump_cycles)
if (allocated(error)) return
if (wann_control%num_dump_cycles < 0) then
call set_error_input(error, 'Error: num_dump_cycles must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'num_print_cycles', found, error, comm, &
i_value=wann_control%num_print_cycles)
if (allocated(error)) return
if (wann_control%num_print_cycles < 0) then
call set_error_input(error, 'Error: num_print_cycles must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'num_iter', found, error, comm, &
i_value=wann_control%num_iter)
if (allocated(error)) return
if (wann_control%num_iter < 0) then
call set_error_input(error, 'Error: num_iter must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'num_cg_steps', found, error, comm, &
i_value=wann_control%num_cg_steps)
if (allocated(error)) return
if (wann_control%num_cg_steps < 0) then
call set_error_input(error, 'Error: num_cg_steps must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'conv_noise_amp', found, error, comm, &
r_value=wann_control%conv_noise_amp)
if (allocated(error)) return
! note that the default here is not to check convergence
wann_control%conv_window = -1
if (wann_control%conv_noise_amp > 0.0_dp) wann_control%conv_window = 5
call w90_readwrite_get_keyword(settings, 'conv_window', found, error, comm, &
i_value=wann_control%conv_window)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'conv_tol', found, error, comm, &
r_value=wann_control%conv_tol)
if (allocated(error)) return
if (wann_control%conv_tol < 0.0_dp) then
call set_error_input(error, 'Error: conv_tol must be positive', comm)
return
end if
if (found .and. wann_control%conv_window .le. 1) then
if (iprint > 0) then
write (stdout, '(a)') ' Warning: conv_window is not set to a value greater than 1, &
&so conv_tol is ignored and wannierisation will always run for num_iter iterations.&
&Set conv_window to a value greater than 1 if you want the minimisation &
&to stop early once the spread change is below conv_tol for that many &
&consecutive iterations.'
end if
end if
call w90_readwrite_get_keyword(settings, 'conv_noise_num', found, error, comm, &
i_value=wann_control%conv_noise_num)
if (allocated(error)) return
if (wann_control%conv_noise_num < 0) then
call set_error_input(error, 'Error: conv_noise_num must be positive', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'guiding_centres', found, error, comm, &
l_value=wann_control%guiding_centres%enable)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'use_ss_functional', found, error, comm, &
l_value=wann_control%use_ss_functional)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'num_guide_cycles', found, error, comm, &
i_value=wann_control%guiding_centres%num_guide_cycles)
if (allocated(error)) return
if (wann_control%guiding_centres%num_guide_cycles < 0) then
call set_error_input(error, 'Error: num_guide_cycles must be >= 0', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'num_no_guide_iter', found, error, comm, &
i_value=wann_control%guiding_centres%num_no_guide_iter)
if (allocated(error)) return
if (wann_control%guiding_centres%num_no_guide_iter < 0) then
call set_error_input(error, 'Error: num_no_guide_iter must be >= 0', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'fixed_step', found, error, comm, &
r_value=wann_control%fixed_step)
if (allocated(error)) return
if (found .and. (wann_control%fixed_step < 0.0_dp)) then
call set_error_input(error, 'Error: fixed_step must be > 0', comm)
return
end if
if (wann_control%fixed_step > 0.0_dp) wann_control%lfixstep = .true.
call w90_readwrite_get_keyword(settings, 'trial_step', found, error, comm, &
r_value=wann_control%trial_step)
if (allocated(error)) return
if (found .and. wann_control%lfixstep) then
call set_error_input(error, 'Error: cannot specify both fixed_step and trial_step', comm)
return
end if
call w90_readwrite_get_keyword(settings, 'precond', found, error, comm, &
l_value=wann_control%precond)
if (allocated(error)) return
wann_control%constrain%slwf_num = num_wann
call w90_readwrite_get_keyword(settings, 'slwf_num', found, error, comm, &
i_value=wann_control%constrain%slwf_num)
if (allocated(error)) return
if (found) then
if (wann_control%constrain%slwf_num .gt. num_wann .or. &
wann_control%constrain%slwf_num .lt. 1) then
call set_error_input(error, 'Error: slwf_num must be an integer between 1 and num_wann', comm)
return
end if
if (wann_control%constrain%slwf_num .lt. num_wann) &
wann_control%constrain%selective_loc = .true.
end if
call w90_readwrite_get_keyword(settings, 'slwf_constrain', found, error, comm, &
l_value=wann_control%constrain%constrain)
if (allocated(error)) return
if (found .and. wann_control%constrain%constrain) then
if (wann_control%constrain%selective_loc) then
allocate (wann_control%constrain%centres(num_wann, 3), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating wann_control%constrain%centres &
& w90_wannier90_readwrite_read_wannierise', comm)
return
end if
else
write (stdout, *) ' No selective localisation requested. Ignoring constraints on centres'
wann_control%constrain%constrain = .false.
end if
end if
call w90_readwrite_get_keyword(settings, 'slwf_lambda', found, error, comm, &
r_value=wann_control%constrain%lambda)
if (allocated(error)) return
if (found) then
if (wann_control%constrain%lambda < 0.0_dp) then
call set_error_input(error, 'Error: slwf_lambda must be positive.', comm)
return
end if
end if
end subroutine w90_wannier90_readwrite_read_wannierise