Transfer I/O statements include READ, WRITE, REWRITE, ACCEPT, TYPE, and PRINT. Auxiliary I/O statements include OPEN, CLOSE, INQUIRE, REWIND, BACKSPACE, ENDFILE, DELETE, and UNLOCK. Transfer I/O statements may be formatted (F), unformatted (U), list-directed (L-D), or namelist (N) as follows: ACCEPT Sequential -- F, L-D, N DELETE Relative -- U Indexed -- U PRINT Sequential -- F, L-D, N READ Sequential -- F, U, L-D, N Direct Access -- F, U Internal -- F, L-D Indexed -- F, U REWRITE Relative -- F, U Sequential -- F Indexed -- F, U TYPE Sequential -- F, L-D, N WRITE Sequential -- F, U, L-D, N Direct Access -- F, U Internal -- F, L-D Indexed -- F, U
1 – Formatted
Formatted I/O statements contain explicit format specifiers that are used to control the translation of data from internal (binary) form within a program to external (readable character) form in the records, or vice versa. Formatted I/O statements must have a format (FMT=) specified in the control list (clist). Additional "clist" elements are required depending on the type of access. Formatted sequential READ: READ (UNIT=u,FMT=f[,ADVANCE=exp][,SIZE=var][,IOSTAT=ios] [,ERR=err][,END=end]) [iolist] READ f [,iolist] Formatted direct access READ: READ (UNIT=u,REC=rec,FMT=f[,IOSTAT=ios][,ERR=err]) [iolist] Formatted indexed READ: READ (UNIT=u,FMT=f,KEY=k[,KEYID=n][,IOSTAT=ios] [,ERR=err]) [iolist] Formatted internal READ: READ (UNIT=u,FMT=f[,IOSTAT=ios][,ERR=err][,END=end]) [iolist] Formatted sequential WRITE: WRITE (UNIT=u,FMT=f[,ADVANCE=exp][,IOSTAT=ios] [,ERR=err]) [iolist] Formatted direct access WRITE: WRITE (UNIT=u,REC=rec,FMT=f[,IOSTAT=ios][,ERR=err]) [iolist] Formatted indexed WRITE: WRITE (UNIT=u,FMT=f[,IOSTAT=ios][,ERR=err]) [iolist] Formatted internal WRITE: WRITE (UNIT=u,FMT=f[,IOSTAT=ios][,ERR=err]) [iolist]
2 – Unformatted
Unformatted I/O statements do not contain format specifiers and therefore do not translate the data being transferred. Unformatted I/O is especially appropriate where the output data will subsequently be used as input. Unformatted I/O saves execution time by eliminating the data translation process, preserves greater precision in the external data, and usually conserves file storage space. Unformatted I/O statements do not specify a format (FMT=) in the control list (clist). Other "clist" elements are required depending on the type of access. Unformatted sequential READ: READ (UNIT=u[,IOSTAT=ios][,ERR=err][,END=end]) [iolist] Unformatted direct access READ: READ (UNIT=u,REC=rec[,IOSTAT=ios][,ERR=err]) [iolist] Unformatted indexed READ: READ (UNIT=u,KEY=k[,KEYID=n][,IOSTAT=ios][,ERR=err]) [iolist] Unformatted sequential WRITE: WRITE (UNIT=u,[,IOSTAT=ios][,ERR=err]) [iolist] Unformatted direct access WRITE: WRITE (UNIT=u,REC=rec[,IOSTAT=ios][,ERR=err]) [iolist] Unformatted indexed WRITE: WRITE (UNIT=u[,IOSTAT=ios][,ERR=err]) [iolist]
3 – List-Directed
List-directed I/O statements are similar to formatted statements in function, but control the translation of data through data types instead of explicit format specifiers. List-directed I/O statements specify a format (FMT=) in the control list (clist). Other "clist" elements are required depending on the type of access. List-directed sequential READ: READ (UNIT=u,FMT=*[,IOSTAT=ios][,ERR=err][,END=end]) [iolist] READ * [,iolist] List-directed internal READ READ (UNIT=u,FMT=*[,IOSTAT=ios][,ERR=err][,END=end]) [iolist] List-directed sequential WRITE WRITE (UNIT=u,FMT=*[,IOSTAT=ios][,ERR=err]) [iolist] List-directed internal WRITE WRITE (UNIT=u,FMT=*[,IOSTAT=ios][,ERR=err]) [iolist]
4 – Namelist
Namelist I/O statements are similar to formatted statements in function, but control the translation of data through data types instead of explicit format specifiers. Namelist I/O statements do not specify a format (FMT=) in the control list (clist). Namelist sequential READ: READ (UNIT=u,NML=nml[,IOSTAT=ios][,ERR=err][,END=end]) READ n Namelist sequential WRITE: WRITE (UNIT=u,NML=nml[,IOSTAT=ios][,ERR=err]) Comments (beginning with ! only) can appear anywhere in namelist input. The comment extends to the end of the source line.