w90_wannier90_readwrite_read_wannierise Subroutine

private subroutine w90_wannier90_readwrite_read_wannierise(settings, wann_control, num_wann, stdout, iprint, error, comm)

Uses

  • proc~~w90_wannier90_readwrite_read_wannierise~~UsesGraph proc~w90_wannier90_readwrite_read_wannierise w90_wannier90_readwrite_read_wannierise module~w90_error w90_error proc~w90_wannier90_readwrite_read_wannierise->module~w90_error module~w90_comms w90_comms module~w90_error->module~w90_comms module~w90_error_base w90_error_base module~w90_error->module~w90_error_base module~w90_comms->module~w90_error_base module~w90_constants w90_constants module~w90_comms->module~w90_constants

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
type(wann_control_type), intent(inout) :: wann_control
integer, intent(in) :: num_wann
integer, intent(in) :: stdout
integer, intent(in) :: iprint
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_wannier90_readwrite_read_wannierise~~CallsGraph proc~w90_wannier90_readwrite_read_wannierise w90_wannier90_readwrite_read_wannierise proc~set_error_alloc set_error_alloc proc~w90_wannier90_readwrite_read_wannierise->proc~set_error_alloc proc~set_error_input set_error_input proc~w90_wannier90_readwrite_read_wannierise->proc~set_error_input proc~w90_readwrite_get_keyword w90_readwrite_get_keyword proc~w90_wannier90_readwrite_read_wannierise->proc~w90_readwrite_get_keyword proc~comms_sync_error comms_sync_error proc~set_error_alloc->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_alloc->proc~set_base_error proc~set_error_input->proc~comms_sync_error proc~set_error_input->proc~set_base_error proc~w90_readwrite_get_keyword->proc~set_error_input proc~set_error_fatal set_error_fatal proc~w90_readwrite_get_keyword->proc~set_error_fatal proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~w90_wannier90_readwrite_read_wannierise~~CalledByGraph proc~w90_wannier90_readwrite_read_wannierise w90_wannier90_readwrite_read_wannierise proc~w90_wannier90_readwrite_read w90_wannier90_readwrite_read proc~w90_wannier90_readwrite_read->proc~w90_wannier90_readwrite_read_wannierise proc~w90_input_reader~2 w90_input_reader proc~w90_input_reader~2->proc~w90_wannier90_readwrite_read proc~w90_input_setopt w90_input_setopt proc~w90_input_setopt->proc~w90_wannier90_readwrite_read proc~w90_input_reader w90_input_reader proc~w90_input_reader->proc~w90_input_reader~2 proc~w90_input_setopt_f w90_input_setopt_f proc~w90_input_setopt_f->proc~w90_input_setopt program~wannier wannier program~wannier->proc~w90_input_reader~2

Source Code

  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