INTEGER, INTENT(INOUT) :: n
INTEGER :: i
!$OMP PARALLEL SECTIONS FIRSTPRIVATE(n)
!$OMP PARALLEL DO
DO i=1, n
!$OMP END PARALLEL DO
!$OMP END PARALLEL SECTIONS
END SUBROUTINE a1
END MODULE aM
INTEGER :: n
This program causes segmentation fault when compiled with -fopenmp switch.
These errors occur with ifort version 15.0.5 and 16.0.2. After removing FIRSTPRIVATE clause the program works fine
Thank you for reporting this error. I need to consult with an OpenMP Developer about this. As written, it appears the seg-fault occurs from variable N being shared vs. private within the PARALLEL DO scope. The error can be avoided with an additional PRIVATE(n) clause on the inner PARALLEL DO, or just not declaring it as FIRSTPRIVATE in the outer PARALLEL scope.
The second solution (i.e.. removing FIRSTPRIVATE clause) to this problem is OK (and I mentioned this).
But the first solution is incorrect. If you add PRIVATE(n) clause at the SECTIONS line, the value of the n is undefined for DO loop - so is incorrect from logical point of view. Just add for example - print*,'i = ',i, n - inside the body of the loop. Than program behaves in random way.
My apologies. Thank you for the correction/clarification on using PRIVATE. I escalated the issue to our OpenMP Development team.
(Internal tracking id: DPD200382055)