Infers the variable type, assuming the following precedence:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str | |||
integer, | intent(out) | :: | itype |
subroutine infer_variable_type(str,itype) implicit none character(len=*),intent(in) :: str integer,intent(out) :: itype real(wp) :: rval !! a real value integer(ip) :: ival !! an iteger value logical :: lval !! a logical value logical :: status_ok !! status flag call to_integer(str,ival,status_ok) if (status_ok) then itype = csv_type_integer return end if call to_real_wp(str,rval,status_ok) if (status_ok) then itype = csv_type_double return end if call to_logical(str,lval,status_ok) if (status_ok) then itype = csv_type_logical return end if ! default is string: itype = csv_type_string end subroutine infer_variable_type