next up previous contents
Next: Array-valued Functions Up: Procedures and Array Arguments Previous: Assumed-shape Arrays

 

Automatic Arrays

 

Other arrays can depend on dummy arguments, these are called automatic arrays and their size is determined by the values of dummy arguments. These arrays have local scope and a limited lifespan and, as they have their size determined by dummy arguments and are created and destroyed with each invocation of the procedure, cannot have the SAVE attribute (or be initialised). Arrays of this class are traditionally used for workspace.

Consider,

    PROGRAM Main
     IMPLICIT NONE
      INTEGER :: IX, IY
       ....
       CALL une_bus_riot(IX,2,3)
       CALL une_bus_riot(IY,7,2)
    CONTAINS
     SUBROUTINE une_bus_riot(A,M,N)
      INTEGER, INTENT(IN) :: M, N
      INTEGER, INTENT(INOUT) :: A(:,:)
      REAL  :: A1(M,N)             ! automatic
      REAL  :: A2(SIZE(A,1),SIZE(A,2)) ! ditto
      REAL  :: A3(A(1,1),A(1,1))   ! automatic
      ...
     END SUBROUTINE
    END PROGRAM Main

The bound specifiers of an automatic array can originate from:

There is currently no way to tell whether an automatic array has been created. Typically, if there is insufficient memory to allocate an automatic array, the program will ungracefully crash. If this is not desired then the less intuitive allocatable array should be used.

Now try this question gif

Return to corresponding overview page gif


next up previous contents
Next: Array-valued Functions Up: Procedures and Array Arguments Previous: Assumed-shape Arrays

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.