EQUIVALENCE
and COMMON
statements, and the BLOCK DATA
program unit,
are considered to be obsolescent (and reported as such when the -f2018 option is used).
ALLOCATABLE
or POINTER
attribute, and thus accept allocatable/pointer variables of any rank.
The syntax is as follows:
Real,Dimension(..) :: a, b Integer :: c(..)That declares three variables (which must be dummy arguments) to be assumed-rank.
The use of assumed-rank dummy arguments within Fortran is extremely limited; basically, the
intrinsic inquiry functions can be used, and there is a SELECT RANK
construct, but other
than that they may only appear as actual arguments to other procedures where they correspond to
another assumed-rank argument.
The main use of assumed rank is for advanced C interoperability (see later section).
Here is an extremely simple example of use within Fortran:
Program assumed_rank_example Real x(1,2),y(3,4,5,6,7) Call showrank(1.5) Call showrank(x) Call showrank(y) Contains Subroutine showrank(a) Real,Intent(In) :: a(..) Print *,'Rank is',Rank(a) End Subroutine End ProgramThat will produce the output
Rank is 0 Rank is 2 Rank is 5
TYPE(*)
type specifier can be used to declare scalar, assumed-size, and assumed-rank dummy arguments.
Such an argument is called assumed-type; the corresponding actual argument may be of any type.
It must not have the ALLOCATABLE
, CODIMENSION
, INTENT (OUT)
, POINTER
,
or VALUE
attribute.
An assumed-type variable is extremely limited in the ways it can be used directly in Fortran:
IS_CONTIGUOUS
, LBOUND
,
PRESENT
, SHAPE
, SIZE
, or UBOUND
;
C_LOC
(in the ISO_C_BINDING
intrinsic module}.
This is mostly useful for interoperating with C programs (see later section).