private subroutine json_get_integer_vec_with_path(me, path, vec, found)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(json_value), |
intent(inout), |
|
pointer | :: |
me | |
character(kind=CK,len=*), |
intent(in) |
|
| :: |
path | |
integer(kind=IK), |
intent(out), |
|
dimension(:), allocatable | :: |
vec | |
logical(kind=LK), |
intent(out), |
optional |
| :: |
found | |
Description
Get an integer vector from a json_value, given the path string.
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
logical(kind=LK), |
public |
| :: |
initialized | | | |
Subroutines
subroutine get_int_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_integer_vec_with_path(me, path, vec, found)
implicit none
type(json_value),pointer :: me
character(kind=CK,len=*),intent(in) :: path
integer(IK),dimension(:),allocatable,intent(out) :: vec
logical(LK),intent(out),optional :: found
logical(LK) :: initialized
initialized = .false.
call json_get(me, path=path, array_callback=get_int_from_array, found=found)
! need to duplicate callback function, no other way
contains
! callback function for integer
subroutine get_int_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_int_from_array
end subroutine json_get_integer_vec_with_path