w90_readwrite_read_distk Subroutine

public subroutine w90_readwrite_read_distk(settings, distk, nkin, stdout, error, comm)

Uses

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

Read MPI distribution of k-points The array to be read must have num_kpt entries, with each entry being the MPI rank to which each k-point is assigned

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
integer, intent(inout), allocatable :: distk(:)
integer, intent(in) :: nkin
integer, intent(in) :: stdout
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_read_distk~~CallsGraph proc~w90_readwrite_read_distk w90_readwrite_read_distk proc~mpirank mpirank proc~w90_readwrite_read_distk->proc~mpirank proc~mpisize mpisize proc~w90_readwrite_read_distk->proc~mpisize proc~set_error_alloc set_error_alloc proc~w90_readwrite_read_distk->proc~set_error_alloc proc~set_error_fatal set_error_fatal proc~w90_readwrite_read_distk->proc~set_error_fatal proc~set_error_input set_error_input proc~w90_readwrite_read_distk->proc~set_error_input proc~w90_readwrite_get_range_vector w90_readwrite_get_range_vector proc~w90_readwrite_read_distk->proc~w90_readwrite_get_range_vector 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_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 proc~w90_readwrite_get_range_vector->proc~set_error_input proc~w90_readwrite_get_keyword_vector w90_readwrite_get_keyword_vector proc~w90_readwrite_get_range_vector->proc~w90_readwrite_get_keyword_vector proc~w90_readwrite_get_vector_length w90_readwrite_get_vector_length proc~w90_readwrite_get_range_vector->proc~w90_readwrite_get_vector_length proc~w90_readwrite_get_keyword_vector->proc~set_error_fatal proc~w90_readwrite_get_keyword_vector->proc~set_error_input proc~w90_readwrite_get_vector_length->proc~set_error_fatal proc~w90_readwrite_get_vector_length->proc~set_error_input

Called by

proc~~w90_readwrite_read_distk~~CalledByGraph proc~w90_readwrite_read_distk w90_readwrite_read_distk proc~w90_wannier90_readwrite_read_special w90_wannier90_readwrite_read_special proc~w90_wannier90_readwrite_read_special->proc~w90_readwrite_read_distk 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 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_distk(settings, distk, nkin, stdout, error, comm)
    !! Read MPI distribution of k-points
    !! The array to be read must have num_kpt entries, with each entry being
    !! the MPI rank to which each k-point is assigned
    use w90_error, only: w90_error_type, set_error_input, set_error_alloc, set_error_fatal
    use w90_comms, only: mpirank
    implicit none

    integer, allocatable, intent(inout) :: distk(:)
    integer, intent(in) :: nkin
    integer, intent(in) :: stdout
    type(settings_type), intent(inout) :: settings
    type(w90_comm_type), intent(in) :: comm
    type(w90_error_type), allocatable, intent(out) :: error

    integer :: ik, nk, ierr
    logical :: found

    found = .false.

    call w90_readwrite_get_range_vector(settings, 'distk', found, nk, .true., error, comm)
    if (allocated(error)) return

    if (found .and. allocated(settings%in_data)) then ! distk is valid only in library mode, prevent .win abuse
      call set_error_input(error, 'Error: distk is not a .win file input token', comm)
      return
    end if

    if (found) then
      if (nk /= nkin) then
        call set_error_input(error, 'Error: incorrect length of k-distribution (distk)', comm)
        return
      end if
      allocate (distk(nkin), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error in allocating distk in w90_readwrite_read_distk', comm)
        return
      end if
      call w90_readwrite_get_range_vector(settings, 'distk', found, nk, .false., error, comm, distk)
      if (allocated(error)) return

      do ik = 1, nkin
        if (distk(ik) < 0 .or. distk(ik) >= mpisize(comm)) then
          call set_error_fatal(error, 'Rank in distk table outside of mpi_size in w90_readwrite_read_distk', comm)
          return
        end if
      end do
    else
      if (mpirank(comm) == 0) then
        write (stdout, '(a)') 'Note: no parallel distribution provided (option distk missing)'
        write (stdout, '(a)') 'Note: all k-points handled by MPI rank 0'
      end if
      allocate (distk(nkin), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error in allocating distk in w90_readwrite_read_distk', comm)
        return
      end if
      distk = 0 ! default to no distribution if not specified
    end if
  end subroutine w90_readwrite_read_distk