reserve Subroutine

private subroutine reserve(self, n, positions, attitudes, colors)

Reserve memory for n points: times, positions (with their optionals) unless positions is false, and attitudes and colors only if attitudes / colors is true. Optional: storage grows as needed, but reserving avoids reallocations for a known size. It never shrinks the storage (see compact).

Type Bound

Trajectory

Arguments

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

number of points

logical, intent(in), optional :: positions

reserve positions (default true)

logical, intent(in), optional :: attitudes

reserve attitudes (default false)

logical, intent(in), optional :: colors

reserve colors (default false)


Calls

proc~~reserve~2~~CallsGraph proc~reserve~2 Trajectory%reserve proc~grow_attitudes grow_attitudes proc~reserve~2->proc~grow_attitudes proc~grow_colors grow_colors proc~reserve~2->proc~grow_colors proc~grow_positions grow_positions proc~reserve~2->proc~grow_positions proc~grow_times grow_times proc~reserve~2->proc~grow_times proc~new_capacity new_capacity proc~grow_attitudes->proc~new_capacity proc~grow_colors->proc~new_capacity proc~grow_positions->proc~new_capacity proc~grow_times->proc~new_capacity

Source Code

    subroutine reserve(self, n, positions, attitudes, colors)
        class(Trajectory), intent(inout) :: self
        integer, intent(in) :: n                            !! number of points
        logical, intent(in), optional :: positions          !! reserve positions (default true)
        logical, intent(in), optional :: attitudes          !! reserve attitudes (default false)
        logical, intent(in), optional :: colors             !! reserve colors (default false)
        logical :: pos, att, col
        pos = .true.
        att = .false.
        col = .false.
        if (present(positions)) pos = positions
        if (present(attitudes)) att = attitudes
        if (present(colors)) col = colors
        call grow_times(self, n, exact=.true.)
        if (pos) call grow_positions(self, n, exact=.true.)
        if (att) call grow_attitudes(self, n, exact=.true.)
        if (col) call grow_colors(self, n, exact=.true.)
    end subroutine reserve