|Skip Navigation Links|
|Exit Print View|
|Oracle Solaris Studio 12.3: Fortran User's Guide Oracle Solaris Studio 12.3 Information Library|
The section describes extensions to Fortran 95 Input/Output handling that are accepted by the f95 compiler that are not part of the Fortran 2003 standard. Some are I/O extensions that appeared in the Fortran 77 compiler, f77, and are now part of the Fortran compiler.
Two new functions enable the user to specify their own error handling routine for formatted input on a logical unit. When a formatting error is detected, the runtime I/O library calls the specified user-supplied handler routine with data pointing at the character in the input line causing the error. The handler routine can supply a new character and allow the I/O operation to continue at the point where the error was detected using the new character; or take the default Fortran error handling.
The new routines, SET_IO_ERR_HANDLER(3f) and GET_IO_ERR_HANDLER(3f), are module subroutines and require USE SUN_IO_HANDLERS in the routine that calls them. See the man pages for these routines for details.
Fortran 77 allowed any integer constant in a format to be replaced by an arbitrary expression enclosed in angle brackets:
1 FORMAT( … < expr > … )
Variable format expressions cannot appear as the n in an nH… edit descriptor, in a FORMAT statement that is referenced by an ASSIGN statement, or in a FORMAT statement within a parallel region.
This feature is enabled natively in f95, and does not require the -f77 compatibility option flag.
The group name may be preceded by $ or & on input. The & is the only form accepted by the Fortran 95 standard, and is what is written by NAMELIST output.
Accepts $ as the symbol terminating input except if the last data item in the group is CHARACTER data, in which case the $ is treated as input data.
Allows NAMELIST input to start in the first column of a record.
Opening a file with FORM=’BINARY’ has roughly the same effect as FORM=’UNFORMATTED’, except that no record lengths are embedded in the file. Without this data, there is no way to tell where one record begins, or ends. Thus, it is impossible to BACKSPACE a FORM=’BINARY’ file, because there is no way of telling where to backspace to. A READ on a ’BINARY’ file will read as much data as needed to fill the variables on the input list.
WRITE statement: Data is written to the file in binary, with as many bytes transferred as specified by the output list.
READ statement: Data is read into the variables on the input list, transferring as many bytes as required by the list. Because there are no record marks on the file, there will be no “end-of-record” error detection. The only errors detected are “end-of-file” or abnormal system errors.
INQUIRE statement: INQUIRE on a file opened with FORM=”BINARY” returns:
FORM=”BINARY”ACCESS=”SEQUENTIAL”DIRECT=”NO”FORMATTED=”NO”UNFORMATTED=”YES”RECL= AND NEXTREC= are undefined
BACKSPACE statement: Not allowed—returns an error.
ENDFILE statement: Truncates file at current position, as usual.
REWIND statement: Repositions file to beginning of data, as usual.
Recursive I/O possible on different units (this is because the f95 I/O library is "MT-Warm").
RECL=2147483646 (231-2) is the default record length on sequential formatted, list directed, and namelist output.
ENCODE and DECODE are recognized and implemented as described in the FORTRAN 77 Language Reference Manual.
Non-advancing I/O is enabled with ADVANCE=’NO’, as in:
write(*,’(a)’,ADVANCE=’NO’) ’n= ’ read(*,*) n