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  2001

COMP-FORTRAN-90 2001

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Direct Unformatted

From:

Richard Maine <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Wed, 14 Feb 2001 09:16:18 -0800

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (84 lines)

Terence Wright wrote:
 > >Yes, I DO think that a FIXED LENGTH DIRECT ACCESS file
 > >should have exactly the same bytes if caused to be created
 > >by a particular fortran program compiled and executed for the
 > >same target machine by different compilers.
 > >
 > >I would go as far to say IRREGARDLESS of the target machine.
 > >
 > >It is fundamental to my faith, that fixed length binary records
 > >are the structure of my universe.
 > >This is one of very few ways data files can be reliably
 > >transferred.

I'm afraid that there are quite a few exceptions I've known of.

Others have mentioned byte-order differences, which admitedly don't
change the size, but do mean you need some porting work.  Likewise
for machines that don't use IEEE floats - and yes, there are quite
a few of those still around.

Let us not forget the huge issues of different word sizes.  If you
write a single precision real on some machine where that is 64 bits,
it just is not going to be the same size as a single precision real on
a machine where it is 32-bits).  If your universe is limitted to
machines where single precision is always 32-bits, then I can only say
that it is a limitted universe.

Even ignoring all those things, I've seen multiple exceptions.
Lahey by default adds a header to direct access unformatted files,
and for ELF90, you can't even disable this "feature".  I've also
seen machines (specifics forgotten - something that our simulation
folk used to use) where unformatted direct access records were
"funny".  I think they were blocked into blocks of a system-defined
size, with extra stuff at the beginning of the blocks; I ended up
having to use formatted direct access with "A" format to read binary
direct access files from other machines - a hack, and a horribly slow
one, but it did work.

Not to mention machines where the file structure can be specified
independently of the access method.  For these sometimes you can
specify the structure you expect, but it isn't a given.

Yes, direct access unformatted files are the best way I know of to
transfer data that needs to be in a binary form for efficiency or
other reasons.  Many years ago, I used to use only formatted for
inter-machine transfer, and unformatted for non-portable efficient
use on a single machine.  But as multiple platforms on site became
widespread and data file sizes grew, massive user complaints ensued.
The formatted files were to big and too slow.

But for best portability, don't just just assume that direct access
unformatted is the way to read or write files without system-dependent
stuff.  It usually is.  But if you care about easy porting, treat this
like so many other system-dependent features.  Isolate your dependence
on thsi to a small portion of the code and document the
system-dependence of that portion.  In a case like file I/O, that
isolation shoule be pretty simple.  You have one code module (could be
an f90 module, but doesn't have to be - I Iuse the term more
generically here) that is responsible only for reading and writing the
fixed-size blocks - everything else just calls the subroutines in that
module.

It is "fundamental to my faith" that I can somehow read and write
binary files with no system-dependent extra bytes, and with with block
lengths that are "nice" powers of 2 in bytes (like 1024 or 2048).  I
do not assume that direct access unformatted I/O is always the way to
do this (though it usually is).  There have existed machines where
this is not practical - I've even worked on such in the past (notably
60-bit CDCs, which I used to do a lot in).  But I've decided that such
machines are now oddball enough that my applications just won't be
readily portable to them.

Don't know whether the f2k stream I/o has been mentioned in this
thread.  That will be the standard way to access files like this
in f2k.  Then you won't be restricted to fixed length records.  Plus
the standard will actually specify that the file has no extra "stuff",
rather than just relying on the fact that that's how most vendors
happen to have done direct access unformatted.

--
Richard Maine                |  Good judgement comes from experience;
[log in to unmask]   |  experience comes from bad judgement.
                             |        -- 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