Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Oversized array ?

alexposts
Beginner
766 Views

Hello,

Could you tell me why the piece of code below give a "segmentation error". There is a limit for the size of an array, in this case what is this limit and how can I avoid it ?

Thanks !

I know that for a value of i = 1577536, everything works well, I didn't try to know for which value of i exactly, the code failed

PROGRAM TEST

TYPE ALEX
real,allocatable :: toto(:)
real,allocatable :: titi(:)
END TYPE

type(alex) :: t_alex
integer :: i

i=11577536

ALLOCATE(t_alex%toto(i+1))
ALLOCATE(t_alex%titi(i+1))

t_alex%toto(1:i) = t_alex%titi(1:i)

END PROGRAM

0 Kudos
9 Replies
Steven_L_Intel1
Employee
766 Views
Does a:

limit stacksize unlimited

or

ulimit

command make a difference? While I don't think it should, the compiler may be creating a stack temporary for the assignment.
0 Kudos
alexposts
Beginner
766 Views
ulimit is set to "unlimited", I 'm not sure it comes from that ... there is a limitation of the stack size with ifort ? if yes, how I can avoid this limitation

Thanks
0 Kudos
Steven_L_Intel1
Employee
766 Views
ifort does not establish a stacksize limit, the OS does. You set the limit using shell commands, as I noted.

Does the segv happen on the assignment or before? I note that these are components of a derived type - I know we don't do as good a job on these as we could, and I have filed a request to improve it. I'd recommend that you send a test case to Intel Premier Support.
0 Kudos
alexposts
Beginner
766 Views
the sigv happen just after :

t_alex%toto(1:i) = t_alex%titi(1:i)

I have tried with several values of i, this morning for i=2096726, I have the sigv, I restarted my computer and I recompile the code and the value of i to have a sigv was not the same (i<2096726).
I also try with toto and titi as pointer and not allocatable type, I have the same error.

It runs on a debian sarge with ifort 9.0 20050430, my kernel is a 2.6.11.

If you need other informations

Thanks for your help
0 Kudos
Steven_L_Intel1
Employee
766 Views
You definitely are running out of stack, then.

As an experiment, try this:

t_alex%toto = t_alex%titi

What happens?
0 Kudos
alexposts
Beginner
766 Views
With t_alex%toto = t_alex%titi, I have a sigv... I have also tried with titi, and toto as pointers and not as allocatable and with
ALLOCATE(t_alex%toto(i)) and ALLOCATE(t_alex%titi(i)) instead of i+1, nothing changes, I have always a sigv.

I have tried to fill up a request with Intel Premier support but I can't access to https://premier.intel.com (error 403)

Thanks
0 Kudos
Steven_L_Intel1
Employee
766 Views
Try https://registrationcenter.intel.com/support if you're having trouble with Intel Premier Support.
0 Kudos
emc-nyc
Beginner
766 Views
Suggestion 1: modify you allocate statements from


ALLOCATE(t_alex%toto(i+1))






to





ALLOCATE(t_alex%toto(i+1),STAT = err_num)




and test to see what the value of err_num is upon return.


Suggestion 2: check to see if you can use allocatable arrays as components of user-defined types.

Message Edited by emc-nyc on 12-27-2005 11:27 PM

Message Edited by emc-nyc on 12-27-2005 11:28 PM

0 Kudos
emc-nyc
Beginner
766 Views
My suggestion would be to change the allocation commands from
allocate(t_alex%toto(i+1))
to
allocate(t_alex%toto(i+1)),STAT = err_num)

This will permit you to catch the error and see what it is.
0 Kudos
Reply