| Fortran Language Reference Manual, Volume 1 - S-3692-51 | ||
|---|---|---|
| Prev Section | Chapter 5. Declarations | Next Section |
Scalars and arrays may use the ALLOCATABLE attribute. An allocatable array is one for which the bounds are determined when an ALLOCATE statement is executed for the array. These arrays must be deferred-shape arrays.
The following is a format for a type declaration statement with an ALLOCATABLE attribute:
type, ALLOCATABLE [, attribute_list ] :: entity_decl_list |
Subject to the rules governing combinations of these attributes, attribute_list can contain the following:
| DIMENSION (with deferred shape) |
| INTENT |
| OPTIONAL |
| PRIVATE |
| PROTECTED (F2003) |
| PUBLIC |
| SAVE |
| STATIC (EXTENSION) |
| TARGET |
| VOLATILE (F2003) |
The format of the ALLOCATABLE statement is defined as follows:
Table 5-22.
| allocatable_stmt | is |
|
Under the Fortran 2003 draft, object_name can be a scalar, dummy argument, or a function result.
If the array is given the DIMENSION attribute elsewhere, the bounds must be specified as colons (deferred shape).
The ALLOCATABLE statement also confers the ALLOCATABLE attribute. It is subject to the same rules and restrictions as the ALLOCATABLE attribute.
The following examples show entity-oriented declarations:
REAL, ALLOCATABLE :: A(:, :) LOGICAL, ALLOCATABLE, DIMENSION(:) :: MASK1 |
The following examples show attribute-oriented declarations:
REAL A(:, :) LOGICAL MASK1 DIMENSION MASK1(:) ALLOCATABLE A, MASK1 |
| Prev Section | Table of Contents | Title Page | Index | Next Section |
| AUTOMATIC Attribute and Statement (EXTENSION) | Up one level | SAVE and STATIC Attributes and Statements |