Fortran Wiki
allocated

Description

allocated(array) checks the status of whether x is allocated.

Standard

Fortran 95 and later

Class

Inquiry function

Syntax

result = allocated(array)

Arguments

  • array - the argument shall be an allocatable array.

Return value

The return value is a scalar logical with the default logical kind type parameter. If array is allocated, allocated(array) 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