This program
program test
real a(10)
open(1, file='f1',access='direct', recl=20)
do i=1, 10
a(i) = i-1
end do
write(1, rec=1)(a(i),i=1,5)
write(1, rec=2)(a(i),i=6,10)
close(1)
open(1, file='f1',access='direct',recl=8)
read(1, rec=4)(a(i),i =5,9,4)
print*,a
end
works incorrect in visual Fortran (incorrect):
0.0000000E+00 1.000000 2.000000 3.000000 9.000000
5.000000 6.000000 7.000000 0.0000000E+00 9.000000
Result in WATCOM (correct):
0.0000000 1.0000000 2.0000000 3.0000000 6.0000000
5.0000000 6.0000000 7.0000000 7.0000000 9.0000000
Why?
The default unit length of RECL in Visual Fortran is a word (4bytes). If you compile with option 'Use bytes as RECL= unit for unformatted file' (/assume:byterecl), you will get what you expect.