Lahey/Fujitsu Fortran



The ALLOCATABLE statement declares arrays as having the allocatable attribute, and may also define the rank of an allocatable array. The shape of an allocatable array is determined when space is allocated for it by executing an ALLOCATE statement.


ALLOCATABLE [::] array-name (deferred-shape) [, array-name (deferred-shape)]...
array-name is the name of an array variable.
deferred-shape is : [, :] ... where the number of colons is equal to the rank of array-name.


The Fortran 95 standard states that the object of the ALLOCATABLE statement must not be a dummy argument, a derived type component, or function result. As an extension, dummy arrays, derived type components, and function results are allowed to have the allocatable attribute. These extensions will become standard when Fortran 2003 is approved.

If the DIMENSION of array-name is specified elsewhere in the scoping unit, it must be specified as a deferred-shape.


integer :: a, c(:,:,:) integer, allocatable :: b(:,:) ! allocatable attribute allocatable a(:), c ! allocatable statement allocate (a(2),b(3,-1:1),c(10,10,10))! space allocated write(*,*) shape(a),shape(b),shape(c)! writes 2 3 3 10 10 10 deallocate (a,b,c) ! space deallocated