I have a fortran program. A subroutine is as below.The program gives segmentation fault after executing line 1434 and printing the below:
i: 115 256 2
Segmentation fault (core dumped)
The parameters are n1=258, n2=258, and n3=258. nr=46480. Why does segmentation fault happen?
75 double precision u(nr),v(nv),r(nr),a(0:3),c(0:3)
76 common /noautom/ u,v,r
......
196 call zero3(u,n1,n2,n3)
......
1418 subroutine zero3(z,n1,n2,n3)
1419
1420 c---------------------------------------------------------------------
1421 c---------------------------------------------------------------------
1422
1423 implicit none
1424
1425
1426 integer n1, n2, n3
1427 double precision z(n1,n2,n3)
1428 integer i1, i2, i3
1429
1430 !$omp parallel do default(shared) private(i1,i2,i3)
1431 do i3=1,n3
1432 do i2=1,n2
1433 do i1=1,n1
1434 print*,"i: ",i1, " ", i2 , " " ,i3
1435 z(i1,i2,i3)=0.0D0
1436 enddo
1437 enddo
1438 enddo
1439
1440 return
1441 end
zisn't as big as you said it was. Since we can't see the definition of the array in the calling code, we can't do more than guess, though.z=0.0D0.