private subroutine json_get_double_vec(me, vec)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(json_value), |
intent(inout), |
|
pointer | :: |
me | |
real(kind=RK), |
intent(out), |
|
dimension(:), allocatable | :: |
vec | |
Description
Get a double vector from a json_value.
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
logical(kind=LK), |
public |
| :: |
initialized | | | |
Subroutines
subroutine get_double_from_array(element, i, count)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(json_value), |
intent(in), |
|
pointer | :: |
element | |
integer(kind=IK), |
intent(in) |
|
| :: |
i | |
integer(kind=IK), |
intent(in) |
|
| :: |
count | |
Source Code
subroutine json_get_double_vec(me, vec)
implicit none
type(json_value),pointer :: me
real(RK),dimension(:),allocatable,intent(out) :: vec
logical(LK) :: initialized
initialized = .false.
if (allocated(vec)) deallocate(vec)
!the callback function is called for each element of the array:
call json_get(me, array_callback=get_double_from_array)
contains
! callback function for double
subroutine get_double_from_array(element, i, count)
implicit none
type(json_value),pointer,intent(in) :: element
integer(IK),intent(in) :: i !index
integer(IK),intent(in) :: count !size of array
!size the output array:
if (.not. initialized) then
allocate(vec(count))
initialized = .true.
end if
!populate the elements:
call json_get(element, value=vec(i))
end subroutine get_double_from_array
end subroutine json_get_double_vec