w90_readwrite_read_kpoints Subroutine

public subroutine w90_readwrite_read_kpoints(settings, pw90_effective_model, kpt_latt, num_kpts, mp_grid, bohr, error, comm)

Uses

  • proc~~w90_readwrite_read_kpoints~~UsesGraph proc~w90_readwrite_read_kpoints w90_readwrite_read_kpoints module~w90_error w90_error proc~w90_readwrite_read_kpoints->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
logical, intent(in) :: pw90_effective_model
real(kind=dp), intent(out), allocatable :: kpt_latt(:,:)
integer, intent(in) :: num_kpts
integer, intent(in) :: mp_grid(3)
real(kind=dp), intent(in) :: bohr
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_read_kpoints~~CallsGraph proc~w90_readwrite_read_kpoints w90_readwrite_read_kpoints proc~set_error_alloc set_error_alloc proc~w90_readwrite_read_kpoints->proc~set_error_alloc proc~set_error_dealloc set_error_dealloc proc~w90_readwrite_read_kpoints->proc~set_error_dealloc proc~w90_readwrite_get_keyword_block w90_readwrite_get_keyword_block proc~w90_readwrite_read_kpoints->proc~w90_readwrite_get_keyword_block 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_dealloc->proc~comms_sync_error proc~set_error_dealloc->proc~set_base_error proc~set_error_fatal set_error_fatal proc~w90_readwrite_get_keyword_block->proc~set_error_fatal proc~set_error_input set_error_input proc~w90_readwrite_get_keyword_block->proc~set_error_input proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error proc~set_error_input->proc~comms_sync_error proc~set_error_input->proc~set_base_error

Called by

proc~~w90_readwrite_read_kpoints~~CalledByGraph proc~w90_readwrite_read_kpoints w90_readwrite_read_kpoints proc~w90_postw90_readwrite_read w90_postw90_readwrite_read proc~w90_postw90_readwrite_read->proc~w90_readwrite_read_kpoints proc~w90_wannier90_readwrite_read_special w90_wannier90_readwrite_read_special proc~w90_wannier90_readwrite_read_special->proc~w90_readwrite_read_kpoints proc~input_reader_special input_reader_special proc~input_reader_special->proc~w90_wannier90_readwrite_read_special proc~w90_input_setopt w90_input_setopt proc~w90_input_setopt->proc~w90_wannier90_readwrite_read_special program~postw90 postw90 program~postw90->proc~w90_postw90_readwrite_read proc~w90_input_setopt_f w90_input_setopt_f proc~w90_input_setopt_f->proc~w90_input_setopt program~wannier wannier program~wannier->proc~input_reader_special

Source Code

  subroutine w90_readwrite_read_kpoints(settings, pw90_effective_model, kpt_latt, num_kpts, mp_grid, &
                                        bohr, error, comm)
    use w90_error, only: w90_error_type, set_error_input, set_error_alloc, set_error_dealloc
    implicit none

    ! arguments
    integer, intent(in) :: num_kpts, mp_grid(3)
    logical, intent(in) :: pw90_effective_model
    real(kind=dp), allocatable, intent(out) :: kpt_latt(:, :)
    real(kind=dp), intent(in) :: bohr
    type(settings_type), intent(inout) :: settings
    type(w90_comm_type), intent(in) :: comm
    type(w90_error_type), allocatable, intent(out) :: error

    ! local variables
    real(kind=dp), allocatable :: kpt_cart(:, :)
    integer :: ierr, ia, ib, ic, ik
    logical :: found

    ! pw90_effective_model ignores kpt_cart
    ! this routine allocates the intent(out) kpt_latt

    ierr = 0

    allocate (kpt_latt(3, num_kpts), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error allocating kpt_latt in w90_readwrite_read_kpoints', comm)
      return
    end if

    if (.not. pw90_effective_model) then
      allocate (kpt_cart(3, num_kpts), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating kpt_cart in w90_readwrite_read_kpoints', comm)
        return
      end if

      call w90_readwrite_get_keyword_block(settings, 'kpoints', found, num_kpts, 3, bohr, error, &
                                           comm, r_value=kpt_cart)
      if (allocated(error)) return
      !if (.not. found) then
      !  call set_error_input(error, 'Error: Did not find the kpoint information in the input file', comm)
      !  return
      !endif
      if (.not. found) then
        ik = 1
        do ia = 1, mp_grid(1)
          do ib = 1, mp_grid(2)
            do ic = 1, mp_grid(3)
              kpt_cart(1, ik) = real(ia - 1, kind=dp)/mp_grid(1)
              kpt_cart(2, ik) = real(ib - 1, kind=dp)/mp_grid(2)
              kpt_cart(3, ik) = real(ic - 1, kind=dp)/mp_grid(3)
              ik = ik + 1
            end do
          end do
        end do
      end if
      kpt_latt = kpt_cart

      deallocate (kpt_cart, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error deallocating kpt_cart in w90_readwrite_read_kpoints', comm)
        return
      end if
    end if
  end subroutine w90_readwrite_read_kpoints