Description
This idea was originally proposed a few months back on C.L.F. b someone else so I'm echoing it here
Add an optional deallocate/reallocate logical argument to ALLOCATE to tell it to check allocation status of any variable in its allocate list and deallocate it prior to allocating to a new size if it is already allocated.
Example
Instead of having to code
If (ALLOCATED(A)) DEALLOCATE(A)
ALLOCATE(A(N))
do
ALLOCATE(A(N), REALLOCATE=.TRUE.) or
ALLOCATE(A(N), DEALLOCATE=.TRUE.) ! either syntax works for me
Basically you are telling the compiler to check allocation status and instead of issueing an error (absent the status variable), do the deallocation for me and then reallocate.
This can save several lines of code if you have a lot of dynamic arrays that you need to periodically resize