Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Deallocation of Pointer Targets

A pointer must not be deallocated unless it has a defined association status. If the DEALLOCATE statement specifies a pointer that has undefined association status, or a pointer whose target was not created by allocation, an error occurs.

A pointer must not be deallocated if it is associated with an allocatable array, or it is associated with a portion of an object (such as an array element or an array section).

If a pointer is deallocated, the association status of any other pointer associated with the target (or portion of the target) becomes undefined.

Execution of a RETURN or END statement in a subprogram causes the pointer association status of any pointer declared or accessed in the procedure to become undefined, unless any of the following applies to the pointer:

  • It has the SAVE attribute.

  • It is in the scoping unit of a module that is accessed by another scoping unit which is currently executing.

  • It is accessible by host association.

  • It is in blank common.

  • It is in a named common block that appears in another scoping unit that is currently executing.

  • It is the return value of a function declared with the POINTER attribute.

If the association status of a pointer becomes undefined, it cannot subsequently be referenced or defined.

Examples

The following example shows deallocation of a pointer:

  INTEGER ERR
  REAL, POINTER :: PTR_A(:)
  ...
  ALLOCATE (PTR_A(10), STAT=ERR)
  ...
  DEALLOCATE(PTR_A)