Can the last record in a direct access file be shorter than the record length?

Can the last record in a direct access file be shorter than the record length?

Post by nospa » Wed, 04 Feb 2009 17:27:06



Yeah. That's a pain. I thought most compilers these days at least had
the option to specify the record lengths in bytes, even if that wasn't
the default.

...

Sorry, but the standard isn't going to help you here. It just requires
the records of a direct access file to be the same length. If they
aren't, then the program is nonconforming. Unfortunately, you also run
into the old bugaboo about I/O errors; there is basically no guarantee
about anything having to do with such errors. The compiler can return an
error code. It can abort, It can quietly "fix" things, or it can do
pretty much anything else.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
 
 
 

Can the last record in a direct access file be shorter than the record length?

Post by Clive Pag » Wed, 04 Feb 2009 18:26:26

In message
< XXXX@XXXXX.COM >,
Arjen Markus < XXXX@XXXXX.COM > writes

This isn't a direct answer to your question (Richard Maine got in first)
but you might consider using stream I/O instead. Most (if not all)
Fortran95 compilers support it according to the Fortran2003 Standard,
and it allows addressing by the byte. It also provides complete
independence from the limitations of a fixed-length structure.

I wrote a short tutorial on it once (pause to dig into website) ah,
still here:
http://www.yqcomputer.com/ ~cgp/streamIO.html

--
Clive Page

 
 
 

Can the last record in a direct access file be shorter than the record length?

Post by nospa » Thu, 05 Feb 2009 00:58:19


Good point, and one I should have made. Guess I was too focussed on
answering the question asked instead of on the larger problem. (I'm more
often accused of the opposite failing - of trying to answer a bigger
question instead of what was directly asked). Heck, I was the one who
wrote the formal proposed that stream I/O be added, and I did it because
I was aware of the many shortcomings (such as this one) of the
alternatives.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain