Unbuffered output in mixed C / Fortran programs
Tobias Burnus
burnus@net-b.de
Wed Oct 15 16:03:00 GMT 2008
Hello George,
Georg Denk wrote:
> Thanks for this hint. To be honest, I was aware of flush, and it might be
> a solution for this simple test case. But for the real thing, there are so
> many output statements that it is more or less impossible to add
> some flush to all of them.
Unfortunately, the FLUSH statement is the only thing which can do this
portably.
> That's the reason for the setvbuf call in
> the C part which is similar to adding a "flush" after each printf.
>
> The behavior seems to be gfortran specific, as I don't see it
> with other compilers. It also worked with GCC 3.4.x.
>
I tried it with g95 and "./a.out |more" eats the fortran output
completely - thus it can get worse. But for all my other compilers I get
the expected result. Just for completeness: g77 and gfortran have no
code in common thus that 3.4.x (= g77) works does not make it in any way
easier to find a proper (= easy and fast) solution.
I don't see any quick solution - maybe Jerry or Thomas do, which have a
better insight into gfortran's I/O.
Tobias
More information about the Fortran
mailing list