[gmx-developers] Errors in tng_io reading box vectors
Peter Kenneth Eastman
peastman at stanford.edu
Tue May 31 19:01:46 CEST 2016
Hi,
I'm using the Gromacs tng_io library to add support for TNG files to MDTraj. I've run into two different problems when trying to read the box shape. One of them is clearly a bug. The other one I'm not sure whether it's a bug, or just a misunderstanding on my part about how it's supposed to work.
The first problem is that tng_util_box_shape_read() returns the box shape via an argument that's declared as "float **box_shape". But it doesn't check that the box shape is actually stored as floats, or convert it if it's something else. You can see this at https://github.com/gromacs/gromacs/blob/master/src/external/tng_io/src/lib/tng_io.c#L15613-L15618. It calls tng_data_vector_interval_get(), but then completely ignores what value gets returned in the type argument. So if the box shape happened to be stored in double precision, you end up with corrupt data (a float* that actually points to doubles, not floats).
I worked around this by instead calling tng_data_vector_interval_get() directly, but now I've run into a different problem. According to the documentation, the returned array should be of length n_frames*n_values_per_frame and contain the box shape for every frame. But instead it only contains data for the very first frame (the first 9 doubles). All elements beyond that look like they just contain garbage (perhaps uninitialized memory).
Thanks for any help on this.
Peter
More information about the gromacs.org_gmx-developers
mailing list