measure Subroutine

private subroutine measure(self, j, lo, hi, x)

The distances along the strip of points lo .. hi of chunk j: from the previous point (in this chunk; the first point of a chunk after the first is the previous chunk's last, measured before), or 0 at point 1. From x (as in written) if given, else from the floats written.

Arguments

Type IntentOptional Attributes Name
type(LineChain), intent(in) :: self
integer, intent(in) :: j

the chunk, and its points lo .. hi (chain indices)

integer, intent(in) :: lo

the chunk, and its points lo .. hi (chain indices)

integer, intent(in) :: hi

the chunk, and its points lo .. hi (chain indices)

real(kind=wp), intent(in), optional :: x(:,:)

(3, chain points): the points, as in written


Calls

proc~~measure~~CallsGraph proc~measure measure proc~line_buffer line_buffer proc~measure->proc~line_buffer proc~split_distances split_distances proc~measure->proc~split_distances interface~vkf_line_points vkf_line_points proc~line_buffer->interface~vkf_line_points

Called by

proc~~measure~~CalledByGraph proc~measure measure proc~written LineChain%written proc~written->proc~measure proc~write_intermediates write_intermediates proc~write_intermediates->proc~written proc~write_marker write_marker proc~write_marker->proc~written proc~write_segments write_segments proc~write_segments->proc~written proc~write_segments~2 write_segments proc~write_segments~2->proc~written proc~add_intermediates add_intermediates proc~add_intermediates->proc~write_intermediates proc~marker_update MarkerArtist%marker_update proc~marker_update->proc~write_marker proc~marker_update->proc~add_intermediates proc~segment_update SegmentArtist%segment_update proc~segment_update->proc~write_segments proc~segments_late_update CustomLineSegments%segments_late_update proc~segments_late_update->proc~write_segments~2

Source Code

    subroutine measure(self, j, lo, hi, x)
        type(LineChain), intent(in) :: self
        integer, intent(in) :: j, lo, hi        !! the chunk, and its points lo .. hi (chain indices)
        real(wp), intent(in), optional :: x(:,:) !! (3, chain points): the points, as in [[written]]
        real(c_float), dimension(:,:,:), pointer :: p, prev
        real(wp), allocatable :: xf(:,:), s(:)
        integer :: k0, k1, k, g
        call line_buffer(self%chunks(j)%line, p)
        if (.not. associated(p)) return
        k1 = hi - self%chunks(j)%first + 1                 ! local indices k0 .. k1
        k0 = lo - self%chunks(j)%first + 1
        if (lo > 1 .and. k0 > 1) k0 = k0 - 1               ! from the point before
        allocate(s(k0:k1))
        if (lo == 1) then
            s(k0) = 0.0_wp
        else if (k0 == lo - self%chunks(j)%first + 1) then ! the chunk's first point: shared with the previous
            call line_buffer(self%chunks(j-1)%line, prev)
            k = self%chunks(j)%first - self%chunks(j-1)%first + 1
            s(k0) = real(prev(4, 1, k), wp) + real(prev(4, 2, k), wp)
        else
            s(k0) = real(p(4, 1, k0), wp) + real(p(4, 2, k0), wp)
        end if
        if (present(x)) then                               ! (one pass, no temporary arrays)
            g = self%chunks(j)%first - 1                   ! chain index = g + local index
            do k = k0 + 1, k1
                s(k) = s(k - 1) + norm2(x(:, g + k) - x(:, g + k - 1))
            end do
        else
            xf = real(p(1:3, 1, k0:k1), wp) + real(p(1:3, 2, k0:k1), wp)
            s(k0+1:k1) = norm2(xf(:, 2:) - xf(:, :k1-k0), dim=1)
            do k = k0 + 1, k1
                s(k) = s(k - 1) + s(k)
            end do
        end if
        call split_distances(s, p(4, :, k0:k1))
    end subroutine measure