Re: F2003 access='stream' question
From: *** Hendrickson (***.hendrickson_at_att.net)
Date: 04/04/04
- Next message: James Van Buskirk: "Re: F2003 access='stream' question"
- Previous message: Frode Vatvedt Fjeld: "Re: alternate RETURN or interprocedure GOTO?"
- In reply to: David Frank: "Re: F2003 access='stream' question"
- Next in thread: James Van Buskirk: "Re: F2003 access='stream' question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 04 Apr 2004 16:55:34 GMT
David Frank wrote:
> "Robert Corbett" <corbett@lupa.Sun.COM> wrote in message
> news:c4ofav$g3i$1@news1nwk.SFbay.Sun.COM...
>
>>In article <eiubc.380626$B81.5710483@twister.tampabay.rr.com>,
>>David Frank <dave_frank@hotmail.com> wrote:
>>
>>>program f2003_question
>>>integer :: item1
>>>character(10) :: item2
>>>real :: item3
>>>
>>>open (1,file='test.txt') ! create a test file
>>>write (1,*) '123 DOG 1e-12' ! record 1
>>>write (1,*) '12345.6789 44 CAT' ! record 2
>>>close (1)
>>>
>>>open (1,file='test.txt',form='formatted',access='stream')
>>>read (1,*) item1, item2
>>>read (1,*) item3
>>>write (*,*) item3 ! what will be the output in F2003?
>>>end program
>>
>>I imagine that for most implementations, it will write a value
>>that approximates 12345.6789. The draft proposed revised
>>standard gives you no guarantees. The first OPEN statement
>>opens the file for sequential access, while the second OPEN
>>statement opens it for stream access. The standard does not
>>require the two to be compatible. Also, since you did not
>>specify a POSITION= specifier on either OPEN statement, you
>>have no guarantee where the file will be positioned after it
>>is opened.
>>
>>Sincerely,
>>Bob Corbett
>>
>
>
> My question is whether the stream option will inhibit advancing the record
> count
> when the test file's first list items are read.
>
> If the 2nd read doesnt resume reading where the 1st read left off, then
> stream option
> does NOTHING in this case that current Fortran would not do.
>
> I'm surprised you say we have no guarantee that opening a file with no
> position
> specifier is not ALWAYS defaulted to file start.
>
>
Well, you shouldn't be ;-) . Many (well OK, one) early F77
implementation OPENed files at the terminal point, the
reason being it was relatively easy to REWIND the file to
the starting position and relatively hard to position it
at the end for appending. That's probably why the
POSITION= stuff on OPEN was added in F90. F95, the one
I have handy, says that "[POSITION=] ASIS leaves the
position unspecified if the file exists but is not
connected" and that if there is no POSITION=
specifier, the default is ASIS. I believe that is
partially to allow the program to get at files that
have been manipulated somehow by the user/OS before the
program starts; that was a relatively common extension.
Remember that in this era of disk files, back in the good
old days "file" and "magnetic tape" were synonyms and
this causes some funny holdovers in the language.
I'm not sure I really understand your first question,
but I think the answer might be that stream I/O does
allow a record structure to be superimposed on the
data stream but doesn't require one.
*** Hendrickson
- Next message: James Van Buskirk: "Re: F2003 access='stream' question"
- Previous message: Frode Vatvedt Fjeld: "Re: alternate RETURN or interprocedure GOTO?"
- In reply to: David Frank: "Re: F2003 access='stream' question"
- Next in thread: James Van Buskirk: "Re: F2003 access='stream' question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]