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

Coarray SYNC ALL issue

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

 

0 Kudos
3 Replies
Highlighted
1 View

This program is malformed  -

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.

Retired 12/31/2016
0 Kudos
Highlighted
Beginner
1 View

Thanks Steve for the

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
  • IF (THIS_IMAGE()==1) THEN CALL SLEEP(1) DO I=1,NUM_IMAGES() J = I END DO SYNC MEMORY DO I=1,NUM_IMAGES() WRITE(*,*) J END DO END IF WRITE(*,*) 'Image ',THIS_IMAGE(),' is done!' END PROGRAM MAIN
  •  

    0 Kudos
    Highlighted
    1 View

    Fortran 2008 doesn't take

    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.

    Retired 12/31/2016
    0 Kudos