Topic: Error message: Segmentation fault

I compiled the code sucessfully, but I got the following error message shortly after I launched it.

---------------------------------------------------------------------------------------------------
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  fffffffff
---------------------------------------------------------------------------------------------------

I think that this error message is related with the big matrix I defined as a real.
the size of the matrix is 6400*6400.
Before I introduced this big matrix, the code run well.
How can I solve the problem while using the big matrix?

Re: Error message: Segmentation fault

Are you compiling in 64-bit mode?  That could be a simple fix.

If you already are in 64-bit mode, there might be a few other things you could try.  For example, add the switch "-mcmodel=medium" to the Fortran compiler flags in the Project Options dialog.  That allows more memory to be accessed by your program.

Jeff Armstrong
Approximatrix, LLC

3 (edited by jin 2013-04-25 13:14:28)

Re: Error message: Segmentation fault

Yes, I am compiling in 64-bit mode with Windows7.
I did it as you recommended, but the same error message came out shortly after launching it.
You mentioned a few other things I can try. What are those?

I extracted some lines from my code following:

module globvar

      !******* prohibit implicit variable declaration *******
      implicit none

      !******* meta parameter *******
      real(8),parameter:: eps     = 1.0d-10     !really small number
      integer,parameter:: scr     = 8             !screen output file number
      integer,parameter:: out     = 10             !output file number

      !******* variables for approximation *******
      integer,parameter:: ne=8                   !number of earnings shocks
      integer,parameter:: na      = 800         !number of grid points

      integer,parameter:: ni=ne*na

end module globvar

program main

      use globvar
      implicit none

      real(8),dimension(1:ni,1:ni)  :: matQ  !matrix for modified policy rule


end program main

Re: Error message: Segmentation fault

I just gave your code a try on my machine, and I'm not seeing any issue.  Which version of Simply Fortran are you currently using?  I just want to confirm you're on the latest version. 

Doing the math manually, I can see that 64-bit wasn't actually necessary in your stripped-down example.  Do you have debugging enabled already?

I've seen similar issues if the standard input and output unit numbers, 5 and 6, are used for file access via OPEN statements.  Is anything of that nature currently occurring in your code?

Jeff Armstrong
Approximatrix, LLC