For example,
allocate(PtoR,STAT=ierr) allocate(PtoA(n*n,2*k-1),STAT=ierr)allocate new space for a single real, and then for a rank 2 array. If PtoA, PtoR were previously associated with other targets, those associations are broken (overwritten) by the ALLOCATE statements.
The deallocation statement
deallocate(PtoR,STAT=ierr)breaks the connection between the pointer and its target and returns the freed space to the heap. The pointer remains in disassociated status.
We cannot use a pointer deallocate statement for objects that were not created by pointer allocation (e.g. allocate an allocatable matrix and associate a pointer to it, cannot just deallocate the pointer).
Note that nullifying the ``allocated'' pointer is possible
nullify(PtoR)but is not recommended; nullification breaks the pointer-target connection, but does not free the target storage; this space will become inaccessible until the program terminates, unless it is pointed to by at least one more pointer.