Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

Shift array index without copying

Hi,

I have an array e.g. A(3:7,4:8). So index starts from 3 / 4 and ends with 7 / 8. I would like to change it to A(43:47,44:48) without creating a new array and copying it. Is that possible? The array could be dynamically allocated ones. The values in the array will be changed so it doesn't matter if they are the same or not.

 

Thanks.

0 Kudos
2 Replies
Highlighted
1 View

program arrayindex

program arrayindex
    implicit none
    real, target :: rawA(5,5)
    real, pointer :: A(:,:)
    integer :: r,c
    do r=1,5
        do c=1,5
            rawA(c,r) = c*10+r
        end do
    end do
    A(3:7,4:8) => rawA
    print *, A
    A(43:47,44:48) => rawA
    print *,A
end program arrayindex

Jim Dempsey

0 Kudos
Highlighted
Beginner
1 View

Thanks Jim for the solution!

Thanks Jim for the solution!

0 Kudos