JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2005

COMP-FORTRAN-90 2005

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Stream I/O questions

From:

Richard E Maine <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Fri, 22 Jul 2005 10:18:54 -0700

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (121 lines)

Somewhat belated rely as I have been on vacation for 3 weeks. I see 
that others have addressed most of the comments I would have made. I 
have just a few additional side comments.

On Jul 6, 2005, at 1:23 PM, Clive Page wrote:

> I had not appreciated the substantial differences between formatted 
> and unformatted stream I/O, and had only looked properly at the 
> sections of the Standard describing the former.

Ouch! Then no wonder you were confused. They are indeed very different. 
Furthermore, unformatted is *FAR* simpler. If you had to concentrate 
only on one of them I'd sure recommend looking at unformatted instead 
of formatted.

In fact, my original proposal for stream I/O didn't include formatted 
because I was trying to keep things simple. Formatted streams are 
substantially more complicated and yet don't add anything that I regard 
as critically new, so I figured that omitting them would help the 
cost/benefit tradeoff. But the gist of the responses to my proposal was 
that "everyone" liked the idea, but many people also wanted formatted 
capability, so it got added. Almost all of the subsequent work on the 
subject was on formatted... because it had all the complications that 
needed work. At times I wish I had resisted the request to add 
formatted....

In regards to the differences:

A formatted stream file is really the same thing as a sequential text 
file. It is perhaps a bit of a misnomer to refer to it as a kind of 
file at all (but the standard does and that's probably my fault at 
least in part). It is a different way to access the same kind of file. 
The form of access is more convenient in some situations, but I don't 
personally regard formatted streams as a critical new feature.

In particular, a formatted stream file *IS* also a record file. It 
comes complete with all the properties that record files have - whether 
you choose to call these "shackles" on not. I personally happen to 
think of record files as a case of the operating system providing 
important additional support that would otherwise have to be done by 
the user. I don't view the fact that most current operating systems 
omit record management support to be an improvement. But I digress... I 
think that many of the restrictions and oddities of formatted stream 
access can be best understood through recognizing that this really is a 
record file.

In that regard, I have not time to do a detailed review of the web page 
you wrote up, but I found one point in it to be seriously misleading. 
No, formatted stream files (aka formatted sequential files) do *NOT* 
have the structure of a line of text followed by a delimiter. If you 
try to think of that as their basic definition, then you will probably 
get confused by many things. Their structure is just a line of text in 
a record. The record is defined by the processor (compiler). In that 
regard, they are just as system-dependent as unformatted files. It just 
happens that essentially all systems define and support a suitable text 
file structure, which Fortran implementations naturally use. (The 
Fortran standard doesn't require that Fortran sequential formatted 
files be compatible with such things as text editors or anything else 
on the system, but the market does require it).

With formatted stream access, the newline character is used in the 
output data to *REPRESENT* the end of a record. This does not in any 
way imply that records are actually stored in such a manner. If I 
recall correctly, the same is true of C. The possible translations 
between this representation and the actual file structure relate to 
some of the restrictions.

Unformatted streams provide capability that is fundamentally new and 
was really *VERY* painful to do portably and within the context of 
previous Fortran standards. Trust me on that :-(. They are also pretty 
simple.

> The whole point of stream I/O, I thought, was that for the first time 
> it frees the Fortran programmer from the shackles of record-based I/O.

I would also say that this majorly mischaracterized the main 
motivations for adding stream I/O. Well, I guess you've got in in other 
material, but with a different emphasis than I would use. I consider 
the primary motivation for unformatted stream access to be 
interoperability (and formatted stream was just an "add-on" in my view, 
as I mention above). In fact, stream I/O originally was introduced as 
part of the C interop stuff, though it has subsequently been identified 
as a separate feature in its own right. You need unformatted stream to 
deal with independently defined file formats (such as graphics image 
files and many others). Prior to stream I/O, there was no way to do 
this that was sanctioned by the standard.

"Faking it" with direct access files often worked, but that involved 
making assumptions about implementation details that were not 
guaranteed by the standard (and the assumptions were not always 
correct). It was also quite a bit of work and had multiple 
complications. It was one area where I regularly recommended that 
people go ahead and use vendor extensions.

The lack of record structure is more of a side matter to me. That's a 
consequence of the interop needs rather than a basic requirement on its 
own.

As with formatted streams, there are times when unformatted streams are 
more convenient, even independent of interop issues. This is 
particularly so when you need random access, but don't want to be 
shackled with a fixed record size (the limitation to fixed record size 
*IS* something I regard as a shackle, though one I understand the 
reasons for). Even if you do need a record structure, if you need both 
random access and variable record size, it is usually far easier to do 
your own record management starting from unformatted stream files than 
to hack up something from what was available in previous Fortran 
standards.

But if variable-size random access records were the main goal, I think 
that could have been more directly addressed. I view the interop issue 
as the primary goal, with the other benefits as handy "free" extras. 
Admittedly, the separation here isn't 100%; sometimes interoperable 
files have requirements for random access to variable-sized chunks of 
data, so it is not a coincidence that you end up with ways to do that.

-- 
Richard Maine                |  Good judgment comes from experience;
[log in to unmask]       |  experience comes from bad judgment.
                             |        -- Mark Twain

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager