ALLOCATABLE (Fortran 2003)
Purpose
The ALLOCATABLE attribute allows you to declare an allocatable object. You can dynamically allocate the storage space of these objects by executing an ALLOCATE statement or by a derived-type assignment statement. If the object is an array, it is a deferred-shape array or an assumed-rank array.
Syntax
- object_name
- The name of an allocatable object.
- deferred_shape_spec
- A colon, where each colon represents a dimension.
- assumed_rank_spec
- Two periods. For more information, see Assumed_rank_spec.
Rules
The object must not be a pointee.
If the object is an array specified elsewhere in the scoping unit with the DIMENSION attribute, the array specification must be a deferred_shape_spec or an assumed_rank_spec.
You can initialize an allocatable object after the storage space is allocated. If you compile your program with -qinitalloc, all uninitialized allocated objects are initialized.
Examples
! Two-dimensional array a declared but no space yet allocated
REAL, ALLOCATABLE :: a(:, :)
READ (5, *) i, j
ALLOCATE(a(i, j))