summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMagnus Lundborg <lundborg.magnus@gmail.com>2013-10-04 08:34:18 (GMT)
committerMagnus Lundborg <lundborg.magnus@gmail.com>2013-10-04 08:34:18 (GMT)
commit6af7c70e8c1f5d0bdcb98529ed88a16dde2e9c68 (patch)
treeb783bc66f6c72bb1ae0520eb4bc90331da742524 /src/tests
parent1acac22f9b52c136ad099844f63cb7d1273557ac (diff)
Improved examples.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/md_openmp_util.c26
-rw-r--r--src/tests/tng_io_read_pos_util.c12
2 files changed, 26 insertions, 12 deletions
diff --git a/src/tests/md_openmp_util.c b/src/tests/md_openmp_util.c
index 920c35d..6f25e7f 100644
--- a/src/tests/md_openmp_util.c
+++ b/src/tests/md_openmp_util.c
@@ -186,7 +186,7 @@ int main ( int argc, char *argv[] )
Compute forces and energies,
Update positions, velocities, accelerations.
*/
- printf(" Every %d steps particle positions, velocities and forces are\n",
+ printf(" Every %d steps box shape, particle positions, velocities and forces are\n",
step_save);
printf(" saved to a TNG trajectory file.\n");
printf ( "\n" );
@@ -205,15 +205,13 @@ int main ( int argc, char *argv[] )
step_print_index++;
step_print = ( step_print_index * step_num ) / step_print_num;
- /* The box shape does not change during the trajectory. */
- if(tng_util_box_shape_write(traj, -1, box_shape) != TNG_SUCCESS)
+ /* Set the output frequency of box shape, positions, velocities and forces */
+ if(tng_util_box_shape_write_frequency_set(traj, step_save) != TNG_SUCCESS)
{
- printf("Error writing box shape. %s: %d\n",
+ printf("Error setting writing frequency data. %s: %d\n",
__FILE__, __LINE__);
exit(1);
}
-
- /* Set the output frequency of positions, velocities and forces */
if(tng_util_pos_write_frequency_set(traj, step_save) != TNG_SUCCESS)
{
printf("Error setting writing frequency data. %s: %d\n",
@@ -233,7 +231,13 @@ int main ( int argc, char *argv[] )
exit(1);
}
- /* Write the first frame of positions, velocities and forces */
+ /* Write the first frame of box shape, positions, velocities and forces */
+ if(tng_util_box_shape_write(traj, 0, box_shape) != TNG_SUCCESS)
+ {
+ printf("Error writing box shape. %s: %d\n",
+ __FILE__, __LINE__);
+ exit(1);
+ }
if(tng_util_pos_write(traj, 0, pos) != TNG_SUCCESS)
{
printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
@@ -265,7 +269,13 @@ int main ( int argc, char *argv[] )
}
if(step % step_save == 0)
{
- /* Write positions, velocities and forces */
+ /* Write box shape, positions, velocities and forces */
+ if(tng_util_box_shape_write(traj, step, box_shape) != TNG_SUCCESS)
+ {
+ printf("Error writing box shape. %s: %d\n",
+ __FILE__, __LINE__);
+ exit(1);
+ }
if(tng_util_pos_write(traj, step, pos) != TNG_SUCCESS)
{
printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
diff --git a/src/tests/tng_io_read_pos_util.c b/src/tests/tng_io_read_pos_util.c
index e7b00d3..22e75d5 100644
--- a/src/tests/tng_io_read_pos_util.c
+++ b/src/tests/tng_io_read_pos_util.c
@@ -73,8 +73,11 @@ int main(int argc, char **argv)
last_frame = tot_n_frames - 1;
}
+
+ n_frames = last_frame - first_frame + 1;
+
if(tng_util_box_shape_read(traj, &box_shape, &stride_length) ==
- TNG_SUCCESS)
+ TNG_SUCCESS)
{
printf("Simulation box shape: ");
for(i=0; i < 9; i++)
@@ -88,9 +91,6 @@ int main(int argc, char **argv)
printf("Simulation box shape not set in the file (or could not be read)\n");
}
- n_frames = last_frame - first_frame + 1;
-
-
// 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.
@@ -123,6 +123,10 @@ int main(int argc, char **argv)
{
free(positions);
}
+ if(box_shape)
+ {
+ free(box_shape);
+ }
tng_util_trajectory_close(&traj);
return(0);
contact: Jan Huwald // Impressum