The DEALLOCATE statement frees the storage allocated for allocatable arrays and pointer targets (and causes the pointers to become disassociated). It takes the following form:
Rules and Behavior
If a STAT variable is specified, it must not be deallocated in the DEALLOCATE statement in which it appears. If the deallocation is successful, the variable is set to zero. If the deallocation is not successful, an error condition occurs, and the variable is set to a positive integer value (representing the run-time error). If no STAT variable is specified and an error condition occurs, program execution terminates.
It is recommended that all explicitly allocated storage be explicitly deallocated when it is no longer needed.
The following example shows deallocation of an allocatable array:
INTEGER ALLOC_ERR REAL, ALLOCATABLE :: A(:), B(:,:) ... ALLOCATE (A(10), B(-2:8,1:5)) ... DEALLOCATE(A, B, STAT = ALLOC_ERR)
For More Information:
For details on run-time error messages, see your user manual or online documentation.