To improve performance, the XL Fortran run-time library has its own buffers
and its own handling of these buffers. This means that mixed-language
programs cannot freely mix I/O operations on the same file from the different
languages. To maintain data integrity in such cases:
- If the file position is not important, open and explicitly close the file
within the Fortran part of the program before performing any I/O operations on
that file from subprograms written in another language.
- To open a file in Fortran and manipulate the open file from another
language, call the flush_ procedure to save any buffer for that file,
and then use the getfd procedure to find the corresponding file
descriptor and pass it to the non-Fortran subprogram. As an alternative
to calling the flush_ procedure, you can use the buffering
run-time option to disable the buffering for I/O operations. When you
specify buffering=disable_preconn, XL Fortran disables the buffering
for preconnected units. When you specify
buffering=disable_all, XL Fortran disables the buffering for all
logical units.
- Note:
- After you call flush_ to flush the buffer for a file, do not do
anything to the file from the Fortran part of the program except to close it
when the non-Fortran processing is finished.
- If any XL Fortran subprograms containing WRITE statements are
called from a non-Fortran main program, explicitly CLOSE the data
file, or use the flush_ subroutine in the XL Fortran subprograms to
ensure that the buffers are flushed. Alternatively, you can use the
buffering run-time option to disable buffering for I/O
operations.
- Related Information:
- For more information on the flush_ and getfd procedures,
see the Service and Utility
Procedures section in the XL Fortran Language
Reference. For more information on the buffering
run-time option, see Setting Run-Time Options.
