<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Hello everyone,<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">I upgraded the code of MDAnalysis to
      read the latest TPR version. To add to Len's comments, it appears
      indeed that the new TPR body is 4 times as big as it use to be for
      the same content, and is not portable between architectures. gmx
      dump does fail at reading a file with a different byte order than
      native, and there is no obvious way to determine the endianness of
      the body. While the TPR format is not meant to really be portable,
      it seemed commonly agreed that it was a good file to share
      (<a class="moz-txt-link-freetext" href="https://pubs.acs.org/doi/abs/10.1021/acs.jcim.9b00665">https://pubs.acs.org/doi/abs/10.1021/acs.jcim.9b00665</a>), it is for
      sure a good input file in MDAnalysis. TPR files are commonly
      produced on a local machine before being actually run on a
      cluster, that may use a different byte order.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">&gt; Second the individual bytes of a
      value are padded to 4 bytes per original bytes (each byte is
      packed as `char`). <br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">To be noted that the in-file XDR
      decoder in gromacs (used for the header and prior to gromacs 2020)
      uses 4 bytes for "char", hence the padding. The in-memory one
      reads 1 padded byte (1 byte of information, 4 bytes in the file).</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">As my use case for noticing these
      differences is fairly niche, I may be missing the reason for them.
      In such case, I would be curious to read about them.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Best regards,</div>
    <div class="moz-cite-prefix">Jonathan<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 12/26/19 7:39 PM, Len Kimms wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:permail-201912261939125a4e468a00002fb3-l_kimm02@message-id.uni-muenster.de">
      <pre class="moz-quote-pre" wrap="">Hello everyone,

while fooling around with the new (i.e. version 2020 rc1) TPR file format I noticed some strange behaviors that I don’t understand. As far as I understand the body of the new format is written by the `gmx::InMemorySerializer`. My following questions are basically about this module.

First it seems that the memory serializer writes the values in native byte order. This means that the body of TPR files differ between big- and little-endian systems. The XDR standard used before requires big-endian data. For me, a novice user, the new implementation seems to be less portable and robust. Endian swapping seems to be implemented but not currently used for TPR files.
Is this intentional, if so, why?

Second the individual bytes of a value are padded to 4 bytes per original bytes (each byte is packed as `char`). Therefore the size increases accordingly.
Do those padding bytes serve a special purpose?
Also regarding the padding bytes: Some bytes are not, like most others, padded with zeros. In some places they are padded with ones. At first glance this seem to happen to the second byte (big-endian) of a float. From some initial testing my best guess is, that this is caused by the union conversion in `CharBuffer`. With an `unsigned char` in the private union `u` those values would be zero padded.

In the attachment one could find example files from a big- and little-endian system as well as a file created with GROMACS 2019.
I also brought this to the attention of the MDAnalysis devs here:
<a class="moz-txt-link-freetext" href="https://github.com/MDAnalysis/mdanalysis/issues/2428">https://github.com/MDAnalysis/mdanalysis/issues/2428</a>

Best regards,
   Len</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>