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

"Segmentation fault occurred" occurs in Fortran, but the error disappears when the print statement is written

kanematsu__tsubasa
2,768 Views

Dear all,

I am creating a program in Fortran90.

"Forrtl: severe (174): SIGSEGV, segmentation fault occurred" occurs in an array in a structure.
I tried to check the index by writing a print statement to identify the cause, but the error disappeared when I wrote the print statement for some reason. Also, when I added -check bounds, the error disappeared as well.

The compiler used intel Fortran, and an error occurred at that time, but when using gfortran, no error occurred.

If you know the cause, can you tell me?

Thank you.

Best
Christoph

0 Kudos
1 Solution
jimdempseyatthecove
Honored Contributor III
2,768 Views

I would suggest you first compile your code with all the warnings and runtime checks enabled. You may have argument mismatch and/or index out of range. I see you used -check bounds. This will catch many of the indexing errors, but not all. The interface checking will also catch additional bounds errors. For example when a dummy argument is declared as REAL FOO(10) and called with actual argument of size other than 10..

If that doesn't lead to a resolution then, are you linking with 3rd party libraries (including your own) which may not have a properly declared interfaces? For example, calling a C compiled function without declaring the interface is to use C calling convention/

AT90's reference is to declaring (explicitly or implicitly) a loop/function/subroutine as to being vector aligned when in fact it is not.

Please state the version number of the compiler.

Jim Dempsey

View solution in original post

0 Kudos
4 Replies
AThar2
Beginner
2,768 Views

Are you by any chance enabling vectorization?

One possible answer is that you have told the compiler to vectorize the loop, and that causes a seg fault due to fault memory access. 

When you enable print statements the loop won't vector any longer and hence the seg fault does not occur. 

 

But the best would be to show the code to specifically say what is wrong.  

0 Kudos
Juergen_R_R
Valued Contributor I
2,768 Views
0 Kudos
jimdempseyatthecove
Honored Contributor III
2,769 Views

I would suggest you first compile your code with all the warnings and runtime checks enabled. You may have argument mismatch and/or index out of range. I see you used -check bounds. This will catch many of the indexing errors, but not all. The interface checking will also catch additional bounds errors. For example when a dummy argument is declared as REAL FOO(10) and called with actual argument of size other than 10..

If that doesn't lead to a resolution then, are you linking with 3rd party libraries (including your own) which may not have a properly declared interfaces? For example, calling a C compiled function without declaring the interface is to use C calling convention/

AT90's reference is to declaring (explicitly or implicitly) a loop/function/subroutine as to being vector aligned when in fact it is not.

Please state the version number of the compiler.

Jim Dempsey

0 Kudos
kanematsu__tsubasa
2,768 Views

Thank you so much everyone! That fixed my issue.

0 Kudos
Reply