Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

ifort vs gfortran - different handling of array manipulation?

lacek
Beginner
1,012 Views
Welcome all,
I have a following code:
program aaaa
implicit none
double precision, dimension(:), allocatable :: inp,outp
integer ::n,i
read(*,*) n
allocate(inp(n),outp(n))
write(*,*) allocated(inp), allocated(outp)
write(*,*) inp(1)
inp=cshift(outp,-size(outp)/2)
write(*,*) inp(1)
end program aaaa
It really does nothing - it just applies cyclic rotation of dynamically created array.
But when I use is for large n (in my case - over 10^6) then Segmentation fault occurs. More precisely this is the output:
T T
0.000000000000000E+000
Segmentation fault
I also discovered that by increasing the limit for stack memory the segmentation fault can be avoided. Clearly I am using cshift not appropriately.
Additionally the code perform does not exists when the compilation is done with gfortran, but it exists with ifort v12.0.0.
What is going on? I tried to compile with -check all, but it provides no info.
0 Kudos
2 Replies
TimP
Honored Contributor III
1,012 Views
You've gone part way to understanding this yourself. Have you checked on whether the "problem" is associated with how large an array you can allocate on stack? Remember that the suggested way in ifort to avoid such a limit is -heap-arrays, while gfortran may switch large arrays automatically to heap.
0 Kudos
lacek
Beginner
1,012 Views
Yes I did check it - as I wrote increasing stack memory solves the problem. Nevertheless the solution works just perfect. Thanks
0 Kudos
Reply