Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP Fortran statements

DEALLOCATE

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Deallocates allocatable arrays and pointer targets.

Syntax

DEALLOCATE (alloc-obj-list[, STAT=scalar-int-var])
alloc-obj-list

is a comma-separated list of pointers or allocatable arrays.

STAT=scalar-int-var

returns the error status after the statement executes. If given, it is set to a positive value if an error is detected, and to zero otherwise. If there is no status variable, the occurrence of an error causes the program to terminate.

Description

The DEALLOCATE statement deallocates allocatable arrays and pointer targets, making the memory available for reuse. A specified allocatable array then becomes not allocated (as reported by the ALLOCATED intrinsic), while a specified pointer becomes disassociated (as reported by the ASSOCIATED intrinsic).

An error occurs if an attempt is made to deallocate an allocatable array that is not currently allocated or a pointer that is not associated. Errors in the operation of DEALLOCATE can be reported by means of the optional STAT= specifier.

You can deallocate an allocatable array by specifying the name of the array with the DEALLOCATE statement. You cannot deallocate a pointer that points to an object that was not allocated.

Some or all of a target associated with a pointer by means of the ALLOCATE statement can also be associated subsequently with other pointers. However, it is not permitted to deallocate a pointer that is not currently associated with the whole of an allocated target object.

Deallocation of a pointer target causes the association status of any other pointer associated with all or part of the target to become undefined. When a pointer is deallocated, its association status becomes disassociated, as if a NULLIFY statement had been executed.

Examples

The following example declares a complex array with the POINTER attribute. The ALLOCATE statement allocates target space to the array at run-time; the amount is determined by the input values to the READ statement. Later in the program, the DEALLOCATE statement will recover the space.

COMPLEX, POINTER :: hermitian (:, :)
...
READ *, m, n
ALLOCATE (hermitian (m, n))
...
DEALLOCATE (hermitian, STAT = ierr)

Related statements

ALLOCATABLE, ALLOCATE, NULLIFY, and POINTER

Related concepts

For related information, see the following:

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.