- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear forum,
I would like to knowif it is possible to redefine array bounds once an array has been allocated. I am not talking about the bounds of a dummy array argument; but the bounds of an actual allocatable array.
For instance
INTEGER,ALLOCATABLE :: A(:)
...
ALLOCATE(A(10)) ! The bounds are 1 and 10
...
! Here I want to redefine the bounds of A (making sure that the condition UBOUND(A)-LBOUND(A)+1=10 is still verified)
Is it possible to do this? I know that of course I could do ALLOCATE(A(-2:7)) at the very begining - but I'd like to change these bounds after the array is allocated.
Olivier
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran 2003 has a "pointer remapping" feature where you could do something like this:
INTEGER, POINTER :: AX(:)
AX(-2:7) => A
but this is not yet supported in Intel Fortran.
There is a library routine FOR_DESCRIPTOR_ASSIGN that can be used to rewrite an array descriptor, so you could do something like this:
USE IFCORE
...
INTEGER, POINTER :: AX(:)
...
CALL FOR_DESCRIPTOR_ASSIGN(AX, LOC(A), SIZEOF(A(1)), &
IOR(FOR_DESCRIPTOR_ARRAY_DEFINED, &
IOR(FOR_DESCRIPTOR_ARRAY_NODEALLOC, FOR_DESCRIPTOR_ARRAY_CONTIGUOUS)), &
RANK=1, DIMS_INFO=[-2,7,4])
Now you use AX instead of A.
INTEGER, POINTER :: AX(:)
AX(-2:7) => A
but this is not yet supported in Intel Fortran.
There is a library routine FOR_DESCRIPTOR_ASSIGN that can be used to rewrite an array descriptor, so you could do something like this:
USE IFCORE
...
INTEGER, POINTER :: AX(:)
...
CALL FOR_DESCRIPTOR_ASSIGN(AX, LOC(A), SIZEOF(A(1)), &
IOR(FOR_DESCRIPTOR_ARRAY_DEFINED, &
IOR(FOR_DESCRIPTOR_ARRAY_NODEALLOC, FOR_DESCRIPTOR_ARRAY_CONTIGUOUS)), &
RANK=1, DIMS_INFO=[-2,7,4])
Now you use AX instead of A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve!
I'll look into this carefully. It seems it's exactly what I need!
Olivier
I'll look into this carefully. It seems it's exactly what I need!
Olivier

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page