1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
/* This code is part of the tng binary trajectory format.
*
* VERSION 1.0
*
* Written by Magnus Lundborg
* Copyright (c) 2012-2013, The GROMACS development team.
* Check out http://www.gromacs.org for more information.
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Revised BSD License.
*/
#ifdef USE_STD_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "tng_io.h"
static tng_function_status tng_test_setup_molecules(tng_trajectory_t traj)
{
tng_molecule_t molecule;
tng_chain_t chain;
tng_residue_t residue;
tng_atom_t atom;
int64_t cnt;
tng_molecule_add(traj, "water", &molecule);
tng_molecule_chain_add(traj, molecule, "W", &chain);
tng_chain_residue_add(traj, chain, "WAT", &residue);
if(tng_residue_atom_add(traj, residue, "O", "O", &atom) == TNG_CRITICAL)
{
return(TNG_CRITICAL);
}
if(tng_residue_atom_add(traj, residue, "HO1", "H", &atom) == TNG_CRITICAL)
{
return(TNG_CRITICAL);
}
if(tng_residue_atom_add(traj, residue, "HO2", "H", &atom) == TNG_CRITICAL)
{
return(TNG_CRITICAL);
}
tng_molecule_cnt_set(traj, molecule, 200);
tng_molecule_cnt_get(traj, molecule, &cnt);
/* printf("Created %"PRId64" %s molecules.\n", cnt, molecule->name); */
/* traj->molecule_cnt_list[traj->n_molecules-1] = 5;
// tng_molecule_name_set(traj, &traj->molecules[1], "ligand");
// tng_molecule_name_set(traj, &traj->molecules[2], "water");
// tng_molecule_name_set(traj, &traj->molecules[3], "dummy");
// traj->molecules[0].id = 0;
// traj->molecules[1].id = 1;
// traj->molecules[2].id = 2;
// traj->molecules[3].id = 3;
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom1", "type1") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom2", "type1") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom3", "type1") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom4", "type2") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom5", "type2") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom6", "type2") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[0], "atom7", "type3") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[1], "C1", "C") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[1], "O1", "O") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[1], "H11", "H") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[1], "H12", "H") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
// if(tng_add_atom_to_molecule(traj, &traj->molecules[1], "H13", "H") == TNG_CRITICAL)
// {
// return(TNG_CRITICAL);
// }
*/
return(TNG_SUCCESS);
}
static tng_function_status tng_test_read_and_write_file
(tng_trajectory_t traj)
{
tng_function_status stat;
stat = tng_file_headers_read(traj, TNG_USE_HASH);
if(stat == TNG_CRITICAL)
{
return(stat);
}
stat = tng_file_headers_write(traj, TNG_USE_HASH);
if(stat == TNG_CRITICAL)
{
return(stat);
}
while(stat == TNG_SUCCESS)
{
stat = tng_frame_set_read_next(traj, TNG_USE_HASH);
if(stat != TNG_SUCCESS)
{
return(stat);
}
stat = tng_frame_set_write(traj, TNG_USE_HASH);
}
return(stat);
}
static tng_function_status tng_test_write_and_read_traj(tng_trajectory_t *traj)
{
int i, j, k, nr, cnt;
float *data, *molpos, *charges;
int64_t mapping[300], n_particles, n_frames_per_frame_set, tot_n_mols;
// int64_t frame_nr;
double box_shape[9];
char atom_type[16], annotation[128];
tng_function_status stat = TNG_SUCCESS;
tng_medium_stride_length_set(*traj, 10);
tng_long_stride_length_set(*traj, 100);
/* Create molecules */
if(tng_test_setup_molecules(*traj) == TNG_CRITICAL)
{
return(TNG_CRITICAL);
}
/* Set the box shape */
box_shape[1] = box_shape[2] = box_shape[3] = box_shape[5] = box_shape[6] =
box_shape[7] = 0;
box_shape[0] = 150.0;
box_shape[4] = 145.5;
box_shape[8] = 155.5;
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_trajectory_destroy(traj);
printf("Cannot write trajectory box shape.\n");
exit(1);
}
/* Set partial charges (treat the water as TIP3P. */
tng_num_particles_get(*traj, &n_particles);
charges = malloc(sizeof(float) * n_particles);
for(i = 0; i < n_particles; i++)
{
stat = tng_atom_type_of_particle_nr_get(*traj, i, atom_type,
sizeof(atom_type));
if(stat == TNG_CRITICAL)
{
break;
}
if(atom_type[0] == 'O')
{
charges[i] = -0.834;
}
else if(atom_type[0] == 'H')
{
charges[i] = 0.417;
}
}
if(stat == TNG_CRITICAL)
{
free(charges);
printf("Failed setting partial charges.\n");
return(TNG_CRITICAL);
}
stat = tng_particle_data_block_add(*traj, TNG_TRAJ_PARTIAL_CHARGES, "PARTIAL CHARGES",
TNG_FLOAT_DATA, TNG_NON_TRAJECTORY_BLOCK,
1, 1, 1, 0, n_particles,
TNG_UNCOMPRESSED, charges);
free(charges);
if(stat != TNG_SUCCESS)
{
printf("Failed adding partial charges\n");
return(TNG_CRITICAL);
}
/* Generate a custom annotation data block */
strcpy(annotation, "This trajectory was generated from tng_io_testing. "
"It is not a real MD trajectory.");
if(tng_data_block_add(*traj, 10100, "DETAILS", TNG_CHAR_DATA,
TNG_NON_TRAJECTORY_BLOCK, 1, 1, 1, TNG_UNCOMPRESSED,
annotation) != TNG_SUCCESS)
{
printf("Failed adding details annotation data block.\n");
return(TNG_CRITICAL);
}
/* Write file headers (includes non trajectory data blocks */
if(tng_file_headers_write(*traj, TNG_SKIP_HASH) == TNG_CRITICAL)
{
printf("Cannot write file headers.\n");
}
tng_num_frames_per_frame_set_get(*traj, &n_frames_per_frame_set);
data = malloc(sizeof(float) * n_particles *
n_frames_per_frame_set * 3);
if(!data)
{
printf("Cannot allocate memory. %s: %d\n", __FILE__, __LINE__);
return(TNG_CRITICAL);
}
tng_num_molecules_get(*traj, &tot_n_mols);
molpos = malloc(sizeof(float) * tot_n_mols * 3);
/* Set initial coordinates */
for(i = 0; i < tot_n_mols; i++)
{
nr = i * 3;
/* Somewhat random coordinates (between 0 and 100),
* but not specifying a random seed */
molpos[nr] = 100.0 * rand() / (RAND_MAX + 1.0);
molpos[nr+1] = 100.0 * rand() / (RAND_MAX + 1.0);
molpos[nr+2] = 100.0 * rand() / (RAND_MAX + 1.0);
}
/* Generate 200 frame sets - each with 100 frames (by default) */
for(i = 0; i < 200; i++)
{
cnt = 0;
for(j = 0; j < n_frames_per_frame_set; j++)
{
for(k = 0; k < tot_n_mols; k++)
{
nr = k * 3;
/* Move -1 to 1 */
molpos[nr] += 2 * (rand() / (RAND_MAX + 1.0)) - 1;
molpos[nr+1] += 2 * (rand() / (RAND_MAX + 1.0)) - 1;
molpos[nr+2] += 2 * (rand() / (RAND_MAX + 1.0)) - 1;
data[cnt++] = molpos[nr];
data[cnt++] = molpos[nr + 1];
data[cnt++] = molpos[nr + 2];
data[cnt++] = molpos[nr] + 1;
data[cnt++] = molpos[nr + 1] + 1;
data[cnt++] = molpos[nr + 2] + 1;
data[cnt++] = molpos[nr] - 1;
data[cnt++] = molpos[nr + 1] - 1;
data[cnt++] = molpos[nr + 2] - 1;
}
}
if(tng_frame_set_new(*traj, i * n_frames_per_frame_set,
n_frames_per_frame_set) != TNG_SUCCESS)
{
printf("Error creating frame set %d. %s: %d\n",
i, __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
tng_frame_set_particle_mapping_free(*traj);
/* Setup particle mapping. Use 4 different mapping blocks with arbitrary
* mappings. */
for(k=0; k<150; k++)
{
mapping[k]=k;
}
if(tng_particle_mapping_add(*traj, 0, 150, mapping) != TNG_SUCCESS)
{
printf("Error creating particle mapping. %s: %d\n",
__FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
for(k=0; k<150; k++)
{
mapping[k]=599-k;
}
if(tng_particle_mapping_add(*traj, 150, 150, mapping) != TNG_SUCCESS)
{
printf("Error creating particle mapping. %s: %d\n",
__FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
for(k=0; k<150; k++)
{
mapping[k]=k+150;
}
if(tng_particle_mapping_add(*traj, 300, 150, mapping) != TNG_SUCCESS)
{
printf("Error creating particle mapping. %s: %d\n",
__FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
for(k=0; k<150; k++)
{
mapping[k]=449-k;
}
if(tng_particle_mapping_add(*traj, 450, 150, mapping) != TNG_SUCCESS)
{
printf("Error creating particle mapping. %s: %d\n",
__FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
/* Add the positions in a data block */
if(tng_particle_data_block_add(*traj, TNG_TRAJ_POSITIONS,
"POSITIONS",
TNG_FLOAT_DATA,
TNG_TRAJECTORY_BLOCK,
n_frames_per_frame_set, 3,
1, 0, n_particles,
/* TNG_UNCOMPRESSED, */
TNG_GZIP_COMPRESSION,
data) != TNG_SUCCESS)
{
printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
/* Write the frame set */
if(tng_frame_set_write(*traj, TNG_SKIP_HASH) != TNG_SUCCESS)
{
printf("Error writing frame set. %s: %d\n", __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
}
/* Write two more frame sets one frame at a time */
/* Make a new frame set - if always using the same mapping blocks
* it is not necessary to explicitly add a new frame set - it will
* be added automatically when adding data for a frame */
/* if(tng_frame_set_new(*traj, i * n_frames_per_frame_set,
n_frames_per_frame_set) != TNG_SUCCESS)
{
printf("Error creating frame set %d. %s: %d\n",
i, __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
frame_nr = i * n_frames_per_frame_set;
for(k=0; k<300; k++)
{
mapping[k]=k;
}
*//* Just use two particle mapping blocks in this frame set *//*
if(tng_particle_mapping_add(*traj, 0, 300, mapping) != TNG_SUCCESS)
{
printf("Error creating particle mapping. %s: %d\n",
__FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
for(k=0; k<300; k++)
{
mapping[k]=599-k;
}
if(tng_particle_mapping_add(*traj, 300, 300, mapping) != TNG_SUCCESS)
{
printf("Error creating particle mapping. %s: %d\n",
__FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
*//* Add the data block to the current frame set *//*
if(tng_particle_data_block_add(*traj, TNG_TRAJ_POSITIONS,
"POSITIONS",
TNG_FLOAT_DATA,
TNG_TRAJECTORY_BLOCK,
n_frames_per_frame_set, 3,
1, 0, n_particles,
TNG_UNCOMPRESSED,
0) != TNG_SUCCESS)
{
printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
*//* Write the frame set to disk *//*
if(tng_frame_set_write(*traj, TNG_SKIP_HASH) != TNG_SUCCESS)
{
printf("Error writing frame set. %s: %d\n", __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
*//* Write particle data to disk - one frame at a time *//*
for(i = 0; i < n_frames_per_frame_set * 2; i++)
{
for(j = 0; j < 2; j++)
{
cnt = 0;
for(k = 0; k < tot_n_mols/2; k++)
{
nr = k * 3;
*//* Move -1 to 1 *//*
molpos[nr] += 2 * (rand() / (RAND_MAX + 1.0)) - 1;
molpos[nr+1] += 2 * (rand() / (RAND_MAX + 1.0)) - 1;
molpos[nr+2] += 2 * (rand() / (RAND_MAX + 1.0)) - 1;
data[cnt++] = molpos[nr];
data[cnt++] = molpos[nr + 1];
data[cnt++] = molpos[nr + 2];
data[cnt++] = molpos[nr] + 1;
data[cnt++] = molpos[nr + 1] + 1;
data[cnt++] = molpos[nr + 2] + 1;
data[cnt++] = molpos[nr] - 1;
data[cnt++] = molpos[nr + 1] - 1;
data[cnt++] = molpos[nr + 2] - 1;
}
if(tng_frame_particle_data_write(*traj, frame_nr + i,
TNG_TRAJ_POSITIONS, j * 300, 300,
data, TNG_SKIP_HASH) != TNG_SUCCESS)
{
printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
free(molpos);
free(data);
return(TNG_CRITICAL);
}
}
}
*/
free(molpos);
free(data);
tng_trajectory_destroy(traj);
tng_trajectory_init(traj);
#ifdef TNG_EXAMPLE_FILES_DIR
tng_input_file_set(*traj, TNG_EXAMPLE_FILES_DIR "tng_test.tng");
#else
tng_input_file_set(*traj, "/tmp/tng_test.tng");
#endif
stat = tng_file_headers_read(*traj, TNG_SKIP_HASH);
while(stat == TNG_SUCCESS)
{
stat = tng_frame_set_read_next(*traj, TNG_SKIP_HASH);
}
return(stat);
}
/* This test relies on knowing that the box shape is stored as double */
tng_function_status tng_test_get_box_data(tng_trajectory_t traj)
{
int64_t n_frames, n_values_per_frame;
union data_values **values = 0;
char type;
if(tng_data_get(traj, TNG_TRAJ_BOX_SHAPE, &values, &n_frames,
&n_values_per_frame, &type) != TNG_SUCCESS)
{
printf("Failed getting box shape. %s: %d\n", __FILE__, __LINE__);
return(TNG_CRITICAL);
}
/*
// int64_t i, j;
// printf("Box shape:");
// for(i=0; i<n_frames; i++)
// {
// for(j=0; j<n_values_per_frame; j++)
// {
// printf("\t%f", (values[i][j]).d);
// }
// printf("\n");
// }
*/
tng_data_values_free(traj, values, n_frames, n_values_per_frame, type);
return(TNG_SUCCESS);
}
/* This test relies on knowing that the positions are stored as float
* and that the data is not sparse (i.e. as many frames in the data
* as in the frame set */
tng_function_status tng_test_get_positions_data(tng_trajectory_t traj)
{
int64_t n_frames, n_particles, n_values_per_frame;
union data_values ***values = 0;
char type;
if(tng_particle_data_get(traj, TNG_TRAJ_POSITIONS, &values, &n_frames,
&n_particles, &n_values_per_frame, &type) !=
TNG_SUCCESS)
{
printf("Failed getting particle positions. %s: %d\n", __FILE__, __LINE__);
return(TNG_CRITICAL);
}
/*
// int64_t i, j, k;
// struct tng_trajectory_frame_set *frame_set =
// &traj->current_trajectory_frame_set;
// for(i = 0; i<n_frames; i++)
// {
// printf("Frame %"PRId64"\n", frame_set->first_frame + i);
// for(j = 0; j<n_particles; j++)
// {
// printf("Particle %"PRId64":", j);
// for(k=0; k<n_values_per_frame; k++)
// {
// printf("\t%f", (values[i][j][k]).f);
// }
// printf("\n");
// }
// }
*/
tng_particle_data_values_free(traj, values, n_frames, n_particles,
n_values_per_frame, type);
values = 0;
tng_particle_data_interval_get(traj, TNG_TRAJ_POSITIONS, 11000, 11499,
TNG_SKIP_HASH, &values, &n_particles,
&n_values_per_frame, &type);
/* Here the particle positions can be printed */
tng_particle_data_values_free(traj, values, 500, n_particles,
n_values_per_frame, type);
return(TNG_SUCCESS);
}
int main()
{
tng_trajectory_t traj;
tng_function_status stat;
char time_str[TNG_MAX_DATE_STR_LEN];
if(tng_trajectory_init(&traj) != TNG_SUCCESS)
{
tng_trajectory_destroy(&traj);
printf("Test Init trajectory:\t\t\t\tFailed. %s: %d.\n",
__FILE__, __LINE__);
exit(1);
}
printf("Test Init trajectory:\t\t\t\tSucceeded.\n");
tng_time_get_str(traj, time_str);
printf("Creation time: %s\n", time_str);
#ifdef TNG_EXAMPLE_FILES_DIR
tng_input_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_example.tng");
tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_example_out.tng");
#else
tng_input_file_set(traj, "tng_example.tng");
tng_output_file_set(traj, "/tmp/tng_example_out.tng");
#endif
if(tng_test_read_and_write_file(traj) == TNG_CRITICAL)
{
printf("Test Read and write file:\t\t\tFailed. %s: %d\n",
__FILE__, __LINE__);
}
else
{
printf("Test Read and write file:\t\t\tSucceeded.\n");
}
if(tng_test_get_box_data(traj) != TNG_SUCCESS)
{
printf("Test Get data:\t\t\t\t\tFailed. %s: %d\n",
__FILE__, __LINE__);
}
else
{
printf("Test Get data:\t\t\t\t\tSucceeded.\n");
}
if(tng_trajectory_destroy(&traj) == TNG_CRITICAL ||
tng_trajectory_init(&traj) == TNG_CRITICAL)
{
printf("Test Destroy and init trajectory:\t\tFailed. %s: %d\n",
__FILE__, __LINE__);
}
else
{
printf("Test Destroy and init trajectory:\t\tSucceeded.\n");
}
#ifdef TNG_EXAMPLE_FILES_DIR
tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_test.tng");
#else
tng_output_file_set(traj, "/tmp/tng_test.tng");
#endif
if(tng_test_write_and_read_traj(&traj) == TNG_CRITICAL)
{
printf("Test Write and read file:\t\t\tFailed. %s: %d\n",
__FILE__, __LINE__);
}
else
{
printf("Test Write and read file:\t\t\tSucceeded.\n");
}
if(tng_test_get_positions_data(traj) != TNG_SUCCESS)
{
printf("Test Get particle data:\t\t\t\tFailed. %s: %d\n",
__FILE__, __LINE__);
}
else
{
printf("Test Get particle data:\t\t\t\tSucceeded.\n");
}
if(tng_trajectory_destroy(&traj) == TNG_CRITICAL)
{
printf("Test Destroy trajectory:\t\t\tFailed. %s: %d.\n",
__FILE__, __LINE__);
exit(1);
}
else
{
printf("Test Destroy trajectory:\t\t\tSucceeded.\n");
}
#ifdef TNG_EXAMPLE_FILES_DIR
stat = tng_util_trajectory_open(TNG_EXAMPLE_FILES_DIR "tng_test.tng", 'r', &traj);
#else
stat = tng_util_trajectory_open("/tmp/tng_test.tng", 'r', &traj);
#endif
if(stat != TNG_SUCCESS)
{
printf("Test Utility function open:\t\t\tFailed. %s: %d.\n",
__FILE__, __LINE__);
exit(1);
}
else
{
printf("Test Utility function open:\t\t\tSucceeded.\n");
}
stat = tng_util_trajectory_close(&traj);
if(stat != TNG_SUCCESS)
{
printf("Test Utility function close:\t\t\tFailed. %s: %d.\n",
__FILE__, __LINE__);
exit(1);
}
else
{
printf("Test Utility function close:\t\t\tSucceeded.\n");
}
printf("Tests finished\n");
exit(0);
}
|