Fortran 90

6.1 Example
In this example, the SIZE intrinsic is used to set the extent of the work array based on the size of the input arrays. The work array is an automatic array; the inputs are assumed-shape arrays. With Fortran 90 constructs, there is therefore no need to supply explicit size information anywhere within this subroutine. Even the potential need to specify explicit bounds for DO-loops has been eliminated, through the use of Fortran 90 array assignments.
 SUBROUTINE swap(a,b)
 IMPLICIT NONE
 REAL, DIMENSION(:) :: a,b
 REAL, DIMENSION(SIZE(a)) :: work
 work = a 
 a = b
 b = work
 END
This example illustrates an important principle of Fortran 90: arrays should be thought of as ``array objects'' which contain embedded information about size and other attributes of the array, as well as the array data.