PR 19925 and expansion of array constructors

Erik Edelmann eedelman@acclab.helsinki.fi
Fri Jul 1 09:48:00 GMT 2005


paul@codesourcery.com wrote:
> Expanding everything takes insane amounts of memory and produces unreasonably 
> large executables. An example from real code:
> 
> program killme
>   integer, parameter :: N = 200000000
>   integer :: i
>   integer :: a(N) = (/(0, i = 1, N)/)
>   call foo(a)
> end program
> 
> For really big variables (Where anything > GFC_MAX_AC_EXPAND counts as big) we 
> want to expand these at runtime. ie. the above code becomes:
> 
> program killme
>   integer, parameter :: N = 200000000
>   integer :: i
>   integer, save :: a(N)
>   logical :: _initialized_a = .false.
>   if (.not. _initialized_a) then
>     do _i = 1, N
>      a(_i) = 0
>     end do
>   end if
>   call foo(a)
> end program

I haven't looked closer at this yet, just one thought that
hit me. In procedures (including main program), the run time
expansion code would of course be put in the body of the
procedure (like in the example above), but what about modules?
Is the any initialization procedure in modules automatically run
when the modules are USEd, where this sort of stuff could be put?


        Erik



More information about the Fortran mailing list