I/O slow (buffered?) ; can I change this?
Brooks Moses
brooks.moses@codesourcery.com
Sat Dec 16 06:03:00 GMT 2006
Rob wrote:
> Ah, yes indeed, I'm doing that. I'd thought this
> would not matter, as it doesn't with executables
> compiled with other compilers.
>
> The executable is called 'vasp', and this is how
> I run the executable in a script called 'runvasp'.
>
> #!/bin/tcsh
> # this is the runvasp script
> vasp.serial >& log
>
> I then call 'runvasp &', which does everythying in
> the background while producing an output log file
> 'log'.
> While the executable is running, I check the
> contents of the log file:
> $ tail -f log
>
> The contents of the log file comes in bursts only
> for the Gfortran compiled executable.
>
> When I run the executable directly from the command
> line:
> $ vasp
> then the output is not delayed anymore. So indeed
> the output redirection seems to cause the confusion.
> But why is this only with Gfortran compiler?
I don't know why it's only Gfortran -- when I do (essentially) that with
my ifort-compiled executables, I have the same thing happen. :)
In general, though, different compilers (and their runtime libraries)
make different choices about when to buffer or not buffer their output
(and how much buffering to do); for gfortran, the decision was made to
buffer output fairly heavily to speed up output, and your other
compilers may have made a different decision.
From what I recall, though, you're also comparing across systems, as
well as different compilers. I note that on the system I have handy,
"man tail" reports that it defaults to waiting 1 second before checking
for more output in the file. So it could be something as simple as the
tail on your Alpha system having a noticably long default delay, perhaps.
> Is there a gfortran compiler flag or something else
> that can help me with this problem?
Try setting the GFORTRAN_UNBUFFERED_ALL environment varible to "Y"
before running your program; that turns off the buffering for all
output. (For what it's worth, that's documented in the "Runtime" option
listing in the gfortran manual.) If it's the program's output
buffering, that's causing the problem, rather than the tail command
settings or something in the system, then that should fix it.
Note that this causes _all_ of the output to be unbuffered, so it could
potentially slow down other file output that the program does.
- Brooks
More information about the Fortran
mailing list