The following code exhibits a different behavior depending on whether line 3 or 4 is commented out. It seems that the SYNC ALL behavior varies depending on which image 'finishes first'.
PROGRAM MAIN IMPLICIT NONE IF (THIS_IMAGE()==1) THEN ! This works. !IF (THIS_IMAGE()==2) THEN ! Any image number > 1 causes the code to hang at the SYNC ALL below. CALL SLEEP(1) WRITE(*,*) 'Image ',THIS_IMAGE(),' is done!' GO TO 100 END IF SYNC ALL WRITE(*,*) 'Image ',THIS_IMAGE(),' is done!' 100 CONTINUE END PROGRAM MAIN
This program is malformed - a SYNC ALL waits for all other images to execute a SYNC ALL the same number of times. If you skip over the SYNC ALL and let the program exit, the behavior is unspecified. What probably happens in the case image 1 skips it is that this image is "special" and it exiting causes all other images to exit.
Thanks Steve for the clarification. I think I got confused with the fact that when an image stops, its coarrays are still accessible (see code below). I thought that therefore a stopped image would not be considered in a SYNC ALL statement (only the images still running would wait for each other).
PROGRAM MAIN IMPLICIT NONE INTEGER :: I,J
Fortran 2008 doesn't take into account stopped or failed images - this is something being added for Fortran 2015. In F2015, if there are stopped or failed images in the current team (another F2015 thing), a SYNC ALL without a STAT= is an error and will cause termination.
In Fortran 2008, it is assumed that all images are still active.