Appending data to pre-exisiting files
Steve Edwards
edwardss@whl.co.uk
Wed Jul 27 11:27:00 GMT 2005
I have been trying to append data writes to exisiting data files using
g77 (3.4.1). As documented in the manual, the following fails:
program check
open(4,FILE='check.dat',STATUS='OLD',
$ FORM='FORMATTED',POSITION='APPEND')
write(4,*)10
end
with g77 reporting:
check.f: In program `check':
check.f:3:
open(4,FILE='check.dat',STATUS='OLD',
^
Unsupported OPEN control item at (^) -- ACTION=, ASSOCIATEVARIABLE=,
BLOCKSIZE=, BUFFERCOUNT=,
CARRIAGECONTROL=, DEFAULTFILE=, DELIM=, DISPOSE=, EXTENDSIZE=,
INITIALSIZE=, KEY=, MAXREC=, NOSPANBLOCKS, ORGANIZATION=, PAD=,
POSITION=, READONLY=, RECORDTYPE=, SHARED=, and USEROPEN= are not
supported
This all semmed quite clear so far. However I came across some code from
a third party using the following syntax:
program check
OPEN(4,FILE='check.dat',STATUS='OLD',
$ FORM='FORMATTED',ACCESS='APPEND')
write(4,*)10
end
which g77 compiles happily and when run does indeed append the data to
the file. However, the xlf compiler under AIX rejects this code and
ftnchek also reports it as an error:
FTNCHEK Version 3.2 November 2002
File check.f:
4 $ FORM='FORMATTED',ACCESS='APPEND')
^
Error near line 4 col 44 file check.f: ACCESS specifier must be
"SEQUENTIAL"
or "DIRECT"
1 syntax error detected in file check.f
I've searched through the gcc bugzilla database and found nothing on
this but I am very confused by it. 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.
I haven't tested this with gfortran yet though, but while gfortran was
still in such heavy development I had intended to hold off on using it
full time for a short while.
S Edwards
--
----------------------------------------------------------
----------------------------------------------------------
More information about the Fortran
mailing list