shape(3f) - [FORTRAN:INTRINSIC:ARRAY INQUIRY] Determine the shape of an array
result = shape(source[, kind])
Determines the shape of an array.
SOURCE Shall be an array or scalar of any type. If SOURCE is a pointer it must be associated and allocatable arrays must be allocated. KIND (Optional) An INTEGER initialization expression indicating the kind parameter of the result.
An INTEGER array of rank one with as many elements as SOURCE has dimensions. The elements of the resulting array correspond to the extend of SOURCE along the respective dimensions. If SOURCE is a scalar, the result is the rank one array of size zero. If KIND is absent, the return value has the default integer kind otherwise the specified kind.
Sample program:
program demo_shape implicit none integer, dimension(-1:1, -1:2) :: a write(*,*) shape(a) ! [ 3, 4 ] write(*,*) size(shape(42)) ! [ ] end program demo_shape
[[Fortran 95]] and later; with KIND argument [[Fortran 2003]] and later
[[Inquiry function]]
reshape(3), size(3)
shape (3) | March 11, 2021 |