Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Increase of array memory in gfortran compiler

Status
Not open for further replies.

cleitonufrgs

Programmer
Sep 24, 2010
2
BR
Dear colleagues

My code in Fortran passes all data in one large vector. I increased the size of this vector for the maximum that the compiler accepts but still need more positions allocable to it. Is there any way I can increase the memory allocation of the compiler?

Thank's
 
We need additional precisions to help you. Could you answer the following questions please ?

What is the amount of memory of your computer ?

What is the error message ? Is it produced by the system or by the FORTRAN code itself ?

How many data have you allocated (more precisely "reserved") in that large array before the crash ? There is always the risk of an infinite loop reserving too many zones.

What is the size of the array keeping the traceback of all reserved zones ? If such array exists, then it will limit the maximum number of zones you may reserve.

What is the unit chosen to compute the address in the large array ? Yes this question is important because I suppose that the array index is a 32bits integer. If the unit is the byte, then you cannot access more that 2 Giga bytes in a single array. But if the unit is the double precision value (8 bytes by double value), then you can access 16 Giga bytes.

Of course, the last question concerns only the 64bits architectures, because if you have a 32bits architecture, then any address is coded on 32bits and you cannot use more than 4 Giga bytes on such computer.

Another solution : you may try to use allocatable arrays. The practice of a large array containing data is really obsolete. This was the typical way before the arrival of FORTRAN-90.
 
Dear FJacq,

Thanks for your replay. I'll try to answer your questions:

1. My RAM is 8GB and the architecture of my computer is 64bits;
2, I'm using the Gfortran-4.4. Its error message is ----
3. Before the computer crashes, I've allocated a single vector named "a" - that contains all variables of my code - with ??? positions, typing common a(???).
4. I'm not sure how to answer this questions. I dimension the array "a" in the follow way:

- First, in the main program, I dimension the vector "a" through the command common, only typing common a(536000000), for instance. In the main program, I don't use the double precision command!
- Secondly, in the subroutines, I declare all real variables in double precision through the command implicit, typing implicit real*8 (a-h,o-z). These variables are allocated into vector "a" by the subroutine mpoint that calculates the pointers for the beginning and the end of each variable according the following rule: it uses two words for real variables and only one word for the integer ones.

However, I don't know if such a kind of allocation will leave the vector "a" a array index of 32bits integer.


If something is missing, please don't hesitate to ask me for.

Again I appreciate very much for your attention and sorry if I could help you more

Thanks,
Cleiton
 
So "a" seems to be declared real*4. The memory size of the array is 536000000 real*4 which means 2.2Gbytes of memory.

A 32bit index is normally sufficient to access all the elements of that array, except if it also contains character fields. In that case, the array "a" could be declared "character" in few routines instead of real*4 => impossible to access characters after 2Gbytes.

But I don't think that this is the origin of your troubles.

I tested the following program of Linux 64 (core-i5 8Gbytes)

Code:
PROGRAM test
  real :: a(500000000)
  a(490000000)=3
  write(*,*) a(490000000)
END PROGRAM

Using the 32bit version of the intel compiler :

Code:
coul@b10p5001:~/test$ ifort -c tt.f90
tt.f90(2): error #5521: A common block or variable may not exceed 2147483647 bytes
  real(8) :: a(500000000)

Using gfortran 4.4.5 (20100728)

Code:
coul@b10p5001:~/test$ gfortran -O3 tt.f90
coul@b10p5001:~/test$ ./a.out
   3.0000000

But when I tried to replace REAL by REAL*8, I was unable to generate the executable program.

Code:
coul@b10p5001:~/test$ gfortran -c -O3 tt.f90
coul@b10p5001:~/test$ gfortran tt.o
  => freezing the computer
  => I needed to reboot

So this is the link phase which does not work correctly. I don't know why !

It is possible that the linker tries to create really the array "a" and is not capable to find a contiguous memory zone of that size.

I suggest to install a more recent version of gfortran. I don't know whether the trouble comes from gfortran or ld (the unix linker).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top