- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Say I've got a subroutine foo(A,output) where A is dimension(:,:) and intent(in). Say output is real and intent(out).
I have a nxp matrix X and call foo(X(:,whichcols),output), where size(whichcols) < p and all elements of whichcols are positive integers <= p.
What is made available to foo? A pointer to the column subset of X ?
What is the best way to handle such calls involving submatrices? Do functions and subroutines behave in the same fashion?
Thanks.
I have a nxp matrix X and call foo(X(:,whichcols),output), where size(whichcols) < p and all elements of whichcols are positive integers <= p.
What is made available to foo? A pointer to the column subset of X ?
What is the best way to handle such calls involving submatrices? Do functions and subroutines behave in the same fashion?
Thanks.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, a "pointer" to column subset of X is passed to foo --(actually, it is referred to as "descriptor" or "dope vector" in this context) but its format (at least in CVF) is identical to the one of pointer arrays (see "Handling Arrays and Visual Fortran Array Descriptors" in CVF docs). That's the reason why routines with assumed-shape arguments require explicit interfaces.
Functions and subroutines behave in the same fashion. Of course, the exception is function's return value. It can get tricky to return a pointer as function's return value, so IMO it's best to stick with normal arguments.
Jugoslav
Functions and subroutines behave in the same fashion. Of course, the exception is function's return value. It can get tricky to return a pointer as function's return value, so IMO it's best to stick with normal arguments.
Jugoslav
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