grow_positions Subroutine

private subroutine grow_positions(self, n, exact)

Grow the positions' (and optionals') storage to hold at least n.

Arguments

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

positions to hold

logical, intent(in), optional :: exact

(true: exactly n (default false))


Calls

proc~~grow_positions~~CallsGraph proc~grow_positions grow_positions proc~new_capacity new_capacity proc~grow_positions->proc~new_capacity

Called by

proc~~grow_positions~~CalledByGraph proc~grow_positions grow_positions proc~add_points Trajectory%add_points proc~add_points->proc~grow_positions proc~add_position Trajectory%add_position proc~add_position->proc~grow_positions proc~reserve~2 Trajectory%reserve proc~reserve~2->proc~grow_positions proc~add_point Trajectory%add_point proc~add_point->proc~add_position

Source Code

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