I have a procedure FRED that is given an argument which is supposed to be a memory address. The job of FRED is to test the value held at that address, and do something if the value meets certian criteria. I am well versed in using C_PTR and C_F_POINTER to convert the address into a Fortran pointer that I can then test in vanilla Fortran code.
My problem is that sometimes the address supplied is invalid, and any attempt to look at its contents causes "forrtl: severe (157): Program Exception - access violation".
I want to find a way to either (a) detect that the address is invalid, and avoid using it; or (b) disable the error 157 for the body of FRED, and re-enable it before FRED returns.
I have been playing around with SIGNAL and SIGNALQQ for a few hours now, without success. The help system for these routines is pretty comprehensive, but alas it omits (what to me, appear to be) vital details. Eg. the entry for SIGNALQQ says:
SIGNALQQ installs the function func as the handler for a signal of the type specified by sig. If you do not install a handler, the system by default terminates the program with exit code 3 when an interrupt signal occurs.
Which is fine as far as it goes, but it doesn't tell you how to reverse the effect of a previous call to SIGNALQQ, i.e. how to do not install a handler, or how to uninstall one, so as to reset things as they were before the call.
Please, can anyone share some example code that might do this? Or point me at some way to detect that a memory address is invalid? The help entry for "Using SIGNALQQ" mentions a sample program called GETEPTRS, but my installation doesn't have this. I am using VS2012 and Composer XE 2013, version 18.104.22.168.