trace_range Subroutine

private subroutine trace_range(traj, t, n, i1, i2)

The points of 1 .. n whose times are at most t (trace mode): i1 .. i2 (none: i2 < i1), the first points for increasing times, the last for decreasing ones (by bisection).

Arguments

Type IntentOptional Attributes Name
type(Trajectory), intent(in) :: traj

the trajectory

real(kind=wp), intent(in) :: t

the current time

integer, intent(in) :: n

the points considered (1 .. n)

integer, intent(out) :: i1

the points passed (none: i2 < i1)

integer, intent(out) :: i2

the points passed (none: i2 < i1)


Calls

proc~~trace_range~~CallsGraph proc~trace_range trace_range proc~decreasing_times decreasing_times proc~trace_range->proc~decreasing_times

Called by

proc~~trace_range~~CalledByGraph proc~trace_range trace_range proc~draw_written draw_written proc~draw_written->proc~trace_range proc~segment_update SegmentArtist%segment_update proc~segment_update->proc~trace_range proc~chain_update ChainArtist%chain_update proc~chain_update->proc~draw_written proc~curve_update CurveArtist%curve_update proc~curve_update->proc~draw_written

Source Code

    subroutine trace_range(traj, t, n, i1, i2)
        type(Trajectory), intent(in) :: traj                !! the trajectory
        real(wp), intent(in) :: t                           !! the current time
        integer, intent(in) :: n                            !! the points considered (1 .. n)
        integer, intent(out) :: i1, i2                      !! the points passed (none: i2 < i1)
        integer :: low, high, mid
        i1 = 1
        i2 = 0
        if (n < 1) return
        low = 0
        high = n + 1
        if (.not. decreasing_times(traj, n)) then       ! points 1 .. low have times <= t
            do while (high - low > 1)
                mid = (low + high) / 2
                if (traj%time(mid) <= t) then
                    low = mid
                else
                    high = mid
                end if
            end do
            i2 = low
        else                                            ! points high .. n have times <= t
            do while (high - low > 1)
                mid = (low + high) / 2
                if (traj%time(mid) <= t) then
                    high = mid
                else
                    low = mid
                end if
            end do
            i1 = high
            i2 = n
        end if
    end subroutine trace_range