Standard: F77 F90 F95 F2003 F2008 Example program


type , ALLOCATABLE [ , attr ]... :: decl-list

ALLOCATABLE [::] allocatable-list

allocatable-list ::= allocatable [ , allocatable ]...
allocatable ::= name [ ( deferred-shape ) ]


Declares that a variable is allocatable. Such a variable is allocated dynamically with the ALLOCATE statement. An allocatable array must have deferred shape; that is, each dimension must be declared with a colon (‘:’); this may be done in the Type Declaration statement, the Component Definition statement, the ALLOCATABLE statement, or a separate DIMENSION statement. The values for the bounds are supplied in the ALLOCATE statement at runtime.

The initial state of an allocatable variable is unallocated. An allocatable variable is automatically deallocated on exit from the procedure it is declared in, unless it has the SAVE attribute.

Prior to Fortran 2003, all allocatable variables were required to be arrays, and were not permitted to be structure components.

If the left-hand-side of an intrinsic assignment statement is an allocatable variable, and it is either unallocated, or allocated with a different shape from the expression, or has a deferred character length and is allocated with a different length from the expression, it is reallocated to have the same shape and/or character length as the expression on the assignment. This automatic reallocation can be suppressed by using array section or substring notation.

In a structure constructor for a type with an allocatable component, the NULL intrinsic function can be used to denote an unallocated value.

In Fortran 2008, a structure constructor is not required to supply any value for an allocatable component; if the value is omitted, the component is unallocated.


ALLOCATE statement, Component Definition statement, DEALLOCATE statement, DIMENSION attribute, LBOUND intrinsic function, MOVE_ALLOC intrinsic subroutine, NULL intrinsic function, SHAPE intrinsic function, SIZE intrinsic function, Type Declaration statement, UBOUND intrinsic function