Diagnostic 6754: An automatic object must not appear in a SAVE statement or be declared with the SAVE attribute.

In Fortran, an automatic object is a local variable in a procedure whose bounds or length are determined, in whole or in part, by a dummy argument, common variable, or use or host-associated variable. These variables are allocated when the procedure is entered and deallocated when the procedure exits.

The SAVE attribute specifies that a variable must retain its definition status across calls to a procedure.  This is not compatible with automatic objects.  For example:

subroutine sub (n)
integer a(n)
save a

Here, a is an automatic array whose bounds are determined by the dummy variable n.  This could be different on each call to sub. The SAVE statement, or SAVE attribute, is not allowed here, and will cause the compiler to give error #6754.

It is possible to have an array with run-time bounds saved across procedure calls if it is ALLOCATABLE.  For example, this would be allowed:

subroutine sub (n)
integer, allocatable, save :: a(:)
if (.not. allocated(a)) allocate(a(n))

In this example, array a would be allocated the first time sub was called to dimension n, and then the bounds (and values in the array) would remain defined across calls. Subsequent calls with different values of n would not change the allocation.

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.
Возможность комментирования русскоязычного контента была отключена. Узнать подробнее.