CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   largest one-dimensional array in fortran 77 (https://www.cfd-online.com/Forums/main/15907-largest-one-dimensional-array-fortran-77-a.html)

yfyap October 20, 2008 23:54

largest one-dimensional array in fortran 77
 
hi there i have a one-dimensional array in fortran 77: A(N), intended to store a very long list of particles. the largest N that i could have currently is around 1.2 millions. larger than that, the compilier wont work. Is there a way to increase N far beyond 1.2 millions, eg. 5 millions? thanks in advance

Jed October 21, 2008 03:43

Re: largest one-dimensional array in fortran 77
 
Uh, the *compiler* won't work? What compiler? The compiler shouldn't complain up to 2^32. With a 32-bit OS, your program won't be able to address more than 2^31 total bytes. But these are run-time issues, and you need to be orders of magnitude larger to run into them.

yfyap October 21, 2008 03:46

Re: largest one-dimensional array in fortran 77
 
hi.. the limit is around 5 millions entry in the array, but still think of getting it even larger. regret for the wrong info of 1.2 millions.

yfyap October 21, 2008 03:49

Re: largest one-dimensional array in fortran 77
 
i am using compaq visual fortran 2000 currently. the data is double precision. thanks.

Richard October 21, 2008 07:40

Re: largest one-dimensional array in fortran 77
 
When you say "the compiler won't work", do you mean that the code will not compile, or the resulting executable will not run?

yfyap October 21, 2008 22:23

Re: largest one-dimensional array in fortran 77
 
hi.. the compiler does compile, but gives warning message:

for five million entries: warning LNK4084: total image size 1813958656 exceeds max (268435456); image may not run

for six million entries: warning LNK4084: total image size -2137006080 exceeds max (268435456); image may not run

the generated exe file for 5 million entries is ok, but that with six million entries does not run.

any light cast on the matter is deeply appreciated.


Jed October 22, 2008 04:55

Re: largest one-dimensional array in fortran 77
 
Could you post the code that triggers this? Somehow your program is putting this array in the text segment (the actual executable image) many times. An array of 5M double precision values should be 40MB, but your image is more than 2GB (hence 32-bit signed integer indices overflow, or if you're on a 32-bit architecture the OS simply won't run it). Normally the compiler will allocate large arrays on the heap so they don't effect the image size and you are only limited by available memory.

Steve October 22, 2008 08:40

Re: largest one-dimensional array in fortran 77
 
Is your array static (e.g. defined using common or data). Or is it a local variable? If it's a local variable, you'll run into stack size limits quite quickly.

yfyap October 22, 2008 08:43

Re: largest one-dimensional array in fortran 77
 
hi the code is a bit too long to be posted here. i have a bunch of arrays with 5M entries. maybe it hits the limit of 2G. will check this. thank you.

yfyap October 22, 2008 08:45

Re: largest one-dimensional array in fortran 77
 
hi.. actually i have a few arrays with 5M entries. all these are defined using COMMON, global variables. thanks.

omfg October 22, 2008 13:58

Re: largest one-dimensional array in fortran 77---
 
first you should learn fortran and then use dynamic memory.

Steve October 23, 2008 07:25

Re: largest one-dimensional array in fortran 77---
 
The original poster is using F77. It's in the title of the post. Why he/she is choosing to use this vintage is not mentioned. However, it precludes anything dynamic.

Steve October 23, 2008 10:45

Re: largest one-dimensional array in fortran 77
 
What kind of machine are you compiling & running on?

yfyap October 23, 2008 10:52

Re: largest one-dimensional array in fortran 77
 
hi..i am building on top of a flow solver written in fortran 77. the program is running on a machine with intel core 2 processor, 4Gb of memory, window vista. guess the system is sufficient for my purpose. thank you.


Jed October 23, 2008 13:48

Re: largest one-dimensional array in fortran 77
 
64-bit OS? Can you compile a 64-bit binary? How large is the binary? Can you write the 4-line program that allocates a huge array and touches it? How large does the single array have to be to fail (link statically to give yourself the most possible room). If it's close to 2GB, then it's a real OS-level issue and you need to need a real 64-bit system to do better. If it's not close to 2GB, then the compiler is doing something weird.

yfyap October 23, 2008 23:11

Re: largest one-dimensional array in fortran 77
 
hi.. running 32bit os. will try that and will let u know the results. thanks!

Steve October 24, 2008 04:36

Re: largest one-dimensional array in fortran 77
 
My question was because some F77 compilers require special switches to control max data size (e.g. xlf on AIX). Similarly, some operating systems have max data size per process hard-coded into the kernel (e.g. HP-UX), requiring a kernel rebuild to change it.

Paul October 24, 2008 14:09

Re: largest one-dimensional array in fortran 77
 
Hello,

try to use a different compiler and see if you have the same problem.

gfortran for Windows is a decent compiler.

Paul


yfyap October 27, 2008 07:48

Re: largest one-dimensional array in fortran 77
 
hi thanks!

Rami October 29, 2008 09:31

Re: largest one-dimensional array in fortran 77
 
Here is a very simple f77 code to test the limits. On WinXP/Visual Studio fortran (v6.6) it gave warning at a much lower dimension than expected (I think 2^28 bits ~ 268M real*4) and on slightly larger array - it crashed. On linux/g77 it ran near the theoretical 2^32 bits when the array was in a common block, as explained formerly in this thread. If you play with this code, you may find whether you have a specific fortran/OS limitation.

I hope that helps, Rami __________________________________________________ ___

program zz

parameter (m=29)

c parameter (i=2**m)

parameter (i=536770912)

c real*4 a(i)

integer a(i)

common a

print *, 'm, i = ', m, i

sum = 0.

do k=1,i

a(k) = k

sum = sum + a(k)

enddo

print *, 'a(1), a(i), sum = ', a(1), a(i), sum

end



All times are GMT -4. The time now is 16:51.