- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi everyone,
I wrote the following code:
[bash]REAL ,DIMENSION(nDOF,nVar,nElem) :: QHAT REAL ,DIMENSION(nDOF,nVar,nElem) :: FHAT,FHATSTAR [/bash]when nElem is greater than 10000 I get aSegmentation fault and the program stops
In the program now there are no more code so I think that is a memory program.
I am using the intel fortran compiler, are there any possibilities to check this? Can I extend the memory that I can use.
Thank you
Link Copied
9 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If these arrays are local variables, you may be running out of stack. Increase the stack limit, or compile with the -heap-arrays option, or modify your program to allocate the arrays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
how can I do it?
I mean the first option is:
[bash]REAL ,ALLOCATABLE,DIMENSION(:,:,:) :: QHAT,FHAT ALLOCATE(QHAT(nDOF,nVar,nElem)) ALLOCATE(FHAT(nDOF,nVar,nElem))[/bash]
How Can I apply the other two options?
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For the -heap-arrays option, read the Intel Fortran documentation.
The method of setting the stack limit is OS-specific. Usually, the shell command
ulimit -s unlimited
is enough. See How to raise my stack limit to solve Segmentation fault .
The method of setting the stack limit is OS-specific. Usually, the shell command
ulimit -s unlimited
is enough. See How to raise my stack limit to solve Segmentation fault .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
thank you I'll check.
with allocate I have a strange problem
consider:
[bash]nElem = 40000[/bash]when I allocate with:
[bash]ALLOCATE(QHAT (nDOF,nVar,nElem))
QHAT = 0.D0[/bash] then I write to screen as:
[bash]WRITE(*,*) "QHAT" ,QHAT(1,2,40001)[/bash]I have no segmentation fault
why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot depend on seg-faults being forced whenever you overrun an array. Often, one variable follows another, as in
COMMON /ABC/A(10),B(10)
It can happen that a reference to A(11) uses B(1). From the Fortran point of view, this is an error, but the OS will not see this as an illegal memory reference.
COMMON /ABC/A(10),B(10)
It can happen that a reference to A(11) uses B(1). From the Fortran point of view, this is an error, but the OS will not see this as an illegal memory reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
so what Can I do?
I have to be more carefull in programming?
or to not use allocatable and increase the cache?
thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No short recommendations can be given beyond what mecej4 said already. The heap-arrays option is reliable when you don't use threaded parallel, although it may hurt performance when unexpected temporary arrays are created.
When writing parallel code, you may need to be careful, as you say, to minimize the unintended use of private arrays and make those you do use work with stack settings.
When writing parallel code, you may need to be careful, as you say, to minimize the unintended use of private arrays and make those you do use work with stack settings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
so the best way seems to change the stack limits.
I am sorry but I am not very able with bash things.
It is correct if I open the bash file:
[bash]/etc/bash.bashrc[/bash]and then a copy and paste:
[bash]ulimit -s unlimited[/bash]
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
that should work, test it with
ulimit -a
next time you login
ulimit -a
next time you login
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page