From: Axel Kohlmeyer (
Date: Tue Jun 16 2009 - 22:59:20 CDT

On Tue, 2009-06-16 at 19:23 -0700, Rob wrote:

> I'm now working on the code to make the binary reading flexible toward
> endian-type (little or big) and record marker length (4 or 8).
> This is a little tricky, because I'm not an expert in this. I noticed on my linux
> system that the first 4 (or 8) bytes of a binary file are a fingerprint of its
> endian-type and recordmarker length.
> Can I assume that this observation is machine independent?

yes, almost. the tricky thing is to tell the difference between
4-byte and 8-byte little endian record markers. you have to know
what comes after the record marker. if there was an integer it
could be 0 and then you cannot know tell. in dcd there are four
characters that are always in the same order, so there it is possible
to tell all cases apart. if abinit does not have something like
that, you have to seek ahead and check whether there is the same
recordmarker or the equivalent amount of zero bytes.

all fortran compilers follow these "rules". they are more-or-less
determined by the semantics of the fortran unformatted write.


> Rob.
> PS: why is there such a long time delay between me sending email to
> this mailing list and my email appearing in the mailing list's archives?

well, john already gave the explanation, but it is worse for you,
since you live in the "wrong" timezone. ;)


Axel Kohlmeyer
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
If you make something idiot-proof, the universe creates a better idiot.