From: Rob (spamrefuse_at_yahoo.com)
Date: Thu Jun 18 2009 - 02:27:08 CDT

Axel Kohlmeyer wrote:
>
> On Wed, 2009-06-17 at 08:59 -0700, Rob wrote:
>
>> the start of the file; this tag depends on the endianness and the

>> record length.
>> With a record length 4 (or 8), it has a 4 (or 8) bytes tag, as follows:
>>
>> Little-endian / 4 : 0e 00 00 00
>> Little-endian / 8 : 0e 00 00 00 00 00 00 00
>>

> exactly. but here you have to be careful in the 8-byte case.
> if the first data element being written is an integer that can
> be 0, then you cannot tell those two cases apart. so you also
> have to know what is the first write statement like. all smart
> packages tend to put some version or type info string there
> and since i know the folks working on abinit to be smart, too,
> i'd expect them to do something similar.

Aha, good news indeed: this tag is followed by a version string
(without the null-termination). This string tells the ABINIT version
number, e.g. "5.8.3".
Hence, the first byte after the tag can never be zero.
I'm happy that my strategy turns out to be OK and safe.

Remains the problem: what was the byte size of integers and
doubles on the computer, which generated the binary file?
(I guess this is a matter of just trying to read the file and check
whether the numbers make sense.....).

If the byte size of integers/doubles in the file does not match
with my program reading it, one has to do a lot of messy
coding (at least for the real numbers) to figure out their values.
Right?

For now I assume that integers are 4 bytes and doubles 8.
May I assume that this is almost generic? Or generic enough?

Rob.