LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 07-18-2006, 10:51 AM   #1
eiffel
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
c
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)
c
end

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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
setenv KMP_STACKSIZE 1g
I was able to avoid segmentation during the static memry allocation.

Now with suse 10.1 and its default kernel which is
2.6.16.13-4-smp, 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.

Thanks

Eric
 
Old 07-19-2006, 11:04 AM   #2
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
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, 11:14 AM   #3
eiffel
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.

Eric
 
  


Reply


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 03:41 AM
fsck fails. Code: Bad EIP value. Segmentation fault. MOHCTP Debian 4 09-07-2005 09:35 PM
Need help: Seg fault, Memcpy, and dynamically allocated arrays benobi Programming 3 06-09-2005 11:58 PM
dpkg returned an error code (1) Segmentation fault questionman Debian 6 11-02-2004 01:04 AM
segmentation fault in following peice of code :please help linorg Programming 2 03-18-2004 09:57 PM


All times are GMT -5. The time now is 10:23 AM.

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