Hello,
In my code , i must to open a file.txt and use those elements.But when i complied with ‘pgfortran -mp -o freefem freefem.f90’ and with 4 threads, i got always ‘SEGMENTATION FAULT’. when i complied with 1 threads, it worked.
Can you explain why?
program freefem
implicit none
integer, parameter :: nmc = 10000 ! number of trials
real, dimension(nmc) :: mu
real :: mean, stdev, t0, t1
integer :: i,j,ix,jt,kscore
!$omp parallel do
do j=1,nmc
cal premier(51477j,kscore)
mu(j)=kscore
enddo
!$omp end parallel do
mean = sum(mu) / dble(nmc)
print,mean
end program freefem
subroutine premier(ix,kscore)
implicit none
real,dimension(1:1000000,1:21) :: xt,yt,vt
integer,dimension(21) :: nb
integer::na,nmax,ix,i,jt,kscore
real::aa
kscore=0
na=16807
nmax=2147483647
open(unit=12,file=‘triernouveaubeta1.txt’,status=‘unknown’)
do jt=1,21
read(12,) nb(jt)
enddo
do jt=1,20
do i=nb(jt)+1,nb(jt+1)
read(12,) xt(i,jt),yt(i,jt),vt(i,jt)
enddo
enddo
close(12)
ix=abs(ix*na)
ix=mod(ix,nmax)
aa=dble(ix)/dble(nmax)
if (aa.lt.0.5) then
kscore=nb(2)
else
kscore=nb(3)
endif
return
end subroutine premier