AUTOMATIC (IBM extension)

Purpose

The AUTOMATIC attribute specifies that a variable has a storage class of automatic; that is, the variable is not defined once the procedure ends.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-AUTOMATIC--+----+--automatic_list---------------------------><
              '-::-'                   

automatic
is a variable name or an array declarator with an explicit-shape specification list or a deferred-shape specification list

Rules

If automatic is a function result it must not be of type character or of derived type.

Function results that are pointers or arrays, dummy arguments, statement functions, automatic objects, or pointees must not have the AUTOMATIC attribute. A variable with the AUTOMATIC attribute cannot be defined in the scoping unit of a module Fortran 2008 beginsor submoduleFortran 2008 ends. A variable that is explicitly declared with the AUTOMATIC attribute cannot be a common block item.

A variable must not have the AUTOMATIC attribute specified more than once in the same scoping unit.

Any variable declared as AUTOMATIC within the scope of a thread's work will be local to that thread.

A variable with the AUTOMATIC attribute cannot be initialized by a DATA statement or a type declaration statement.

If automatic is a pointer, the AUTOMATIC attribute applies to the pointer itself, not to any target that is (or may become) associated with the pointer.

Note: An object with the AUTOMATIC attribute should not be confused with an automatic object. See Automatic objects.
Table 1. Attributes compatible with the AUTOMATIC attribute
ALLOCATABLE  1  CONTIGUOUS  2  VOLATILE
ASYNCHRONOUS POINTER  
DIMENSION TARGET  
Note:
  •  1  Fortran 2003
  •  2  Fortran 2008

Examples

CALL SUB
CONTAINS
  SUBROUTINE SUB
    INTEGER, AUTOMATIC :: VAR
    VAR = 12
  END SUBROUTINE                  ! VAR becomes undefined
END

Related information