- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK no, at least not in the sense you'd like. This is an inherent limitation -- pointers are expressed via array descriptors, which are hidden structures of several bytes, containing starting address, offset and step for each dimension (see documentation for exact Compaq format). For the way you'd like to use pointers, the required information simply cannot fit into that structure.
You might workaround it using your own function. Didn't try the following code but that should be along these lines:
You have to be very careful about memory management & leaks. There also should be an equivalent routine for freeing memory. Note that you have to allocate/deallocate memory for yourself and that the technique is not very efficient.
An (probably more efficient) alternative, of course, would be to stick to DO-loops
without making a copy as above.
HTH
Jugoslav
You might workaround it using your own function. Didn't try the following code but that should be along these lines:
SUBROUTINE ASSOCIATE (ptrArray, IndexArray, targetArray) REAL, POINTER:: ptrArray(:) INTEGER:: IndexArray(:) REAL, TARGET:: targetArray(:) IF (ASSOCIATED(ptrArray)) ... !Allocation/deallocation exception handling here END IF ALLOCATE(ptrArray(SIZE(IndexArray))) DO i=1,SIZE(IndexArray) ptrArray(i) = TargetArray(IndexArray(i)) END DO END SUBROUTINE ASSOCIATE
You have to be very careful about memory management & leaks. There also should be an equivalent routine for freeing memory. Note that you have to allocate/deallocate memory for yourself and that the technique is not very efficient.
An (probably more efficient) alternative, of course, would be to stick to DO-loops
without making a copy as above.
HTH
Jugoslav
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, rereading my own post I see I wasn't very clear.
Problem with the approach above is that ptrArray is a POINTER only by sintax, not by essence -- if, say, TargetArray changes, ptrArray won't change, since it points to a copy, not to 'real' TargetArray. What I meant under DO-loops is to simply avoid referencing TargetArray via ptrArray and use double-indexing instead at every occurence, i.e.
Problem with the approach above is that ptrArray is a POINTER only by sintax, not by essence -- if, say, TargetArray changes, ptrArray won't change, since it points to a copy, not to 'real' TargetArray. What I meant under DO-loops is to simply avoid referencing TargetArray via ptrArray and use double-indexing instead at every occurence, i.e.
TargetArray(IndexArray(i))
. Note that TargetArray(IndexArray)
(array-valued) construct is also allowed.

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