next up previous contents
Next: F77's Assumed-Size Arrays Up: Array Arguments Previous: Assumed Shape Arrays   Contents

Automatic Arrays

Some temporary arrays can depend on dummy arguments; these arrays are truly automatic, they are created and destroyed with each invocation of the procedure. Automatic arrays are not dummy arguments; they are declared as explicit-shape arrays are, except that the size is depends oninput arguments - it is therefore known at run time only. Traditionally, such arrays are used for workspace. For example, two automatic arrays P1, P2 can be declared to conform to A:
subroutine commut(A,B,C)
  implicit none
  real, dimension(:,:), intent(in)  :: A, B
  real, dimension(:,:), intent(out) :: C
  real, dimension(size(A,1),size(B,2)) :: P1
  real, dimension(size(B,1),size(A,2)) :: P2
  P1 = matmul(A,B)
  P2 = matmul(B,A)
  C = P1 - P2
end subroutine commut
When using automatic arrays we have to include an interface in the calling program.

In F77 we had to explicitly pass the size of A in the argument list, and use this dummy variable to declare P1,P2:

subroutine commut(A,B,C,N)
real, dimension(N,N) :: P1,P2}

Note that automatic arrays cannot have the SAVE attribute - the reason being that they can have different shapes and sizes during different procedure calls.

Adrian Sandu 2001-08-26