Fortran 95 - Segmentation Fault

Discussion in 'Mac Programming' started by huskrfreak88, Oct 16, 2008.

  1. huskrfreak88 macrumors newbie

    Oct 16, 2008
    I am going CRAZY for a solution to this problem! Hopefully these outputs are of some help to you, however if not, please specify what more you would like and I can attempt to do it!

    To further elaborate on the problem described above. The Segmentation Error occurs when j =9,10,11 but ONLY after the sub-routine is called. There is some kind of error going back to the main program when j = 9, 10, or 11. If the subroutine is NOT called while j=9,10,11 the program will finish, however if the subroutine is called while j is any of those values, I get a segmentation fault. Hopefully this can point out the problem?

  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    This is the line with the problem:
    array(x) = sum(temp_array)
    You surely mean:
    array(k) = sum(temp_array)
    You write far enough past the end of array, eventually, that you crush the stack (that's what it looked like to me, at least). When that happens, the address of some local variables now point to 0xfffffffa and things, and when a read is attempted from this address... crash.

    Also, why not make group_two an internal subroutine? It will save you room on the stack, as you are essentially just using the same variables? Since it's all by reference, it's not that much space, but it still seems clearer. You also pass infected, with a dimension of 10000, to infected_array with dimension of 100. Did you mean to pass an array slice of infected to group_two?


Share This Page