grow_colors Subroutine

private subroutine grow_colors(self, n, exact)

Grow the colors' storage to hold at least n.

Arguments

Type IntentOptional Attributes Name
type(Trajectory), intent(inout) :: self
integer, intent(in) :: n

colors to hold

logical, intent(in), optional :: exact

(true: exactly n (default false))


Calls

proc~~grow_colors~~CallsGraph proc~grow_colors grow_colors proc~new_capacity new_capacity proc~grow_colors->proc~new_capacity

Called by

proc~~grow_colors~~CalledByGraph proc~grow_colors grow_colors proc~add_color Trajectory%add_color proc~add_color->proc~grow_colors proc~add_points Trajectory%add_points proc~add_points->proc~grow_colors proc~reserve~2 Trajectory%reserve proc~reserve~2->proc~grow_colors proc~add_point Trajectory%add_point proc~add_point->proc~add_color

Source Code

    subroutine grow_colors(self, n, exact)
        type(Trajectory), intent(inout) :: self
        integer, intent(in) :: n                            !! colors to hold
        logical, intent(in), optional :: exact              !! (true: exactly n (default false))
        real(c_float), allocatable :: tmp(:,:)
        integer :: cap
        cap = 0
        if (allocated(self%col)) cap = size(self%col, 2)
        if (n <= cap) return
        allocate(tmp(4, new_capacity(cap, n, exact)))
        if (self%n_col > 0) tmp(:, 1:self%n_col) = self%col(:, 1:self%n_col)
        call move_alloc(tmp, self%col)
    end subroutine grow_colors