Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

Asynchronous File - How to Set Up

I noticed there are several methods for setting up asynchronous file writing.

The first is opening the file with asynchronous='YES', then having any read or write with asynchronous='YES', but I also saw the attribute asynchronous.

Do I need to have all three specified in order to ensure that the asynchronous writing occurs? Or can I get away with just using the attribute.

For example the following:

USE, INTRINSIC:: ISO_FORTRAN_ENV, ONLY: REAL32, REAL64

REAL(REAL64), DIMENSION(NCOL,NROW,NLAY):: BUF

OPEN(55, ACTION='WRITE', FORM='UNFORMATTED', ACCESS='STREAM', STATUS='REPLACE', POSITION='REWIND',  BUFFERED='yes', BLOCKSIZE=1048576,BUFFERCOUNT=1)

DO K=1,NLAY;  DO I=1,NROW;  DO J=1,NCOL
                                      WRITE(55) REAL(BUF(J,I,K), REAL32)
END DO; END DO; END DO

would make use of asycn if:

USE, INTRINSIC:: ISO_FORTRAN_ENV, ONLY: REAL32, REAL64

REAL(REAL64), DIMENSION(NCOL,NROW,NLAY):: BUF

OPEN(55, ACTION='WRITE', FORM='UNFORMATTED', ACCESS='STREAM', STATUS='REPLACE', POSITION='REWIND',  BUFFERED='yes', BLOCKSIZE=1048576,BUFFERCOUNT=1)

DO K=1,NLAY;  DO I=1,NROW;  DO J=1,NCOL
                                       WRITE(55,ASYNCHRONOUS='YES') REAL(BUF(J,I,K), REAL32)
END DO; END DO; END DO

or

USE, INTRINSIC:: ISO_FORTRAN_ENV, ONLY: REAL32, REAL64

REAL(REAL64), DIMENSION(NCOL,NROW,NLAY):: BUF

OPEN(55, ACTION='WRITE', FORM='UNFORMATTED', ACCESS='STREAM', STATUS='REPLACE', POSITION='REWIND',  BUFFERED='yes', BLOCKSIZE=1048576,BUFFERCOUNT=1,ASYNCHRONOUS='YES')

DO K=1,NLAY;  DO I=1,NROW;  DO J=1,NCOL
                                       WRITE(55,ASYNCHRONOUS='YES') REAL(BUF(J,I,K), REAL32)
END DO; END DO; END DO

or

USE, INTRINSIC:: ISO_FORTRAN_ENV, ONLY: REAL32, REAL64

REAL(REAL64), DIMENSION(NCOL,NROW,NLAY),ASYNCHRONOUS='YES':: BUF

OPEN(55, ACTION='WRITE', FORM='UNFORMATTED', ACCESS='STREAM', STATUS='REPLACE', POSITION='REWIND',  BUFFERED='yes', BLOCKSIZE=1048576,BUFFERCOUNT=1,ASYNCHRONOUS='YES')

DO K=1,NLAY;  DO I=1,NROW;  DO J=1,NCOL
                                       WRITE(55,ASYNCHRONOUS='YES') REAL(BUF(J,I,K), REAL32)
END DO; END DO; END DO

 

So in summary, what combination of ASYNCHRONOUS words do I need to have ASYNCHRONOUS to be in effect.

 

Also is there any penalty for opening a file with ASYNCHRONOUS='YES', but never writing a file with it (so there never is a write statement with ASYNCHRONOUS='YES')

 

One last point, is there any danger to using ASYNCHRONOUS='YES' along with BUFFERED='YES'

 

0 Kudos