infer_variable_type Subroutine

private subroutine infer_variable_type(str, itype)

Infers the variable type, assuming the following precedence:

  • integer
  • double
  • logical
  • character

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str
integer, intent(out) :: itype

Calls

proc~~infer_variable_type~~CallsGraph proc~infer_variable_type infer_variable_type proc~to_integer to_integer proc~infer_variable_type->proc~to_integer proc~to_logical to_logical proc~infer_variable_type->proc~to_logical proc~to_real_wp to_real_wp proc~infer_variable_type->proc~to_real_wp proc~lowercase_string lowercase_string proc~to_logical->proc~lowercase_string

Called by

proc~~infer_variable_type~~CalledByGraph proc~infer_variable_type infer_variable_type proc~variable_types csv_file%variable_types proc~variable_types->proc~infer_variable_type

Source Code

    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