subroutine add_variables_to_input(json, me, variable, units, frame, center, rdata, error_cnt)
!Used by test_2.
implicit none
type(json_core),intent(inout) :: json
type(json_value),pointer :: me
character(len=*),intent(in) :: variable, units, frame, center
real(wp),dimension(:),intent(in) :: rdata
integer, intent(inout) :: error_cnt
type(json_value),pointer :: var !a variable in the trajectory:
!initialize:
nullify(var)
!create the object before data can be added:
call json%create_object(var,'') !name does not matter
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
!variable info:
call json%add(var, 'VARIABLE',trim(variable))
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
call json%add(var, 'UNITS', trim(units))
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
call json%add(var, 'FRAME', trim(frame))
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
call json%add(var, 'CENTER', trim(center))
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
!trajectory [vector of reals]:
call json%add(var, 'DATA', rdata)
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
!add this variable to trajectory structure:
call json%add(me, var)
if (json%failed()) then
call json%print_error_message(error_unit)
error_cnt = error_cnt + 1
end if
!cleanup:
nullify(var)
end subroutine add_variables_to_input