Clicky

Fortran Wiki
allocated

Description

allocated(array) and allocated(scalar) check the allocation status of array and scalar, respectively.

Standard

Fortran 95 and later. Note, the scalar= keyword and allocatable scalar entities are available in Fortran 2003 and later.

Class

Inquiry function

Syntax

  • result = allocated(array)
  • result = allocated(scalar)

Arguments

  • array - the argument shall be an allocatable array.
  • scalar - the argument shall be an allocatable scalar.

Return value

The return value is a scalar logical with the default logical kind type parameter. If the argument is allocated then the result is .true.; otherwise, it returns .false..

Example

program test_allocated
  integer :: i = 4
  real(4), allocatable :: x(:)
  if (allocated(x) .eqv. .false.) allocate(x(i))
end program test_allocated

See Also

move_alloc

category: intrinsics