Unbuffered output in mixed C / Fortran programs

Brian Dessent brian@dessent.net
Wed Oct 15 16:35:00 GMT 2008


Georg Denk wrote:

> late. At least this was the result of a small test, where
> I added a putenv call at the beginning of the main
> routine (which is in C, but I don't think this makes
> a difference).

You might be able to arrange for the putenv to execute before the
libgfortran initialization routines by:

void whatever() __attribute__((constructor))
{
  putenv ("GFORTRAN_UNBUFFERED_PRECONNECTED=y");
}

If that still doesn't result in it being called early enough you can
also try giving it the lowest allowable numerical priority, e.g.
__attribute__((constructor(101))).  I seem to recall that 100 and below
are reserved for internal use, meaning it might be impossible to supply
a priority able to cause it to run earlier than internal library init
routines, but it's worth a try anyway.

Brian



More information about the Fortran mailing list