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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| 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 |
||
| type(w90_error_type), | intent(out), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm |
function w90_readwrite_get_smearing_index(string, keyword, error, comm) !! 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_error, only: w90_error_type, set_error_input 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 type(w90_comm_type), intent(in) :: comm type(w90_error_type), allocatable, intent(out) :: error integer :: w90_readwrite_get_smearing_index integer :: pos w90_readwrite_get_smearing_index = 0 ! To avoid warnings of unset variables if (index(string, 'm-v') > 0) then w90_readwrite_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 w90_readwrite_get_smearing_index = 1 else read (string(pos + 3:), *, err=337) w90_readwrite_get_smearing_index if (w90_readwrite_get_smearing_index < 0) then call set_error_input(error, 'Wrong m-p smearing order in keyword '//trim(keyword), comm) return end if end if elseif (index(string, 'f-d') > 0) then w90_readwrite_get_smearing_index = -99 ! Some aliases elseif (index(string, 'cold') > 0) then w90_readwrite_get_smearing_index = -1 elseif (index(string, 'gauss') > 0) then w90_readwrite_get_smearing_index = 0 ! Unrecognised keyword else call set_error_input(error, 'Unrecognised value for keyword '//trim(keyword), comm) return end if return 337 call set_error_input(error, 'Wrong m-p smearing order in keyword '//trim(keyword), comm) return end function w90_readwrite_get_smearing_index