Reading unknown number of values in unformatted file



I am stuck on an I/O probleme with unformatted read in fortran.

- I've opened an unformatted file,
OPEN(10,FILE='toto.dat',FORM='UNFORMATTED')
REWIND(10)
- I've read several datas.
- At this step I can have to read 2 or 3 real values !
It could be:
READ(10,err=101,end=102) u1, u2, u3
or
READ(10,err=101,end=102) u1, u2
with u1, u2, u3 declared as REAL.
- read other datas...

I cannot found a solution to read safely u1,u2,u3 OR u1,u2 depending on what is in the file. I was looking for a solution like reading in a buffer (and then analyse the buffer)... but all that I try fails... Most of my ideas only works for Formatted files :-(

Thanks for any suggestions

Patrick

.



Relevant Pages

  • Re: unformatted files (again)
    ... you write an unformatted file in fortran, it sticks a "header" before ... is implemented are left to the compiler. ...
    (comp.lang.fortran)
  • Re: Reading unknown number of values in unformatted file
    ... I've opened an unformatted file, ... I've read several datas. ... This is, in my opinion, the absolute worst way to do it as it is a PITA and is not guaranteed to be portable: based solely on more knowledgable clf'ers statements, I don't think unformatted sequential file formats are specified in the standard. ... Without more info on the file itself and where you got it from (big or littel endian machine?) I can't think of anything else too useful. ...
    (comp.lang.fortran)
  • Re: unformatted files (again)
    ... you write an unformatted file in fortran, it sticks a "header" before ... Heck, the Fortran language doesn't even specify that bytes exist, and ...
    (comp.lang.fortran)
  • Re: GNU f90 read() run time error
    ... I/O past end of record on unformatted file ... GNU Fortran supports many. ... Fortran rule for being an unformatted file. ...
    (comp.lang.fortran)
  • unformatted files (again)
    ... you write an unformatted file in fortran, it sticks a "header" before ... is there an easy, robust, way to discover what ...
    (comp.lang.fortran)