Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 3/31/2025
Public
Document Table of Contents

User-Defined Derived-Type I/O

By default, when a derived-type (DT) object is in a formatted I/O statement, it is treated as if all of its components were specified in the component order. The components must be accessible in the scope of the I/O statement and they cannot be pointers or allocatables. In an unformatted I/O statement, a derived-type object is treated as a single value in a processor-dependent form.

User-defined derived-type I/O lets you replace the default I/O processing for a derived-type object. For both unformatted and formatted I/O, a procedure can be invoked that will handle the I/O of the derived type. This is similar to defined operators and defined assignment.

For formatted I/O, the replacement occurs for list-directed formatting, namelist formatting, and for an explicit format with the DT edit descriptor. Other edit descriptors in the explicit format do not have any effect on user-defined I/O.

A procedure can be associated with defined I/O through generic bindings or generic interface blocks. The procedure must conform to the interface that specifies its characteristics. It cannot directly or indirectly use OpenMP* constructs. A defined I/O procedure can also call itself recursively.

An I/O statement that includes a derived-type object and causes a defined I/O procedure to be invoked is called a parent I/O statement. An I/O statement that is executed while a parent statement is being processed, and specifies the unit passed to a defined I/O procedure, is called a child I/O statement.

A defined I/O procedure can be invoked as a parent I/O statement for an external or internal file opened for sequential, direct, or stream access.

This section also has information about how to resolve user-defined I/O procedure references.

NOTE:
Defined I/O procedures must be compiled with the nomixed_str_len_arg argument passing convention for Windows. This can be achieved either by specifying /iface:nomixed_len_str_arg on the command line, or with a !DEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG directive.