FORTRAN 77 Language Reference

Internal Files

An internal file is a character-string object, such as a constant, variable, substring, array, element of an array, or field of a structured record--all of type character. For a variable or substring, there is only a single record in the file but for an array; each array element is a record.

Sequential Formatted I/O

On internal files, the FORTRAN Standard includes only sequential formatted I/O. (I/O is not a precise term to use here, but internal files are dealt with using READ and WRITE statements.) Internal files are used by giving the name of the character object in place of the unit number. The first read from a sequential-access internal file always starts at the beginning of the internal file; similarly for a write.

Example: Sequential, formatted reads:

	READ( 5, '(A)' ) X 
	READ( X, '(I3,I4)' ) N1, N2 

The above code reads a print-line image into X, and then reads two integers from X.

Direct Access I/O

f77 extends direct I/O to internal files.@

This is like direct I/O on external files, except that the number of records in the file cannot be changed. In this case, a record is a single element of an array of character strings.

Example: Direct access read of the third record of the internal file, LINE:

demo% cat intern.f 
	DATA LINE(1) / ' 81 81 ' / 
	DATA LINE(2) / ' 82 82 ' / 
	DATA LINE(3) / ' 83 83 ' / 
	READ ( LINE, FMT='(2I4)', REC=3 ) M, N 
	PRINT *, M, N 
demo% f77 -silent intern.f 
demo% a.out 
  83 83