# 6 Dynamic Allocation

Data objects can be static or dynamic. If a data object is static, a fixed amount of memory storage is created for it at compile time and is not freed until the program exits. If a data object is dynamic, memory storage for the object can be created (allocated), altered, or freed (deallocated) as a program executes.

In Fortran 95/90, pointers, allocatable arrays, and automatic arrays are dynamic data objects.

No storage space is created for a pointer until it is allocated with an ALLOCATE statement or until it is assigned to a allocated target. A pointer can be dynamically disassociated from a target by using a NULLIFY statement.

An ALLOCATE statement can also be used to create storage for an allocatable array. A DEALLOCATE statement is used to free the storage space reserved in a previous ALLOCATE statement.

Automatic arrays differ from allocatable arrays in that they are automatically allocated and deallocated whenever you enter or leave a procedure, respectively.

This chapter contains information on the following topics:

- The ALLOCATE Statement (Section 6.1)
- The DEALLOCATE Statement (Section 6.2)
- The NULLIFY Statement (Section 6.3)

For More Information:

- On pointer assignment, see Section 4.2.3.
- On automatic arrays, see Section 5.1.4.1.
- On the NULL intrinsic function, which can also be used to disassociate a pointer, see Section 9.3.111.

Previous Page Next Page Table of Contents