w90_wannier90_readwrite_read_berry Subroutine

private subroutine w90_wannier90_readwrite_read_berry(settings, pw90_calculation, pw90_berry, pw90_smearing, error, comm)

Uses

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

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
type(pw90_calculation_type), intent(in) :: pw90_calculation
type(pw90_berry_mod_type), intent(inout) :: pw90_berry
type(pw90_smearing_type), intent(in) :: pw90_smearing
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_wannier90_readwrite_read_berry~~CallsGraph proc~w90_wannier90_readwrite_read_berry w90_wannier90_readwrite_read_berry proc~set_error_alloc set_error_alloc proc~w90_wannier90_readwrite_read_berry->proc~set_error_alloc proc~set_error_input set_error_input proc~w90_wannier90_readwrite_read_berry->proc~set_error_input proc~w90_readwrite_get_keyword w90_readwrite_get_keyword proc~w90_wannier90_readwrite_read_berry->proc~w90_readwrite_get_keyword proc~w90_readwrite_get_keyword_vector w90_readwrite_get_keyword_vector proc~w90_wannier90_readwrite_read_berry->proc~w90_readwrite_get_keyword_vector proc~w90_readwrite_get_range_vector w90_readwrite_get_range_vector proc~w90_wannier90_readwrite_read_berry->proc~w90_readwrite_get_range_vector proc~w90_readwrite_get_smearing_index w90_readwrite_get_smearing_index proc~w90_wannier90_readwrite_read_berry->proc~w90_readwrite_get_smearing_index 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_keyword_vector->proc~set_error_input proc~w90_readwrite_get_keyword_vector->proc~set_error_fatal proc~w90_readwrite_get_range_vector->proc~set_error_input 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_smearing_index->proc~set_error_input proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error proc~w90_readwrite_get_vector_length->proc~set_error_input proc~w90_readwrite_get_vector_length->proc~set_error_fatal

Called by

proc~~w90_wannier90_readwrite_read_berry~~CalledByGraph proc~w90_wannier90_readwrite_read_berry w90_wannier90_readwrite_read_berry proc~w90_postw90_readwrite_read w90_postw90_readwrite_read proc~w90_postw90_readwrite_read->proc~w90_wannier90_readwrite_read_berry proc~w90_postw90_readwrite_readall w90_postw90_readwrite_readall proc~w90_postw90_readwrite_readall->proc~w90_wannier90_readwrite_read_berry program~postw90 postw90 program~postw90->proc~w90_postw90_readwrite_read

Source Code

  subroutine w90_wannier90_readwrite_read_berry(settings, pw90_calculation, pw90_berry, &
                                                pw90_smearing, error, comm)
    !================================================!

    use w90_error, only: w90_error_type
    use w90_comms, only: w90_comm_type

    implicit none
    type(pw90_calculation_type), intent(in) :: pw90_calculation
    type(pw90_berry_mod_type), intent(inout) :: pw90_berry
    type(pw90_smearing_type), intent(in) :: pw90_smearing
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm
    type(settings_type), intent(inout) :: settings

    logical :: found
    integer :: kdotp_num_bands, ierr
    character(len=maxlen)              :: ctmp

!-------------------------------------------------------
!    alpha=0
!    call w90_readwrite_get_keyword(settings, 'alpha',found,i_value=alpha)

!    beta=0
!    call w90_readwrite_get_keyword(settings, 'beta',found,i_value=beta)

!    gamma=0
!    call w90_readwrite_get_keyword(settings, 'gamma',found,i_value=gamma)
!-------------------------------------------------------

    call w90_readwrite_get_keyword(settings, 'transl_inv', found, error, comm, &
                                   l_value=pw90_berry%transl_inv)
    if (allocated(error)) return
    call w90_readwrite_get_keyword(settings, 'transl_inv_full', found, error, comm, &
                                   l_value=pw90_berry%transl_inv_full)
    if (allocated(error)) return
    if (pw90_berry%transl_inv .and. pw90_berry%transl_inv_full) then
      call set_error_input(error, 'Error: If transl_inv_full=T, transl_inv=T is not recommended', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'guiding_centres', found, error, comm, &
                                   l_value=pw90_berry%guiding_centres)

    call w90_readwrite_get_keyword(settings, 'berry_task', found, error, comm, &
                                   c_value=pw90_berry%task)
    if (allocated(error)) return
    if (pw90_calculation%berry .and. .not. found) then
      call set_error_input(error, 'Error: berry=T and berry_task is not set', comm)
      return
    end if
    if (pw90_calculation%berry .and. index(pw90_berry%task, 'ahc') == 0 &
        .and. index(pw90_berry%task, 'morb') == 0 &
        .and. index(pw90_berry%task, 'kubo') == 0 .and. index(pw90_berry%task, 'sc') == 0 &
        .and. index(pw90_berry%task, 'shc') == 0 .and. index(pw90_berry%task, 'kdotp') == 0) then

      call set_error_input(error, 'Error: value of berry_task not recognised in w90_wannier90_readwrite_read', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'berry_curv_adpt_kmesh', found, error, comm, &
                                   i_value=pw90_berry%curv_adpt_kmesh)
    if (allocated(error)) return
    if (pw90_berry%curv_adpt_kmesh < 1) then
      call set_error_input(error, 'Error:  berry_curv_adpt_kmesh must be a positive integer', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'berry_curv_adpt_kmesh_thresh', found, error, comm, &
                                   r_value=pw90_berry%curv_adpt_kmesh_thresh)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'berry_curv_unit', found, error, comm, &
                                   c_value=pw90_berry%curv_unit)
    if (allocated(error)) return
    if (pw90_berry%curv_unit .ne. 'ang2' .and. pw90_berry%curv_unit .ne. 'bohr2') then
      call set_error_input(error, 'Error: value of berry_curv_unit not recognised in w90_wannier90_readwrite_read', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'wanint_kpoint_file', found, error, comm, &
                                   l_value=pw90_berry%wanint_kpoint_file)
    if (allocated(error)) return

!    smear_temp = -1.0_dp
!    call w90_readwrite_get_keyword(settings, 'smear_temp',found,r_value=smear_temp)

    pw90_berry%kubo_smearing%use_adaptive = pw90_smearing%use_adaptive
    call w90_readwrite_get_keyword(settings, 'kubo_adpt_smr', found, error, comm, &
                                   l_value=pw90_berry%kubo_smearing%use_adaptive)
    if (allocated(error)) return

    pw90_berry%kubo_smearing%adaptive_prefactor = pw90_smearing%adaptive_prefactor
    call w90_readwrite_get_keyword(settings, 'kubo_adpt_smr_fac', found, error, comm, &
                                   r_value=pw90_berry%kubo_smearing%adaptive_prefactor)
    if (allocated(error)) return
    if (found .and. (pw90_berry%kubo_smearing%adaptive_prefactor <= 0._dp)) then
      call set_error_input(error, 'Error: kubo_adpt_smr_fac must be greater than zero', comm)
      return
    end if

    pw90_berry%kubo_smearing%adaptive_max_width = pw90_smearing%adaptive_max_width
    call w90_readwrite_get_keyword(settings, 'kubo_adpt_smr_max', found, error, comm, &
                                   r_value=pw90_berry%kubo_smearing%adaptive_max_width)
    if (allocated(error)) return
    if (pw90_berry%kubo_smearing%adaptive_max_width <= 0._dp) then
      call set_error_input(error, 'Error: kubo_adpt_smr_max must be greater than zero', comm)
      return
    end if

    pw90_berry%kubo_smearing%fixed_width = pw90_smearing%fixed_width
    call w90_readwrite_get_keyword(settings, 'kubo_smr_fixed_en_width', found, error, comm, &
                                   r_value=pw90_berry%kubo_smearing%fixed_width)
    if (allocated(error)) return
    if (found .and. (pw90_berry%kubo_smearing%fixed_width < 0._dp)) then
      call set_error_input(error, 'Error: kubo_smr_fixed_en_width must be greater than or equal to zero', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'sc_phase_conv', found, error, comm, &
                                   i_value=pw90_berry%sc_phase_conv)
    if (allocated(error)) return
    if ((pw90_berry%sc_phase_conv .ne. 1) .and. ((pw90_berry%sc_phase_conv .ne. 2))) then
      call set_error_input(error, 'Error: sc_phase_conv must be either 1 or 2', comm)
      return
    end if

    call w90_readwrite_get_keyword(settings, 'sc_use_eta_corr', found, error, comm, &
                                   l_value=pw90_berry%sc_use_eta_corr)
    if (allocated(error)) return

    ! By default: use the "global" smearing index
    pw90_berry%kubo_smearing%type_index = pw90_smearing%type_index
    call w90_readwrite_get_keyword(settings, 'kubo_smr_type', found, error, comm, c_value=ctmp)
    if (allocated(error)) return
    if (found) then
      pw90_berry%kubo_smearing%type_index = w90_readwrite_get_smearing_index(ctmp, 'kubo_smr_type', &
                                                                             error, comm)
      if (allocated(error)) return
    end if

    call w90_readwrite_get_keyword(settings, 'sc_eta', found, error, comm, &
                                   r_value=pw90_berry%sc_eta)
    if (allocated(error)) return

    call w90_readwrite_get_keyword(settings, 'sc_w_thr', found, error, comm, &
                                   r_value=pw90_berry%sc_w_thr)
    if (allocated(error)) return

    call w90_readwrite_get_keyword_vector(settings, 'kdotp_kpoint', found, 3, error, comm, &
                                          r_value=pw90_berry%kdotp_kpoint)
    if (allocated(error)) return

    pw90_berry%tetrahedron_method = .false.
    call w90_readwrite_get_keyword(settings, 'tetrahedron_method', found, error, comm, &
                                   l_value=pw90_berry%tetrahedron_method)
    if (pw90_berry%tetrahedron_method .and. index(pw90_berry%task, 'shc') == 0) &
      call set_error_input(error, 'Error: tetrahedron_method only implemented in the shc routine', comm)
    if (allocated(error)) return

    pw90_berry%tetrahedron_higher_correction = .true.
    call w90_readwrite_get_keyword(settings, 'tetrahedron_higher_correction', found, error, comm, &
                                   l_value=pw90_berry%tetrahedron_higher_correction)
    if (.not. pw90_berry%tetrahedron_higher_correction) call set_error_input &
      (error, 'Error: Set tetrahedron_higher_correction = .true., tetrahedron_method works only with correction', comm)
    if (allocated(error)) return

    pw90_berry%tetrahedron_cutoff = 1.e-4_dp
    call w90_readwrite_get_keyword(settings, 'tetrahedron_cutoff', found, error, comm, &
                                   r_value=pw90_berry%tetrahedron_cutoff)
    if (pw90_berry%tetrahedron_cutoff <= 0._dp) call set_error_input &
      (error, 'Error: tetrahedron_cutoff must be greater than zero', comm)
    if (allocated(error)) return

    pw90_berry%tetrahedron_avoid_degeneracy = 3.e-4_dp
    call w90_readwrite_get_keyword(settings, 'tetrahedron_avoid_degeneracy', found, error, comm, &
                                   r_value=pw90_berry%tetrahedron_avoid_degeneracy)
    if (pw90_berry%tetrahedron_avoid_degeneracy <= 0._dp) call set_error_input &
      (error, 'Error: tetrahedron_avoid_degeneracy must be greater than zero', comm)
    if (allocated(error)) return

    kdotp_num_bands = 0
    call w90_readwrite_get_keyword(settings, 'kdotp_num_bands', found, error, comm, &
                                   i_value=kdotp_num_bands)
    if (allocated(error)) return
    if (found) then
      if (kdotp_num_bands < 1) then
        call set_error_input(error, 'Error: problem reading kdotp_num_bands', comm)
        return
      end if
      allocate (pw90_berry%kdotp_bands(kdotp_num_bands), stat=ierr)
      if (ierr /= 0) then
        call set_error_alloc(error, 'Error allocating kdotp_num_bands in w90_wannier90_readwrite_read', comm)
        return
      end if
      call w90_readwrite_get_range_vector(settings, 'kdotp_bands', found, kdotp_num_bands, &
                                          .false., error, comm, pw90_berry%kdotp_bands)
      if (allocated(error)) return
      if (any(pw90_berry%kdotp_bands < 1)) then
        call set_error_input(error, 'Error: kdotp_bands must contain positive numbers', comm)
        return
      end if
    end if

  end subroutine w90_wannier90_readwrite_read_berry