json_get_real32_vec_by_path Subroutine

private subroutine json_get_real32_vec_by_path(json, me, path, vec, found, default)

Alternate version of json_get_real_vec_by_path where vec is real32.

Arguments

Type IntentOptional AttributesName
class(json_core), intent(inout) :: json
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
real(kind=real32), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found
real(kind=real32), intent(in), optional dimension(:):: default

default value if not found


Contents


Source Code

    subroutine json_get_real32_vec_by_path(json, me, path, vec, found, default)

    implicit none

    class(json_core),intent(inout)                    :: json
    type(json_value),pointer,intent(in)               :: me
    character(kind=CK,len=*),intent(in)               :: path
    real(real32),dimension(:),allocatable,intent(out) :: vec
    logical(LK),intent(out),optional                  :: found
    real(real32),dimension(:),intent(in),optional     :: default !! default value if not found

    real(RK),dimension(:),allocatable :: tmp
    real(RK),dimension(:),allocatable :: tmp_default

    if (present(default)) then
        tmp_default = real(default,RK)
        call json%get(me, path, tmp, found, tmp_default)
    else
        call json%get(me, path, tmp, found)
    end if

    if (allocated(tmp)) vec = real(tmp,real32)

    end subroutine json_get_real32_vec_by_path