Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Shift array index without copying

Wee_Beng_T_
Beginner
691 Views

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
jimdempseyatthecove
Honored Contributor III
691 Views
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
Wee_Beng_T_
Beginner
691 Views

Thanks Jim for the solution!

0 Kudos
Reply