Cannot allocate array - overflow on array size calculation.

Cannot allocate array - overflow on array size calculation.

I am trying to run a simulation program on my laptop (Linux 3.8.0-25-generic x86_64, with Ubuntu 13.04). it compiles ok but when getting to allocation of some array sizes i get:

forrtl: severe (179): Cannot allocate array - overflow on array size calculation.

what I did is:

Some googling about this message (some links attached) led me to conclude that this is generated because my program is out of memory.

But, then I made my array very small, but still got the same problem.

Some found threads about my error:

But did not help.

This is the code:

program memoria
implicit none
integer :: n,num
complex, dimension(:,:,:,:,:,:,:,:,:,:,:,&
                   :), allocatable :: ddptrj
endprogram memoria

Does anybody see what is the problem?

Thank you

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

So you're asking for:

4^21 x 21 elements, each 8 bytes, or 738,871,813,865,472 bytes of memory - 738 terabytes of RAM.

 I can compile this code with the latest Composer XE 2013 SP1 compiler - what version are you using.  But this will never never never run, not even close.  Even though you can have VIRTUALLY unlimited memory with 64 bit addressing, you have to have on your PC or server (PHYSICAL RAM + PAGE SPACE) in bytes sufficient to hold the array.  Do you have 738TB of Ram, or even 738TB of disk space allocated for paging space?  I doubt it.

One must size a problem to fit their server or PC capacity.  This is RAM + PAGE space, ideally you want about 80% of that MAXIMUM for your arrays or less. And even then, you'll be paging which will grind your code to a crawl.  Best case: take 80% of RAM and target that for all arrays.


My guess is that the IA-32 compiler is being used.

As also mentioned in the StackOverflow discussion where you also posted this, your use of 20 dimensions is non-standard and non-portable.

Steve - Intel Developer Support

Ok, thanks both Ron and Steve, I think I need to figure out something else in order to not allocate such huge array. Because it is obvious from everybodie's comments about this issue, that is not a common thing to do such thing, therefore, there must be another way to do what I want to do.

Thanks wise people!!


What is your need for that many dimensions?  Running a typical "3D" simulation that varies in time generally only requires 5 dimensions: x, y, z, time, variable (Often represented as many 3d or 4d array variables and not a single 5d array).  Also keep in mind, as noted above, using more than 7 dimensions (15 in Fortran 2008) is nonconforming to the standard and your code is not guaranteed to compile with other fortran compilers.

Sorry guys,

I need to post a new question and I can't see where, I do not see the option to post a question :(

Go back to the forum main page ( and look for the New Topic button on the left, below the Announcements box.

Leave a Comment

Please sign in to add a comment. Not a member? Join today