Appending data to pre-exisiting files
Richard E Maine
Richard.Maine@nasa.gov
Wed Jul 27 15:09:00 GMT 2005
On Jul 27, 2005, at 4:27 AM, Steve Edwards wrote:
> I have been trying to append data writes to exisiting data files using
> g77 (3.4.1).
Your basic problem is that there is no simple portable way to do this
in Fortran 77.
Position='append' is a standard feature in f90 and thus will work with
all f90 compilers. But there is no simple standard way to do it in f77.
Some f77 compilers support the f90 form. The access='append' that you
noticed is a nonstandard form specific to a few compilers.
The only standard and portable way to do this in fortran 77 is to open
the file and read through it to the end (backspacing after you hit the
end of file). Yes, this is a pain - particularly if the file is large.
It is enough of a pain that it is sometimes worth doing nonstandard
things even though they cause porting problems.
As long as you have to stick to f77, it will continue o be a pain one
way or another.
> I was under the impression that in
> order to append data using g77 it was necessary to read to the EOF and
> then backspace accordingly.
That's the only standard way; I don't recall whether g77 supports a
nonstandard form.
> I haven't tested this with gfortran yet though,
Position='append' is standard f90. If it doesn't work with gfortran,
then that's a bug. I haven't checked.
--
Richard Maine | Good judgment comes from experience;
Richard.Maine@nasa.gov | experience comes from bad judgment.
| -- Mark Twain
More information about the Fortran
mailing list