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

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

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

READ(unit_number,ID=idvar) a<br />

....<br />

WAIT(ID=idvar)<br />

....<br />

2. In a WAIT statement with the DONE= specifier, the WAIT statement returns<br />

the completion status of an asynchronous I/O statement:<br />

integer idvar<br />

logical done<br />

integer, dimension(1000):: a<br />

....<br />

READ(unit_number,ID=idvar) a<br />

....<br />

WAIT(ID=idvar, DONE=done)<br />

....<br />

The variable you specified in the DONE= specifier is set to ″true″ if the<br />

corresponding asynchronous I/O statement completes. Otherwise, it is set to<br />

″false″.<br />

The actual data transfer can take place in the following cases:<br />

v During the asynchronous READ or WRITE statement<br />

v<br />

At any time be<strong>for</strong>e the execution of the corresponding WAIT statement<br />

v During the corresponding WAIT statement<br />

Because of the nature of asynchronous I/O, the actual completion time of the<br />

request cannot be predicted.<br />

You specify <strong>Fortran</strong> asynchronous READ and WRITE statements by using the ID=<br />

specifier. The value set <strong>for</strong> the ID= specifier by an asynchronous READ or WRITE<br />

statement must be the same value specified in the ID= specifier in the<br />

corresponding WAIT statement. You must preserve this value until the associated<br />

asynchronous I/O statement has completed.<br />

The following program shows a valid asynchronous WRITE statement:<br />

program sample0<br />

integer, dimension(1000):: a<br />

integer idvar<br />

a = (/(i,i=1,1000)/)<br />

WRITE(10,ID=idvar) a<br />

WAIT(ID=idvar)<br />

end<br />

The following program is not valid, because <strong>XL</strong> <strong>Fortran</strong> destroys the value of the<br />

asynchronous I/O identifier be<strong>for</strong>e the associated WAIT statement:<br />

program sample1<br />

integer, dimension(1000):: a<br />

integer idvar<br />

a = (/(i,i=1,1000)/)<br />

WRITE(10,ID=idvar) a<br />

idvar = 999 ! Valid id is destroyed.<br />

WAIT(ID=idvar)<br />

end<br />

An application that uses asynchronous I/O typically improves per<strong>for</strong>mance by<br />

overlapping processing with I/O operations. The following is a simple example:<br />

program sample2<br />

integer (kind=4), parameter :: isize=1000000, icol=5<br />

integer (kind=4) :: i, j, k<br />

integer (kind=4), dimension(icol) :: handle<br />

336 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!