w90_readwrite_read_kmesh_data Subroutine

public subroutine w90_readwrite_read_kmesh_data(settings, kmesh_input, error, comm)

Uses

  • proc~~w90_readwrite_read_kmesh_data~~UsesGraph proc~w90_readwrite_read_kmesh_data w90_readwrite_read_kmesh_data module~w90_error w90_error proc~w90_readwrite_read_kmesh_data->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

Reads finite-difference input variables: "search_shells" "kmesh_tol" "shell_list" "num_shells" "skip_B1_tests"

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
type(kmesh_input_type), intent(inout) :: kmesh_input
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_read_kmesh_data~~CallsGraph proc~w90_readwrite_read_kmesh_data w90_readwrite_read_kmesh_data proc~set_error_alloc set_error_alloc proc~w90_readwrite_read_kmesh_data->proc~set_error_alloc proc~set_error_input set_error_input proc~w90_readwrite_read_kmesh_data->proc~set_error_input proc~w90_readwrite_get_keyword w90_readwrite_get_keyword proc~w90_readwrite_read_kmesh_data->proc~w90_readwrite_get_keyword proc~w90_readwrite_get_range_vector w90_readwrite_get_range_vector proc~w90_readwrite_read_kmesh_data->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_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~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~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error proc~w90_readwrite_get_keyword_vector->proc~set_error_input proc~w90_readwrite_get_keyword_vector->proc~set_error_fatal proc~w90_readwrite_get_vector_length->proc~set_error_input proc~w90_readwrite_get_vector_length->proc~set_error_fatal

Called by

proc~~w90_readwrite_read_kmesh_data~~CalledByGraph proc~w90_readwrite_read_kmesh_data w90_readwrite_read_kmesh_data proc~w90_postw90_readwrite_read w90_postw90_readwrite_read proc~w90_postw90_readwrite_read->proc~w90_readwrite_read_kmesh_data proc~w90_wannier90_readwrite_read_special w90_wannier90_readwrite_read_special proc~w90_wannier90_readwrite_read_special->proc~w90_readwrite_read_kmesh_data 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_kmesh_data(settings, kmesh_input, error, comm)
    !! Reads finite-difference input variables:
    !!   "search_shells"
    !!   "kmesh_tol"
    !!   "shell_list"
    !!   "num_shells"
    !!   "skip_B1_tests"
    use w90_error, only: w90_error_type, set_error_input, set_error_alloc
    implicit none
    type(kmesh_input_type), intent(inout) :: kmesh_input
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm
    type(settings_type), intent(inout) :: settings

    integer :: itmp, ierr
    logical :: found
    integer :: n

    call w90_readwrite_get_keyword(settings, 'search_shells', found, error, comm, &
                                   i_value=kmesh_input%search_shells)
    if (allocated(error)) return
    if (kmesh_input%search_shells < 0) then
      call set_error_input(error, 'Error: search_shells must be positive', comm)
      return
    end if
    call w90_readwrite_get_keyword(settings, 'search_supcell_size', found, error, comm, &
                                   i_value=kmesh_input%search_supcell_size)
    if (allocated(error)) return
    if (kmesh_input%search_supcell_size < 0) then
      call set_error_input(error, 'Error: search_supcell_size must be positive', comm)
      return
    end if
    call w90_readwrite_get_keyword(settings, 'higher_order_n', found, error, comm, &
                                   i_value=kmesh_input%higher_order_n)
    if (allocated(error)) return
    if (kmesh_input%higher_order_n < 0) then
      call set_error_input(error, 'Error: higher_order_n must be positive', comm)
      return
    end if

    n = kmesh_input%higher_order_n
    kmesh_input%max_shells_h = n*(4*n**2 + 15*n + 17)/6
    kmesh_input%max_shells_aux = kmesh_input%max_shells_h
    kmesh_input%num_nnmax_h = 2*kmesh_input%max_shells_h

    call w90_readwrite_get_keyword(settings, 'higher_order_nearest_shells', found, error, comm, &
                                   l_value=kmesh_input%higher_order_nearest_shells)
    if (allocated(error)) return
    if (.not. kmesh_input%higher_order_nearest_shells) then
      kmesh_input%max_shells_aux = 6
    end if

    ! override mechanism for cases where automatic determination of b-vector shells fails
    call w90_readwrite_get_keyword(settings, 'kmesh_shell_from_file', found, error, comm, &
                                   l_value=kmesh_input%kmesh_shell_from_file)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'kmesh_tol', found, error, comm, &
                                   r_value=kmesh_input%tol)
    if (allocated(error)) return
    if (kmesh_input%tol < 0.0_dp) then
      call set_error_input(error, 'Error: kmesh_tol must be positive', comm)
      return
    end if

    call w90_readwrite_get_range_vector(settings, 'shell_list', found, kmesh_input%num_shells, &
                                        .true., error, comm)
    if (allocated(error)) return
    if (found) then
      if (kmesh_input%num_shells < 0 .or. kmesh_input%num_shells > kmesh_input%max_shells_h) then
        call set_error_input(error, 'Error: number of shell in shell_list must be between zero and kmesh_input%max_shells_h', comm)
        return
      end if
      allocate (kmesh_input%shell_list(kmesh_input%num_shells), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating shell_list in w90_readwrite_read_kmesh_data', comm)
        return
      end if
      call w90_readwrite_get_range_vector(settings, 'shell_list', found, kmesh_input%num_shells, &
                                          .false., error, comm, kmesh_input%shell_list)
      if (allocated(error)) return
      if (any(kmesh_input%shell_list < 1)) then
        call set_error_input(error, 'Error: shell_list must contain positive numbers', comm)
        return
      end if
    else
      ! this is the default allocation of the shell_list--used by kmesh_shell_automatic()
      allocate (kmesh_input%shell_list(kmesh_input%max_shells_h), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating shell_list in w90_readwrite_read_kmesh_data', comm)
        return
      end if
    end if

    call w90_readwrite_get_keyword(settings, 'num_shells', found, error, comm, i_value=itmp)
    if (allocated(error)) return
    if (found .and. (itmp /= kmesh_input%num_shells)) then
      call set_error_input(error, &
                           'Error: Found obsolete keyword num_shells. Its value does not agree with shell_list', comm)
      return
    end if

    ! If .true., does not perform the check of B1 of
    ! Marzari, Vanderbild, PRB 56, 12847 (1997)
    ! in kmesh.F90
    ! mainly needed for the interaction with Z2PACK
    ! By default: .false. (perform the tests)
    call w90_readwrite_get_keyword(settings, 'skip_b1_tests', found, error, comm, &
                                   l_value=kmesh_input%skip_B1_tests)
    if (allocated(error)) return
  end subroutine w90_readwrite_read_kmesh_data