Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jf_test_01 for NVHPC by removing unnecessary function in function #549

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 32 additions & 39 deletions src/json_value_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9530,58 +9530,51 @@ end subroutine json_get_array
! This routine calls the user-specified [[json_traverse_callback_func]]
! for each element of the structure.

subroutine json_traverse(json,p,traverse_callback)
recursive subroutine json_traverse(json,p,traverse_callback)

implicit none

class(json_core),intent(inout) :: json
type(json_value),pointer,intent(in) :: p
procedure(json_traverse_callback_func) :: traverse_callback

logical(LK) :: finished !! can be used to stop the process

if (.not. json%exception_thrown) call traverse(p)

contains

recursive subroutine traverse(p)

!! recursive [[json_value]] traversal.

implicit none

type(json_value),pointer,intent(in) :: p
type(json_value),pointer :: element !! a child element
integer(IK) :: i !! counter
integer(IK) :: icount !! number of children

type(json_value),pointer :: element !! a child element
integer(IK) :: i !! counter
integer(IK) :: icount !! number of children
logical(LK) :: finished !! can be used to stop the process

if (json%exception_thrown) return
call traverse_callback(json,p,finished) ! first call for this object
if (finished) return
if (json%exception_thrown) return

!for arrays and objects, have to also call for all children:
if (p%var_type==json_array .or. p%var_type==json_object) then

icount = json%count(p) ! number of children
if (icount>0) then
element => p%children ! first one
do i = 1, icount ! call for each child
if (.not. associated(element)) then
call json%throw_exception('Error in json_traverse: '//&
'Malformed JSON linked list')
return
end if
call traverse(element)
if (finished .or. json%exception_thrown) exit
element => element%next
end do
end if
nullify(element)
!! recursive [[json_value]] traversal.

if (json%exception_thrown) return
call traverse_callback(json,p,finished) ! first call for this object
if (finished) return

!for arrays and objects, have to also call for all children:
if (p%var_type==json_array .or. p%var_type==json_object) then

print *, loc(p), associated(p)
icount = json%count(p) ! number of children
print *, icount
if (icount>0) then
print *, icount, ">0"
element => p%children ! first one
do i = 1, icount ! call for each child
if (.not. associated(element)) then
call json%throw_exception('Error in json_traverse: '//&
'Malformed JSON linked list')
return
end if
call json%traverse(element, traverse_callback)
if (finished .or. json%exception_thrown) exit
element => element%next
end do
end if
nullify(element)

end subroutine traverse
end if

end subroutine json_traverse
!*****************************************************************************************
Expand Down