| James Giles 2008-01-29, 7:27 pm |
| Richard Maine wrote:
> <nure123@gmail.com> wrote:
>
>
> Well, the "right" way to fix it is to fix whatever program writes the
> file. That program is basically broken. Any other fix is justy a hack
> around the initial error. Once you have the broken file, you can't
> count on Fortran being able to read it at all.
....
The Fortran standard does not specify the internal conventions of files.
The answer here is not that the file is "broken" or that the Fortran
implementation is "broken" or that the program that creates the file
is "broken". The two programs are using distinct conventions for
the internal structure of a file. Both conventions are perfectly
legitimate.
As it happens, the structure under consideration is closer than most
file structures to the recommendations of the ASCII standard itself.
In that standard, the intent is to use a record separator, ACHAR(30),
between records of the file and no such character at the end of the
final record. The file under consideration here doesn't use ACHAR(30),
but otherwise behaves that way.
For the OP: if it's true that you created or processed the file with
notepad, you can make your last intentional record conform to your
expectations by adding a subsequent record. It can be an empty record.
That is, open the file, move to the end of the last line, press "enter",
and save the file again. The new last record doesn't even need to
contain a single character. You can do it automated with many Fortran
implementations by using "binary" or (if you have the f2003 feature)
unformatted "stream". Copy the whole file and add whatever character
you think should be the record mark.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
|