get_smearing_index Function

private function get_smearing_index(string, keyword)

Uses

  • proc~~get_smearing_index~~UsesGraph proc~get_smearing_index get_smearing_index module~w90_io w90_io proc~get_smearing_index->module~w90_io module~w90_constants w90_constants module~w90_io->module~w90_constants

This function parses a string containing the type of smearing and returns the correct index for the smearing_index variable

If the string is not valid, an io_error is issued

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: string

The string read from input

character(len=*), intent(in) :: keyword

The keyword that was read (e.g., smr_type), so that we can print a more useful error message

Return Value integer


Called by

proc~~get_smearing_index~~CalledByGraph proc~get_smearing_index get_smearing_index proc~param_read param_read proc~param_read->proc~get_smearing_index program~wannier wannier program~wannier->proc~param_read proc~wannier_run wannier_run proc~wannier_run->proc~param_read proc~wannier_setup wannier_setup proc~wannier_setup->proc~param_read program~postw90 postw90 program~postw90->proc~param_read

Contents

Source Code


Source Code

  function get_smearing_index(string, keyword)
    !! This function parses a string containing the type of
    !! smearing and returns the correct index for the smearing_index variable
    !
    !! If the string is not valid, an io_error is issued
    use w90_io, only: io_error
    character(len=*), intent(in) :: string
    !! The string read from input
    character(len=*), intent(in) :: keyword
    !! The keyword that was read (e.g., smr_type), so that we can print a more useful error message
    integer :: get_smearing_index

    integer :: pos

    get_smearing_index = 0 ! To avoid warnings of unset variables

    if (index(string, 'm-v') > 0) then
      get_smearing_index = -1
    elseif (index(string, 'm-p') > 0) then
      pos = index(string, 'm-p')
      if (len(trim(string(pos + 3:))) .eq. 0) then
        ! If the string is only 'm-p', we assume that 'm-p1' was intended
        get_smearing_index = 1
      else
        read (string(pos + 3:), *, err=337) get_smearing_index
        if (get_smearing_index < 0) &
          call io_error('Wrong m-p smearing order in keyword '//trim(keyword))
      end if
    elseif (index(string, 'f-d') > 0) then
      get_smearing_index = -99
      ! Some aliases
    elseif (index(string, 'cold') > 0) then
      get_smearing_index = -1
    elseif (index(string, 'gauss') > 0) then
      get_smearing_index = 0
      ! Unrecognised keyword
    else
      call io_error('Unrecognised value for keyword '//trim(keyword))
    end if

    return

337 call io_error('Wrong m-p smearing order in keyword '//trim(keyword))

  end function get_smearing_index