- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
I have written a fortran code that involves several calculations with 2D arrays. The program works fine below certain threshold... namely, 360x360. Above this, the program crash and a segmentation fault message appears. As I am working on a Mac OX 10.8.4 I can't increase the stack size... So, I have compiled with the -heap-arrays option, and the program runs without "problems" except for it takes around 2GB of the RAM memory, causing a poor performance on the machine. Below the thershold the program just takes 20MB in the RAM. All the arrays have been defined dinamically.
I've used the gdb debugger and I know exactly from where (which subroutine) the segmentation is coming, but, the code seems to be ok there.
Somebody can figure out how I could handling this issue?
Thanks in advanced,
Crist.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, the change in behavior when you use -heap-arrays is a big clue. Without it, you have some large array being allocated on the stack. Maybe it's a local array, maybe it's a temporary copy made to satisfy a contihguity requirement. Have you also tried -check arg_temp_created to see if you get any useful diagnostics at run-time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Thank you for your reply. Effectively, the problem was in local arrays... Althought all "my" arrays were defined dynamically, I was using a subroutine from the Fortran 90 numerical recipes, which possesses some internal arrays locally defined. I think that my problem was originated from the old precept about do not modify the subroutines...
Thanks a lot!
Crist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad to hear it. You could modify those routines to make the local arrays allocatable, allocating them to the desired size. For example, if you had this:
subroutine sub (a,b,n)
integer n
real localarray(n)
you could change it to:
subroutine sub (a,b,n)
integer n
real, allocatable :: localarray(:)
...
allocate (localarray(n))
This would have the behavior you want. Or use -heap-arrays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quite so!
Now, it is running with a grid 1028x1028, and just takes around 100MB in the RAM memory. Great!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page