Recursive function making a deep copy of stack_entry
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mimic_stack_entry), | intent(in) | :: | src | Source entry |
||
type(mimic_stack_entry), | intent(out), | target | :: | dst | Result |
recursive subroutine copy_entry(src, dst)
!> Source entry
type(mimic_stack_entry), intent(in) :: src
!> Result
type(mimic_stack_entry), intent(out), target :: dst
integer :: i
dst%name = src%name
dst%hash = src%hash
dst%num_calls = src%num_calls
dst%parent => src%parent
if (allocated(src%start_times)) then
allocate(dst%start_times(size(src%start_times)))
allocate(dst%end_times(size(src%end_times)))
dst%start_times = src%start_times
dst%end_times = src%end_times
endif
dst%num_children = src%num_children
if (associated(src%children) .and. src%num_children > 0) then
allocate(dst%children(src%num_children))
do i = 1, src%num_children
call copy_entry(src%children(i), dst%children(i))
dst%children(i)%parent => dst
end do
endif
end subroutine copy_entry