ottbot Thanks a million that makes a lot more sense! I read sever al webpages on this and never found anything about the difference in RECL between formatted and unformatted. Do you have a link?
My shell script just dose
[code]
echo $i >> file.dat
[/code]
where "i" is between 0 and 9 so only ever one character long nd the file looks like this for example
[code]
1
5
2
2
9
3
4
[/code]
so it looks like I should beable to do a formatted read with RECL=1 and then pick out the record I want.
You have a small kink due the newlines in your file.. You just have to adjust your record size and format to account for it.. This program will read the first nine records:
[code] PROGRAM reader
INTEGER :: a, i
CHARACTER*1 :: nl
OPEN(2, FILE='file.dat', ACCESS='DIRECT', RECL=2, FORM='FORMATTED')
DO i=1, 9
READ( 2, '(I1,A)', REC= i ) a, nl
WRITE(*,*) 'record ', i, ' is ', a
ENDDO
END PROGRAM[/code]
Hope you get it sorted - fortran can be really esoteric, especially when dealing with code written in the 80's.. does my head in..
Found that bit about formatted direct i/o here: http://docs.sun.com/source/819-3685/2_io.html
You have a small kink due the newlines in your file.. You just have to adjust your record size and format to account for it.. This program will read the first nine records:
[code] PROGRAM reader
Hope you get it sorted - fortran can be really esoteric, especially when dealing with code written in the 80's.. does my head in..