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.

integer<br />

(kind=4), dimension(isize,icol), static :: a, a1<br />

!<br />

! Opens the file <strong>for</strong> both synchronous and asynchronous I/O.<br />

!<br />

open(20,<strong>for</strong>m="un<strong>for</strong>matted",access="direct", &<br />

status="scratch", recl=isize*4,asynch="yes")<br />

!<br />

! This loop overlaps the initialization of a(:,j) with<br />

! asynchronous write statements.<br />

!<br />

! NOTE: The array is written out one column at a time.<br />

! Since the arrays in <strong>Fortran</strong> are arranged in column<br />

! major order, each WRITE statement writes out a<br />

! contiguous block of the array.<br />

!<br />

do 200 j = 1, icol<br />

a(:,j) = (/ (i*j,i=1,isize) /)<br />

write(20, id=handle(j), rec=j) a(:,j)<br />

200 end do<br />

!<br />

! Wait <strong>for</strong> all writes to complete be<strong>for</strong>e reading.<br />

!<br />

do 300 j = 1, icol<br />

wait(id=handle(j))<br />

300 end do<br />

!<br />

! Reads in the first record.<br />

!<br />

read(20, id=handle(1), rec=1) a1(:,1)<br />

do 400 j = 2, icol<br />

k = j - 1<br />

!<br />

! Waits <strong>for</strong> a previously initiated read to complete.<br />

!<br />

wait(id=handle(k))<br />

!<br />

! Initiates the next read immediately.<br />

!<br />

read(20, id=handle(j), rec=j) a1(:,j)<br />

!<br />

! While the next read is going on, we do some processing here.<br />

!<br />

do 350 i = 1, isize<br />

if (a(i,k) .ne. a1(i,k)) then<br />

print *, "(",i,",",k,") &<br />

& expected ", a(i,k), " got ", a1(i,k)<br />

end if<br />

350 end do<br />

400 end do<br />

!<br />

! Finish the last record.<br />

!<br />

wait(id=handle(icol))<br />

do 450 i = 1, isize<br />

if (a(i,icol) .ne. a1(i,icol)) then<br />

print *, "(",i,",",icol,") &<br />

& expected ", a(i,icol), " got ", a1(i,icol)<br />

end if<br />

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

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

Saved successfully!

Ooh no, something went wrong!