/Qsave and automatic arrays

/Qsave and automatic arrays

My understanding is that /Qsave will place almost all variables into static allocation. I have also read that arrays declared as:

Subroutine Example(A,n)

    Integer :: n

    Integer :: A(n)

    The rest of the program...

End Subroutine

Are allocated on the stack unless /heap-arrays is specified. Where are arrays of these type (automatic arrays?) allocated with the /Qsave switch? I appreciate any insight anyone might be able to offer. Thanks.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Your example is what is called an "adjustable array" - a dummy argument whose bounds are taken from another dummy argument (or a COMMON or module variable.) Its allocation comes from the caller.

Now if you had left A out of the argument list, then you'd indeed have an automatic array. /Qsave has no effect on these. An automatic array is stack allocated unless /heap-arrays is in effect.

/Qsave applies to local variables that are not automatic. It is the equivalent of adding SAVE for every non-automatic variable in the routine. One unfortunate side effect is that it also makes any ALLOCATABLE variables SAVEd, which may not be what you want.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today