The Deallocate statement dynamically deallocates allocatable arrays and pointer arrays. This means that the memory space that was associated with these variables is freed up for possible reuse elsewhere in the program.
There are a few rules and things to keep in mind when using this statement. First, the array that is specified to be deallocated must have been allocated earlier on. Next, if the array that to be deallocated was specified as a target array, any pointers that are associated with the array become undefined once the target is deallocated. Also, an allocatable target array can not be deallocated through the deallocation of a pointer array that points to all or part of the target array. Finally, deallocation of a dynamically allocated pointer array prior to associating it with another target is the only way of preventing the block of memory the pointer was associated with from becoming inaccessible for use by the program, if the pointer is associated with another target.
The use of the deallocate statement is pretty simple. The syntax is exactly the same when using it to deallocate a pointer array or an allocatable array. It is used in the following manner.
Written by Jason Wehr: firstname.lastname@example.org and Maintained by John Mahaffy : email@example.com