Lahey/Fujitsu Fortran

SHAPE Function


The SHAPE function returns the shape of an array argument.


SHAPE (source)


source is an INTENT(IN) scalar or array of any type.

source must not be an assumed-size array, a pointer that is disassociated or an allocatable array that is not allocated.


The result is a default INTEGER array of rank one whose size is the rank of source and whose value is the shape of source.

If source is scalar, the result is an array of rank one and zero size.


integer :: i,ia(-2:2),ib(3,5,7),ic(9,2,4,6,5,3,3) write(*,*) shape(i) ! zero sized array write(*,*) shape(ia) ! writes 5 write(*,*) shape(ib) ! writes 3 5 7 write(*,*) shape(ic) ! writes 9 2 4 6 5 3 3