IERRNO

Portability Function: Returns the number of the last detected error from any routines in the IFPORT module that return error codes.

Module

USE IFPORT

result = IERRNO( )

Results

The result type is INTEGER(4). The result value is the last error code from any portability routines that return error codes. These error codes are analogous to errno on a Linux* or OS X* system. The module IFPORT.F90 provides parameter definitions for the following errno names (typically found in errno.h on Linux systems):

Symbolic name

Number

Description

EPERM

1

Insufficient permission for operation

ENOENT

2

No such file or directory

ESRCH

3

No such process

EIO

5

I/O error

E2BIG

7

Argument list too long

ENOEXEC

8

File is not executable

ENOMEM

12

Not enough resources

EACCES

13

Permission denied

EXDEV

18

Cross-device link

ENOTDIR

20

Not a directory

EINVAL

22

Invalid argument

The value returned by IERRNO is updated only when an error occurs. For example, if an error occurs on a GETLOG call and then two CHMOD calls succeed, a subsequent call to IERRNO returns the error for the GETLOG call.

Examine IERRNO immediately after returning from a portability routine. IERRNO is set on a per thread basis.

Example

USE IFPORT
CHARACTER*20 username
INTEGER(4) ierrval
ierrval=0 !initialize return value
CALL GETLOG(username)
IF (IERRNO( ) == ierrval) then
  print *, 'User name is ',username
  exit
ELSE
  ierrval = ierrno()
  print *, 'Error is ',ierrval
END IF
For more complete information about compiler optimizations, see our Optimization Notice.