Copyright (c) 1994 J. Adams, W. Brainerd, J. Martin, and B. Smith. All rights reserved. This file may not be copied without permission of the authors.
The ALLOCATE statement creates space for allocatable arrays and variables with the POINTER attribute. The DEALLOCATE statement frees space previously allocated for allocatable arrays and pointer targets. These statements give the user the ability to manage space dynamically at execution time.
COMPLEX, POINTER :: HERMITIAN (:, :) ! Complex array pointer READ *, M, N ALLOCATE ( HERMITIAN (M, N) ) . . . DEALLOCATE (HERMITIAN, STAT = IERR7)
REAL, ALLOCATABLE :: INTENSITIES (:,:) ! Rank-2 allocatable array DO ALLOCATE (INTENSITIES (I, J), & ! IERR4 will be positive STAT = IERR4) ! if there is IF (IERR4 == 0) EXIT ! insufficient space. I = I/2; J = J/2 END DO . . . IF (ALLOCATED (INTENSITIES)) DEALLOCATE (INTENSITIES)
TYPE NODE REAL VAL TYPE(NODE), POINTER :: LEFT, RIGHT ! Pointer components END TYPE NODE TYPE(NODE) TOP, BOTTOM . . . ALLOCATE (TOP % LEFT, TOP % RIGHT) IF (ASSOCIATED (BOTTOM % RIGHT)) DEALLOCATE (BOTTOM % RIGHT)
CHARACTER, POINTER :: PARA(:), KEY(:) ! Pointers to char arrays ALLOCATE (PARA (1000) ) . . . KEY => PARA (K : K + LGTH)
ALLOCATABLE Attribute and Statement
Dynamic Objects
NULLIFY Statement
POINTER Attribute and Statement
Pointers
ALLOCATED
ASSOCIATED
ISO 1539 : 1991, Fortran Standard, 6.3.1, 6.3.3
Fortran 90 Handbook, 6.5.1, 6.5.3
Programmer's Guide to Fortran 90, 4.1.5, 8.1.3
An ALLOCATE statement is:
ALLOCATE (
allocation-list [ , STAT =
scalar-integer-variable ] )
An allocation is:
allocate-object [ (
allocate-shape-spec-list )
]
An allocate object is one of:
variable-name
structure-component
An allocate shape specification is:
[ lower-bound :
] upper-bound
A DEALLOCATE statement is:
DEALLOCATE (
allocate-object-list [ , STAT =
scalar-integer-variable ] )