Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 12/12/2025
Public
Document Table of Contents

RANK Clause

Type declaration clause: Specifies the DIMENSION attribute and the rank of a pointer, allocatable, or assumed-shape object.

Type Declaration Statement:

type,[att-ls,] RANK(scalar-int-const-exp) [,att-ls :: object [, object]...

type

Is a data type specifier.

att-ls

Is an optional list of attribute specifiers.

scalar-int-const-exp

Is non-negative with a value less than or equal to the maximum number of dimensions permitted (standard Fortran permits 15, the Intel Fortran compiler permits 31).

object

Is an allocatable, pointer or assumed-shape object.

Description

If scalar-int-const-exp is zero, the object is scalar, otherwise the object is given the DIMENSION attribute with the specified rank. An object declared with the RANK clause must either be a dummy argument, or have either the ALLOCATABLE or the POINTER attribute. If scalar-int-const-exp is non-zero and object has either the ALLOCATABLE or POINTER attribute, the object is a deferred-shape array, otherwise, it is an assumed-shape array whose lower bounds are all one.

An object may not be declared with both the RANK clause and the DIMENSION attribute, as RANK gives the object the DIMENSION attribute.

Example

The following examples show valid uses of the RANK clause in type declaration statements:

SUBROUTINE SUB (A, B)
REAL, DIMENSION(:,:, :)             :: A
REAL, RANK(RANK(A))                 :: B   ! Rank 3 assumed-shape
INTEGER, POINTER, RANK (2)          :: PTR ! Rank 2 deferred-shape
LOGICAL, ALLOCATABLE, RANK(RANK(A)) :: LA  ! Rank 3 deferred-shape
INTEGER                             :: I
INTEGER, RANK(RANK(I))              :: J   ! Scalar