Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Cannot allocate array

yairsuari
Beginner
3,964 Views

i am trying to run an oceanic model on my laptop (3 GB memory Intel Pentium Dual Core T2330 running ubuntu 8.04 with the ifort 10 compiler). it compiles ok but when getting to allocation of some array sizes i get:

forrtl: severe (179): Cannot allocate array ? overflow array size calculation

i will shortly explain what i tried to do:

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

To check this assumption I tried to allocate the same array a smaller dimension which worked and strengthened my essumption.

What I did next the last few days was run the model on a monster[1] (at least compared with my laptop) only to find out that I get the same error message then I thought about looking at the memory status just before I get the error message and found out that the process only takes about 500Mb.

then i tried to increase my stack memory (umem -s) which did not work and left me with no new ideas


Some forum threads about my error:

http://cms.mpi.univie.ac.at/vasp-forum/forum_viewtopic.php?2.857

http://www.iri.tudelft.nl/HELP/FORTRAN/RUN_TIME_MESSAGES/ARRSIZEOVF



[1] amzon ec2 large instance Large Instance 7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each), 850 GB of instance storage, 64-bit platform

0 Kudos
1 Solution
Steven_L_Intel1
Employee
3,964 Views

I tried your program with 11.0 and it worked fine. I don't have the particular version you are using handy. You can try the 11.0 beta using the link in the topic at the top of this forum and see if the behavior changes.

I do note that I see the error if I use the 32-bit compiler.

View solution in original post

0 Kudos
17 Replies
jimdempseyatthecove
Honored Contributor III
3,964 Views
Quoting - yairsuari

i am trying to run an oceanic model on my laptop (3 GB memory Intel Pentium Dual Core T2330 running ubuntu 8.04 with the ifort 10 compiler). it compiles ok but when getting to allocation of some array sizes i get:

forrtl: severe (179): Cannot allocate array ? overflow array size calculation

i will shortly explain what i tried to do:

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

To check this assumption I tried to allocate the same array a smaller dimension which worked and strengthened my essumption.

What I did next the last few days was run the model on a monster[1] (at least compared with my laptop) only to find out that I get the same error message then I thought about looking at the memory status just before I get the error message and found out that the process only takes about 500Mb.

then i tried to increase my stack memory (umem -s) which did not work and left me with no new ideas


Some forum threads about my error:

http://cms.mpi.univie.ac.at/vasp-forum/forum_viewtopic.php?2.857

http://www.iri.tudelft.nl/HELP/FORTRAN/RUN_TIME_MESSAGES/ARRSIZEOVF



[1] amzon ec2 large instance Large Instance 7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each), 850 GB of instance storage, 64-bit platform

How are you allocating your array?

If explicitly by way of ALLOCATE(YourArray(dim1,dim2,...)) then what will the eventual size require for storage? (compute product of dims times size of element). If this size is unreasonable (incorrect dimension) then that is a programming bug that needs to be fixed. If this size is correct and reasonable then this is an operating system issue whereby it is restricting the amount of virtual memory,

If implicitly by way of subroutine withlocal array with large dimensions passed in as arguments then try using the option for heap arrays or making the local array ALLOCATABLE and allocating the array explicitly.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
3,964 Views

You say you are using Ubuntu 8.10 (not yet a supported version), but don't say if this is the 32-bit or 64-bit (x64) version, nor if you are using the 32-bit or 64-bit compiler. You need both a 64-bit OS and 64-bit compiler in order to be able to allocate more than 2GB of data. You nay also need to compile with "-mcmodel medium".

0 Kudos
yairsuari
Beginner
3,964 Views

How are you allocating your array?

If explicitly by way of ALLOCATE(YourArray(dim1,dim2,...)) then what will the eventual size require for storage? (compute product of dims times size of element). If this size is unreasonable (incorrect dimension) then that is a programming bug that needs to be fixed. If this size is correct and reasonable then this is an operating system issue whereby it is restricting the amount of virtual memory,

If implicitly by way of subroutine with local array with large dimensions passed in as arguments then try using the option for heap arrays or making the local array ALLOCATABLE and allocating the array explicitly.

Jim Dempsey

i am using the allocate command for that but i am pretty new to that so here is my calculation

my array dimensions are about:

(1:125,1:130,1:30,1:50) and its a real (i assume kind=8)

so the calculation is 125*130*30*50*8*8=1560000000byte or 1487Mb whic is reasonable for such application but i will definately have to use a big virtual memory. is that true?

should i try playing with the virtual memory?

0 Kudos
yairsuari
Beginner
3,964 Views

You say you are using Ubuntu 8.10 (not yet a supported version), but don't say if this is the 32-bit or 64-bit (x64) version, nor if you are using the 32-bit or 64-bit compiler. You need both a 64-bit OS and 64-bit compiler in order to be able to allocate more than 2GB of data. You nay also need to compile with "-mcmodel medium".

i am realy sorry for that

the OS is ubuntu 8.04 and on it i use the 32 bit but on the 'big machine i used both the os and the compiler 64bit version

sorry again and thanks alot

0 Kudos
Steven_L_Intel1
Employee
3,964 Views

The error message suggests that you are using the 32-bit compiler. Can you show the output of the console session including the compile command and its output?

0 Kudos
yairsuari
Beginner
3,964 Views

The error message suggests that you are using the 32-bit compiler. Can you show the output of the console session including the compile command and its output?

First of all let me apologize, its been some time since I started programming but not with compiled languages. I was sure that the fact I cant find the answer right away on the web is because I don't ask the right questions and you guys will answer it in a moment.

Now I will try giving some more details:

The line where I get the error reads:

allocate(D3SOURCE(1:NO_D3_BOX_STATES,1:NO_D3_BOX_STATES,1:NO_BOXES))

when NO_D3_BOX_STATES=50 NO_BOXES=541305

so my array has 50*50*541305=13,532,625,000 elements (they are real and type=8) which means 50Gb.

The compiler command I used through makefile is:

ifort -DBFM_POM -ew -DFORTRAN95 -DREAL_4B=real(4) -DPRODUCTION -O3 -module /home/yair/Documents/BFM_POM/bfm-trunk/modules/IFORT -I/usr/local/netcdf/include -I/usr/local/include -I/home/yair/Documents/BFM_POM/bfm-trunk/include -I/home/yair/Documents/BFM_POM/bfm-trunk/modules/IFORT -I/home/yair/Documents/BFM_POM/bfm-trunk/src/BFM/include -I../include -w95 -g -c /home/yair/Documents/BFM_POM/bfm-trunk/src/BFM/General/AllocateMem.F90 -o /home/yair/Documents/BFM_POM/bfm-trunk/src/BFM/General/AllocateMem.o

And the message I am getting is:

NO_D3_BOX_STATES=50 NO_BOXES=541305

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

Image PC Routine Line Source

bfm_pom_adriatic_ 0819EE19 Unknown Unknown Unknown

bfm_pom_adriatic_ 0819E39D Unknown Unknown Unknown

bfm_pom_adriatic_ 08162B8A Unknown Unknown Unknown

bfm_pom_adriatic_ 0812D89A Unknown Unknown Unknown

bfm_pom_adriatic_ 0814AE21 Unknown Unknown Unknown

bfm_pom_adriatic_ 080AC4B8 Unknown Unknown Unknown

bfm_pom_adriatic_ 080810FC Unknown Unknown Unknown

bfm_pom_adriatic_ 08070AAA Unknown Unknown Unknown

bfm_pom_adriatic_ 08067914 Unknown Unknown Unknown

bfm_pom_adriatic_ 0804C6B9 Unknown Unknown Unknown

bfm_pom_adriatic_ 08049FA1 Unknown Unknown Unknown

libc.so.6 B7E32450 Unknown Unknown Unknown

bfm_pom_adriatic_ 08049F01 Unknown Unknown Unknown

After I understood this is to much to ask from my machine I tried using a stronger machine which runs 64bit OS and I had the latest ifort 64bit version installed on it. Since this was an amazon ec2 machine (a virtual machine for rent by the hour' I did not save anything and cannot reproduce this machines error messages.

My qustion now is is it possible to somehow make the system allocate this array to virtual memory?

Thanks allot for you guys help!!!

0 Kudos
Steven_L_Intel1
Employee
3,964 Views

Please type:

ifort -V

and show the output. While you may have the 64-bit compiler installed, I am almost certain that you are using the 32-bit compiler. In version 10.1, you would have to specify in the "source" command a path including "fce". If you used "fc" instead, you get the 32-bit compiler.

0 Kudos
jimdempseyatthecove
Honored Contributor III
3,964 Views

Let me preface this by "I am not a Linux programmer" but from my understanding 32-bit Linux uses -Negative addressing for stack (grows down from -4 to 0x8000000) in theory, and code grows from 0x00000000 to 0x7FFFFFFF with some portion of the middle address reserved for shared virtual memory address with O/S. Depending on your distribution the heap could be allocated out of the remainder of either or both pools, but not cross pools. Therefore, on 32-bit Linux, the maximum contiguous allocation would be some number significantly less than 2GB (2GB address space less shared address with O/S). If the heap "can" live on both sides of the 0x80000000 barrier then you might be able to allocate more than 2GB but not in one piece. That is on the O/S side. 32-bit Fortran may exhibit problems when the index computations near 2GB.

I noticed that your last array index was on the order of 50. Can you allocate 50 smaller arrays then work with those?

Or at least run a test and see where you bomb out.

Jim Dempsey

0 Kudos
yairsuari
Beginner
3,964 Views

Please type:

ifort -V

and show the output. While you may have the 64-bit compiler installed, I am almost certain that you are using the 32-bit compiler. In version 10.1, you would have to specify in the "source" command a path including "fce". If you used "fc" instead, you get the 32-bit compiler.

as i did not backup had to redo this agin on 64 bit machine and here are some info outputs:

uname -m
x86_64
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 122944
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 122944
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

dmesg | grep RAM
BIOS-provided physical RAM map:
RAMDISK driver initialized: 16 RAM disks of 16384K size 4096 blocksize

free
total used free shared buffers cached
Mem: 15736360 537348 15199012 0 15304 174424
-/+ buffers/cache: 347620 15388740
Swap: 0 0 0

ifort -V
Intel Fortran Compiler for applications running on Intel 64, Version 10.1 Build 20080801 Package ID: l_fc_p_10.1.018
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY

$PATH
/opt/intel/fce/10.1.018/bin:/opt/intel/fce/10.1.018/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

compilation command

ifort -DBFM_POM -DFORTRAN95 -DREAL_4B=real(4) -DPRODUCTION -O3 -module /home/yair/Documents/BFM_POM/bfm-trunk/modules/IFORT -I/usr/local/netcdf/include -I/usr/local/include -I/home/yair/Documents/BFM_POM/bfm-trunk/include -I/home/yair/Documents/BFM_POM/bfm-trunk/modules/IFORT -I/home/yair/Documents/BFM_POM/bfm-trunk/src/BFM/include -I../include -w95 -g -c /home/yair/Documents/BFM_POM/bfm-trunk/src/BFM/General/AllocateMem.F90 -o /home/yair/Documents/BFM_POM/bfm-trunk/src/BFM/General/AllocateMem.o

and finaly error message:

# Allocating State Variables and Rates array ...
NO_D3_BOX_STATES= 50 NO_BOXES= 541305
forrtl: severe (179): Cannot allocate array - overflow on array size calculation.
Image PC Routine Line Source
bfm_pom_adriatic_ 0819EE19 Unknown Unknown Unknown
bfm_pom_adriatic_ 0819E39D Unknown Unknown Unknown
bfm_pom_adriatic_ 08162B8A Unknown Unknown Unknown
bfm_pom_adriatic_ 0812D89A Unknown Unknown Unknown
bfm_pom_adriatic_ 0814AE21 Unknown Unknown Unknown
bfm_pom_adriatic_ 080AC4B8 Unknown Unknown Unknown
bfm_pom_adriatic_ 080810FC Unknown Unknown Unknown
bfm_pom_adriatic_ 08070AAA Unknown Unknown Unknown
bfm_pom_adriatic_ 08067914 Unknown Unknown Unknown
bfm_pom_adriatic_ 0804C6B9 Unknown Unknown Unknown
bfm_pom_adriatic_ 08049FA1 Unknown Unknown Unknown
libc.so.6 F7E77450 Unknown Unknown Unknown
bfm_pom_adriatic_ 08049F01 Unknown Unknown Unknown

thanks again for all the help!!

0 Kudos
TimP
Honored Contributor III
3,964 Views

ifort -V
Intel Fortran Compiler for applications running on Intel 64, Version 10.1 Build 20080801 Package ID: l_fc_p_10.1.018
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.

You showed us that you are using the 64-bit compiler. However, if you use 32-bit signed integer arithmetic to calculate the size of an array, it can't much exceed 2 billion elements (16GB for 64-bit array elements), while you said you intended 53GB. As some of the more expert advice givers continually point out, declarations matter, and the fact that you need to ask questions may indicate the trouble lies somewhere you didn't suspect.

0 Kudos
Steven_L_Intel1
Employee
3,964 Views

The error message is given by the generated code/run-time library when its own array indexing calculation overflowed. Since you are using the 64-bit compiler, this is rather surprising. Can you show us a small but complete example that demonstrates the problem?

0 Kudos
yairsuari
Beginner
3,964 Views

The error message is given by the generated code/run-time library when its own array indexing calculation overflowed. Since you are using the 64-bit compiler, this is rather surprising. Can you show us a small but complete example that demonstrates the problem?

just trying to allocate the same dimensions does this

program test
real,allocatable,dimension(:,:,:) :: a
allocate(a(1:50,1:50,1:541305))
write(6,*)i
end

thanks alot for the help

0 Kudos
Steven_L_Intel1
Employee
3,965 Views

I tried your program with 11.0 and it worked fine. I don't have the particular version you are using handy. You can try the 11.0 beta using the link in the topic at the top of this forum and see if the behavior changes.

I do note that I see the error if I use the 32-bit compiler.

0 Kudos
yairsuari
Beginner
3,964 Views

I tried your program with 11.0 and it worked fine. I don't have the particular version you are using handy. You can try the 11.0 beta using the link in the topic at the top of this forum and see if the behavior changes.

I do note that I see the error if I use the 32-bit compiler.

thanks alot i will try version 11 and if not working i will have to find a way to work with smaller arrays

anyway its time to close this post

thanks alot for you guys time

0 Kudos
jimdempseyatthecove
Honored Contributor III
3,964 Views

>>

# Allocating State Variables and Rates array ...
NO_D3_BOX_STATES= 50 NO_BOXES= 541305
forrtl: severe (179): Cannot allocate array - overflow on array size calculation.
Image PC Routine Line Source
bfm_pom_adriatic_ 0819EE19 Unknown Unknown Unknown
bfm_pom_adriatic_ 0819E39D Unknown Unknown Unknown
<<

In the above error message, the routine addresses are expressed in 32-bit numbers. I suspect you are using the 64-bit compiler to cross compile and generate a 32-bit application.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
3,964 Views

Good catch, Jim. It is clear that the 32-bit compiler was used. One can't "use the 64-bit compiler as a cross-compiler", but you can use the 32-bit compiler on a 64-bit system if you have the right libraries in place.

0 Kudos
yairsuari
Beginner
3,964 Views
Quoting - yairsuari

i am trying to run an oceanic model on my laptop (3 GB memory Intel Pentium Dual Core T2330 running ubuntu 8.04 with the ifort 10 compiler). it compiles ok but when getting to allocation of some array sizes i get:

forrtl: severe (179): Cannot allocate array ? overflow array size calculation

i will shortly explain what i tried to do:

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

To check this assumption I tried to allocate the same array a smaller dimension which worked and strengthened my essumption.

What I did next the last few days was run the model on a monster[1] (at least compared with my laptop) only to find out that I get the same error message then I thought about looking at the memory status just before I get the error message and found out that the process only takes about 500Mb.

then i tried to increase my stack memory (umem -s) which did not work and left me with no new ideas


Some forum threads about my error:

http://cms.mpi.univie.ac.at/vasp-forum/forum_viewtopic.php?2.857

http://www.iri.tudelft.nl/HELP/FORTRAN/RUN_TIME_MESSAGES/ARRSIZEOVF



[1] amzon ec2 large instance Large Instance 7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each), 850 GB of instance storage, 64-bit platform


for future readers:

as been told here: when moving to 64bit OS, and compiling with ifort 11 problem dissapeared (then i got insufficient virtual memory but thats another problem

thanks for everyones help

0 Kudos
Reply