Flushing libgfortran from C

Tobias Burnus burnus@net-b.de
Thu Mar 3 10:01:00 GMT 2011


On 03/03/2011 09:37 AM, Yuri Gribov wrote:
> The problem is that CAF_EXIT does _exit() internally (don't ask me
> why) which bypasses all registered exit handlers including
> libgfortran's destructor (cleanup in runtime/main.c). This seems to
> cause problems with Fortran IO: I tried all sorts of fflushes, fsyncs
> and sleeps in CAF_EXIT but neither of them makes libgfortran print
> it's internal buffers.
> Is there any way to workaround this i.e. to ask libgfortran to flush
> (from C program)? I know about `call flush()' and environment
> variables but these really solve different problems and would not be
> useful in CAF's case

For flushing the buffer, you could simply call from C:
   _gfortran_flush_i4 (NULL);

It should solve at least some of your problems. However, I do not 
understand why you get an empty stdout. To my knowledge, stdout is not 
buffered. (Unless that's different in 4.4.)

(I admit that having a call which properly shuts down the library would 
be sometimes useful.)

Tobias



More information about the Fortran mailing list