Debian Codegraph @

doc/src/intrinsics/array/allocated.md

raw
1 # allocated(x): Status Check
2
3 Logical status of an allocatable integer.
4
5 ## Declaration
6
7 ### Syntax
8
9 ```fortran
10 retval = allocated(x)
11 logical function allocated(x)
12 ```
13
14 ### Arguments
15
16 `x` is an integer input parameter.
17
18 ### Return values
19
20 The return value is a logical scalar with the default logical kind type
21 parameter.
22
23 ## Description
24
25 `allocated(x)` checks the allocation status of a integer input parameter. It
26 returns a logical value as `TRUE` if the input argument `x` is allocated,
27 `FALSE` otherwise.
28
29 ## Types
30
31 Supported argument type is integer.
32
33 ```fortran
34 module lfortran_intrinsic_builtin
35 implicit none
36
37 interface
38 logical function allocated(x)
39 integer, intent(in) :: x(:)
40 end function
41 end interface
42
43 end module
44 ```
45
46 ## Examples
47
48 ```fortran
49 program intrinsics_allocated
50 implicit none
51 integer :: i = 1
52 real(1), allocatable :: x(:)
53 if (.not. allocated(x))
54 allocate(x(i))
55 print *, allocated(i)
56 end program
57 ```
58
59 **Result**:
60
61 ```
62 TRUE
63 ```
64
65 ## See Also
66