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

Segmentation Fault with OpenMP

trobitaille
Beginner
801 Views
Hi,

If I compile the following code:
[fortran]module routine

  implicit none

contains

  subroutine sub()
    implicit none
    integer,parameter :: nmax=1000000
    complex(8),dimension(nmax) :: d
    d = 0.
  end subroutine sub

end module routine

program test

  use routine

  !$OMP PARALLEL DO
  do iw=1,100
     call sub()
  end do
  !$OMP END PARALLEL DO

end program test
[/fortran]
with the following compile command:
ifort -heap-arrays -O0 -openmp test.f90 -static-intel
Then run it, I get:
$ ./a.out
Segmentation fault
Notes:
  • If I change complex(8) to real(8) I get:
forrtl: severe (180): SIGBUS, bus error occurred
Image PC Routine Line Source
a.out 00000001000011AA Unknown Unknown Unknown
a.out 0000000100001423 Unknown Unknown Unknown
a.out 00000001000BED13 Unknown Unknown Unknown
  • If I set nmax <=262061 then the code runs properly (with complex(8))
  • If I set262061 < nmax <=262308 then I get
Illegal instruction
  • If I set nmax >262308 then I get a segfault as before
Details
$ ifort -V
Intel Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.2.142 Build 20110112
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
System: MacOS 10.6.6, XCode 3.2.5
Thanks in advance for any help!
0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
801 Views

As an experiment, declare sub as a recursive subroutine

recursive subroutine sub()
...


Jim Dempsey
0 Kudos
TimP
Honored Contributor III
801 Views
It's probably better to attempt to design separate experiments for each abuse of the compiler.
Are you asking why the compiler doesn't complain, or which issues prevent dead code elimination?
0 Kudos
trobitaille
Beginner
801 Views
Adding 'recursive' does not seem to change anything - I still get a Segmentation fault. Any ideas?
0 Kudos
Steven_L_Intel1
Employee
801 Views
You are getting a stack overflow, even with -heap-arrays. Try this substitute code which works for me:

complex(8),dimension(:),allocatable :: d
allocate (d(nmax))
0 Kudos
Reply