<p dir="ltr">Hi, </p>
<p dir="ltr">I&#39;ll look into this when I&#39;m back from vacation next week. </p>
<p dir="ltr">Cheers, </p>
<p dir="ltr">Magnus</p>
<div class="gmail_quote">On 7 Aug 2014 12:19, &quot;Semen Esilevsky&quot; &lt;<a href="mailto:yesint4@yahoo.com">yesint4@yahoo.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear All,<br>
I&#39;m currently trying to add support for tng files to my code and I realised that I can&#39;t understand the logic of the library at all. I&#39;m definetely doing something wrong, but can&#39;t figure out a mistake.<br>

The tng code is got from the latest git. Test trajectory is generated by Gromacs 5.0.<br>
<br>
<br>
I can open the tng file and can extract, for example, position exponential correctly, but after that...<br>
<br>
<br>
Problem #1: getting number of frames.<br>
<br>
int64_t n1,n2;<br>
tng_num_frames_get(trj, &amp;n1);<br>
tng_num_frame_sets_get(trj, &amp;n2);<br>
<br>
This gets<br>
n1 = 10761<br>
n2 = 1086<br>
<br>
The correct number of frames is 1086.<br>
<br>
What on Earth is returned from tng_num_frames_get()?<br>
<br>
Problem #2: Reading past the end of file.<br>
<br>
stat = tng_util_particle_data_next_frame_read(trj, TNG_TRAJ_POSITIONS, &amp;values,<br>
                                                  &amp;datatype, &amp;frame, &amp;physical_time);<br>
<br>
This function should return false when no more frames are available, right? It doesn&#39;t do this and reads forever returning garbage in values when called in a loop. stat is always true. How should I use it correctly to finish reading at the end of file?<br>

Also concerning the strange thing with the number of frames and frame sets - what it reads actually each time?<br>
<br>
Problem #3: tng_util_pos_read_range() behaves insane<br>
<br>
int n=0;<br>
bool stat = true;<br>
while(stat){<br>
    stat = tng_util_pos_read_range(trj,n,n, &amp;ptr, &amp;len);<br>
    n++;<br>
}<br>
<br>
This always stops at n=10 (why?!), while the number of frames is 1086! What I&#39;m doing wrong here?<br>
<br>
I&#39;ve also tried VMD plugin from pre-release VMD 1.9.2. It is said that this plugin is contributed by Gromacs developers, so it should work in principle. It doesn&#39;t work because of the bug #2 - it reads forever beyond the end of file.<br>

<br>
<br>
The test tng file is here: <a href="https://drive.google.com/file/d/0Bx_ng_72VH8BQlFsTGJOVC1oMjQ/edit?usp=sharing" target="_blank">https://drive.google.com/file/d/0Bx_ng_72VH8BQlFsTGJOVC1oMjQ/edit?usp=sharing</a><br>
<br>
<br>
Any help is appreciated!<br>
<br>
Sincerely,<br>
Semen<br>
<br>
--<br>
Gromacs Developers mailing list<br>
<br>
* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" target="_blank">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a> before posting!<br>
<br>
* Can&#39;t post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists" target="_blank">http://www.gromacs.org/Support/Mailing_Lists</a><br>
<br>
* For (un)subscribe requests visit<br>
<a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br>

</blockquote></div>