This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Buffered/unbuffered I/O issues
- From: "Harald Anlauf" <anlauf at gmx dot de>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 16 Oct 2007 16:24:34 +0200
- Subject: Buffered/unbuffered I/O issues
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