Fortran Wiki
rank

Description

rank(a) returns the rank of a scalar or array data object.

Standard

TS 29113?

Class

Inquiry function

Syntax

result = rank(a)

Arguments

  • a - can be of any type

Return value

The return value is of type integer and of the default integer kind. For arrays, their rank is returned; for scalars zero is returned.

Example

program test_rank
  integer :: a
  real, allocatable :: b(:,:)

  print *, rank(a), rank(b) ! Prints:  0  2
end program test_rank

category: intrinsics