Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

/Qsave and automatic arrays

Aaron_S_1
Beginner
387 Views

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.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
387 Views

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.

0 Kudos
Reply