Re: File output buffer overrun?




"Swandog46" <Swandog46@xxxxxx> wrote in message
news:1129664766.668640.192230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I am porting a very old Fortran program written in the 80's for a very
> old IBM mainframe Fortran 77 compiler to a modern Linux system. The
> program is largely OK except for one module which generates a
> segmentation fault every time I run it. After some investigation, I
> figured out that this module is outputting its standard output to a DAT
> file, which is supposed to become very large, but I found out that the
> file is being 'capped' at 4096 bytes. If I try to write more than 4096
> bytes to the output file, the program crashes and the text is not
> written. What could be doing this? Thanks so much for any suggestions.

After re-reading your original message, I'm starting to think that your
problem has nothing to do with the 4096 byte file and more attention
should be focused at the segmentation fault. A lot of systems have
a 4K buffer, so it sounds like you're getting far enough into the code
to flush the buffer ONCE but then the code crashes before the next
buffer flush.

Perhaps you can "manually" flush the buffer after each write (hopefully
your compiler has a "flush" routine).

For example, change

write(6,*) 'line one'
... some calcs...
write(6,*) 'line two'
... more calcs ...

to

write(6,*) 'line one'
call flush(6)
... some calcs...
write(6,*) 'line two'
call flush(6)
... more calcs ...

With some luck, you may be able to track down what is causing the
segmentation fault.

Good Luck,

--Mark


.



Relevant Pages

  • Re: "secure" file flag?
    ... you really need to flush the on-device cache on each ... > pass to make sure the bit patterns get written to the platter in proper ... A simple algorithm could just mark each buffer with a special ... read all file blocks into buffers that are marked dirty and get the ...
    (freebsd-hackers)
  • Re: Response.Flush: Differences between IIS 6.0 and 5.0?
    ... since IIS 6.0 is now on top of http.sys. ... smaller buffer and so on, each flush cause the packet to send.... ... > Server: Microsoft-IIS/5.0 ...
    (microsoft.public.inetserver.iis)
  • Re: Can anyone explain why this is happening?
    ... Is it possible that your writes do not include a local buffer flush ... written file (to guarantee that newly written data have been flushed to ... before it reads from a new file (which also flushes all buffered written ...
    (comp.parallel.mpi)
  • Re: Problems with sys.stout.flush()
    ... Carl Banks wrote: ... console until it sees a newline unless you flush the buffer. ... option for python and a few examples from this sitehttp://stackoverflow.com/questions/107705/python-output-buffering ...
    (comp.lang.python)