| 1 |
# size(x): Size of Array |
| 2 |
|
| 3 |
Returns the size of an array `x`. |
| 4 |
|
| 5 |
## Declaration |
| 6 |
|
| 7 |
### Syntax |
| 8 |
|
| 9 |
```fortran |
| 10 |
retval = size(A[, dim[, kind]]) |
| 11 |
integer function size(x) |
| 12 |
``` |
| 13 |
|
| 14 |
### Arguments |
| 15 |
|
| 16 |
`A` the input array of any type or rank. |
| 17 |
|
| 18 |
`dim` optional dimension, if present, `size` returns the size of this dimension. |
| 19 |
|
| 20 |
`kind` optional the kind of the return value. |
| 21 |
|
| 22 |
### Return values |
| 23 |
|
| 24 |
`n` the size of an array (integer). |
| 25 |
|
| 26 |
## Description |
| 27 |
|
| 28 |
The `size` intrinsic function returns the size of an array. It returns the |
| 29 |
product of all dimensions, unless the `dim` argument is specified, in which |
| 30 |
case it only returns the size of this particular dimension. The `kind` argument |
| 31 |
can be used to specify the integer kind of the result. |
| 32 |
|
| 33 |
## Types |
| 34 |
|
| 35 |
Supported argument type is integer. |
| 36 |
|
| 37 |
## Examples |
| 38 |
|
| 39 |
```fortran |
| 40 |
program intrinsics_size |
| 41 |
implicit none |
| 42 |
real :: A(3, 4) |
| 43 |
print *, size(A) |
| 44 |
print *, size(A, 2) |
| 45 |
end program |
| 46 |
``` |
| 47 |
|
| 48 |
**Result**: |
| 49 |
|
| 50 |
``` |
| 51 |
12 |
| 52 |
4 |
| 53 |
``` |
| 54 |
|
| 55 |
## See Also |
| 56 |
|
| 57 |
[shape](), [reshape](). |