Problems with STREAM I/0

Jerry DeLisle jvdelisle@verizon.net
Wed Sep 13 00:52:00 GMT 2006


Steve Kargl wrote:
> Jerry,
> 
> I spent the day helping a colleague debug a problem with
> the STREAM IO feature.  I'm not sure if this is FreeBSD
> specific, but I thought I'd get your opinion before 
> filing a bug report.
> 
> Consider this code
> 
> program avl
>    implicit none
>    real dt, t, a(10)
>    integer i
>    dt = 1.e-6
>    a = real( (/ (i, i=1, 10) /) )
>    open(unit=11, file='a.dat', access='stream')
>    open(unit=12, file='b.dat', access='stream')
>    do i = 1, 10
>       t = i * dt
>       write(11) t
>       write(12) a
>    end do
>    close(11)
>    close(12)
> end program avl
> 
> The file a.dat should contain 10 REAL values and thus have
> a size of 40 bytes.  The file b.dat has 100 values and should
> have a size of 400.  What I actuall see is 
> 
> -rw-r--r--  1 kargl  kargl  - 396 Sep 12 17:04 a.dat
> -rw-r--r--  1 kargl  kargl  - 436 Sep 12 17:04 b.dat
> 
> It appears that write(11) and write(12) are both writing
> to both files.
> 
> Note, if I comment out the 'write(12) a' and erase the above files
> I see
> 
> node10:kargl[229] ll *dat
> -rw-r--r--  1 kargl  kargl  - 40 Sep 12 17:16 a.dat
> -rw-r--r--  1 kargl  kargl  -  0 Sep 12 17:16 b.dat
> 
> which is what I expect.
> 
Steve,

This is definitely a bug.  If I comment out one of the writes, the file length 
of the file resulting from the remaining write is the correct length. (Either 
one, 40 or 400)

Not good!

Jerry



More information about the Fortran mailing list