strange gfortran error

Discussion in 'Mac Programming' started by angrynynph, Apr 3, 2015.

  1. angrynynph macrumors newbie

    Apr 3, 2015

    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)?
  2. subsonix macrumors 68040

    Feb 2, 2008
    Hard to tell, but the symptoms sounds suspiciously much like undefined behavior.
  3. angrynynph thread starter macrumors newbie

    Apr 3, 2015
    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.
  4. subsonix macrumors 68040

    Feb 2, 2008
    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?
  5. angrynynph thread starter macrumors newbie

    Apr 3, 2015
    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?
  6. monokakata macrumors 68000


    May 8, 2008
    Hilo, Hawai'i
    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.
  7. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    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.

    It's possible, but there's no way to know for sure.
  8. RightHalfPlane macrumors newbie

    Mar 9, 2015
    Look in the CrashReporter listing

    Go to /Applications/Utilities and run the - the trace back by "CrashReporter" may give you some more clues.
  9. RightHalfPlane macrumors newbie

    Mar 9, 2015
    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.

Share This Page