string_to_dble Function

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

Convert a string into a real(RK) value.

Arguments

Type IntentOptional AttributesName
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 string_to_dble proc~string_to_real string_to_real proc~string_to_dble->proc~string_to_real

Contents

Source Code


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]]

    if (.not. json%exception_thrown) then

        call string_to_real(str,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

    else
        rval = 0.0_RK
    end if

    end function string_to_dble