Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29580 Discussions

Stopped image synchronization question

OP1
New Contributor III
1,402 Views

With IVF 16.0 Update 1, the following code will go in an infinite loop, suggesting that a STOPped image is SYNChronizable with any other (still running) image. Is this interpretation correct? I was initially thinking that the code would hang, since images>1 would not be able to SYNC with image 1.

PROGRAM P
IMPLICIT NONE
SYNC ALL
IF (THIS_IMAGE()==1) THEN
    STOP
END IF
DO
    SYNC ALL
    WRITE(*,*) 'Oops!'
END DO
END PROGRAM P

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,402 Views

Use ERROR STOP instead of STOP.

The current standard doesn't give you much help in detecting "failed images". Fortran 2015 is better behaved in this regard. The other images are waiting for a message from image 1 that never arrives, so the loop.  ERROR STOP is there in the language for this purpose.

0 Kudos
OP1
New Contributor III
1,402 Views

Thanks Steve for the comment. I slightly modified the example, and still get the same behavior: in other words, a stopped image (an image that reached the end of the program) can still synchronize ad infinitum with other images. Maybe this is expected behavior (it makes sense that coarrays persist when an image stops, so that other images can still access its coarray values, but I am a bit surprised by the synchronization aspect).

PROGRAM P
IMPLICIT NONE
SYNC ALL
IF (THIS_IMAGE()>1) THEN
    DO
        SYNC ALL
        WRITE(*,*) 'Oops!'
    END DO
END IF
END PROGRAM P

 

0 Kudos
Steven_L_Intel1
Employee
1,402 Views

Indeed, the standard says "If an image has initiated normal termination [which in your examples image 1 has done], its data remain available for possible reference or definition by other images that are still executing."  The standard also says "Normal termination occurs only when all images initiate normal termination..."

The F2008 definition of coarrays tends to assume that everything goes ok. Your examples don't have anything to break out of the DO loop, so it is not clear to me what useful behavior you expect. As I mentioned, F2015 adds the concept of a "stopped image" and status specifiers to image control statements to allow you to detect that some other image stopped. (There is more to this, but I am not going into details here.)

0 Kudos
Reply