XL Fortran for AIX 8.1

Language Reference



The ALLOCATE statement dynamically provides storage for pointer targets and allocatable objects.


                                 '-,--STAT-- = --stat_variable-'

is a scalar integer variable


                    |    .-,-------------------------------.    |
                    |    V                                 |    |

is a variable name or structure component. It must be a pointer or an allocatable object.

lower_bound, upper_bound
are each scalar integer expressions


Execution of an ALLOCATE statement for a pointer causes the pointer to become associated with the target allocated. For an allocatable object, the object becomes definable.

The number of dimensions specified (i.e., the number of upper bounds in allocation) must be equal to the rank of allocate_object. When an ALLOCATE statement is executed for an array, the values of the bounds are determined at that time. Subsequent redefinition or undefinition of any entities in the bound expressions does not affect the array specification. Any lower bound, if omitted, is assigned a default value of 1. If any lower bound value exceeds the corresponding upper bound value, that dimension has an extent of 0 and allocate_object is zero-sized.

An allocate_object or a specified bound of an allocate_object shall not depend on stat_variable, or on the value, bounds, allocation status, or association status of any An allocate_object in the same ALLOCATE statement.

stat_variable shall not be allocated within the ALLOCATE statement in which it appears; nor shall it depend on the value, bounds, allocation status, or association status of any allocate_object in the same ALLOCATE statement.

If the STAT= specifier is not present and an error condition occurs during execution of the statement, the program terminates. If the STAT= specifier is present, the stat_variable is assigned one of the following values:

+-------------------------------IBM Extension--------------------------------+

Stat value Error condition
0 No error
1 Error in system routine attempting to do allocation
2 An invalid data object has been specified for allocation
3 Both error conditions 1 and 2 have occurred

+----------------------------End of IBM Extension----------------------------+

Allocating an allocatable object that is already allocated causes an error condition in the ALLOCATE statement.

Pointer allocation creates an object that has the TARGET attribute. Additional pointers can be associated with this target (or a subobject of it) through pointer assignment. If you reallocate a pointer that is already associated with a target:

When an object of derived type is created by an ALLOCATE statement, any allocatable ultimate components have an allocation status of not currently allocated.

Use the ALLOCATED intrinsic function to determine if an allocatable object is currently allocated. Use the ASSOCIATED intrinsic function to determine the association status of a pointer or whether a pointer is currently associated with a specified target.


P => C
N = 2; M = N
ALLOCATE (P(N,M),STAT=I)         ! P is no longer associated with C
N = 3                            ! Target array for P maintains 2X2 shape

Related Information

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]