24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Language</strong> <strong>Reference</strong><br />

accessed directly. You have no choice but to write records sequentially. Sometimes a file<br />

that was created using the sequential access method may not be accessed using the direct<br />

method or vice versa. <strong>FORTRAN</strong> calls this property of a file the "set of allowed access<br />

methods".<br />

Record Form<br />

Some files have the property of being able to handle both formatted and unformatted record<br />

formats. Some files may only have one of these properties. For example, if you tried to<br />

write unformatted records to a line printer, the result might be gibberish. On the other hand<br />

a graphics printer may readily accept unformatted records for reproducing graphical images<br />

on paper. <strong>FORTRAN</strong> calls this property of a file the "set of allowed forms".<br />

Record Length Another property of a file is record length. Some files may have restrictions on the length<br />

of a record. Some files do not allow records of zero length. Other files, such as printers,<br />

may restrict the length of a record to some maximum. <strong>FORTRAN</strong> calls this property the<br />

"set of allowed record lengths".<br />

10.4.2 Internal Files<br />

Internal files are special files that reside only in memory. They do not exist before or after the execution of<br />

a <strong>FORTRAN</strong> program, only during the execution of a program. An internal file allows you to treat<br />

memory in the computer as if it were one or more records in a file. The file must be a character variable,<br />

character array element, character array, or character substring. A record in this file may be a character<br />

variable, character array element or character substring.<br />

Another way of looking at this is that an internal file that is either a character variable, character array<br />

element or character substring can contain only one record but an internal file that is a character array can<br />

contain several records (as many as there are elements in the array).<br />

Properties of Internal Files<br />

Records<br />

Unless the name of a character array is used, only one record is contained in an internal file.<br />

The length of this record is the same as the length of the variable, array element, or<br />

substring. If the file is a character array then each element in the array is a record. The<br />

order of the records in the file is the same as the order of the elements in the array. The<br />

length of a record in this case is the same as the length of the character array elements.<br />

If the number of characters written to a record in an internal file is less than the length of<br />

the record then the record is padded with blanks.<br />

Definition<br />

Position<br />

Restrictions<br />

A record may be read only if the variable, array element, or substring is defined (i.e., it has<br />

been assigned some value). Definition may not only result from an output statement such<br />

as WRITE. It may also be defined through other means; for example, a character<br />

assignment statement.<br />

For all input/output statements, the file is positioned at the beginning of the first record.<br />

Multiple records may be read or written using the "slash" format edit descriptor (see the<br />

chapter entitled "Format" on page 225).<br />

Only sequential access formatted input and output statements ( READ and WRITE) may be<br />

used to transfer data to and from records in an internal file.<br />

218 Files

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!