diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-04-18 09:57:39 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-04-18 09:57:39 (GMT) |
commit | b054bef7b59e535bb696b1c7a58b33f94af6ab43 (patch) | |
tree | f245b01a604da64c01faf39f439806edae8082c0 /src/tests/tng_io_read_pos.c | |
parent | dc88a1b81befe574228c00712530a53ce9245c60 (diff) |
Add tng_num_frames_get() to get the number of frames in the trajectory. Added to reading example as well.
Diffstat (limited to 'src/tests/tng_io_read_pos.c')
-rw-r--r-- | src/tests/tng_io_read_pos.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tests/tng_io_read_pos.c b/src/tests/tng_io_read_pos.c index af5e828..493e10e 100644 --- a/src/tests/tng_io_read_pos.c +++ b/src/tests/tng_io_read_pos.c @@ -21,7 +21,7 @@ int main(int argc, char **argv) { tng_trajectory_t traj; union data_values ***positions = 0; // A 3-dimensional array to be populated - int64_t n_particles, n_values_per_frame, n_frames; + int64_t n_particles, n_values_per_frame, n_frames, tot_n_frames; tng_data_type data_type; int i, j; int64_t particle = 0; @@ -63,6 +63,20 @@ int main(int argc, char **argv) } } + if(tng_num_frames_get(traj, &tot_n_frames) != TNG_SUCCESS) + { + printf("Cannot determine the number of frames in the file\n"); + tng_trajectory_destroy(&traj); + exit(1); + } + + printf("%"PRId64" frames in file\n", tot_n_frames); + + if(last_frame > tot_n_frames - 1) + { + last_frame = tot_n_frames - 1; + } + n_frames = last_frame - first_frame + 1; if(tng_atom_name_of_particle_nr_get(traj, particle, atom_name, |