I am very new in Openmp. I was summing up N integer numbers stored in an array and compiling the code using gfortran. Upto N=10^6, the results obtained from the serial and parallel codes are exactly same. For N=10^7, the serial code is running but, the parallel code (after compilation using -fopenmp flag) is giving "Segmentation fault". I have given my code here. Could anyone please help me why it is happening?
use omp_lib
REAL*8 r,summ,sl
parameter (N=10000000)
dimension r(N)
do i=1,N
r(i)=i
enddo
summ=0.0d00
sl=0.0d00
!$OMP PARALLEL FIRSTPRIVATE(sl) SHARED(r,summ)
!$OMP DO
do i=1,N
sl=sl+r(i)
enddo
!$OMP END DO
!$OMP CRITICAL
summ=summ+sl
!$OMP END CRITICAL
!$OMP END PARALLEL
write(*,*)'SUM',summ
end