public subroutine rename(p, finished)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
type(json_value), |
intent(in), |
|
pointer | :: |
p | |
logical, |
intent(out) |
|
| :: |
finished | |
Description
change all "name" variable values to "Fred"
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
integer, |
public |
| :: |
var_type | | | |
character(kind=CK,len=:), |
public, |
allocatable | :: |
str | | | |
logical, |
public |
| :: |
found | | | |
Source Code
subroutine rename(p,finished) !! change all "name" variable values to "Fred"
implicit none
type(json_value),pointer,intent(in) :: p
logical,intent(out) :: finished
integer :: var_type
character(kind=CK,len=:),allocatable :: str
logical :: found
!get info about this variable:
call json_info(p,var_type=var_type,name=str)
!it must be a string named "name":
if (var_type==json_string .and. str=='name') then
call json_get(p,'@',str) ! get original name
call json_update(p,'@','Fred',found) !change it
write(error_unit,'(A)') str//' name changed'
icount = icount + 1
end if
!cleanup:
if (allocated(str)) deallocate(str)
!always false, since we want to traverse all nodes:
finished = .false.
end subroutine rename