to_double Subroutine

private subroutine to_double(json, p, val, name)

Change the json_value variable to a double.

Arguments

Type IntentOptional AttributesName
class(json_core), intent(inout) :: json
type(json_value), pointer:: p
real(kind=RK), intent(in), optional :: val

if the value is also to be set (if not present, then 0.0_rk is used).

character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.


Calls

proc~~to_double~~CallsGraph proc~to_double to_double proc~destroy_json_data destroy_json_data proc~to_double->proc~destroy_json_data

Contents

Source Code


Source Code

    subroutine to_double(json,p,val,name)

    implicit none

    class(json_core),intent(inout)               :: json
    type(json_value),pointer                     :: p
    real(RK),intent(in),optional                 :: val   !! if the value is also to be set
                                                          !! (if not present, then 0.0_rk is used).
    character(kind=CK,len=*),intent(in),optional :: name  !! if the name is also to be changed.

    !set type and value:
    call destroy_json_data(p)
    p%var_type = json_double
    allocate(p%dbl_value)
    if (present(val)) then
        p%dbl_value = val
    else
        p%dbl_value = 0.0_RK    !default value
    end if

    !name:
    if (present(name)) call json%rename(p,name)

    end subroutine to_double