- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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?
- Balises:
- Intel® Fortran Compiler
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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)- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable