Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(tree_t), | intent(inout) | :: | self |
pure subroutine tree_graph__reallocate(self) implicit none class(tree_t), intent(inout) :: self integer :: new_part_begin, new_part_end, i type(tree_node_t), allocatable :: tmp(:) if (.not. allocated(self%nodes)) then allocate(self%nodes(TREE_NODE_BASE:TREE_NODE_UNIT)) self%num_alloc = 1 end if new_part_begin = ubound(self%nodes, dim=1) + 1 new_part_end = ubound(self%nodes, dim=1) * 2 if (new_part_end > TREE_NODE_HARD_LIMIT) then error stop "Exceeded the maximum number of tree nodes can be allocated." end if call move_alloc(self%nodes, tmp) allocate(self%nodes(TREE_NODE_BASE:new_part_end)) self%nodes(TREE_NODE_BASE:new_part_begin-1) = tmp(TREE_NODE_BASE:new_part_begin-1) self%nodes(new_part_begin:new_part_end)%own_i = [(i, i = new_part_begin, new_part_end)] deallocate(tmp) end subroutine tree_graph__reallocate