According to the Fortran standards,
If the STAT= specifier appears, successful execution of the ALLOCATE statement causes the stat-variable to become defined with a value of zero. If an error condition occurs during the execution of the ALLOCATE statement, the stat-variable becomes defined with a processor-dependent positive integer value...
So far so good. However, it happens that modern operative systems tend to use delayed memory allocation, i.e. no error condition is raised when the ALLOCATE statement is executed. The program goes on, but when the exceeding memory is required, it crashes.
I thought that using the source statement in the allocation could allow to retain control of the memory but, at least trying on my MacBook Pro with gfortran, it does not work. Is there any workaround or we should renounce to keep control on memory management?