This subroutine performs reallocating array that represents the DFA graph.
It evaluates the current upper limit for the array reallocation request call,
and if the hard limit is not exceeded, performs the reallocation and updates the
upper limit, otherwise the program stops with ERROR STOP
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dfa_graph_t), | intent(inout) | :: | self |
pure subroutine lazy_dfa__reallocate(self) implicit none class(dfa_graph_t), intent(inout) :: self type(dfa_state_node_t), allocatable :: tmp(:) integer :: siz, prev_count, i integer :: new_part_begin, new_part_end if (allocated(self%nodes)) then siz = size(self%nodes, dim=1) -1 allocate(tmp(siz)) call move_alloc(self%nodes, tmp) else siz = 0 endif prev_count = self%alloc_count_node self%alloc_count_node = prev_count + 1 new_part_begin = siz + 1 new_part_end = siz*2 if (new_part_end > DFA_STATE_HARD_LIMIT) then error stop "Too many DFA state nodes requested." end if allocate(self%nodes(0:new_part_end)) self%nodes(1:siz) = tmp(1:siz) self%nodes(new_part_begin:new_part_end)%own_i = [(i, i=new_part_begin, new_part_end)] self%dfa_limit = new_part_end end subroutine lazy_dfa__reallocate