Data transfer statements

The READ statement obtains data from an external or internal file and transfers the data to internal storage. If you specify an input list, values transfer from the file to the data items you specify.

The WRITE statement transfers data from internal storage into an external or internal file.

The PRINT statement transfers data from internal storage into an external file. Specifying the –qport=typestmt compiler option enables the TYPE statement which supports functionality identical to PRINT. If you specify an output list and format specification, values transfer to the file from the data items you specify. If you do not specify an output list, the PRINT statement transfers a blank record to the output device unless the FORMAT statement it refers to contains, as the first specification, a character string edit descriptor or a slash edit descriptor. In this case, the records these specifications indicate transfer to the output device.

Execution of a WRITE or PRINT statement for a file that does not exist creates that file, unless an error occurs.

If an input/output item is a pointer, data is transferred between the file and the associated target.

Fortran 2003 begins If an input or output item is polymorphic, or is a derived type with a pointer or an allocatable component, it must be processed by a user-defined derived-type input/output procedure. Fortran 2003 ends

During advancing input from a file with a PAD= specifier that has the value NO, the input list and format specification must not require more characters from the record than that record contains. If the PAD= specifier has the value YES, blank characters are supplied if the input list and format specification require more characters from the record than the record contains.

IBM extension begins If you want to pad files connected for sequential access, specify the -qxlf77=noblankpad compiler option. This compiler option also sets the default value for the PAD= specifier to NO for direct and stream files and YES for sequential files. IBM extension ends

During nonadvancing input from a file with a PAD= specifier that has the value NO, an end-of-record condition occurs if the input list and format specification require more characters from the record than the record contains. If the PAD= specifier has the value YES, an end-of-record condition occurs and blank characters are supplied if an input item and its corresponding data edit descriptor require more characters from the record than the record contains. If the record is the last record of a stream file, an end-of-file condition occurs.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us