0

I try to run the following code on (a 64-bit) gfortran 14.2

program test1
   real, allocatable :: a(:), b(:,:)
   ! allocate( a(3870457856_8) )
   allocate( b(8000, 2000000) )
end program test1

and get the error: In file 'test4.f90', around line 5: Error allocating 3870457856 bytes: Not enough space. At the same time, if I uncomment the first allocate and comment the second one, the program runs with no errors. Using compiler option -mcmodel=large does not help.

I get the same issue with gcc 12. The problem seems somehow to deal with transition of addressing from integer(4) to integer(8), since allocate( b(6000, 2000000) ) causes no errors.

What can I do to allocate the 2-dimensional array?

Update: Everything is Ok with this code. It seems that 3870457856 is just a chunk size or something like that. 8000*2000000 real array needs 64Gb of RAM, which is not available at this moment.

1 Answer 1

0

I think the problem is there is not enough memory in the system for an array so big. Try with smaller values. If you need to manage so big array, you will need a new algorithm, or get more ram. According to the message, 4 GB are required just for this variable b. Integer(4) use less memory space, half than integer(8), so this could be the reason it works with integer(4).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.