Binary file format

Version 1

Such binary files consist of two records: description whose length is 32 bytes and data whose length is determined by the description. The rest of the bytes are of special use described below or ignored.

Description record consists of four groups of bytes:

Format identifier for version 1 is equal to 1760568055 and is unique with alternative byte orderings taken into account (-148705176).

Format code consists of 4 bytes defined as follows:

  1. element type: 1 – integer, 2 – float
  2. element size in bytes: 1, 2, 4, 8
  3. shape:
  4. byte ordering: 1 – native (default), 2 – network, 3 – big, 4 – little

The dimensions list depends on the shape:

Additional bytes are used as follows:

Finally, data record gives the elements one by one in the order prescribed by the shape. For shape 13, vector of varying dimensions (described by code) is followed by linearized records corresponding to the fixed secondary dimension.


Code for reading/writing such binary files: Maple – BasicTools[ReadBIN/WriteBIN], Python – BasicTools.ReadBIN/WriteBIN from MolMod package, Fortran – see readdump for example

Test samples:

file=bin.evl
code=[2,8,1,1]
dims=[31]
data=[-522.788480,-521.586832,-281.447629,...,46.626176]
elements: [1]=-522.788480, sum=-1086.285092

file=bin.evc
code=[2,8,22,1]
dims=[31,31]
data=[0.000047,-0.000188,-0.000145,...,-0.092279]
elements: [1,1]=0.000047, [2,1]=-0.000188, [1,2]=0.000218, sum=19.433223

file=bin.s1e
code=[2,8,3,1]
dims=[31]
data=[1.000000,0.219059,1.000000,...,1.000000]
elements: [1,1]=1.000000, [1,2]=[2,1]=0.219059, [2,2]=1.000000, sum=66.308944