private subroutine json_update_integer(p, name, val, found)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(json_value), |
intent(inout), |
|
pointer | :: |
p | |
character(kind=CK,len=*), |
intent(in) |
|
| :: |
name | |
integer(kind=IK), |
intent(in) |
|
| :: |
val | |
logical(kind=LK), |
intent(out) |
|
| :: |
found | |
Description
Given the path string, if the variable is present,
and is a scalar, then update its value.
If it is not present, then create it and set its value.
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
type(json_value), |
public, |
pointer | :: |
p_var | | | |
integer(kind=IK), |
public |
| :: |
var_type | | | |
Source Code
subroutine json_update_integer(p,name,val,found)
implicit none
type(json_value),pointer :: p
character(kind=CK,len=*),intent(in) :: name
integer(IK),intent(in) :: val
logical(LK),intent(out) :: found
type(json_value),pointer :: p_var
integer(IK) :: var_type
call json_get(p,name,p_var,found)
if (found) then
call json_info(p_var,var_type)
select case (var_type)
case (json_null,json_logical,json_integer,json_double,json_string)
call to_integer(p_var,val) !update the value
case default
found = .false.
call throw_exception('Error in json_update_integer: '//&
'the variable is not a scalar value')
end select
else
call json_add(p,name,val) !add the new element
end if
end subroutine json_update_integer