SHAPE — Determine the shape of an array#
- 
SHAPE(SOURCE, KIND)#
- Determines the shape of an array. - Parameters
- SOURCE – Shall be an array or scalar of any type. If - SOURCEis a pointer it must be associated and allocatable arrays must be allocated.
- KIND – (Optional) An - INTEGERinitialization expression indicating the kind parameter of the result.
 
- Returns
- An - INTEGERarray of rank one with as many elements as- SOURCEhas dimensions. The elements of the resulting array correspond to the extend of- SOURCEalong the respective dimensions. If- SOURCEis a scalar, the result is the rank one array of size zero. If- KINDis absent, the return value has the default integer kind otherwise the specified kind.
 - Standard:
- Fortran 90 and later, with - KINDargument Fortran 2003 and later
- Class:
- Inquiry function 
- Syntax:
- RESULT = SHAPE(SOURCE [, KIND]) 
- Example:
- PROGRAM test_shape INTEGER, DIMENSION(-1:1, -1:2) :: A WRITE(*,*) SHAPE(A) ! (/ 3, 4 /) WRITE(*,*) SIZE(SHAPE(42)) ! (/ /) END PROGRAM 
- See also:
- RESHAPE — Function to reshape an array, SIZE — Determine the size of an array