This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
possible small bug in g77 when writing direct access files
- From: "Kevin B. Hendricks" <kevin dot hendricks at sympatico dot ca>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 4 Sep 2003 11:41:54 -0400
- Subject: possible small bug in g77 when writing direct access files
Hi,
I think I found a small bug in g77 but I am not sure ...
I have some sample fortran code that writes out direct access data to files.
The problem is that the resulting file length is not a multiple of the LRECL
length (as expected) unless you literally pad the data written to the record
to exactly match the LRECL length for the last record written.
This behaviour is inconsistent with f77 under Solaris and Fortran 77 under
AIX.
This behavior also prevents direct access files from being generated piecewize
and later catted together.
For example:
If I open a file like so:
C OPEN STATEMENT FOR DIRECT ACCESS DATA FILE
OPEN (15, FILE='datafile.bin', STATUS='NEW',
* ACCESS='DIRECT', RECL=15755, FORM='UNFORMATTED')
And write mutliple records to it as such:
C WRITE DATA FROM RECORDS 1-4 TO OUTPUT FILE AS FIRST OF TWO
C RECORDS TO BE WRITTEN:
WRITE(UNIT=15,REC=RECNO) KEYVAL, DNUM, CNUM, CIC, 1, PERMNO,
* ZLIST, CONAME, INAME, SMBL, FYR, YEAR, XREL, STK,
* UCODE, AFTNT1, DATA1
Unless I add a variable RPAD1 to force the length of the record to be written
to be exactly 15755 when it was a few bytes less for this particular record,
the file size will end up not being a multiple of 15755 because the last
record written will not be a full 15755 in size.
Records are correctly started at offsets of 15755 in the file, it is just the
last record that needs to be padded out so that pieces of the direct access
file can be concatenated together.
I guess I just expect a direct access file to always be an exact multiple of
the record length in size?
Is this a bug? I can easily work around it by always forcing the padding so
that every byte of the 15,755 record length is used all of the time.
Thanks,
Kevin