Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Allocation of Allocatable Variables

The status of an allocatable variable becomes "allocated" under the following conditions:

  • If it is allocated by an ALLOCATE statement

  • If it is allocated during assignment

  • If it is allocated by the intrinsic subroutine MOVE_ALLOC

An allocatable variable with allocated status can be referenced, defined, or deallocated; allocating it causes an error condition in the ALLOCATE statement. The intrinsic function ALLOCATED returns TRUE for such a variable.

The status of an allocatable variable becomes "unallocated" under the following conditions:

  • If it is not allocated

  • If it is deallocated

  • If it is unallocated by the intrinsic subroutine MOVE_ALLOC

  • If it goes out of scope and does not have the SAVE attribute

An allocatable variable with unallocated status must not be referenced or defined. It must not be supplied as an actual argument corresponding to a nonallocatable dummy argument, except to certain intrinsic inquiry functions. It can be allocated with the ALLOCATE statement. Deallocating it causes an error condition in the DEALLOCATE statement. The intrinsic function ALLOCATED returns FALSE for such a variable.

At the beginning of execution of a program, allocatable variables are unallocated.

When the allocation status of an allocatable variable changes, the allocation status of any associated allocatable variable also changes accordingly. Allocation of an allocatable variable establishes values for the deferred type parameters of all associated allocatable variables.

An unsaved allocatable local variable of a procedure has a status of unallocated at the beginning of each invocation of the procedure. An unsaved local variable of a construct has a status of unallocated at the beginning of each execution of the construct.

When an object of derived type is created by an ALLOCATE statement, any allocatable ultimate components have an allocation status of unallocated unless the SOURCE= specifier appears and the corresponding component of the SOURCE= expression is allocated.

The intrinsic function ALLOCATED can be used to determine whether a variable is allocated or unallocated.