Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 07-18-2006, 09:51 AM   #1
LQ Newbie
Registered: Oct 2003
Posts: 10

Rep: Reputation: 0
Fortran Code with Large arrays statically allocated -> segmentation fault

Hi There,

I am having the following problem.
Here is simple code which allocates a large set of arrays
program timing
parameter (NSIZE = 10000)
real*8 mat(NSIZE,NSIZE)
real*8 v1(NSIZE)
real*8 v2(NSIZE)
integer i,j

call timings(NSIZE,mat,v1,v2)

My system is as follows:
dual opteron with 16GB of RAM

I had suse 10 installed with the kernel 2.6.13-15.10-smp x86_64
Using the following env variable
I was able to avoid segmentation during the static memry allocation.

Now with suse 10.1 and its default kernel which is, I am ending with a segmentation fault at runtime (I guess while it is trying to allocate the static memory).
The env variable does not seem to work anymore.

Is there something that can be done. Note that I have never recompiled the kernel and my knowledge is very limited in that matter. The code above is very simple but the one I am using are much more complicated and can not be changed to dynamic allocation easily.

Any help would be greatly appreciated. The kernel used are either the one installed from the installation disks or the one installed by the automatic updates.


Old 07-19-2006, 10:04 AM   #2
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,499
Blog Entries: 4

Rep: Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951Reputation: 2951
Personally, I'm not persuaded that it the cause of the segmentation fault is caused by the allocation of static memory. I don't see anything that affirms your assumption; hence it could be a red-herring.

I expect that the static allocation process is done by the loader before the program starts executing: the executable would say that the program needs so-many megabytes of space, and the loader has to go get it.

One thing that I would start out by doing is, as root, execute /sbin/ldconfig. This rebuilds the cache that the loader (ld) uses to resolve external references. There is no output from this command.

Then, check the requirements of your FORTRAN compiler to see what runtime libraries and such each program may require when it runs, and make sure not only that they are present but that they are all the same and the most-current version.
Old 07-19-2006, 10:14 AM   #3
LQ Newbie
Registered: Oct 2003
Posts: 10

Original Poster
Rep: Reputation: 0
Well it really seems to be a static memory limitation problem.
That make this clear, I did the following:

1. compile with an NSIZE much smaller:
it works.

2. keep the same High value for NSIZE and compile on a suse 10.0 and a suse 10.1 with the same intel compiler. Note that 10.0 has kernel 2.6.13 while 10.1 has 2.6.16.

On suse 10.0 If I omit "setenv KMP_STACKSIZE 1g" I get the segmentation fault. If I specify the "setenv KMP_STACKSIZE 1g
", the code runs fine.

On Suse 10.1, with or without "setenv KMP_STACKSIZE 1g" I get a segmentation fault.

That seems to be due to a stacksize limit reached. If I define large arrays dynamically usin the fortran90 functions, everything is fine. Unfortunately, for the current problem I can not use dynamic allocation.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault after declaring a large array. oulevon Programming 6 11-08-2005 02:41 AM
fsck fails. Code: Bad EIP value. Segmentation fault. MOHCTP Debian 4 09-07-2005 08:35 PM
Need help: Seg fault, Memcpy, and dynamically allocated arrays benobi Programming 3 06-09-2005 10:58 PM
dpkg returned an error code (1) Segmentation fault questionman Debian 6 11-02-2004 12:04 AM
segmentation fault in following peice of code :please help linorg Programming 2 03-18-2004 08:57 PM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:39 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration