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

Mixed coarray/OpenMP code with STOP statement in parallel region

OP1
New Contributor II
220 Views

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
Steven_L_Intel1
Employee
220 Views

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.

0 Kudos
Reply