Fortran Library Reference

perror, gerror, ierrno: Get System Error Messages

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.  

perror: Print Message to Logical Unit 0, stderr

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" ) 

gerror: Get Message for Last Detected System Error

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 

ierrno: Get Number for Last Detected System Error

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: