PR 19925 and expansion of array constructors

Paul Brook paul@codesourcery.com
Fri Jul 1 12:25:00 GMT 2005


On Friday 01 July 2005 10:44, Erik Edelmann wrote:
> > 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?

You'd need to create a new routine in the module, and put the initialization 
code there.
You then either call that from every routine that USEs the variable, or make 
it __attribute__((constructor)). I suspect the latter is preferable.

Paul



More information about the Fortran mailing list