allocated(x): Checagem de Condição

Logical status of an allocatable integer.

Declaration

Sintaxe

retval = allocated(x)
logical function allocated(x)

Argumentos

x is an integer input parameter.

Valores de retorno

The return value is a logical scalar with the default logical kind type parameter.

Descrição

allocated(x) checks the allocation status of a integer input parameter. It returns a logical value as TRUE if the input argument x is allocated, FALSE otherwise.

Tipos

Supported argument type is integer.

module lfortran_intrinsic_builtin
implicit none

interface
    logical function allocated(x)
	integer, intent(in) :: x(:)
	end function
end interface

end module

Exemplos

program intrinsics_allocated
    implicit none
    integer :: i = 1
	real(1), allocatable :: x(:)
	if (.not. allocated(x))
		allocate(x(i))
    print *, allocated(i)
end program

Resultado:

TRUE

Veja Também