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

Mixed coarray/OpenMP code with STOP statement in parallel region

According to OpenMP 4.5, a Fortran STOP statement is allowed inside a structured block. The code below works (as expected) when only one coarray image is used; but it hangs if more than 1 coarray image is executed.

Now, if ERROR STOP is used instead of STOP, the code works as expected. Am I missing something (or doing something illicit) here?

SUBROUTINE S(I)
IMPLICIT NONE
INTEGER :: I,J
REAL(KIND=8) R
IF (I==20) THEN
    STOP                  ! This causes the code to hang...
    !ERROR STOP           ! This works...
ELSE
    R = 0.
    DO J=100*I,5000000
        R = COS(R+J*COS(R))
    END DO
    WRITE(*,*) I,R
END IF
END SUBROUTINE S


PROGRAM MAIN
IMPLICIT NONE
INTEGER  :: I

!$OMP PARALLEL DEFAULT(NONE) PRIVATE(I)
!$OMP DO ORDERED SCHEDULE(MONOTONIC:STATIC,1)
DO I=1,500
    CALL S(I)
END DO
!$OMP END DO
!$OMP END PARALLEL

WRITE(*,*) THIS_IMAGE()

END PROGRAM MAIN

 

0 Kudos
1 Reply
Highlighted

OpenMP has nothing to do with

OpenMP has nothing to do with it. If you want a clean shutdown of a coarray program, use ERROR STOP. If you just use STOP the other images may not properly detect that the failed image has exited. This is something we're hoping to improve in the future.

Retired 12/31/2016
0 Kudos