Next: Automatic Arrays
Up: Procedures and Array Arguments
Previous: Explicit-shape Arrays
Declaring dummy arrays as assumed-shape arrays is the recommended
method in Fortran 90. Consider,
PROGRAM TV
IMPLICIT NONE
...
REAL, DIMENSION(40) :: X
REAL, DIMENSION(40,40) :: Y
...
CALL gimlet(X,Y)
CALL gimlet(X(1:39:2),Y(2:4,4:4))
CALL gimlet(X(1:39:2),Y(2:4,4)) ! invalid
...
CONTAINS
SUBROUTINE gimlet(a,b)
REAL, INTENT(IN) :: a(:), b(:,:)
...
END SUBROUTINE gimlet
END PROGRAM TV
An assumed-shape array declaration must have the same
type, rank and kind as the actual argument. The compiler will insist on
this.
Note:
- array sections can be passed so long as they are regular, that is, not
defined by vector subscripts. The reason for this is concerned with
efficiency. A vector
subscripted section will be non-trivial to find in the memory, it is
likely to be widely scattered and would
probably need to be copied on entry to the procedure and then copied back
on exit, this will create all sorts of runtime penalties.
- the actual argument cannot be an assumed-size array. If an actual
argument were an assumed-size array then the
bound / extent information of the last dimension would not be known meaning
that
the relevant information could not be passed on to a further procedure.
The third call is invalid because
the second section reference has one dimensions whereas the
declaration of the dummy has two.
Return to corresponding overview page
Next: Automatic Arrays
Up: Procedures and Array Arguments
Previous: Explicit-shape Arrays
©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997Not for commercial use.