- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I noticed different behavior of allocatable arrays defined in a subroutine or function between CVF and IVF. In CVF a local allocatable array is automatically deallocated upon exit from the routine unless it was declared with a 'save' attribute. However in IVF the array remains allocated. Is this down to a change in standard or is it controlled by a compiler setting?
- Balises:
- Intel® Fortran Compiler
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Yes. /Qsave says to make all local variables SAVE and it is doing that. If that is not what you want, then don't use that switch (which I consider a Band-Aid for incorrect code.)
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Just based on what you wrote, I'd have to say you are mistaken in your observation. The standard says that local ALLOCATABLE arrays, if they do not have the SAVE attribute, are automatically deallocated on exit and Intel Fortran does that. If you have an example showing otherwise I'd like to see it.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Just based on what you wrote, I'd have to say you are mistaken in your observation. The standard says that local ALLOCATABLE arrays, if they do not have the SAVE attribute, are automatically deallocated on exit and Intel Fortran does that. If you have an example showing otherwise I'd like to see it.
Hi Steve,
I have the All variables SAVE/QSave set but from your reply this directive should not affect the allocatable array. I have to deallocate the array before allocating it again.
When I turn the "All variables SAVE/QSave" directive off the array is deallocatedas expected.
IsQSave supposed to behave like this with respect to allocatable arrays?
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Yes. /Qsave says to make all local variables SAVE and it is doing that. If that is not what you want, then don't use that switch (which I consider a Band-Aid for incorrect code.)
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Yes. /Qsave says to make all local variables SAVE and it is doing that. If that is not what you want, then don't use that switch (which I consider a Band-Aid for incorrect code.)
Thanks Steve,
You answered my original question regarding the QSave switch. I agree with your approach and I'm using the save attribute only where required in new code. The problem arose because during the project conversion from CVF to IVF the QSave attribute was automatically set up because CVF did not conform to the standard by assuming all variables (except allocatable) are saved.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
CVF conformed to the standard - your program did not. The standard, in most cases, specifies the rules for a standard-conforming program. A program that does not conform to the standard - for example, it references a non-SAVEd variable before definition, could do anything. CVF's behavior to apply assumed SAVE semantics to non-allocatable variables is an extension, but is allowed by the standard.

- 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