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)


Calls

proc~~string_to_dble~~CallsGraph proc~string_to_dble json_core%string_to_dble none~throw_exception json_core%throw_exception proc~string_to_dble->none~throw_exception proc~json_throw_exception json_core%json_throw_exception none~throw_exception->proc~json_throw_exception proc~wrap_json_throw_exception json_core%wrap_json_throw_exception none~throw_exception->proc~wrap_json_throw_exception proc~wrap_json_throw_exception->none~throw_exception interface~to_unicode to_unicode proc~wrap_json_throw_exception->interface~to_unicode proc~to_uni to_uni interface~to_unicode->proc~to_uni proc~to_uni_vec to_uni_vec interface~to_unicode->proc~to_uni_vec

Called by

proc~~string_to_dble~~CalledByGraph proc~string_to_dble json_core%string_to_dble proc~parse_number json_core%parse_number proc~parse_number->proc~string_to_dble proc~parse_value_nonrecursive parse_value_nonrecursive proc~parse_value_nonrecursive->proc~parse_number proc~parse_value_recursive parse_value_recursive proc~parse_value_recursive->proc~parse_number

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 json%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