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

strange problem, no problem by gfortran, but ifort

Yongjia_S_
Beginner
1,865 Views
I met a very strange problem and took several days to figure out how to solve it, no success so far. the fortran programs can been compiled successfully by both gfortran and ifort, but only excutable file by gfortran can run no problem, the one by ifort metSegmentation fault immediately. Can anyone help me to find the problem in fortran codes, which is a land surface data program, (can been downloadhttp://www.cnrm.meteo.fr/gmme/PROJETS/ECOCLIMAP/ecoclimap_october04_corseptember06.tar), it is simple to compile. Thanks in advance. by the way, I use the latest version of ifort.
0 Kudos
1 Solution
Ron_Green
Moderator
1,865 Views

thanks Ronald and tim, when I add the option heap_array to ifort, everything is fine, so I wonder what is difference w/wo this option, what is reason to make this problem, thank a lot!

All Fortran compilers sometimes need to make temporary copies of arrays during runtime. Some compilers put those temporary data elements on the heap, some put it on the stack. Intel Fortran uses stack by default for array temporaries for performance reasons. Other compilers, like gfortran, use heap. It's just a simple matter of choice where you put them. Intel tries to default to the most efficient and fastest place to put them, which is stack.

ron

View solution in original post

0 Kudos
8 Replies
Yongjia_S_
Beginner
1,865 Views
I met a very strange problem and took several days to figure out how to solve it, no success so far. the fortran programs can been compiled successfully by both gfortran and ifort, but only excutable file by gfortran can run no problem, the one by ifort metSegmentation fault immediately. Can anyone help me to find the problem in fortran codes, which is a land surface data program, (can been downloadhttp://www.cnrm.meteo.fr/gmme/PROJETS/ECOCLIMAP/ecoclimap_october04_corseptember06.tar), it is simple to compile. Thanks in advance. by the way, I use the latest version of ifort.
more comment about this problem, I have tried the compile option "-CB" or "-no-ansi-alias", but no one can fix the problem.
0 Kudos
TimP
Honored Contributor III
1,865 Views
I met a very strange problem and took several days to figure out how to solve it, no success so far. the fortran programs can been compiled successfully by both gfortran and ifort, but only excutable file by gfortran can run no problem, the one by ifort metSegmentation fault immediately. Can anyone help me to find the problem in fortran codes, which is a land surface data program, (can been downloadhttp://www.cnrm.meteo.fr/gmme/PROJETS/ECOCLIMAP/ecoclimap_october04_corseptember06.tar), it is simple to compile. Thanks in advance. by the way, I use the latest version of ifort.
You should tell us what efforts you have made with setting stack size limits in your shell, or with -heap-arrays option (if not using -openmp). These are described in many other posts on the forum. You appear to be asking for many others to perform or repeat your work for you. Remember that gfortran has a different default which could be imitated by heap-arrays setting.
0 Kudos
Ron_Green
Moderator
1,865 Views
Quoting - tim18
You should tell us what efforts you have made with setting stack size limits in your shell, or with -heap-arrays option (if not using -openmp). These are described in many other posts on the forum. You appear to be asking for many others to perform or repeat your work for you. Remember that gfortran has a different default which could be imitated by heap-arrays setting.

simple test, with ifort try these:

-g -traceback -heap-arrays -mcmodel=medium

ron
0 Kudos
Yongjia_S_
Beginner
1,865 Views

simple test, with ifort try these:

-g -traceback -heap-arrays -mcmodel=medium

ron

thanks Ronald and tim, when I add the option heap_array to ifort, everything is fine, so I wonder what is difference w/wo this option, what is reason to make this problem, thank a lot!
0 Kudos
Ron_Green
Moderator
1,866 Views

thanks Ronald and tim, when I add the option heap_array to ifort, everything is fine, so I wonder what is difference w/wo this option, what is reason to make this problem, thank a lot!

All Fortran compilers sometimes need to make temporary copies of arrays during runtime. Some compilers put those temporary data elements on the heap, some put it on the stack. Intel Fortran uses stack by default for array temporaries for performance reasons. Other compilers, like gfortran, use heap. It's just a simple matter of choice where you put them. Intel tries to default to the most efficient and fastest place to put them, which is stack.

ron
0 Kudos
roddur
Beginner
1,865 Views

All Fortran compilers sometimes need to make temporary copies of arrays during runtime. Some compilers put those temporary data elements on the heap, some put it on the stack. Intel Fortran uses stack by default for array temporaries for performance reasons. Other compilers, like gfortran, use heap. It's just a simple matter of choice where you put them. Intel tries to default to the most efficient and fastest place to put them, which is stack.

ron
hello,
As I am not very known, so i followed this thread. stack and heap, in layman's version is in ram and swap, right?
also, i found this boost description
on pool.
is it something else? what is the fastest as long as ifort is concerned?
0 Kudos
TimP
Honored Contributor III
1,865 Views
ifort has the heap-arrays option to switch from stack to heap for allocations larger than the specified size. In a given situation, there is likely to be an optimum value for this choice, but that might well be large enough to require more than the default stack limit of your shell. Ron mentioned earlier today that stack allocation is better with openmp.
0 Kudos
Yongjia_S_
Beginner
1,865 Views
Quoting - tim18
ifort has the heap-arrays option to switch from stack to heap for allocations larger than the specified size. In a given situation, there is likely to be an optimum value for this choice, but that might well be large enough to require more than the default stack limit of your shell. Ron mentioned earlier today that stack allocation is better with openmp.


Thanks Tim and Ronald again, I got idea about temporary arrays and automatic arrays created in runtime.
0 Kudos
Reply