w90_wannier90_readwrite_read_energy_range Subroutine

private subroutine w90_wannier90_readwrite_read_energy_range(settings, pw90_berry, pw90_dos, pw90_gyrotropic, dis_manifold, fermi_energy_list, eigval, pw90_extra_io, error, comm)

Uses

  • proc~~w90_wannier90_readwrite_read_energy_range~~UsesGraph proc~w90_wannier90_readwrite_read_energy_range w90_wannier90_readwrite_read_energy_range module~w90_comms w90_comms proc~w90_wannier90_readwrite_read_energy_range->module~w90_comms module~w90_constants w90_constants proc~w90_wannier90_readwrite_read_energy_range->module~w90_constants module~w90_error w90_error proc~w90_wannier90_readwrite_read_energy_range->module~w90_error 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_berry_mod_type), intent(inout) :: pw90_berry
type(pw90_dos_mod_type), intent(inout) :: pw90_dos
type(pw90_gyrotropic_type), intent(inout) :: pw90_gyrotropic
type(dis_manifold_type), intent(in) :: dis_manifold
real(kind=dp), intent(in), allocatable :: fermi_energy_list(:)
real(kind=dp), intent(in), pointer :: eigval(:,:)
type(pw90_extra_io_type), intent(inout) :: pw90_extra_io
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_wannier90_readwrite_read_energy_range~~CallsGraph proc~w90_wannier90_readwrite_read_energy_range w90_wannier90_readwrite_read_energy_range proc~set_error_alloc set_error_alloc proc~w90_wannier90_readwrite_read_energy_range->proc~set_error_alloc proc~set_error_input set_error_input proc~w90_wannier90_readwrite_read_energy_range->proc~set_error_input proc~w90_readwrite_get_keyword w90_readwrite_get_keyword proc~w90_wannier90_readwrite_read_energy_range->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_energy_range~~CalledByGraph proc~w90_wannier90_readwrite_read_energy_range w90_wannier90_readwrite_read_energy_range proc~w90_postw90_readwrite_read w90_postw90_readwrite_read proc~w90_postw90_readwrite_read->proc~w90_wannier90_readwrite_read_energy_range proc~w90_postw90_readwrite_readall w90_postw90_readwrite_readall proc~w90_postw90_readwrite_readall->proc~w90_wannier90_readwrite_read_energy_range program~postw90 postw90 program~postw90->proc~w90_postw90_readwrite_read

Source Code

  subroutine w90_wannier90_readwrite_read_energy_range(settings, pw90_berry, pw90_dos, &
                                                       pw90_gyrotropic, dis_manifold, &
                                                       fermi_energy_list, eigval, pw90_extra_io, &
                                                       error, comm)
    !================================================!

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

    implicit none

    type(pw90_berry_mod_type), intent(inout) :: pw90_berry
    type(pw90_dos_mod_type), intent(inout) :: pw90_dos
    type(pw90_gyrotropic_type), intent(inout) :: pw90_gyrotropic
    type(dis_manifold_type), intent(in) :: dis_manifold
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm
    type(settings_type), intent(inout) :: settings

    real(kind=dp), allocatable, intent(in) :: fermi_energy_list(:)
    real(kind=dp), pointer, intent(in) :: eigval(:, :)
    type(pw90_extra_io_type), intent(inout) :: pw90_extra_io

    integer :: i, ierr
    logical :: found

    if (dis_manifold%frozen_states) then
      pw90_dos%energy_max = dis_manifold%froz_max + 0.6667_dp
    elseif (associated(eigval)) then
      pw90_dos%energy_max = maxval(eigval) + 0.6667_dp
    else
      pw90_dos%energy_max = dis_manifold%win_max + 0.6667_dp
    end if
    call w90_readwrite_get_keyword(settings, 'dos_energy_max', found, error, comm, &
                                   r_value=pw90_dos%energy_max)
    if (allocated(error)) return

    if (associated(eigval)) then
      pw90_dos%energy_min = minval(eigval) - 0.6667_dp
    else
      pw90_dos%energy_min = dis_manifold%win_min - 0.6667_dp
    end if
    call w90_readwrite_get_keyword(settings, 'dos_energy_min', found, error, comm, &
                                   r_value=pw90_dos%energy_min)
    if (allocated(error)) return

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

    if (dis_manifold%frozen_states) then
      pw90_extra_io%kubo_freq_max = dis_manifold%froz_max - fermi_energy_list(1) + 0.6667_dp
    elseif (associated(eigval)) then
      pw90_extra_io%kubo_freq_max = maxval(eigval) - minval(eigval) + 0.6667_dp
    else
      pw90_extra_io%kubo_freq_max = dis_manifold%win_max - dis_manifold%win_min + 0.6667_dp
    end if
    pw90_extra_io%gyrotropic_freq_max = pw90_extra_io%kubo_freq_max
    call w90_readwrite_get_keyword(settings, 'kubo_freq_max', found, error, comm, &
                                   r_value=pw90_extra_io%kubo_freq_max)
    if (allocated(error)) return

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

    pw90_berry%kubo_nfreq = nint((pw90_extra_io%kubo_freq_max - pw90_extra_io%kubo_freq_min) &
                                 /pw90_extra_io%kubo_freq_step) + 1
    if (pw90_berry%kubo_nfreq <= 1) pw90_berry%kubo_nfreq = 2
    pw90_extra_io%kubo_freq_step = (pw90_extra_io%kubo_freq_max - pw90_extra_io%kubo_freq_min) &
                                   /(pw90_berry%kubo_nfreq - 1)

    if (allocated(pw90_berry%kubo_freq_list)) deallocate (pw90_berry%kubo_freq_list)
    allocate (pw90_berry%kubo_freq_list(pw90_berry%kubo_nfreq), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error allocating kubo_freq_list in w90_wannier90_readwrite_read', comm)
      return
    end if
    do i = 1, pw90_berry%kubo_nfreq
      pw90_berry%kubo_freq_list(i) = pw90_extra_io%kubo_freq_min + &
                                     (i - 1)*(pw90_extra_io%kubo_freq_max - &
                                              pw90_extra_io%kubo_freq_min)/(pw90_berry%kubo_nfreq - 1)
    end do

    ! TODO: Alternatively, read list of (complex) frequencies; kubo_nfreq is
    !       the length of the list

    call w90_readwrite_get_keyword(settings, 'gyrotropic_freq_min', found, error, comm, &
                                   r_value=pw90_extra_io%gyrotropic_freq_min)
    if (allocated(error)) return
    call w90_readwrite_get_keyword(settings, 'gyrotropic_freq_max', found, error, comm, &
                                   r_value=pw90_extra_io%gyrotropic_freq_max)
    if (allocated(error)) return
    call w90_readwrite_get_keyword(settings, 'gyrotropic_freq_step', found, error, comm, &
                                   r_value=pw90_extra_io%gyrotropic_freq_step)
    if (allocated(error)) return
    pw90_gyrotropic%nfreq = nint((pw90_extra_io%gyrotropic_freq_max - &
                                  pw90_extra_io%gyrotropic_freq_min)/ &
                                 pw90_extra_io%gyrotropic_freq_step) + 1
    if (pw90_gyrotropic%nfreq <= 1) pw90_gyrotropic%nfreq = 2
    pw90_extra_io%gyrotropic_freq_step = (pw90_extra_io%gyrotropic_freq_max &
                                          - pw90_extra_io%gyrotropic_freq_min)/ &
                                         (pw90_gyrotropic%nfreq - 1)
    if (allocated(pw90_gyrotropic%freq_list)) deallocate (pw90_gyrotropic%freq_list)
    allocate (pw90_gyrotropic%freq_list(pw90_gyrotropic%nfreq), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error allocating gyrotropic_freq_list in w90_wannier90_readwrite_read', comm)
      return
    end if
    do i = 1, pw90_gyrotropic%nfreq
      pw90_gyrotropic%freq_list(i) = pw90_extra_io%gyrotropic_freq_min &
                                     + (i - 1)*(pw90_extra_io%gyrotropic_freq_max &
                                                - pw90_extra_io%gyrotropic_freq_min)/(pw90_gyrotropic%nfreq - 1) &
                                     + cmplx_i*pw90_gyrotropic%smearing%fixed_width
    end do

    if (dis_manifold%frozen_states) then
      pw90_berry%kubo_eigval_max = dis_manifold%froz_max + 0.6667_dp
    elseif (associated(eigval)) then
      pw90_berry%kubo_eigval_max = maxval(eigval) + 0.6667_dp
    else
      pw90_berry%kubo_eigval_max = dis_manifold%win_max + 0.6667_dp
    end if
    pw90_gyrotropic%eigval_max = pw90_berry%kubo_eigval_max

    call w90_readwrite_get_keyword(settings, 'kubo_eigval_max', found, error, comm, &
                                   r_value=pw90_berry%kubo_eigval_max)
    if (allocated(error)) return
    call w90_readwrite_get_keyword(settings, 'gyrotropic_eigval_max', found, error, comm, &
                                   r_value=pw90_gyrotropic%eigval_max)
    if (allocated(error)) return
  end subroutine w90_wannier90_readwrite_read_energy_range