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.
| Type | Intent | Optional | 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 |
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