Buffered/unbuffered I/O issues
Harald Anlauf
anlauf@gmx.de
Tue Oct 16 14:24:00 GMT 2007
Hi,
I am a little bit confused about the handling of buffering
of I/O with gfortran, especially when piping stddout to
another program. Instead of opening a bug report, I would
like to ask here about opinions.
(I am working on an older Suse 9.0 Linux system (x86)).
Consider the program:
print *, "foo"
call sleep (2)
write(*,*) "bar"
call sleep (2)
print *, "Done."
end
I have set:
% echo $GFORTRAN_UNBUFFERED_6
1
% echo $GFORTRAN_UNBUFFERED_ALL
Running the program without stdout redirection, it prints
foo
bar
Done.
with the desired delay of two seconds between the prints.
But when starting as:
% ./a.out | tee foobar
it appears to buffer the standard output.
Am I doing something plain wrong?
Funnily, setting GFORTRAN_UNBUFFERED_ALL=1 makes the above
example work, but will unbuffer everything.
Now I tried:
% unbuffer ./a.out | tee foobar |cat -e
foo^M$
bar^M$
Done.^M$
This now works almost as expected, but exhibits a !"§$% bug
in "unbuffer".
(unbuffer is also broken because it redirects stderr to stdout)
Did I miss something obvious?
Cheers,
-ha
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
More information about the Fortran
mailing list