Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

angrynynph

macrumors newbie
Original poster
Apr 3, 2015
3
0
Hello,

I wrote a very long (around 10.000 lines) code .f90.
The last version of the program i modified, is normally compiled with gfortran and runs in a loop, since giving me BUS ERROR.
So I restarted from the last-working version, that never gave me any problem, but re-compiling and launching it, gives me the same bus error.
After some check, i realized that all my versions show this error, that is very strange because I always runned them without errors.

I thought it was a gfortran problem, so reinstalled it, but the situation did not change.
To make the debug, i lauched the last version with valgrind, and in this ways it runs without problem.
Moreover, I tried to compile and run the program with another compiler, ifort, and IT WORKS.
So i move on windows and linux, and gfortran there compiles my code with no errors.

Have I to consider this as an error or a type of incompatibility between gfortran(version 4.9.0) and my system? (10.9.5)?
 
Hard to tell, but the symptoms sounds suspiciously much like undefined behavior.

It sounds, yer. Moreover, I note that very rarely (but happens) it runs after being compiled by gfortran on my mac. That makes everything more strange.
 
It sounds, yer. Moreover, I note that very rarely (but happens) it runs after being compiled by gfortran on my mac. That makes everything more strange.

IMO that fits the bill for undefined behavior as well. Have you checked the code for this? I'm not that familiar with Fortran at all, but you know, look for things that are specified as undefined behavior by the language. Because it means that it's perfectly legit to work, sometimes. Perhaps look for uninitialized variables and stuff like that?
 
Is the type of error i m looking for in the code, but is quit impossible to find it.
Let suppose is this kind of error, should you think is possible to believe in the result obtained by ifort that by-pass this error?
 
I wrote a lot of Fortran years ago, with 3 or 4 different DEC (Digital Equipment Corporation) compilers. The compilers handled things like uninitialized variables differently.

So yes, I think that ifort is finding and fixing a problem for you that the other compilers just ignored.
 
The problem could be anywhere. It might be in code you wrote. It might be in libraries you used but didn't write. It might even be in a compiler library routine.

The only practical way I know of to find the cause of a BUS ERROR is to use a debugger. When the error occurs, the debugger may be able to show what was happening at the time of the error. That might be a list of functions you can follow to track down the cause. Or the debugger might not have enough info to show anything useful. The actual cause might be something else entirely separate from the point where the error occurred, done at some time earlier in the run, by some unknown routine.

If you don't know how to use the debugger, you should learn and practice on a known-good known-working program. Then you can move to the not-working program.


Let suppose is this kind of error, should you think is possible to believe in the result obtained by ifort that by-pass this error?
It's possible, but there's no way to know for sure.
 
Look in the CrashReporter listing

Go to /Applications/Utilities and run the Console.app - the trace back by "CrashReporter" may give you some more clues.
 
New Compiler Flag for gfortran

I just recalled that I had to add a new flag when compiling for Yosemite or most of my gfortran programs crashed.

Try adding "-fno-aggressive-loop-optimizations" to your gfortran flags.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.