Flushing libgfortran from C
Yuri Gribov
tetra2005@googlemail.com
Thu Mar 3 08:37:00 GMT 2011
Hi all,
Perhaps this is a well known issue but I could not find suitable
solution on the web. Here is my problem.
Some of you may know about the Co-array Fortran 2.0 project in Rice
university. CAF translates it's input files to an ordinary Fortran and
then uses gfortran (4.4 in my case) to compile them (libgfortran is
linked as shared library). CAF's runtime system is written in C so
main() looks like:
int main() {
CAF_INIT();
MAIN__();
CAF_EXIT();
}
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. This results in empty stdout on most of the CAF
programs on my platform (even simple Hello world fails to print).
If I change _exit to exit or gfortran to ifort everything prints fine.
Does this sound reasonable? Is this a known IO problem/feature?
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.
Best regards,
Yuri
More information about the Fortran
mailing list