Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in) | :: | name | |||
real(kind=dp), | intent(in), | optional | :: | range(2) | ||
real(kind=dp), | intent(in), | optional | :: | value | ||
integer, | intent(in), | optional | :: | int_range(2) | ||
integer, | intent(in), | optional | :: | int_value | ||
integer, | intent(in), | optional | :: | counter | ||
integer, | intent(in), | optional | :: | index |
subroutine out_of_range_error(name, range, value, int_range, int_value, counter, index)
! Abstracted fatal error used in check_range and check_int_range
character(*), intent(in) :: name
real(dp), intent(in), optional :: value, range(2)
integer, intent(in), optional :: int_value, int_range(2), counter, index
character(len=64) strvalue
character(len=2*len(strvalue)) strrange, strat
strrange = ""
strvalue = ""
if (present(range)) then
if (present(value)) strvalue = to_string(value)
strrange = trim(to_string(range(1)))//" - "//to_string(range(2))
else if (present(int_range)) then
if (present(int_value)) strvalue = to_string(int=int_value)
strrange = trim(to_string(int=int_range(1)))//" - "//to_string(int=int_range(2))
else
call log_error("out_of_range_error", "range or int_range must be given")
end if
! Array with counter
if (present(counter)) then
call log_error("out_of_range_error", "Number of values of "//name//" are out "// &
"of range ("//trim(strrange)//")", int=counter)
! Single value with/without index
else
strat = ""
if (present(index)) strat = "("//trim(to_string(int=index))//")"
call log_error("out_of_range_error", name//trim(strat)//" = "//trim(strvalue)// &
" is out of range", reals=range)
end if
end subroutine out_of_range_error