shape

Date:

02-06-2023

NAME

SHAPE - Returns the shape of an array or a scalar

SYNOPSIS

SHAPE ([SOURCE=]source[, [KIND=]kind])

STANDARDS

Fortran

DESCRIPTION

The SHAPE intrinsic function returns the shape of an array or a scalar. It accepts the following argument:

source

The source argument may be of any type. It can be array valued or scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated. It must not be an assumed-size array.

kind

The kind argument determines the kind type of the return result. If this argument is not specified, the return result is of type default integer.

  • This argument must be a scalar integer initialization expression.

SHAPE is an inquiry function. The name of this intrinsic cannot be passed as an argument.

RETURN VALUES

The result is an integer array of rank 1 whose size is equal to the rank of source. The value of the result is the shape of source.

EXAMPLES

SHAPE(3) yields a zero-sized, rank-one array.

INTEGER, DIMENSION(2:5,-1:1) :: A
SHAPE(A)    ! yields **(/4,3/)**.