24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

File Positioning<br />

Note: Because unit 0 is preconnected <strong>for</strong> standard error, you cannot use it <strong>for</strong> the<br />

following statements: CLOSE, ENDFILE, BACKSPACE, REWIND, and<br />

direct or stream input/output. You can use it in an OPEN statement only to<br />

change the values of the BLANK=, DELIM=, or PAD= specifiers.<br />

You can also implicitly connect units 5 and 6 (and *) by using I/O statements that<br />

follow a CLOSE:<br />

WRITE (6,10) "This message goes to stdout."<br />

CLOSE (6)<br />

WRITE (6,10) "This message goes in the file <strong>for</strong>t.6."<br />

PRINT *, "Output to * now also goes in <strong>for</strong>t.6."<br />

10 FORMAT (A)<br />

END<br />

The FORM= specifier of implicitly connected files has the value FORMATTED<br />

be<strong>for</strong>e any READ, WRITE, or PRINT statement is per<strong>for</strong>med on the unit. The first<br />

such statement on such a file determines the FORM= specifier from that point on:<br />

FORMATTED if the <strong>for</strong>matting of the statement is <strong>for</strong>mat-directed, list-directed, or<br />

namelist; and UNFORMATTED if the statement is un<strong>for</strong>matted.<br />

Preconnected files also have FORM=’FORMATTED’, STATUS=’OLD’, and<br />

ACTION=’READWRITE’ as default specifier values.<br />

The other properties of a preconnected or implicitly connected file are the default<br />

specifier values <strong>for</strong> the OPEN statement. These files always use sequential access.<br />

If you want <strong>XL</strong> <strong>Fortran</strong> to use your own file instead of the <strong>for</strong>t.n file, you can<br />

either specify your file <strong>for</strong> that unit through an OPEN statement or create a<br />

symbolic link be<strong>for</strong>e running the application. In the following example, there is a<br />

symbolic link between myfile and <strong>for</strong>t.10:<br />

ln myfile <strong>for</strong>t.10<br />

When you run an application that uses the preconnected file <strong>for</strong>t.10 <strong>for</strong><br />

input/output, <strong>XL</strong> <strong>Fortran</strong> uses the file myfile instead. The file <strong>for</strong>t.10 exists, but<br />

only as a symbolic link. The following command will remove the symbolic link,<br />

but will not affect the existence of myfile:<br />

rm <strong>for</strong>t.10<br />

Table 21. Position of the File Pointer When a File Is Opened with No POSITION= Specifier<br />

-qposition suboptions Implicit OPEN Explicit OPEN<br />

File<br />

exists<br />

File<br />

does<br />

not<br />

exist<br />

STATUS =<br />

’NEW’<br />

File<br />

exists<br />

File<br />

does<br />

not<br />

exist<br />

STATUS = ’OLD’ STATUS =<br />

’UNKNOWN’<br />

File<br />

exists<br />

option not specified Start Start Error Start Start<br />

▌1▐, ▌3▐<br />

File<br />

does<br />

not<br />

exist<br />

File<br />

exists<br />

File<br />

does<br />

not<br />

exist<br />

Error Start Start<br />

appendold ▌2▐ Start Start Error Start End Error Start Start<br />

appendunknown Start Start Error Start Start<br />

▌3▐<br />

Error End Start<br />

appendold and appendunknown Start Start Error Start End Error End Start<br />

Implementation Details of <strong>XL</strong> <strong>Fortran</strong> Input/Output 327

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

Saved successfully!

Ooh no, something went wrong!