diff options
Diffstat (limited to 'src/tests/md_openmp_util.c')
-rw-r--r-- | src/tests/md_openmp_util.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/src/tests/md_openmp_util.c b/src/tests/md_openmp_util.c index 6a2f377..99ab60e 100644 --- a/src/tests/md_openmp_util.c +++ b/src/tests/md_openmp_util.c @@ -155,17 +155,17 @@ int main ( int argc, char *argv[] ) /* Add the box shape data block and write the file headers */ - if(tng_data_block_add(traj, TNG_TRAJ_BOX_SHAPE, "BOX SHAPE", TNG_DOUBLE_DATA, - TNG_NON_TRAJECTORY_BLOCK, 1, 9, 1, TNG_UNCOMPRESSED, - box_shape) == TNG_CRITICAL || - tng_file_headers_write(traj, TNG_USE_HASH) == TNG_CRITICAL) - { - free(box_shape); - tng_util_trajectory_close(&traj); - printf(" Cannot write trajectory headers and box shape.\n"); - exit(1); - } - free(box_shape); +// if(tng_data_block_add(traj, TNG_TRAJ_BOX_SHAPE, "BOX SHAPE", TNG_DOUBLE_DATA, +// TNG_NON_TRAJECTORY_BLOCK, 1, 9, 1, TNG_UNCOMPRESSED, +// box_shape) == TNG_CRITICAL || +// tng_file_headers_write(traj, TNG_USE_HASH) == TNG_CRITICAL) +// { +// free(box_shape); +// tng_util_trajectory_close(&traj); +// printf(" Cannot write trajectory headers and box shape.\n"); +// exit(1); +// } +// free(box_shape); printf ( "\n" ); printf ( " Initializing positions, velocities, and accelerations.\n" ); @@ -184,11 +184,11 @@ int main ( int argc, char *argv[] ) e0 = potential + kinetic; /* Saving frequency */ - step_save = 100; + step_save = 400; step_print = 0; step_print_index = 0; - step_print_num = 10; + step_print_num = 100; /* This is the main time stepping loop: @@ -214,15 +214,44 @@ int main ( int argc, char *argv[] ) step_print_index++; step_print = ( step_print_index * step_num ) / step_print_num; + if(tng_util_pos_write_frequency_set(traj, step_save) != TNG_SUCCESS) + { + printf("Error setting writing frequency data. %s: %d\n", + __FILE__, __LINE__); + exit(1); + } + if(tng_util_vel_write_frequency_set(traj, step_save) != TNG_SUCCESS) + { + printf("Error setting writing frequency data. %s: %d\n", + __FILE__, __LINE__); + exit(1); + } + if(tng_util_force_write_frequency_set(traj, step_save) != TNG_SUCCESS) + { + printf("Error setting writing frequency data. %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__); exit(1); } + if(tng_util_vel_write(traj, 0, vel) != TNG_SUCCESS) + { + printf("Error adding data. %s: %d\n", __FILE__, __LINE__); + exit(1); + } + if(tng_util_force_write(traj, 0, force) != TNG_SUCCESS) + { + printf("Error adding data. %s: %d\n", __FILE__, __LINE__); + exit(1); + } wtime = omp_get_wtime ( ); - for ( step = 1; step <= step_num; step++ ) + for ( step = 1; step < step_num; step++ ) { compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); @@ -240,6 +269,16 @@ int main ( int argc, char *argv[] ) printf("Error adding data. %s: %d\n", __FILE__, __LINE__); exit(1); } + if(tng_util_vel_write(traj, step, vel) != TNG_SUCCESS) + { + printf("Error adding data. %s: %d\n", __FILE__, __LINE__); + exit(1); + } + if(tng_util_force_write(traj, step, force) != TNG_SUCCESS) + { + printf("Error adding data. %s: %d\n", __FILE__, __LINE__); + exit(1); + } } update ( np, nd, pos, vel, force, acc, mass, dt ); } |