David Hitchin writes: > --On 09 September 2003 16:14 +0200 Michael Metcalf > <[log in to unmask]> wrote: > >> > > Possibly, but reading just one element might help: > > > > real vector(1000000) > > open(11,file='test',access='sequential',FORM='UNFORMATTED') > > do i = 1, 9 > > read (11) vector(1) ! > > end do > > What if some of the records to be skipped contained fields that weren't > valid real numbers? Would it be better to read characters instead? And what if they don't contain valid chatacters...or don't contain any data at all? (Yes, a record with no data is allowed and can be meaningful; also, yes, it is possible for data not to constitute valid characters). The usual approach to this is to read with an empty I/O list as in read(11) This is quite common practice. I do it a lot, as do many other people. This is the *ONLY* form that is guaranteed to be able to skip over any record. (Well, ok, you could also generate an empty I/O list with a zero-trip implied DO, but that's just a complicated way to express the same thing). However, as others have noted, this is not the same as direct access. You might get a slight performance benefit compared to reading with a non-empty I/O list, but nothing like the multiple orders of magnitide that direct access gives you. To the original poster. Sequential files are inherently for reading sequentially. Direct access is for jumping directly to arbitrary records. Do note that standard Fortran direct access is limited to fixed-length records (mostly because that is simple to implement - or at least I assume that was the reason). If you need direct access with variable length records, then extra work on top of standard Fortran is needed; there are libraries for such things (or you could write your own, though it is nontrivial to do a good job). Also note that sequential and direct access files are likely to have physically different structure. If the file in question was written as a sequential file, and you can't change that, then you technically have to read it as a sequantial file; you can't just decide to read a sequential file as direct access because you want to be able to jump to arbitrary records. The file has to be written as direct access in the first place. (Nonstandard system-dependent tricks may well be possible...I've even done such things so I know they are possible, but that gets a little deeper.) -- Richard Maine | Good judgment comes from experience; [log in to unmask] | experience comes from bad judgment. | -- Mark Twain