XL Fortran for AIX 8.1

Language Reference

DEALLOCATE

Purpose

The DEALLOCATE statement dynamically deallocates allocatable objects and pointer targets. A specified pointer becomes disassociated, while any other pointers associated with the target become undefined.

Format



>>-DEALLOCATE--(--allocate_object_list--+-----------------------------+--)-><
                                        '-,--STAT-- = --stat_variable-'
 
 

object
is a pointer or an allocatable object

stat_variable
is a scalar integer variable

Rules

An allocatable object that appears in a DEALLOCATE statement must be currently allocated. An allocatable object with the TARGET attribute cannot be deallocated through an associated pointer. Deallocation of such an object causes the association status of any associated pointer to become undefined. An allocatable object that has an undefined allocation status cannot be subsequently referenced, defined, allocated, or deallocated. Successful execution of a DEALLOCATE statement causes the allocation status of an allocatable object to become not allocated.

When a variable of derived type is deallocated, any allocated subobject is also deallocated.

When an intrinsic assignment statement is executed, any allocated subobject of the variable is deallocated before the assignment takes place.

A pointer that appears in a DEALLOCATE statement must be associated with a whole target that was created with an ALLOCATE statement. Deallocation of a pointer target causes the association status of any other pointer associated with all or part of the target to become undefined.

Tips

Use the DEALLOCATE statement instead of the NULLIFY statement if no other pointer is associated with the allocated memory.

Deallocate memory that a pointer function has allocated.

If the STAT= specifier is not present and an error condition occurs during execution of the statement, the program terminates. If the STAT= specifier is present, stat_variable is assigned one of the following values:

+-------------------------------IBM Extension--------------------------------+


Stat value Error condition
0 No error
1 Error in system routine attempting to do deallocation
2 An invalid data object has been specified for deallocation
3 Both error conditions 1 and 2 have occurred

+----------------------------End of IBM Extension----------------------------+

An allocate_object does not depend on the value, bounds, allocation status, or association status of another allocate_object in the same DEALLOCATE statement; nor does it depend on the value of the stat_variable in the same DEALLOCATE statement.

stat_variable cannot be deallocated within the same DEALLOCATE statement; nor does it depend on the value, bounds, allocation status, or association status of any allocate_object in the same DEALLOCATE statement.

Examples

INTEGER, ALLOCATABLE :: A(:,:)
INTEGER X,Y
      
  ·
  ·
  ·
ALLOCATE (A(X,Y))
  ·
  ·
  ·
DEALLOCATE (A,STAT=I) END

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]