The DEALLOCATE statement deallocates allocatable arrays and pointer targets and disassociates pointers.
SyntaxDEALLOCATE ( object-list [, STAT=stat-variable] )Where:
object-list is a comma-separated list of pointers or allocatable arrays.
stat-variable is a scalar INTEGER variable that returns a status value.
If the optional STAT= is present and the DEALLOCATE statement succeeds, stat-variable is assigned the value zero. If STAT= is present and the DEALLOCATE statement fails, stat-variable is assigned the number of the error message generated at runtime.
If an error condition occurs during execution of a DEALLOCATE statement that does not contain the STAT= specifier, the executable program is terminated.
Deallocating an allocatable array that is not currently allocated or a pointer that is disassociated or whose target was not allocated causes an error condition in the DEALLOCATE statement.
If a pointer is currently associated with an allocatable array, the pointer must not be deallocated.
Deallocating an allocatable array or pointer causes the status of any pointer associated with it to become undefined.
Exampleinteger,pointer,dimension(:,:) :: ip => null() integer,allocatable,dimension(:) :: jp integer :: allostat allocate (ip(10,20),jp(10)) deallocate(ip) deallocate(jp,stat=allostat) write(*,*) allostat