I seem to remember the open in gfortran has the possibility to return the result of iostat as a string, but I have forgotten the option name to return the string.
Does anybody remember the parameter to use?
From ftp://ftp.nag.co.uk/sc22wg5/n1551-n1600/n1579.pdf:
IOMSG= specifier: Any input/output statement is permitted to have an IOMSG= specifier. This identifies a scalar variable of type default character into which the processor places a message if an error, end-of-file, or end-of-record condition occurs during execution of the statement. If no such condition occurs, the value of the variable is not changed.