Given a 1D array, I want to create a pointer to the array boundaries, say the first 2 and last 2 elements of the array. I have investigated a bit about this but the only non-contiguous pointer examples I have come across are those defined as strided access.
Given the following test case
program test
implicit none
integer, target :: a(10)
integer, pointer :: p(:)
integer :: i
do i=1,10
a(i)=i
end do
p => a(:) ! Point all
p => a(::2) ! Point every 2 elments
print*, p
end program test
how can I point to separated array slices of the original array using a single pointer? So to be clear, in this example when printing p
I would like to get 1 2 9 10
.