2.4 Library Interfaces and system.inc

The Fortran compiler provides an include file, system.inc, that defines the interfaces for most
non-intrinsic library routines. Declare this include file to insure that functions you call
and their arguments are properly typed, especially when default data types are changed
with -xtypemap.

For example, the following may produce an arithmetic exception because function getpid() is
not explicitly typed:

integer(4) mypid
mypid = getpid()
print *, mypid

The getpid() routine returns an integer value but the compiler assumes it returns
a real value if no explicit type is declared for the function. This
value is further converted to integer, most likely producing a floating-point error.

To correct this you should explicitly type getuid() and functions like it that
you call:

integer(4) mypid, getpid
mypid = getpid()
print *, mypid

Problems like these can be diagnosed with the -Xlist (global program checking) option.
The Fortran include file ”system.inc’ provides explicit interface definitions for these routines.

include ’system.inc’
integer(4) mypid
mypid = getpid()
print *, mypid

Including system.inc in program units calling routines in the Fortran library will automatically
define the interfaces for you, and help the compiler diagnose type mismatches. (See
the Fortran Library Reference for more information.)