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

segmentation fault error

bhargava2208
Beginner
1,540 Views
Hello,

I compiled the following code using the intel fortran compiler of version 8.1.018 and it showed a segmentation fault error while running on the intel pentium linux processor (kernel: 2.4.22). But the same code compiled by NAG compiler didn't show any runtime error and completed the run successfully.

Compilation command given:
ifort -o test.x test.f90

I would appreciate if you could point to any bugs in my code or in the way I used ifort.

program new
implicit none
integer::i,j,k,l,m,n
double precision,allocatable :: time(:,:,:)
l=1000
m=100
n=3
allocate(time(l,m,n))
open(11,file='bbb',action='read')
do i=1,l
if (mod(i,100)==0)write(*,*)i
do j=1,m
do k=1,n
read(11,*)time(i,j,:)
enddo
enddo
enddo
end

Using ifort, the segmentation fault appears when i=874.

Note: If I change the allocatable array into a hard-wired one (i.e., declare it as time(1000,100,3)), then the code does not give a segmentation fault, even when compiled with ifort.

Thanks in advance,
Bhargava
0 Kudos
1 Reply
Steven_L_Intel1
Employee
1,540 Views
I think I know what's going on here - the compiler is creating a stack temporary for the READ and not removing it from the stack inside the DO loop. I think this is fixed in 8.1.023.
As an alternative, use an implied DO loop instead of an array section.
0 Kudos
Reply