grow_times Subroutine

private subroutine grow_times(self, n, exact)

Grow the times' storage to hold at least n (see new_capacity).

Arguments

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

times to hold

logical, intent(in), optional :: exact

(true: exactly n (default false))


Calls

proc~~grow_times~~CallsGraph proc~grow_times grow_times proc~new_capacity new_capacity proc~grow_times->proc~new_capacity

Called by

proc~~grow_times~~CalledByGraph proc~grow_times grow_times proc~add_points Trajectory%add_points proc~add_points->proc~grow_times proc~add_time Trajectory%add_time proc~add_time->proc~grow_times proc~reserve~2 Trajectory%reserve proc~reserve~2->proc~grow_times proc~add_point Trajectory%add_point proc~add_point->proc~add_time

Source Code

    subroutine grow_times(self, n, exact)
        type(Trajectory), intent(inout) :: self
        integer, intent(in) :: n                            !! times to hold
        logical, intent(in), optional :: exact              !! (true: exactly n (default false))
        real(wp), allocatable :: tmp(:)
        integer :: cap
        cap = 0
        if (allocated(self%t)) cap = size(self%t)
        if (n <= cap) return
        allocate(tmp(new_capacity(cap, n, exact)))
        if (self%n_times > 0) tmp(1:self%n_times) = self%t(1:self%n_times)
        call move_alloc(tmp, self%t)
    end subroutine grow_times