Explicit-shape arrays

Explicit-shape arrays are arrays where the bounds are explicitly specified for each dimension.

Explicit_shape_spec_list

Read syntax diagramSkip visual syntax diagram,lower_bound:upper_bound
lower_bound, upper_bound
are specification expressions

Arrays with bounds that are nonconstant expressions must be declared inside subprograms or Fortran 2008 beginsBLOCK constructsFortran 2008 ends. The nonconstant bounds are determined on entry to the subprogram or Fortran 2008 beginsBLOCK constructFortran 2008 ends. If a lower bound is omitted, its default value is one.

The rank is the number of specified upper bounds. The shape of an explicit-shape dummy argument can differ from that of the corresponding actual argument.

The size is determined by the specified bounds.

The size of an explicit-shape dummy argument does not need to be the same as the size of the actual argument, but the size of the dummy argument cannot be larger than the size of the actual argument.

F2008 beginsYou can specify the VALUE attribute on explicit-shape arrays.Fortran 2008 ends

Examples

INTEGER A,B,C(1:10,-5:5)  ! All bounds are constant
A=8; B=3
CALL SUB1(A,B,C)
END
SUBROUTINE SUB1(X,Y,Z)
  INTEGER X,Y,Z(X,Y)      ! Some bounds are not constant
END SUBROUTINE

Related information

BLOCK construct (Fortran 2008)

VALUE (Fortran 2003)