ALLOCATED(X)

Purpose

Indicates whether or not an allocatable object is allocated.

Class

Inquiry function

Argument type and attributes

X can be one of the following:

ARRAY
An allocatable array whose allocation status you want to know.
SCALAR
An allocatable scalar whose allocation status you want to know.

Result type and attributes

Default logical scalar.

Result value

The result corresponds to the allocation status of ARRAY or SCALAR: .TRUE. if it is allocated, .FALSE. if it is not allocated, or undefined if its allocation status is undefined. If you are compiling with the -qxlf90=autodealloc compiler option there is no undefined allocation status.

Examples

INTEGER, ALLOCATABLE, DIMENSION(:) :: A
PRINT *, ALLOCATED(A)      ! A is not allocated yet.
ALLOCATE (A(1000))
PRINT *, ALLOCATED(A)      ! A is now allocated.
END

Related information

Allocatable arrays, ALLOCATE, Allocation status.