- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a dynamic array declared in a subroutine, which I then need to pass back to the main.
In my subroutine the dynamic array is declared as follows:
SUBROUTINE TEST(MY_LIST)
TYPE(MY_STRUCT) , ALLOCATABLE :: MY_LIST(:)
- How can I pass the arrary back to the main?
- How should my array be declared in the main routine?
- Do I need deallocate the memory? If yes, then how?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tim18 has given the F95 answer, if you can use F2003, then you need to have an explicit interface for your subroutine visible to the caller (perhaps because the subroutine is in a module) and you need to declare both the actual and dummy argument with the allocatable attribute and with the same rank (using (:,...)). Here's an example that also tries to demonstrate the impact of INTENT. Move the CALLs around to cover all options...
(Edit: I botched the paste-code thing - trying as an attachment)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page