| mcalhoun@ksu.edu 2005-05-13, 4:10 pm |
| Several w s ago there was a thread about how various Fortran's
handled non-contiguous writes to and reads from direct-access files.
FWIW, I ran the following on MS FORTRAN 5.1:
PROGRAM Test
CHARACTER Record5*20/' '/
INTEGER IOerr
OPEN (1,FILE='TestFile',ACCESS='DIRECT',STATU
S='NEW',RECL=20)
WRITE (1, REC= 1) 'This is record # 1'
WRITE (1, REC=10) 'This is record #10'
READ (1, REC= 5, IOSTAT=IOerr) Record5
PRINT *, 'I/O error =', IOerr
END
From several w s ago:
>What should happen here?
>I have worked on systems which exhibited the following:
>a) The WRITE to record10 was illegal because records 2-9 have not
> been written yet. Thus one never gets to the READ.
>b) The WRITE to record10 completes, but 'under the table' the I/O
> system fills the intermediate records with zeros (or worse yet,
> garbage.) So the READ completes, but who knows what to expect...
>Most modern systems fall into the latter category.
Microsoft FORTRAN 5.1 does "b", creating a file of 200 characters
(for a record-length of 20), with garbage in place of records 2-9,
and returns some of that garbage for Record5 with IOerr=0.
--
--Myron A. Calhoun.
Five boxes preserve our freedoms: soap, ballot, witness, jury, and cartridge
PhD EE (retired). "Barbershop" tenor. CDL(PTXS). W0PBV. (785) 539-4448
NRA Life Member and Certified Instructor (Home Firearm Safety, Rifle, Pistol)
|