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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Example:<br />

WRITE(1,*) ’Output on unit 1’<br />

END<br />

<strong>Open</strong> <strong>Watcom</strong> <strong>FORTRAN</strong> <strong>77</strong> constructs a file name using the specified unit number. The format of the file<br />

name is described in the User’s Guide since it varies from one computer system to the next.<br />

Connection of a unit to a file does not imply that the file must exist. For example, it could be a new file.<br />

When we speak of a unit being connected to a file, we can also say that a file is connected to a unit. Under<br />

the rules of <strong>FORTRAN</strong>, it is illegal to connect the same file to more than one unit at the same time.<br />

However, a file may be connected to different units at different times. We shall explain how this is<br />

possible.<br />

A file may be disconnected from a unit by the use of the CLOSE statement.<br />

Example:<br />

CLOSE(UNIT=1)<br />

Under certain circumstances, the file may be disconnected from a unit by the use of the OPEN statement.<br />

Example:<br />

OPEN(UNIT=1,FILE=’FILE1’)<br />

.<br />

.<br />

.<br />

OPEN(UNIT=1,FILE=’FILE2’)<br />

In the above example, the second OPEN statement disconnects unit 1 from one file and connects it to a<br />

second file. You may think of the second OPEN statement as automatically closing the first file and then<br />

establishing a connection to the second file.<br />

If a unit has been disconnected from a file through the execution of a CLOSE statement, the unit may<br />

subsequently be connected to the same file or to a different file. It also follows that a file which has been<br />

disconnected from one unit number may be connected to the same unit number or a different unit number.<br />

The following example may help to illustrate this last point.<br />

Example:<br />

OPEN(UNIT=1,FILE=’FILE1’)<br />

.<br />

.<br />

.<br />

CLOSE(UNIT=1)<br />

OPEN(UNIT=2,FILE=’FILE1’)<br />

Once a file has been disconnected, the only means for referring to the file is by its name in an OPEN<br />

statement or an INQUIRE statement.<br />

220 Units

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

Saved successfully!

Ooh no, something went wrong!