These routines perform the following functions:
perror |
Print a message to Fortran logical unit 0, stderr. |
gerror |
Get a system error message (of the last detected system error) |
ierrno |
Get the error number of the last detected system error. |
The subroutine is called by:
call perror( string ) |
|||
string |
character*n |
Input |
The message. It is written preceding the standard error message for the last detected system error. |
Example 1:
call perror( "file is for formatted I/O" ) |
The subroutine or function is called by:
call gerror( string ) |
|||
string |
character*n |
Output |
Message for the last detected system error |
Example 2: gerror() as a subroutine:
character string*30 … call gerror ( string ) write(*,*) string |
Example 3: gerror() as a function; string not used:
character gerror*30, z*30 … z = gerror( ) write(*,*) z |
The function is called by:
n = ierrno() |
|||
Return value |
INTEGER*4 |
Output |
Number of last detected system error |
This number is updated only when an error actually occurs. Most routines and I/O statements that might generate such errors return an error code after the call; that value is a more reliable indicator of what caused the error condition.
Example 4: ierrno():
INTEGER*4 ierrno, n … n = ierrno() write(*,*) n |
See also intro(2) and perror(3).
Note:
string in the call to perror cannot be longer than 127 characters.
The length of the string returned by gerror is determined by the calling program.
Runtime I/O error codes for f95 are listed in the Fortran User’s Guide.