string_to_dble Function

private function string_to_dble(json, str) result(rval)

Convert a string into a real(RK) value.

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
class(json_core), intent(inout) :: json
character(kind=CK, len=*), intent(in) :: str

a string

Return Value real(kind=RK)

str converted to a real(RK)


Source Code

    function string_to_dble(json,str) result(rval)

    implicit none

    class(json_core),intent(inout)      :: json
    character(kind=CK,len=*),intent(in) :: str   !! a string
    real(RK)                            :: rval  !! `str` converted to a `real(RK)`

    logical(LK) :: status_ok  !! error flag for [[string_to_real]]

    call string_to_real(str,json%use_quiet_nan,rval,status_ok)

    if (.not. status_ok) then    !if there was an error
        rval = 0.0_RK
        call json%throw_exception('Error in string_to_dble: '//&
                                  'string cannot be converted to a real: '//&
                                  trim(str))
    end if

    end function string_to_dble