Assumed-rank objects (TS 29113)
Assumed-rank objects are dummy argument objects whose ranks are assumed from the associated actual arguments at run time. The actual argument that corresponds to an assumed-rank object can be an array or a scalar.
Assumed_rank_spec
If an assumed-rank dummy argument is associated with a scalar actual argument, the rank of the assumed-rank dummy argument is zero, and the shape of it is a zero-sized array.
Restrictions:
- An assumed-type actual argument that corresponds to an assumed-rank dummy argument must be assumed-shape or assumed-rank.
- An assumed-rank object cannot have the VALUE attribute.
- An assumed-rank object cannot be used in a designator or expression except in the following ways:
- As an actual argument that corresponds to a dummy argument that is assumed-rank
- As the argument of the C_LOC function in the ISO_C_BINDING intrinsic module
- As the first argument in a reference to an intrinsic inquiry function
Examples
REAL :: a0
REAL :: a1(10)
REAL :: a2(10, 20)
REAL, POINTER :: a3(:,:,:)
CALL sub1(a0)
CALL sub1(a1)
CALL sub1(a2)
CALL sub1(a3)
CONTAINS
SUBROUTINE sub1(a)
REAL :: a(..)
PRINT *, RANK(a)
END
END
The output is as follows:0
1
2
3