Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Bug with DENYNONE specifier?

$
0
0

For the code below I am using Intel Fortran 14.0.5.239 (64-bit) on Windows 7. Multiple images attempt to write (in orderly fashion) to a file that has been created with the SHARE='DENYNONE' attribute; and yet only the last image writes to it.

I may be overlooking something here, but this behavior puzzles me.

PROGRAM COARRAY_FILE_WRITE
USE ISO_FORTRAN_ENV
IMPLICIT NONE
INTEGER :: I_IMAGE
LOGICAL :: LOCK_IS_ACQUIRED
TYPE(LOCK_TYPE) :: FILE_LOCK[*]

! Image 1 creates the shared file.

    IF (THIS_IMAGE()==1) THEN
        OPEN(UNIT=200,FORM='FORMATTED',FILE='Test.txt',STATUS='REPLACE',ACTION='READWRITE',SHARE='DENYNONE')
    END IF
    SYNC ALL

! Other images open the (same) shared file.

    IF (THIS_IMAGE()>1) THEN
        OPEN(UNIT=200,FORM='FORMATTED',FILE='Test.txt',STATUS='OLD',ACCESS='APPEND',ACTION='READWRITE',SHARE='DENYNONE')
    END IF
    SYNC ALL

! All images write something in the shared file, using a lock to prevent simultaneous writes.

    LOCK_IS_ACQUIRED = .FALSE.
    DO WHILE (.NOT.LOCK_IS_ACQUIRED)
        LOCK(FILE_LOCK[1],ACQUIRED_LOCK=LOCK_IS_ACQUIRED)
        IF (LOCK_IS_ACQUIRED) THEN
            WRITE(*,*) 'Hi from image ',THIS_IMAGE()
            WRITE(200,*) 'Hi from image ',THIS_IMAGE()
            FLUSH(200)
            UNLOCK(FILE_LOCK[1])
        END IF
    END DO

    SYNC ALL

END PROGRAM COARRAY_FILE_WRITE

 


Viewing all articles
Browse latest Browse all 3270

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>