FORTRAN Reference Manual

Mixed-Language Programming
FORTRAN Reference Manual528615-001
13-27
Using Shared Files
Manage traps.
Provide standard math routines that support FORTRAN intrinsic functions.
Manage $RECEIVE.
Ensure proper initialization and graceful termination of your program.
Using Shared Files
The CRE provides shared access to three files:
Standard input
Standard output
Standard log
Sharing File Opens
A FORTRAN program accesses standard input if it reads from unit 5. It accesses
standard output if it writes to unit 6. A FORTRAN program cannot establish a unit
connection to standard log, although the FORTRAN run-time library can write
messages to standard log, typically if errors occur while a FORTRAN module is
executing. In addition, FORTRAN writes to standard log the message you specify on a
PAUSE or STOP statement and in a call to the FORTRAN_COMPLETION_ utility.
Except for units 5 and 6, all FORTRAN units have the same semantics when you
specify ENV COMMON as they do when you specify ENV OLD or you run a program
compiled with a C-series FORTRAN compiler.
Using Unit 5 and Unit 6
If you open unit 5 or unit 6, either implicitly or without specifying the MODE specifier,
your program accesses units 5 and 6 just as it does in C-series software. The default
access MODE for both units is I-O. If you open unit 5 or unit 6 with MODE = I-O,
FORTRAN establishes a connection between the specified unit and a Guardian file.
Your program does not share a file open—a path to the file—with routines written in
other languages and bound, along with your FORTRAN routines, into a single object
file.
If you change the access MODE for unit 5 to 'INPUT' or for unit 6 to 'OUTPUT', the
FORTRAN run-time library calls routines in the CRE to manage the standard input and
standard output files. (Additional parameters can affect whether the FORTRAN run-
time library calls CRE routines. For additional information, see the OPEN Statement on
page 7-70.) In this case, your FORTRAN routines share access to a single Guardian
open of standard input and a single Guardian open of standard output with routines in
your process that are written in other languages. The CRE manages the single file
open. Upon receiving its first request to open a shared file (that is, unit 5 or unit 6 for
FORTRAN), the CRE opens the specified Guardian file. However, subsequent
requests to open standard input or standard output from routines written in different