<ASYNCHRONOUS= Example Program>
Program asynchronous_specifier_example Real, :: a(100,2) Logical finished Open (17,File='Results',Form='Unformatted',Asynchronous='Yes') Do Call produce_results(a(:,1),finished) Call write_results(a(:,1)) If (finished) Exit Call produce_results(a(:,2),finished) Call write_results(a(:,2)) If (finished) Exit End Do Contains Subroutine produce_results(vector,finished) Real,Intent(Out) :: vector(:) Logical,Intent(Out) :: finished Call Random_Number(vector) finished = vector(1)<0.1 End Subroutine Subroutine write_results(vector) Real,,Intent(In) :: vector(:) Write (17,Asynchronous='Yes') vector End Subroutine End Program
<Comments>
The use of the ASYNCHRONOUS= specifier allows the overlap of the writing of one set of results while computing the next. The WAIT statement in WRITE_RESULTS waits for the previous output to unit 17 to finish, thus ensuring that the previous VECTOR can be re-used for computation.
The ASYNCHRONOUS attribute is needed to tell the compiler that A is subject to asynchronous input/output; this information prevents unsafe optimisations.