diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-10-08 10:21:02 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-10-08 10:24:24 (GMT) |
commit | 0fad649af860bebdc3b4e422700b721c0f09007d (patch) | |
tree | 06d260b79f73108586dff39c68001793124862c7 /src/tests | |
parent | 5b70fd5f6fd645a7f827c3eae9d0c5adf1b69bbf (diff) |
Fixing bugs reading data.
Also make compression slightly faster.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/tng_io_read_pos_util.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/tests/tng_io_read_pos_util.c b/src/tests/tng_io_read_pos_util.c index 22e75d5..a80ae53 100644 --- a/src/tests/tng_io_read_pos_util.c +++ b/src/tests/tng_io_read_pos_util.c @@ -27,8 +27,7 @@ int main(int argc, char **argv) float *positions = 0, *box_shape = 0; int64_t n_particles, n_frames, tot_n_frames, stride_length, i, j; // Set a default frame range - int64_t first_frame = 0, last_frame = 5000; - int k; + int64_t first_frame = 0, last_frame = 5000, n_strides; if(argc <= 1) { @@ -91,6 +90,9 @@ int main(int argc, char **argv) printf("Simulation box shape not set in the file (or could not be read)\n"); } + n_strides = (n_frames % stride_length) ? n_frames / stride_length + 1: + n_frames / stride_length; + // Get the positions of all particles in the requested frame range. // The positions are stored in the positions array. // N.B. No proper error checks. @@ -98,17 +100,15 @@ int main(int argc, char **argv) == TNG_SUCCESS) { // Print the positions of the wanted particle (zero based) - for(i=0; i < n_frames; i += stride_length) + for(i=0; i < n_strides; i++) { - printf("\nFrame %"PRId64":\n", first_frame + i); + printf("\nFrame %"PRId64":\n", first_frame + i*stride_length); for(j=0; j < n_particles; j++) { printf("Atom nr: %"PRId64"", j); - for(k=0; k < 3; k++) - { - printf("\t%f", positions[i/stride_length*n_particles* - 3+j*3+k]); - } + printf("\t%f", positions[i*n_particles*3+j*3]); + printf("\t%f", positions[i*n_particles*3+j*3+1]); + printf("\t%f", positions[i*n_particles*3+j*3+2]); printf("\n"); } } |