I am running a FORTRAN program that allocates memory dynamically for rather large arrays, and sometimes they do not fit into memory.
Thus the allocation
allocate(my_array(really big_number))
will give the error
Operating system error: Cannot allocate memory
Allocation would exceed memory limit
and the program would exit. I would like to know if there is any way to capture this or test that the memory will be available, so that i can take appropriate measures if I'm not allowed to allocate such a big array?