Richard E Maine wrote:
> I make sure that my own outputs won't overflow buffers. Yes, I'm aware
> that this is sometimes nontrivial. It is particularly nontrivial for
> things like list-directed and namelist output, where the compiler has
> many options and the user doesn't have any way of knowing what
> particular options the compiler uses. Fortunately for me, I've never
> used namelist internal output, and my uses of list-directed internal
> output are pretty simple.
>
> Note that list-directed and namelist internal I/O used to be
> disallowed. This is *NOT* a coincidence. My understanding is that was
> exactly part of the reason, perhaps even the whole reason. But
> list-directed internal I/O is so widely useful that it later got added
> anyway in spite of this problem. After all, in at least the simplest
> cases, it is easy for the user to provide buffers that are more than
> adequate for any eventuality... and it isn't an issue at all for input.
Namelist I/O is not allowed on internal files in Fortran 95
(9.2.2.2(2), [138:3-4]) but I see that this restriction is removed in
Fortran 2003 (9.3(9), [178:15-16]).
Also the restriction to only sequential access on internal files and
the requirement that internal files be opened implicitly means that
there is no way to specify a record length; RECL= is not an option with
the READ or WRITE statements. In both standards, there is a
restriction, "The number of characters written shall not exceed the
length of the record", but this is a restriction on the program and the
standards are silent on what happens if the record length is exceeded.
Can anyone suggest reasons why the standard prohibits direct access
on internal files? From an I/O standp[oint, it appears to me that a
character array of 1000 elements is very much the same thing as a disk
file with 1000 records.
Similarly, can anyone suggest reasons why the standard prohibits
unformatted I/O on internal files? From an application developer's
perspective, it appears that this would be a great way to stuff
character variables and array elements with binary data.
--
----------
Sincerely,
Craig T. Dedo
17130 W. Burleigh Place Internet: [log in to unmask]
Brookfield, WI 53005-2759 Voice Phone: (262) 783-5869
USA Fax Phone: (262) 783-5928
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." -- Benjamin Franklin
(1759)
|