- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was hoping to allocate an array in a dll and pass it back to the calling VB code. From browsing the docs, a locally allocated array is deallocated when the sub/func is exited, either by default or by DEALLOCATE. The SAVE attribute conflicts with the ALLOCATABLE attribute.
It appears that I cannot do what I want. Is this true, or have I missed something?
My work around is to write another function to determine the size, dimension it in VB and pass the first element of the array and its dimension.
Thanks for any remarks.
Ted
It appears that I cannot do what I want. Is this true, or have I missed something?
My work around is to write another function to determine the size, dimension it in VB and pass the first element of the array and its dimension.
Thanks for any remarks.
Ted
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SAVE attribute does not conflict with ALLOCATABLE. It's perfectly OK and standard to declare an array ALLOCATABLE,SAVE. The problem might be if VB unloads your dll in the meantime -- I don't think it does it, so you might give it a try.
However, (out of curiosity, I'm not familiar with VB), how do you mean to "pass it" to VB code? That implies that VB is able to dereference it via a C-style pointer -- I don't recall if it can do it (note that even standard Fortran-95 cannot have ALLOCATABLE arguments). OTOH, that method would require separate routines (or additional argument in the call) to allocate/deallocate arrays.
...I must admit I like your "workaround" more -- that interface is cleaner.
Jugoslav
However, (out of curiosity, I'm not familiar with VB), how do you mean to "pass it" to VB code? That implies that VB is able to dereference it via a C-style pointer -- I don't recall if it can do it (note that even standard Fortran-95 cannot have ALLOCATABLE arguments). OTOH, that method would require separate routines (or additional argument in the call) to allocate/deallocate arrays.
...I must admit I like your "workaround" more -- that interface is cleaner.
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