summaryrefslogtreecommitdiff
path: root/include/tng_io.h
blob: 5b89cd6357255fad170d502a0d2044cdeb39fa1b (plain)
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
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
/* This code is part of the tng binary trajectory format.
 *
 * Written by Magnus Lundborg
 * Copyright (c) 2012-2014, 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.
 */

/** @file tng_io.h
 *  @brief API for input and output of tng trajectory files
 *  @mainpage TNG: A flexible binary trajectory format
 *  @section intro_sec Introduction
 *
 * The TNG format is developed as part of the ScalaLife EU project.
 * It is flexible by design to allow parallel writing, custom data blocks,
 * different output frequencies and different compression algorithms.
 *
 * Each block can contain MD5 hashes to verify data integrity and the file
 * can be signed by the user to ensure that the origin is correct.
 *
 * This is version 1.4 of the TNG API. The intention is that this version of
 * the API and ABI should be stable, but it is still possible that future
 * changes might make that impossible, in which case that will be clarified.
 *
 * The API and all examples are released without any warranties. Use them at
 * your own risk.
 *
 * @section authors_sec Authors
 *
 * The TNG trajectory format is developed by:
 *
 * Magnus Lundborg magnus.lundborg@scilifelab.se
 *
 * Daniel Spångberg daniels@mkem.uu.se
 *
 * Rossen Apostolov rossen@kth.se
 *
 * The API is implemented mainly by:
 *
 * Magnus Lundborg
 *
 * @section License
 *
 * Copyright (c) 2012, The GROMACS development team.
 * check out http://www.gromacs.org for more information.
 *
 * The TNG API is released under the Revised BSD License and is free to
 * redistribute according to that license.
 *
 * A license file (named COPYING) should be included with each copy of the API.
 *
 * @section install_sec Installation
 *
 * \code
 * mkdir build
 *
 * cd build
 *
 * cmake ..
 *
 * make
 *
 * make install
 * \endcode
 * Test by running:
 * \code
 * bin/tests/tng_testing
 * \endcode
 *
 * @section change_sec Change Log
 *
 * See git log for full revision history.
 *
 * Revisions
 *
 * v. 1.5 - Third stable release of the API.
 *
 *        - Fortran wrapper split into separate file
 *        - Added more block IDs.
 *        - Some new functions and utility functions added.
 *        - Improved compression precision settings.
 *        - Improved tests.
 *        - Make appending to file work better.
 *        - Modified CMake settings
 *        - Bugs fixed
 *
 * v. 1.4 - Changed from LGPL to the Revised BSD License.
 *
 *        - More flexible support for digital signatures in header.
 *        - Block ID numbers changed.
 *
 * v. 1.3 - Second stable release of the API.
 *
 *      - Added multiplication factor for coordinate units to general info.
 *      - Added time stamps and time per frame in frame sets.
 *      - High-level API functions added (not for managing molecules yet)
 *      - Added functions for reading data blocks into 1D arrays.
 *      - TNG compression added.
 *      - C++ interface added.
 *      - Avoid memory allocation if no data is submitted when adding data
 *        blocks.
 *      - Added function tng_num_frames_per_frame_set_set
 *      - Added data block IDs for charges, b-factors and occupancy.
 *      - GZIP compression added.
 *      - Fixed bug when updating MD5 hashes of data blocks.
 *      - Fixed bug in chain_name_of_particle_get(...)
 *      - Update frame set pointers properly.
 *      - Moved fortran wrapper from header file to source file.
 *      - Write sparse data in mdrun examples.
 *      - Fixed bugs related to reading and writing sparse data.
 *      - Fixed memory leak for non-trajectory particle data blocks.
 *      - Fixed bug when writing data blocks.
 *      - Fixed wrong values in dependency constants
 *      - Write box shape, partial charges and annotation data in tng_testing
 *      - Bug fixes in tng_testing (frame sets not written before)
 *
 * v. 1.0 - First stable release of the API.
 *
 *
 * @section examples_sec Examples
 *
 * There are some examples of how to use the library located in src/tests/
 *
 * @subsection tng_subsec TNG files
 *
 * The build directory contains an example_files directory, which in turn
 * contains a very short example of a TNG file containing a few water molecules,
 * a box shape description and positions in 10 frames.
 *
 * It is also possible to run the bin/examples/md_openmp_util
 * (see src/tests/md_openmp_util.c)
 * testing program, which will save MD simulations output to a new file
 * (saved in the example_files directory).
 *
 * These files can be read using the bin/examples/tng_io_read_pos_util
 * program.
 *
 * @subsection c_subsec C
 *
 * Example writing data to a TNG file (just an excerpt):
 * \code
 *     for ( step = 1; step < step_num; step++ )
 *     {
 *         compute ( np, nd, pos, vel, mass, force, &potential, &kinetic );
 *
 *         if(step % step_save == 0)
 *         {
 *             // Write positions, velocities and forces
 *             if(tng_util_pos_write(traj, step, pos) != TNG_SUCCESS)
 *             {
 *                 printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
 *                 break;
 *             }
 *             if(tng_util_vel_write(traj, step, vel) != TNG_SUCCESS)
 *             {
 *                 printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
 *                 break;
 *             }
 *             if(tng_util_force_write(traj, step, force) != TNG_SUCCESS)
 *             {
 *                 printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
 *                 break;
 *             }
 *         }
 *         update ( np, nd, pos, vel, force, acc, mass, dt );
 *     }
 * \endcode
 *
 * Example reading positions from a TNG file:
 * \code
 * #include <stdlib.h>
 * #include <stdio.h>
 * #include "tng_io.h"
 *
 * int main(int argc, char **argv)
 * {
 *     tng_trajectory_t traj;
 *     // Assume that the data is stored as floats. The data is placed in 1-D
 *     // arrays
 *     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;
 *
 *     // A reference must be passed to allocate memory
 *     tng_util_trajectory_open(argv[1], 'r', &traj);
 *
 *     if(tng_num_frames_get(traj, &tot_n_frames) != TNG_SUCCESS)
 *     {
 *         printf("Cannot determine the number of frames in the file\n");
 *         tng_util_trajectory_close(&traj);
 *         exit(1);
 *     }
 *
 *     if(tng_num_particles_get(traj, &n_particles) != TNG_SUCCESS)
 *     {
 *         printf("Cannot determine the number of particles in the file\n");
 *         tng_util_trajectory_close(&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;
 *     }
 *
 *     if(tng_util_box_shape_read(traj, &box_shape, &stride_length) ==
 *         TNG_SUCCESS)
 *     {
 *         printf("Simulation box shape: ");
 *         for(i=0; i < 9; i++)
 *         {
 *             printf("%f ", box_shape[i]);
 *         }
 *         printf("\n");
 *     }
 *     else
 *     {
 *         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.
 *     if(tng_util_pos_read_range(traj, 0, last_frame, &positions, &stride_length)
 *        == TNG_SUCCESS)
 *     {
 *         // Print the positions of the wanted particle (zero based)
 *         for(i=0; i < n_frames; i += stride_length)
 *         {
 *             printf("\nFrame %"PRId64":\n", first_frame + i);
 *             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("\n");
 *             }
 *         }
 *     }
 *     else
 *     {
 *         printf("Cannot read positions\n");
 *     }
 *
 *     // Free memory
 *     if(positions)
 *     {
 *         free(positions);
 *     }
 *     tng_util_trajectory_close(&traj);
 *
 *     return(0);
 * }
 *
 * \endcode
 *
 * @subsection fortran_subsec Fortran
 *
 * The TNG library can be used from Fortran. It requires cray pointers, which
 * are not part of the Fortran 77 standard, but available in most compilers.
 *
 * To compile the fortran example -DTNG_BUILD_FORTRAN=ON needs to be specified when
 * running cmake.
 *
 */

#ifndef TNG_IO_H
#define TNG_IO_H     1

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "tng_io_fwd.h"

#ifdef USE_STD_INTTYPES_H
#include <inttypes.h>
#else
/* Visual Studio does not contain inttypes.h and stdint.h. Some defines and
 * typedefs are used from the GNU C Library */
#ifdef _MSC_VER

typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;

#else
#include <stdint.h>
#endif /* _MSC_VER */

/* This is from inttypes.h  (GNU C Library) */
/* The ISO C99 standard specifies that these macros must only be
   defined if explicitly requested.  */
#if !defined __cplusplus || defined __STDC_FORMAT_MACROS

# if __WORDSIZE == 64
#  define __PRI64_PREFIX        "l"
#  define __PRIPTR_PREFIX       "l"
# else
#  define __PRI64_PREFIX        "ll"
#  define __PRIPTR_PREFIX
# endif

/* From stdint.h (GNU C Library) */
/* Macros for printing format specifiers. */
/* Decimal notation.  */
#ifndef PRId64
# define PRId64         __PRI64_PREFIX "d"
#endif

#endif

#endif /* USE_STD_INTTYPES_H */


#ifndef USE_WINDOWS
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#define USE_WINDOWS
#endif /* win32... */
#endif /* not defined USE_WINDOWS */

#ifndef DECLSPECDLLEXPORT
#ifdef USE_WINDOWS
#define DECLSPECDLLEXPORT __declspec(dllexport)
#else /* USE_WINDOWS */
#define DECLSPECDLLEXPORT
#endif /* USE_WINDOWS */
#endif /* DECLSPECDLLEXPORT */

/** Flag to indicate frame dependent data. */
#define TNG_FRAME_DEPENDENT 1
/** Flag to indicate particle dependent data. */
#define TNG_PARTICLE_DEPENDENT 2

/** The maximum length of a date string */
#define TNG_MAX_DATE_STR_LEN 24
/** The length of an MD5 hash */
#define TNG_MD5_HASH_LEN 16
/** The maximum allowed length of a string */
#define TNG_MAX_STR_LEN 1024

#ifndef NDEBUG
#define TNG_ASSERT(cnd, msg) if(!(cnd)) {printf("%s\n", msg); assert(cnd);}
#else
#define TNG_ASSERT(cnd, msg) (void)0;
#endif

/** Flag to specify the endianness of a TNG file */
typedef enum {TNG_BIG_ENDIAN,
              TNG_LITTLE_ENDIAN} tng_file_endianness;

/** Flag to specify the endianness of 32 bit values of the current architecture. */
typedef enum {TNG_BIG_ENDIAN_32,
              TNG_LITTLE_ENDIAN_32,
              TNG_BYTE_PAIR_SWAP_32} tng_endianness_32;

/** Flag to specify the endianness of 64 bit values of the current architecture. */
typedef enum {TNG_BIG_ENDIAN_64,
              TNG_LITTLE_ENDIAN_64,
              TNG_QUAD_SWAP_64,
              TNG_BYTE_PAIR_SWAP_64,
              TNG_BYTE_SWAP_64} tng_endianness_64;

/** Compression mode is specified in each data block */
typedef enum {TNG_UNCOMPRESSED,
              TNG_XTC_COMPRESSION,
              TNG_TNG_COMPRESSION,
              TNG_GZIP_COMPRESSION} tng_compression;

/** Hash types */
typedef enum {TNG_NO_HASH,
              TNG_MD5,
              TNG_SHA256} tng_hash_type;

/** Non trajectory blocks come before the first frame set block */
typedef enum {TNG_NON_TRAJECTORY_BLOCK, TNG_TRAJECTORY_BLOCK} tng_block_type;

/** @defgroup def1 Standard non-trajectory blocks
 *  Block IDs of standard non-trajectory blocks.
 * @{
 */
#define TNG_GENERAL_INFO                0x0000000000000000LL
#define TNG_MOLECULES                   0x0000000000000001LL
#define TNG_TRAJECTORY_FRAME_SET        0x0000000000000002LL
#define TNG_PARTICLE_MAPPING            0x0000000000000003LL
/** @} */

/** @defgroup def2 Standard trajectory blocks
 * Block IDs of standard trajectory blocks. Box shape and partial charges can
 * be either trajectory blocks or non-trajectory blocks
 * @{
 */
#define TNG_TRAJ_BOX_SHAPE              0x0000000010000000LL
#define TNG_TRAJ_POSITIONS              0x0000000010000001LL
#define TNG_TRAJ_VELOCITIES             0x0000000010000002LL
#define TNG_TRAJ_FORCES                 0x0000000010000003LL
#define TNG_TRAJ_PARTIAL_CHARGES        0x0000000010000004LL
#define TNG_TRAJ_FORMAL_CHARGES         0x0000000010000005LL
#define TNG_TRAJ_B_FACTORS              0x0000000010000006LL
#define TNG_TRAJ_ANISOTROPIC_B_FACTORS  0x0000000010000007LL
#define TNG_TRAJ_OCCUPANCY              0x0000000010000008LL
#define TNG_TRAJ_GENERAL_COMMENTS       0x0000000010000009LL
/** @} */


/** @defgroup def3 GROMACS data block IDs
 *  Block IDs of data blocks specific to GROMACS.
 * @{
 */
#define TNG_GMX_LAMBDA                  0x1000000010000000LL
#define TNG_GMX_ENERGY_ANGLE            0x1000000010000001LL
#define TNG_GMX_ENERGY_RYCKAERT_BELL    0x1000000010000002LL
#define TNG_GMX_ENERGY_LJ_14            0x1000000010000003LL
#define TNG_GMX_ENERGY_COULOMB_14       0x1000000010000004LL
#define TNG_GMX_ENERGY_LJ_(SR)          0x1000000010000005LL
#define TNG_GMX_ENERGY_COULOMB_(SR)     0x1000000010000006LL
#define TNG_GMX_ENERGY_COUL_RECIP       0x1000000010000007LL
#define TNG_GMX_ENERGY_POTENTIAL        0x1000000010000008LL
#define TNG_GMX_ENERGY_KINETIC_EN       0x1000000010000009LL
#define TNG_GMX_ENERGY_TOTAL_ENERGY     0x1000000010000010LL
#define TNG_GMX_ENERGY_TEMPERATURE      0x1000000010000011LL
#define TNG_GMX_ENERGY_PRESSURE         0x1000000010000012LL
#define TNG_GMX_ENERGY_CONSTR_RMSD      0x1000000010000013LL
#define TNG_GMX_ENERGY_BOX_X            0x1000000010000014LL
#define TNG_GMX_ENERGY_BOX_Y            0x1000000010000015LL
#define TNG_GMX_ENERGY_BOX_Z            0x1000000010000016LL
#define TNG_GMX_ENERGY_VOLUME           0x1000000010000017LL
#define TNG_GMX_ENERGY_DENSITY          0x1000000010000018LL
#define TNG_GMX_ENERGY_PV               0x1000000010000019LL
#define TNG_GMX_ENERGY_ENTHALPY         0x1000000010000020LL
#define TNG_GMX_ENERGY_VIR_XX           0x1000000010000021LL
#define TNG_GMX_ENERGY_VIR_XY           0x1000000010000022LL
#define TNG_GMX_ENERGY_VIR_XZ           0x1000000010000023LL
#define TNG_GMX_ENERGY_VIR_YX           0x1000000010000024LL
#define TNG_GMX_ENERGY_VIR_YY           0x1000000010000025LL
#define TNG_GMX_ENERGY_VIR_YZ           0x1000000010000026LL
#define TNG_GMX_ENERGY_VIR_ZX           0x1000000010000027LL
#define TNG_GMX_ENERGY_VIR_ZY           0x1000000010000028LL
#define TNG_GMX_ENERGY_VIR_ZZ           0x1000000010000029LL
#define TNG_GMX_ENERGY_PRES_XX          0x1000000010000030LL
#define TNG_GMX_ENERGY_PRES_XY          0x1000000010000031LL
#define TNG_GMX_ENERGY_PRES_XZ          0x1000000010000032LL
#define TNG_GMX_ENERGY_PRES_YX          0x1000000010000033LL
#define TNG_GMX_ENERGY_PRES_YY          0x1000000010000034LL
#define TNG_GMX_ENERGY_PRES_YZ          0x1000000010000035LL
#define TNG_GMX_ENERGY_PRES_ZX          0x1000000010000036LL
#define TNG_GMX_ENERGY_PRES_ZY          0x1000000010000037LL
#define TNG_GMX_ENERGY_PRES_ZZ          0x1000000010000038LL
#define TNG_GMX_ENERGY_SURFXSURFTEN     0x1000000010000039LL
#define TNG_GMX_ENERGY_T_SYSTEM         0x1000000010000040LL
#define TNG_GMX_ENERGY_LAMB_SYSTEM      0x1000000010000041LL
#define TNG_GMX_SELECTION_GROUP_NAMES   0x1000000010000042LL
#define TNG_GMX_ATOM_SELECTION_GROUP    0x1000000010000043LL
/** @} */

/** Flag to specify if a data block contains data related to particles or not.*/
typedef enum {TNG_NON_PARTICLE_BLOCK_DATA,
              TNG_PARTICLE_BLOCK_DATA} tng_particle_dependency;


typedef enum {TNG_FALSE, TNG_TRUE} tng_bool;

/** Flag to specify if the number of atoms change throughout the trajectory or
 *  if it is constant. */
typedef enum {TNG_CONSTANT_N_ATOMS, TNG_VARIABLE_N_ATOMS}
             tng_variable_n_atoms_flag;

/** Return values of API functions. TNG_SUCCESS means that the operation
 *  was successful. TNG_FAILURE means that the operation failed for some
 *  reason, but it is possible to try to continue anyhow. TNG_CRITICAL
 *  means that the error is irrecoverable. */
typedef enum {TNG_SUCCESS, TNG_FAILURE, TNG_CRITICAL} tng_function_status;

/** If tng_hash_mode == TNG_USE_HASH md5 hashes will be written to output files
 *  and when reading a file the md5 hashes of the contents will be compared to
 *  those in the file (for each block) in order to ensure data integrity */
typedef enum {TNG_SKIP_HASH, TNG_USE_HASH} tng_hash_mode;

/** Possible formats of data block contents */
typedef enum {TNG_CHAR_DATA,
              TNG_INT_DATA,
              TNG_FLOAT_DATA,
              TNG_DOUBLE_DATA} tng_data_type;


struct tng_trajectory;
struct tng_molecule;
struct tng_chain;
struct tng_residue;
struct tng_atom;
struct tng_bond;
struct tng_gen_block;
struct tng_particle_mapping;
struct tng_trajectory_frame_set;
struct tng_particle_data;
struct tng_non_particle_data;

/** Data can be either double, float, int or a string */
union data_values {
    double d;
    float f;
    int64_t i;
    char *c;
};


#ifdef __cplusplus
extern "C"
{
#endif

/** @defgroup group1 Low-level API
 *  These functions give detailed control of the TNG data management. Most
 *  things can be done using the more convenient high-level API functions
 *  instead.
 *  @{
 */

/**
 * @brief Setup a trajectory data container.
 * @param tng_data_p a pointer to memory to initialise as a trajectory.
 * @pre tng_data_p must not be pointing at a reserved memory block.
 * @details Memory is allocated during initialisation.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_trajectory_init
                (tng_trajectory_t *tng_data_p);

/**
 * @brief Clean up a trajectory data container.
 * @param tng_data_p a pointer to the trajectory data to destroy.
 * @details All allocated memory in the data structure is freed, as well as
 * tng_data_p itself.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy
                (tng_trajectory_t *tng_data_p);

/**
 * @brief Copy a trajectory data container (dest is setup as well).
 * @details This initialises dest and copies only what is absolute necessary for
 * parallel i/o. This can be used inside pragma omp for setting up a thread
 * local copy of src. It can be freed (using tng_trajectory_destroy) at the
 * end of the parallel block.
 * @param src the original trajectory.
 * @param dest_p a pointer to memory to initialise as a trajectory.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre tng_data_p must not be pointing at a reserved memory block.
 * @details Memory is allocated during initialisation.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src
                (tng_trajectory_t src, tng_trajectory_t *dest_p);

/**
 * @brief Get the name of the input file.
 * @param tng_data the trajectory of which to get the input file name.
 * @param file_name the string to fill with the name of the input file,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for file_name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code file_name != 0 \endcode The pointer to the file name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_input_file_get
                (const tng_trajectory_t tng_data,
                 char *file_name, const int max_len);

/**
 * @brief Set the name of the input file.
 * @param tng_data the trajectory of which to set the input file name.
 * @param file_name the name of the input file.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code file_name != 0 \endcode The pointer to the file name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_input_file_set
                (tng_trajectory_t tng_data,
                 const char *file_name);

/**
 * @brief Get the name of the output file.
 * @param tng_data the trajectory of which to get the input file name.
 * @param file_name the string to fill with the name of the output file,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for file_name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code file_name != 0 \endcode The pointer to the file name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_output_file_get
                (const tng_trajectory_t tng_data,
                 char *file_name, const int max_len);

/**
 * @brief Set the name of the output file.
 * @param tng_data the trajectory of which to set the output file name.
 * @param file_name the name of the output file.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code file_name != 0 \endcode The pointer to the file name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_output_file_set
                (tng_trajectory_t tng_data,
                 const char *file_name);

/**
 * @brief Set the name of the output file for appending. The output file
 * will not be overwritten.
 * @param tng_data the trajectory of which to set the output file name.
 * @param file_name the name of the output file to append to.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code file_name != 0 \endcode The pointer to the file name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set
                (tng_trajectory_t tng_data,
                 const char *file_name);

/**
 * @brief Get the endianness of the output file.
 * @param tng_data the trajectory of which to get the endianness of the current
 * output file.
 * @param endianness will contain the enumeration of the endianness.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code endianness != 0 \endcode The pointer to the endianness container
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness
 * could not be retrieved.
 */
tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get
                (const tng_trajectory_t tng_data, tng_file_endianness *endianness);

/**
 * @brief Set the endianness of the output file.
 * @param tng_data the trajectory of which to set the endianness of the current
 * output file.
 * @param endianness the enumeration of the endianness, can be either
 * TNG_BIG_ENDIAN (0) or TNG_LITTLE_ENDIAN (1).
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details The endianness cannot be changed after file output has started.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness
 * could not be set.
 */
tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set
                (tng_trajectory_t tng_data,
                 const tng_file_endianness endianness);

/**
 * @brief Get the name of the program used when creating the trajectory.
 * @param tng_data the trajectory of which to get the program name.
 * @param name the string to fill with the name of the program,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the program used when creating the trajectory.
 * @param tng_data the trajectory of which to set the program name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the name of the program used when last modifying the trajectory.
 * @param tng_data the trajectory of which to get the program name.
 * @param name the string to fill with the name of the program,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the program used when last modifying the trajectory.
 * @param tng_data the trajectory of which to set the program name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the name of the user who created the trajectory.
 * @param tng_data the trajectory of which to get the user name.
 * @param name the string to fill with the name of the user,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the user who created the trajectory.
 * @param tng_data the trajectory of which to set the user name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the name of the user who last modified the trajectory.
 * @param tng_data the trajectory of which to get the user name.
 * @param name the string to fill with the name of the user,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the user who last modified the trajectory.
 * @param tng_data the trajectory of which to set the user name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the name of the computer used when creating the trajectory.
 * @param tng_data the trajectory of which to get the computer name.
 * @param name the string to fill with the name of the computer,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the computer used when creating the trajectory.
 * @param tng_data the trajectory of which to set the computer name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the name of the computer used when last modifying the trajectory.
 * @param tng_data the trajectory of which to get the computer name.
 * @param name the string to fill with the name of the computer,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the computer used when last modifying the trajectory.
 * @param tng_data the trajectory of which to set the computer name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the pgp_signature of the user creating the trajectory.
 * @param tng_data the trajectory of which to get the computer name.
 * @param signature the string to fill with the signature,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code signature != 0 \endcode The pointer to the signature
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_first_signature_get
                (const tng_trajectory_t tng_data,
                 char *signature, const int max_len);

/**
 * @brief Set the pgp_signature of the user creating the trajectory.
 * @param tng_data the trajectory of which to set the computer name.
 * @param signature is a string containing the pgp_signature.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code signature != 0 \endcode The pointer to the signature
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_first_signature_set
                (tng_trajectory_t tng_data,
                 const char *signature);

/**
 * @brief Get the pgp_signature of the user last modifying the trajectory.
 * @param tng_data the trajectory of which to get the computer name.
 * @param signature the string to fill with the signature,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code signature != 0 \endcode The pointer to the signature
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_last_signature_get
                (const tng_trajectory_t tng_data,
                 char *signature, const int max_len);

/**
 * @brief Set the pgp_signature of the user last modifying the trajectory.
 * @param tng_data the trajectory of which to set the computer name.
 * @param signature is a string containing the pgp_signature.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code signature != 0 \endcode The pointer to the signature
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_last_signature_set
                (tng_trajectory_t tng_data,
                 const char *signature);

/**
 * @brief Get the name of the forcefield used in the trajectory.
 * @param tng_data the trajectory of which to get the forcefield name.
 * @param name the string to fill with the name of the forcefield,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get
                (const tng_trajectory_t tng_data,
                 char *name, const int max_len);

/**
 * @brief Set the name of the forcefield used in the trajectory.
 * @param tng_data the trajectory of which to set the forcefield name.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the new_name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set
                (tng_trajectory_t tng_data,
                 const char *new_name);

/**
 * @brief Get the medium stride length of the trajectory.
 * @param tng_data is the trajectory from which to get the stride length.
 * @param len is pointing to a value set to the stride length.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code len != 0 \endcode The pointer to len must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get
                (const tng_trajectory_t tng_data,
                 int64_t *len);

/**
 * @brief Set the medium stride length of the trajectory.
 * @param tng_data is the trajectory of which to set the stride length.
 * @param len is the wanted medium stride length.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred.
 */
tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set
                (tng_trajectory_t tng_data,
                 const int64_t len);

/**
 * @brief Get the long stride length of the trajectory.
 * @param tng_data is the trajectory from which to get the stride length.
 * @param len is pointing to a value set to the stride length.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code len != 0 \endcode The pointer to len must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get
                (const tng_trajectory_t tng_data,
                 int64_t *len);

/**
 * @brief Set the long stride length of the trajectory.
 * @param tng_data is the trajectory of which to set the stride length.
 * @param len is the wanted long stride length.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred.
 */
tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set
                (tng_trajectory_t tng_data,
                 const int64_t len);

/**
 * @brief Get the current time per frame of the trajectory.
 * @param tng_data is the trajectory from which to get the time per frame.
 * @param time is pointing to a value set to the time per frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code time != 0 \endcode The pointer to time must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_time_per_frame_get
                (const tng_trajectory_t tng_data,
                 double *time);

/**
 * @brief Set the time per frame of the trajectory.
 * @param tng_data is the trajectory of which to set the time per frame.
 * @param time is the new time per frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code time > 0 \endcode The time per frame must be >= 0.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred.
 */
tng_function_status DECLSPECDLLEXPORT tng_time_per_frame_set
                (tng_trajectory_t tng_data,
                 const double time);

/**
 * @brief Get the length of the input file.
 * @param tng_data is the trajectory from which to get the input file length.
 * @param len is pointing to a value set to the file length.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code len != 0 \endcode The pointer to len must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get
                (const tng_trajectory_t tng_data,
                 int64_t *len);

/**
 * @brief Get the number of frames in the trajectory
 * @param tng_data is the trajectory of which to get the number of frames.
 * @param n is pointing to a value set to the number of frames.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code tng_data->input_file != 0 \endcode An input file must be open
 * to find the next frame set.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (could not find last frame set).
 */
tng_function_status DECLSPECDLLEXPORT tng_num_frames_get
                (const tng_trajectory_t tng_data,
                 int64_t *n);

/**
 * @brief Get the precision of lossy compression.
 * @param tng_data is the trajectory of which to get the compression precision.
 * @param precision will be pointing to the retrieved compression precision.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details A compression precision of 0.001 (the default) means that the
 * compressed values are accurate to the third decimal. This function does
 * not check actual precision of compressed data, but just returns what has
 * previously been set using tng_compression_precision_set().
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_compression_precision_get
                (const tng_trajectory_t tng_data,
                 double *precision);

/**
 * @brief Set the precision of lossy compression.
 * @param tng_data is the trajectory of which to set the compression precision.
 * @param precision is the new compression precision.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details A compression precision of 0.001 (the default) means that the
 * compressed values are accurate to the third decimal.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_compression_precision_set
                (tng_trajectory_t tng_data,
                 const double precision);

/**
 * @brief Set the number of particles, in the case no molecular system is used.
 * @param tng_data is the trajectory of which to get the number of particles.
 * @param n is the number of particles to use.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details When creating a molecular system the number of particles are set
 * automatically. This should only be used when there is no molecular system
 * specified or if the number of atoms needs to be overridden for some reason.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_implicit_num_particles_set
                (tng_trajectory_t tng_data,
                 const int64_t n);

/**
 * @brief Get the current number of particles.
 * @param tng_data is the trajectory from which to get the number of particles.
 * @param n is pointing to a value set to the number of particles.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @details If variable number of particles are used this function will return
 * the number of particles in the current frame set.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_particles_get
                (const tng_trajectory_t tng_data,
                 int64_t *n);

/**
 * @brief Get if the number of particle can be varied during the simulation.
 * @param tng_data is the trajectory from which to get the number of particles.
 * @param variable is pointing to a value set to TNG_CONSTANT_N_ATOMS if the
 * number of particles cannot change or TNG_VARIABLE_N_ATOMS if the number of
 * particles can change.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code variable != 0 \endcode The pointer to variable must not be
 * a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_particles_variable_get
                (const tng_trajectory_t tng_data,
                 char *variable);

/**
 * @brief Get the number of molecule types (length of tng_data->molecules).
 * @param tng_data is the trajectory from which to get the number of molecules.
 * @param n is pointing to a value set to the number of molecule types.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_molecule_types_get
                (const tng_trajectory_t tng_data,
                 int64_t *n);

/**
 * @brief Get the current total number of molecules.
 * @param tng_data is the trajectory from which to get the number of molecules.
 * @param n is pointing to a value set to the number of molecules.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @details If variable number of particles are used this function will return
 * the total number of molecules in the current frame set.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get
                (const tng_trajectory_t tng_data,
                 int64_t *n);

/** @brief Get the list of the count of each molecule.
 * @param tng_data is the trajectory from which to get the molecule count list.
 * @param mol_cnt_list is a list of the count of each molecule in the
 * mol system. This is a pointer to the list in the TNG container, which
 * means that it should be handled carefully, e.g. not freed.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE(1) if the list of
 * molecule counts was not valid.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_list_get
                (const tng_trajectory_t tng_data,
                 int64_t **mol_cnt_list);

/**
 * @brief Get the exponent used for distances in the trajectory.
 * @param tng_data is the trajectory from which to get the information.
 * @param exp is pointing to a value set to the distance unit exponent.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code exp != 0 \endcode The pointer to exp must not be a NULL pointer.
 * @details Example: If the distances are specified in nm (default) exp is -9.
 * If the distances are specified in Ã… exp is -10.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_distance_unit_exponential_get
                (const tng_trajectory_t tng_data,
                 int64_t *exp);

/**
 * @brief Set the exponent used for distances in the trajectory.
 * @param tng_data is the trajectory of which to set the unit exponent.
 * @param exp is the distance unit exponent to use.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details Example: If the distances are specified in nm (default) exp is -9.
 * If the distances are specified in Ã… exp is -10.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_distance_unit_exponential_set
                (const tng_trajectory_t tng_data,
                 const int64_t exp);

/**
 * @brief Get the number of frames per frame set.
 * @param tng_data is the trajectory from which to get the number of frames
 * per frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @param n is pointing to a value set to the number of frames per frame set.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get
                (const tng_trajectory_t tng_data,
                 int64_t *n);

/**
 * @brief Set the number of frames per frame set.
 * @param tng_data is the trajectory of which to set the number of frames
 * per frame set.
 * @param n is the number of frames per frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details This does not affect already existing frame sets. For
 * consistency the number of frames per frame set should be set
 * betfore creating any frame sets.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set
                (const tng_trajectory_t tng_data,
                 const int64_t n);

/**
 * @brief Get the number of frame sets.
 * @details This updates tng_data->n_trajectory_frame_sets before returning it.
 * @param tng_data is the trajectory from which to get the number of frame sets.
 * @param n is pointing to a value set to the number of frame sets.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                (const tng_trajectory_t tng_data,
                 int64_t *n);

/**
 * @brief Get the current trajectory frame set.
 * @param tng_data is the trajectory from which to get the frame set.
 * @param frame_set_p will be set to point at the memory position of
 * the found frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get
                (const tng_trajectory_t tng_data,
                 tng_trajectory_frame_set_t *frame_set_p);

/**
 * @brief Find the requested frame set number.
 * @param tng_data is the trajectory from which to get the frame set.
 * @param nr is the frame set number to search for.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code nr >= 0 \endcode The frame set number (nr) must be >= 0.
 * @details tng_data->current_trajectory_frame_set will contain the
 * found trajectory if successful.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
                (tng_trajectory_t tng_data,
                 const int64_t nr);

/**
 * @brief Find the frame set containing a specific frame.
 * @param tng_data is the trajectory from which to get the frame set.
 * @param frame is the frame number to search for.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame >= 0 \endcode The frame number must be >= 0.
 * @details tng_data->current_trajectory_frame_set will contain the
 * found trajectory if successful.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
                (tng_trajectory_t tng_data,
                 const int64_t frame);

/**
 * @brief Get the file position of the next frame set in the input file.
 * @param tng_data is a trajectory data container.
 * @param frame_set is the frame set of which to get the position of the
 * following frame set.
 * @param pos is pointing to a value set to the file position.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code pos != 0 \endcode The pointer to pos must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get
                (const tng_trajectory_t tng_data,
                 const tng_trajectory_frame_set_t frame_set,
                 int64_t *pos);

/**
 * @brief Get the file position of the previous frame set in the input file.
 * @param tng_data is a trajectory data container.
 * @param frame_set is the frame set of which to get the position of the
 * previous frame set.
 * @param pos is pointing to a value set to the file position.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code pos != 0 \endcode The pointer to pos must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get
                (const tng_trajectory_t tng_data,
                 const tng_trajectory_frame_set_t frame_set,
                 int64_t *pos);

/**
 * @brief Get the first and last frames of the frame set.
 * @param tng_data is a trajectory data container.
 * @param frame_set is the frame set of which to get the frame range.
 * @param first_frame is set to the first frame of the frame set.
 * @param last_frame is set to the last frame of the frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code first_frame != 0 \endcode The pointer to first_frame must
 * not be a NULL pointer.
 * @pre \code last_frame != 0 \endcode The pointer to last_frame must
 * not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get
                (const tng_trajectory_t tng_data,
                 const tng_trajectory_frame_set_t frame_set,
                 int64_t *first_frame,
                 int64_t *last_frame);

/**
 * @brief Allocate memory for and setup a molecule container.
 * @param tng_data is a trajectory data container.
 * @param molecule_p is a pointer to molecule to allocate and initialise.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_alloc(const tng_trajectory_t tng_data,
                                                         tng_molecule_t *molecule_p);

/**
 * @brief Clean up a molecule container and free its allocated memory.
 * @param tng_data is a trajectory data container.
 * @param molecule_p is the molecule to destroy.
 * @details All allocated memory in the data structure is freed and also the memory
 * of the molecule itself.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_free(const tng_trajectory_t tng_data,
                                                        tng_molecule_t *molecule_p);

/**
 * @brief Setup a molecule container.
 * @param tng_data is a trajectory data container.
 * @param molecule is the molecule to initialise. Memory must be preallocated.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_init
                (const tng_trajectory_t tng_data,
                 tng_molecule_t molecule);

/**
 * @brief Clean up a molecule container.
 * @param tng_data is a trajectory data container.
 * @param molecule is the molecule to destroy.
 * @details All allocated memory in the data structure is freed, but not the
 * memory of molecule itself.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy
                (const tng_trajectory_t tng_data,
                 tng_molecule_t molecule);

/**
 * @brief Add a molecule to the trajectory.
 * @param tng_data is the trajectory data container containing the block..
 * @param name is a pointer to the string containing the name of the new molecule.
 * @param molecule is a pointer to the newly created molecule.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_add
                (tng_trajectory_t tng_data,
                 const char *name,
                 tng_molecule_t *molecule);

/**
 * @brief Add a molecule with a specific ID to the trajectory.
 * @param tng_data is the trajectory data container containing the block..
 * @param name is a pointer to the string containing the name of the new molecule.
 * @param id is the ID of the created molecule.
 * @param molecule is a pointer to the newly created molecule.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_w_id_add
                (tng_trajectory_t tng_data,
                 const char *name,
                 const int64_t id,
                 tng_molecule_t *molecule);

/**
 * @brief Add an existing molecule (from a molecule container) to the trajectory.
 * @param tng_data is the trajectory data container containing the block..
 * @param molecule is a pointer to the molecule to add to the trajectory and will
 * afterwards point to the molecule in the trajectory.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
                (tng_trajectory_t tng_data,
                 tng_molecule_t *molecule);

/**
 * @brief Get the name of a molecule.
 * @param tng_data the trajectory containing the molecule.
 * @param molecule the molecule of which to get the name.
 * @param name the string to fill with the name of the molecule,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code molecule != 0 \endcode The molecule must not be NULL.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_name_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 char *name,
                 const int max_len);

/**
 * @brief Set the name of a molecule.
 * @param tng_data is the trajectory data container containing the molecule..
 * @param molecule is the molecule to rename.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const char *new_name);

/**
 * @brief Get the count of a molecule.
 * @param tng_data is the trajectory data container containing the molecule..
 * @param molecule is the molecule of which to get the count.
 * @param cnt is a pointer to the variable to be populated with the count.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code cnt != 0 \endcode The pointer to the molecule count
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 int64_t *cnt);

/**
 * @brief Set the count of a molecule.
 * @param tng_data is the trajectory data container containing the molecule..
 * @param molecule is the molecule of which to set the count.
 * @param cnt is the number of instances of this molecule.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const int64_t cnt);

/**
 * @brief Find a molecule.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param name is a string containing the name of the molecule. If name is empty
 * only id will be used for finding the molecule.
 * @param id is the id of the molecule to look for. If id is -1 only the name of
 * the molecule will be used for finding the molecule.
 * @param molecule is a pointer to the molecule if it was found - otherwise 0.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the molecule is found or TNG_FAILURE (1) if the
 * molecule is not found.
 * @details If name is an empty string and id == -1 the first residue will
 * be found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_find
                (tng_trajectory_t tng_data,
                 const char *name,
                 int64_t id,
                 tng_molecule_t *molecule);

/**
 * @brief Retrieve the molecule with specified index in the list of molecules.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param index is the index (in tng_data->molecules) of the molecule to return
 * @param molecule is a pointer to the molecule if it was found - otherwise 0.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the molecule is found or TNG_FAILURE (1) if the
 * molecule is not found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_of_index_get
                (tng_trajectory_t tng_data,
                 int64_t index,
                 tng_molecule_t *molecule);

/**
 * @brief Copy all molecules and the molecule counts from one TNG trajectory
 * to another.
 * @param tng_data_src is the source trajectory containing the molecular
 * system to copy.
 * @param tng_data_dest is the destination trajectory.
 * @pre \code tng_data_src != 0 \endcode The trajectory container (tng_data_src)
 * must be initialised before using it.
 * @pre \code tng_data_dest != 0 \endcode The trajectory container (tng_data_dest)
 * must be initialised before using it.
 * @details The molecular system in tng_data_dest will be overwritten.
 * @return TNG_SUCCESS(0) if the copying is successful, TNG_FAILURE if a minor
 * error has occured or TNG_CRITICAL(2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_system_copy(tng_trajectory_t tng_data_src,
                                                               tng_trajectory_t tng_data_dest);

/**
 * @brief Get the number of chains in a molecule.
 * @param tng_data is the trajectory containing the molecule.
 * @param molecule is the molecule of which to get the number of chains.
 * @param n is pointing to a value set to the number of chains.
 * @pre \code molecule != 0 \endcode The molecule must not be NULL.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_num_chains_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 int64_t *n);

/**
 * @brief Retrieve the chain of a molecule with specified index in the list
 * of chains.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param index is the index (in molecule->chains) of the chain to return
 * @param molecule is the molecule from which to get the chain.
 * @param chain is a pointer to the chain if it was found - otherwise 0.
 * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
 * @pre \code chain != 0 \endcode chain must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the chain is found or TNG_FAILURE (1) if the
 * chain is not found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_of_index_get
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 int64_t index,
                 tng_chain_t *chain);

/**
 * @brief Get the number of residues in a molecule.
 * @param tng_data is the trajectory containing the molecule.
 * @param molecule is the molecule of which to get the number residues.
 * @param n is pointing to a value set to the number of residues.
 * @pre \code molecule != 0 \endcode The molecule must not be NULL.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 int64_t *n);

/**
 * @brief Retrieve the residue of a molecule with specified index in the list
 * of chains.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param index is the index (in molecule->residues) of the residue to return
 * @param molecule is the molecule from which to get the residue.
 * @param residue is a pointer to the residue if it was found - otherwise 0.
 * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
 * @pre \code residue != 0 \endcode residue must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
 * residue is not found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 const int64_t index,
                 tng_residue_t *residue);

/**
 * @brief Get the number of atoms in a molecule.
 * @param tng_data is the trajectory containing the molecule.
 * @param molecule is the molecule of which to get the number of atoms.
 * @param n is pointing to a value set to the number of atoms.
 * @pre \code molecule != 0 \endcode The molecule must not be NULL.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 int64_t *n);

/**
 * @brief Retrieve the atom of a molecule with specified index in the list
 * of atoms.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param index is the index (in molecule->atoms) of the atom to return
 * @param molecule is the molecule from which to get the atom.
 * @param atom is a pointer to the atom if it was found - otherwise 0.
 * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
 * @pre \code atom != 0 \endcode atom must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the atom is found or TNG_FAILURE (1) if the
 * atom is not found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_of_index_get
                (const tng_trajectory_t tng_data,
                 const tng_molecule_t molecule,
                 const int64_t index,
                 tng_atom_t *atom);

/**
 * @brief Find a chain in a molecule.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param molecule is the molecule in which to search for the chain.
 * @param name is a string containing the name of the chain. If name is empty
 * only id will be used for finding the chain.
 * @param id is the id of the chain to look for. If id is -1 only the name of
 * the chain will be used for finding the chain.
 * @param chain is a pointer to the chain if it was found - otherwise 0.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the chain is found or TNG_FAILURE (1) if the
 * chain is not found.
 * @details If name is an empty string and id == -1 the first residue will
 * be found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const char *name,
                 int64_t id,
                 tng_chain_t *chain);

/**
 * @brief Add a chain to a molecule.
 * @param tng_data is the trajectory data container containing the molecule..
 * @param molecule is the molecule to add a chain to.
 * @param name is a string containing the name of the chain.
 * @param chain is a pointer to the newly created chain.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const char *name,
                 tng_chain_t *chain);

/**
 * @brief Add a chain with a specific id to a molecule.
 * @param tng_data is the trajectory data container containing the molecule..
 * @param molecule is the molecule to add a chain to.
 * @param name is a string containing the name of the chain.
 * @param id is the ID of the created chain.
 * @param chain is a pointer to the newly created chain.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_w_id_add
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const char *name,
                 const int64_t id,
                 tng_chain_t *chain);

/**
 * @brief Add a bond between two atoms to a molecule.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param molecule is the molecule containing the atoms to connect.
 * @param from_atom_id is the id of one of the two atoms in the bond.
 * @param to_atom_id is the id of the other atom in the bond.
 * @param bond is a pointer to the newly created bond.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (!) if a minor error
 * has occured or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_bond_add
                (const tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const int64_t from_atom_id,
                 const int64_t to_atom_id,
                 tng_bond_t *bond);

/**
 * @brief Find an atom in a molecule.
 * @param tng_data is the trajectory data container containing the molecule.
 * @param molecule is the molecule in which to search for the atom.
 * @param name is a string containing the name of the atom. If name is an
 * empty string only id will be used for searching.
 * @param id is the id of the atom to find. If id == -1 the first atom
 * that matches the specified name will be found.
 * @param atom is a pointer to the atom if it was found - otherwise 0.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the atom is found or TNG_FAILURE (1) if the
 * atom is not found.
 * @details If name is an empty string and id == -1 the first residue will
 * be found.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_find
                (tng_trajectory_t tng_data,
                 tng_molecule_t molecule,
                 const char *name,
                 int64_t id,
                 tng_atom_t *atom);

/**
 * @brief Get the name of a chain.
 * @param tng_data the trajectory containing the chain.
 * @param chain the chain of which to get the name.
 * @param name the string to fill with the name of the chain,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code chain != 0 \endcode The chain must not be NULL.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_name_get
                (const tng_trajectory_t tng_data,
                 const tng_chain_t chain,
                 char *name,
                 const int max_len);

/**
 * @brief Set the name of a chain.
 * @param tng_data is the trajectory data container containing the atom..
 * @param chain is the chain to rename.
 * @param new_name is a string containing the wanted name.
 * @pre \code new_name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_name_set
                (tng_trajectory_t tng_data,
                 tng_chain_t chain,
                 const char *new_name);

/**
 * @brief Get the number of residues in a molecule chain.
 * @param tng_data is the trajectory containing the chain.
 * @param chain is the chain of which to get the number of residues.
 * @param n is pointing to a value set to the number of residues.
 * @pre \code chain != 0 \endcode The chain must not be NULL.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_num_residues_get
                (const tng_trajectory_t tng_data,
                 const tng_chain_t chain,
                 int64_t *n);

/**
 * @brief Retrieve the residue of a chain with specified index in the list
 * of residues.
 * @param tng_data is the trajectory data container containing the chain.
 * @param index is the index (in chain->residues) of the residue to return
 * @param chain is the chain from which to get the residue.
 * @param residue is a pointer to the residue if it was found - otherwise 0.
 * @pre \code chain != 0 \endcode chain must not be a NULL pointer.
 * @pre \code residue != 0 \endcode residue must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
 * residue is not found.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_residue_of_index_get
                (const tng_trajectory_t tng_data,
                 const tng_chain_t chain,
                 const int64_t index,
                 tng_residue_t *residue);

/**
 * @brief Find a residue in a chain.
 * @param tng_data is the trajectory data container containing the chain.
 * @param chain is the chain in which to search for the residue.
 * @param name is a string containing the name of the residue.  If name is an
 * empty string only id will be used for searching.
 * @param id is the id of the residue to find. If id == -1 the first residue
 * that matches the specified name will be found.
 * @param residue is a pointer to the residue if it was found - otherwise 0.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
 * residue is not found.
 * @details If name is an empty string and id == -1 the first residue will
 * be found.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_residue_find
                (tng_trajectory_t tng_data,
                 tng_chain_t chain,
                 const char *name,
                 int64_t id,
                 tng_residue_t *residue);

/**
 * @brief Add a residue to a chain.
 * @param tng_data is the trajectory data container containing the chain..
 * @param chain is the chain to add a residue to.
 * @param name is a string containing the name of the residue.
 * @param residue is a pointer to the newly created residue.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add
                (tng_trajectory_t tng_data,
                 tng_chain_t chain,
                 const char *name,
                 tng_residue_t *residue);

/**
 * @brief Add a residue with a specific ID to a chain.
 * @param tng_data is the trajectory data container containing the chain..
 * @param chain is the chain to add a residue to.
 * @param name is a string containing the name of the residue.
 * @param id is the ID of the created residue.
 * @param residue is a pointer to the newly created residue.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_residue_w_id_add
                (tng_trajectory_t tng_data,
                 tng_chain_t chain,
                 const char *name,
                 const int64_t id,
                 tng_residue_t *residue);

/**
 * @brief Get the name of a residue.
 * @param tng_data the trajectory containing the residue.
 * @param residue the residue of which to get the name.
 * @param name the string to fill with the name of the residue,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code residue != 0 \endcode The residue must not be NULL.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_name_get
                (const tng_trajectory_t tng_data,
                 const tng_residue_t residue,
                 char *name,
                 const int max_len);

/**
 * @brief Set the name of a residue.
 * @param tng_data is the trajectory data container containing the residue.
 * @param residue is the residue to rename.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The new name to set (new_name) must
 * not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_name_set
                (tng_trajectory_t tng_data,
                 tng_residue_t residue,
                 const char *new_name);

/**
 * @brief Get the number of atoms in a residue.
 * @param tng_data is the trajectory containing the residue.
 * @param residue is the residue of which to get the number atoms.
 * @param n is pointing to a value set to the number of atoms.
 * @pre \code residue != 0 \endcode The residue must not be NULL.
 * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_num_atoms_get
                (const tng_trajectory_t tng_data,
                 const tng_residue_t residue,
                 int64_t *n);

/**
 * @brief Retrieve the atom of a residue with specified index in the list
 * of atoms.
 * @param tng_data is the trajectory data container containing the residue.
 * @param index is the index (in residue->atoms) of the atom to return
 * @param residue is the residue from which to get the atom.
 * @param atom is a pointer to the atom if it was found - otherwise 0.
 * @pre \code residue != 0 \endcode residue must not be a NULL pointer.
 * @pre \code atom != 0 \endcode atom must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the atom is found or TNG_FAILURE (1) if the
 * atom is not found.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_atom_of_index_get
                (const tng_trajectory_t tng_data,
                 const tng_residue_t residue,
                 const int64_t index,
                 tng_atom_t *atom);

/**
 * @brief Add an atom to a residue.
 * @param tng_data is the trajectory containing the residue.
 * @param residue is the residue to add an atom to.
 * @param atom_name is a string containing the name of the atom.
 * @param atom_type is a string containing the atom type of the atom.
 * @param atom is a pointer to the newly created atom.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code atom_name != 0 \endcode The pointer to the atom name string
 * must not be a NULL pointer.
 * @pre \code atom_type != 0 \endcode The pointer to the atom_type string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add
                (tng_trajectory_t tng_data,
                 tng_residue_t residue,
                 const char *atom_name,
                 const char *atom_type,
                 tng_atom_t *atom);

/**
 * @brief Add an atom with a specific ID to a residue.
 * @param tng_data is the trajectory containing the residue.
 * @param residue is the residue to add an atom to.
 * @param atom_name is a string containing the name of the atom.
 * @param atom_type is a string containing the atom type of the atom.
 * @param id is the ID of the created atom.
 * @param atom is a pointer to the newly created atom.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code atom_name != 0 \endcode The pointer to the atom name string
 * must not be a NULL pointer.
 * @pre \code atom_type != 0 \endcode The pointer to the atom_type string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
 * not be set properly or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_atom_w_id_add
                (tng_trajectory_t tng_data,
                 tng_residue_t residue,
                 const char *atom_name,
                 const char *atom_type,
                 const int64_t id,
                 tng_atom_t *atom);

/**
 * @brief Get the residue of an atom.
 * @param tng_data the trajectory containing the atom.
 * @param atom the atom of which to get the name.
 * @param residue is set to the residue of the atom.
 * @pre \code atom != 0 \endcode The atom must not be NULL.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status tng_atom_residue_get(const tng_trajectory_t tng_data,
                                         const tng_atom_t atom,
                                         tng_residue_t *residue);

/**
 * @brief Get the name of an atom.
 * @param tng_data the trajectory containing the atom.
 * @param atom the atom of which to get the name.
 * @param name the string to fill with the name of the atom,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for name. This includes \0 terminating character.
 * @pre \code atom != 0 \endcode The atom must not be NULL.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_atom_name_get
                (const tng_trajectory_t tng_data,
                 const tng_atom_t atom,
                 char *name,
                 const int max_len);

/**
 * @brief Set the name of an atom.
 * @param tng_data is the trajectory data container containing the atom.
 * @param atom is the atom to rename.
 * @param new_name is a string containing the wanted name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_atom_name_set
                (tng_trajectory_t tng_data,
                 tng_atom_t atom,
                 const char *new_name);

/**
 * @brief Get the type of an atom.
 * @param tng_data the trajectory containing the atom.
 * @param atom the atom of which to get the type.
 * @param type the string to fill with the type of the atom,
 * memory must be allocated before.
 * @param max_len maximum char length of the string, i.e. how much memory has
 * been reserved for type. This includes \0 terminating character.
 * @pre \code atom != 0 \endcode The atom must not be NULL.
 * @pre \code type != 0 \endcode The pointer to the type string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred (source string longer than destination string).
 */
tng_function_status DECLSPECDLLEXPORT tng_atom_type_get
                (const tng_trajectory_t tng_data,
                 const tng_atom_t atom,
                 char *type,
                 const int max_len);

/**
 * @brief Set the atom type of an atom.
 * @param tng_data is the trajectory data container containing the atom.
 * @param atom is the atom to change.
 * @param new_type is a string containing the atom type.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code new_type != 0 \endcode The pointer to the atom type string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_atom_type_set
                (tng_trajectory_t tng_data,
                 tng_atom_t atom,
                 const char *new_type);

/**
 * @brief Get the molecule name of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param name is a string, which is set to the name of the molecule. Memory
 * must be reserved beforehand.
 * @param max_len is the maximum length of name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 char *name,
                 int max_len);

/**
 * @brief Get the molecule id of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param id is will be set to the id of the molecule.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code id != 0 \endcode The pointer to id must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molecule_id_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 int64_t *id);

/**
 * @brief Get the bonds of the current molecular system.
 * @param tng_data is the trajectory data container containing the molecular
 * system.
 * @param n_bonds is set to the number of bonds in the molecular system and
 * thereby also the lengths of the two lists: from_atoms and to_atoms.
 * @param from_atoms is a list (memory reserved by this function) of atoms
 * (number of atom in mol system) in bonds.
 * @param to_atoms is a list (memory reserved by this function) of atoms
 * (number of atom in mol system) in bonds.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_bonds != 0 \endcode The pointer to n_bonds must not be a
 * NULL pointer.
 * @pre \code from_atoms != 0 \endcode The pointer to from_atoms must not
 * be a NULL pointer.
 * @pre \code to_atoms != 0 \endcode The pointer to to_atoms must not
 * be a NULL pointer.
 * @details The two lists of atoms use the same index, i.e. from_atoms[0]
 * and to_atoms[0] are linked with a bond. Since memory is reserved in
 * this function it must be freed afterwards.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_molsystem_bonds_get
                (const tng_trajectory_t tng_data,
                 int64_t *n_bonds,
                 int64_t **from_atoms,
                 int64_t **to_atoms);

/**
 * @brief Get the chain name of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param name is a string, which is set to the name of the chain. Memory
 * must be reserved beforehand.
 * @param max_len is the maximum length of name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 char *name,
                 int max_len);

/**
 * @brief Get the residue name of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param name is a string, which is set to the name of the residue. Memory
 * must be reserved beforehand.
 * @param max_len is the maximum length of name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 char *name,
                 int max_len);

/**
 * @brief Get the residue id (local to molecule) of real particle number
 * (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param id is a pointer to the variable, which will be set to the ID.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code id != 0 \endcode The pointer to id must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_residue_id_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 int64_t *id);

/**
 * @brief Get the residue id (based on other molecules and molecule counts)
 * of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param id is a pointer to the variable, which will be set to the ID.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code id != 0 \endcode The pointer to id must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_global_residue_id_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 int64_t *id);

/**
 * @brief Get the atom name of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param name is a string, which is set to the name of the atom. Memory
 * must be reserved beforehand.
 * @param max_len is the maximum length of name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 char *name,
                 int max_len);

/**
 * @brief Get the atom type of real particle number (number in mol system).
 * @param tng_data is the trajectory data container containing the atom.
 * @param nr is the real number of the particle in the molecular system.
 * @param type is a string, which is set to the type of the atom. Memory
 * must be reserved beforehand.
 * @param max_len is the maximum length of type.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code type != 0 \endcode The pointer to the type string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_atom_type_of_particle_nr_get
                (const tng_trajectory_t tng_data,
                 const int64_t nr,
                 char *type,
                 int max_len);

/**
 * @brief Add a particle mapping table.
 * @details Each particle mapping table will be written as a separate block,
 * followed by the data blocks for the corresponding particles. In most cases
 * there is one particle mapping block for each thread writing the trajectory.
 * @param tng_data is the trajectory, with the frame set to which to add
 * the mapping block.
 * @details The mapping information is added to the currently active frame set
 * of tng_data
 * @param num_first_particle is the first particle number of this mapping
 * block.
 * @param n_particles is the number of particles in this mapping block.
 * @param mapping_table is a list of the real particle numbers (i.e. the numbers
 * used in the molecular system). The list is n_particles long.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details mapping_table[0] is the real particle number of the first particle
 * in the following data blocks.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add
                (tng_trajectory_t tng_data,
                 const int64_t num_first_particle,
                 const int64_t n_particles,
                 const int64_t *mapping_table);

/**
 * @brief Remove all particle mappings (in memory) from the current frame set.
 * @details Clears the currently setup particle mappings of the current frame
 * set.
 * @param tng_data is the trajectory, with the frame set of which to clear
 * all particle mappings.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_particle_mapping_free
                (tng_trajectory_t tng_data);

/**
 * @brief Read the header blocks from the input_file of tng_data.
 * @details The trajectory blocks must be read separately and iteratively in chunks
 * to fit in memory.
 * @param tng_data is a trajectory data container.
 * @details tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_file_headers_read
                (tng_trajectory_t tng_data,
                 const char hash_mode);

/**
 * @brief Write the header blocks to the output_file of tng_data.
 * @details The trajectory blocks must be written separately and iteratively in chunks
 * to fit in memory.
 * @param tng_data is a trajectory data container.
 * @details tng_data->output_file_path
 * specifies which file to write to. If the file (output_file) is not open it
 * will be opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
 * error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_file_headers_write
                (tng_trajectory_t tng_data,
                 const char hash_mode);

/**
 * @brief Read one (the next) block (of any kind) from the input_file of tng_data.
 * @param tng_data is a trajectory data container.
 * @details tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_data is a pointer to the struct which will be populated with the
 * data.
 * @details If block_data->input_file_pos > 0 it is the position from where the
 * reading starts otherwise it starts from the current position.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code block != 0 \endcode The block container (block) must be
 * initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_block_read_next
                (tng_trajectory_t tng_data,
                 tng_gen_block_t block_data,
                 const char hash_mode);

/**
 * @brief Read one frame set, including all particle mapping blocks and data
 * blocks, starting from the current file position.
 * @param tng_data is a trajectory data container.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
                (tng_trajectory_t tng_data,
                 const char hash_mode);

/**
 * @brief Read data from the current frame set from the input_file. Only read
 * particle mapping and data blocks matching the specified block_id.
 * @param tng_data is a trajectory data container.
 * @details  tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @param block_id is the ID of the data block to read from file.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_block_id
                (tng_trajectory_t tng_data,
                 const char hash_mode,
                 const int64_t block_id);

/**
 * @brief Read one (the next) frame set, including particle mapping and related data blocks
 * from the input_file of tng_data.
 * @param tng_data is a trajectory data container.
 * @details  tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next
                (tng_trajectory_t tng_data,
                 const char hash_mode);

/**
 * @brief Read one (the next) frame set, including particle mapping and data blocks with a
 * specific block id from the input_file of tng_data.
 * @param tng_data is a trajectory data container.
 * @details  tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @param block_id is the ID number of the blocks that should be read from file.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_only_data_from_block_id
                (tng_trajectory_t tng_data,
                 const char hash_mode,
                 const int64_t block_id);

/**
 * @brief Write one frame set, including mapping and related data blocks
 * to the output_file of tng_data.
 * @param tng_data is a trajectory data container.
 * @details  tng_data->output_file_path specifies
 * which file to write to. If the file (output_file) is not open it will be
 * opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_write
                (tng_trajectory_t tng_data,
                 const char hash_mode);

/**
 * @brief Write one frame set even if it does not have as many frames as
 * expected. The function also writes mapping and related data blocks
 * to the output_file of tng_data.
 * @param tng_data is a trajectory data container.
 * @details  tng_data->output_file_path specifies
 * which file to write to. If the file (output_file) is not open it will be
 * opened.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @details The number of frames in the frame set is set to the number of
 * frames of the data blocks before writing it to disk.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_premature_write
                (tng_trajectory_t tng_data,
                 const char hash_mode);

/**
 * @brief Create and initialise a frame set.
 * @details Particle mappings are retained from previous frame set (if any).
 * To explicitly clear particle mappings use tng_frame_set_particle_mapping_free().
 * @param tng_data is the trajectory data container in which to add the frame
 * set.
 * @param first_frame is the first frame of the frame set.
 * @param n_frames is the number of frames in the frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code first_frame >= 0 \endcode The first frame must not be negative.
 * @pre \code n_frames >= 0 \endcode The number of frames must not be negative.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
                (tng_trajectory_t tng_data,
                 const int64_t first_frame,
                 const int64_t n_frames);

/**
 * @brief Create and initialise a frame set with the time of the first frame
 * specified.
 * @param tng_data is the trajectory data container in which to add the frame
 * set.
 * @param first_frame is the first frame of the frame set.
 * @param n_frames is the number of frames in the frame set.
 * @param first_frame_time is the time stamp of the first frame (in seconds).
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code first_frame >= 0 \endcode The first frame must not be negative.
 * @pre \code n_frames >= 0 \endcode The number of frames must not be negative.
 * @pre \code first_frame_time >= 0 \endcode The time stamp of the first frame
 * must not be negative.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_with_time_new
                (tng_trajectory_t tng_data,
                 const int64_t first_frame,
                 const int64_t n_frames,
                 const double first_frame_time);

/**
 * @brief Set the time stamp of the first frame of the current frame set.
 * @param tng_data is the trajectory containing the frame set.
 * @param first_frame_time is the time stamp of the first frame in the
 * frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code first_frame_time >= 0 \endcode The time stamp of the first frame
 * must not be negative.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set
                (tng_trajectory_t tng_data,
                 const double first_frame_time);

/**
 * @brief Read the number of the first frame of the next frame set.
 * @param tng_data is the trajectory containing the frame set.
 * @param frame is set to the frame number of the first frame in the
 * next frame set.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code tng_data->input_file != 0 \endcode An input file must be open
 * to find the next frame set.
 * @pre \code frame != 0 \endcode The pointer to the frame must not be a NULL
 * pointer.
 * @return TNG_SUCCESS(0) if successful, TNG_FAILURE(1) if there is no next
 * frame set or TNG_CRITICAL(2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
                (const tng_trajectory_t tng_data,
                 int64_t *frame);

/**
 * @brief Add a non-particle dependent data block.
 * @param tng_data is the trajectory data container in which to add the data
 * block
 * @param id is the block ID of the block to add.
 * @param block_name is a descriptive name of the block to add
 * @param datatype is the datatype of the data in the block (e.g. int/float)
 * @param block_type_flag indicates if this is a non-trajectory block (added
 * directly to tng_data) or if it is a trajectory block (added to the
 * frame set)
 * @param n_frames is the number of frames of the data block (automatically
 * set to 1 if adding a non-trajectory data block)
 * @param n_values_per_frame is how many values a stored each frame (e.g. 9
 * for a box shape block)
 * @param stride_length is how many frames are between each entry in the
 * data block
 * @param codec_id is the ID of the codec to compress the data.
 * @param new_data is an array of data values to add.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code block_name != 0 \endcode The pointer to the block name must
 * not be a NULL pointer.
 * @pre \code n_values_per_frame > 0 \endcode n_values_per_frame must be
 * a positive integer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_block_add
                (tng_trajectory_t tng_data,
                 const int64_t id,
                 const char *block_name,
                 const char datatype,
                 const char block_type_flag,
                 int64_t n_frames,
                 const int64_t n_values_per_frame,
                 int64_t stride_length,
                 const int64_t codec_id,
                 void *new_data);

/**
 * @brief Add a particle dependent data block.
 * @param tng_data is the trajectory data container in which to add the data
 * block
 * @param id is the block ID of the block to add.
 * @param block_name is a descriptive name of the block to add
 * @param datatype is the datatype of the data in the block (e.g. int/float)
 * @param block_type_flag indicates if this is a non-trajectory block (added
 * directly to tng_data) or if it is a trajectory block (added to the
 * frame set)
 * @param n_frames is the number of frames of the data block (automatically
 * set to 1 if adding a non-trajectory data block)
 * @param n_values_per_frame is how many values a stored each frame (e.g. 9
 * for a box shape block)
 * @param stride_length is how many frames are between each entry in the
 * data block
 * @param num_first_particle is the number of the first particle stored
 * in this data block
 * @param n_particles is the number of particles stored in this data block
 * @param codec_id is the ID of the codec to compress the data.
 * @param new_data is an array of data values to add.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code block_name != 0 \endcode The pointer to the block name must
 * not be a NULL pointer.
 * @pre \code n_values_per_frame > 0 \endcode n_values_per_frame must be
 * a positive integer.
 * @pre \code num_first_particle >= 0 \endcode The number of the
 * first particle must be >= 0.
 * @pre \code n_particles >= 0 \endcode n_particles must be >= 0.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add
                (tng_trajectory_t tng_data,
                 const int64_t id,
                 const char *block_name,
                 const char datatype,
                 const char block_type_flag,
                 int64_t n_frames,
                 const int64_t n_values_per_frame,
                 int64_t stride_length,
                 const int64_t num_first_particle,
                 const int64_t n_particles,
                 const int64_t codec_id,
                 void *new_data);

/** @brief Get the name of a data block of a specific ID.
 * @param tng_data is the trajectory data container.
 * @param block_id is the ID of the data block of which to get the name.
 * @param name is a string, which is set to the name of the data block.
 * Memory must be reserved beforehand.
 * @param max_len is the maximum length of name.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code name != 0 \endcode The pointer to the name string
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the data block is found, TNG_FAILURE (1)
 * if a minor error has occured or the data block is not found or
 * TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_block_name_get
                (tng_trajectory_t tng_data,
                 int64_t block_id,
                 char *name,
                 int max_len);

/** @brief Get the dependency of a data block of a specific ID.
 * @param tng_data is the trajectory data container.
 * @param block_id is the ID of the data block of which to get the name.
 * @param block_dependency is a pointer to the dependency of the data block.
 * If the block is frame dependent it will be set to TNG_FRAME_DEPENDENT,
 * if it is particle dependent it will be set to TNG_PARTICLE_DEPENDENT and
 * if it is both it will be set to TNG_FRAME_DEPENDENT & TNG_PARTICLE_DEPENDENT.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code block_dependency != 0 \endcode The pointer to the block dependency
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the data block is found, TNG_FAILURE (1)
 * if a minor error has occured or the data block is not found or
 * TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get
                (const tng_trajectory_t tng_data,
                 int64_t block_id,
                 int *block_dependency);

/** @brief Get the number of values per frame of a data block of a specific ID.
 * @param tng_data is the trajectory data container.
 * @param block_id is the ID of the data block of which to get the name.
 * @param n_values_per_frame is a pointer set to the number of values per frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of values
 * per frame must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if the data block is found, TNG_FAILURE (1)
 * if a minor error has occured or the data block is not found or
 * TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_block_num_values_per_frame_get
                (const tng_trajectory_t tng_data,
                 int64_t block_id,
                 int64_t *n_values_per_frame);

/**
 * @brief Write data of one trajectory frame to the output_file of tng_data.
 * @param tng_data is a trajectory data container. tng_data->output_file_path
 * specifies which file to write to. If the file (output_file) is not open it
 * will be opened.
 * @param frame_nr is the index number of the frame to write.
 * @param block_id is the ID of the data block to write the data to.
 * @param values is an array of data to write. The length of the array should
 * equal n_values_per_frame.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code values != 0 \endcode The pointer to the values must not be a NULL
 * pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const int64_t block_id,
                 const void *values,
                 const char hash_mode);

/**
 * @brief Write particle data of one trajectory frame to the output_file of
 * tng_data.
 * @param tng_data is a trajectory data container. tng_data->output_file_path
 * specifies which file to write to. If the file (output_file) is not open it
 * will be opened.
 * @param frame_nr is the index number of the frame to write.
 * @param block_id is the ID of the data block to write the data to.
 * @param val_first_particle is the number of the first particle in the data
 * array.
 * @param val_n_particles is the number of particles in the data array.
 * @param values is a 1D-array of data to write. The length of the array should
 * equal n_particles * n_values_per_frame.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code val_first_particle >= 0 \endcode The number of the
 * first particle must be >= 0.
 * @pre \code val_n_particles >= 0 \endcode The number of particles must be >= 0.
 * @pre \code values != 0 \endcode The pointer to the values must not be a NULL
 * pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const int64_t block_id,
                 const int64_t val_first_particle,
                 const int64_t val_n_particles,
                 const void *values,
                 const char hash_mode);

/**
 * @brief Free data of an array of values (2D).
 * @param tng_data is a trajectory data container.
 * @param values is the 2D array to free and will be set to 0 afterwards.
 * @param n_frames is the number of frames in the data array.
 * @param n_values_per_frame is the number of values per frame in the data array.
 * @param type is the data type of the data in the array (e.g. int/float/char).
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_values_free
                (const tng_trajectory_t tng_data,
                 union data_values **values,
                 const int64_t n_frames,
                 const int64_t n_values_per_frame,
                 const char type);

/**
 * @brief Free data of an array of values (3D).
 * @param tng_data is a trajectory data container.
 * @param values is the array to free and will be set to 0 afterwards.
 * @param n_frames is the number of frames in the data array.
 * @param n_particles is the number of particles in the data array.
 * @param n_values_per_frame is the number of values per frame in the data array.
 * @param type is the data type of the data in the array (e.g. int/float/char).
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free
                (const tng_trajectory_t tng_data,
                 union data_values ***values,
                 const int64_t n_frames,
                 const int64_t n_particles,
                 const int64_t n_values_per_frame,
                 const char type);

/**
 * @brief Retrieve non-particle data, from the last read frame set. Obsolete!
 * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_id is the id number of the particle data block to read.
 * @param values is a pointer to a 2-dimensional array (memory unallocated), which
 * will be filled with data. The array will be sized
 * (n_frames * n_values_per_frame).
 * Since ***values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param n_frames is set to the number of frames in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_frames != 0 \endcode The pointer to the number of frames
 * must not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This function is obsolete and only retained for compatibility. Use
 * tng_data_vector_get() instead.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_get(tng_trajectory_t tng_data,
                                                   const int64_t block_id,
                                                   union data_values ***values,
                                                   int64_t *n_frames,
                                                   int64_t *n_values_per_frame,
                                                   char *type);

/**
 * @brief Retrieve a vector (1D array) of non-particle data, from the last read frame set.
 * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_id is the id number of the particle data block to read.
 * @param values is a pointer to a 1-dimensional array (memory unallocated), which
 * will be filled with data. The length of the array will be (n_frames * n_values_per_frame).
 * Since **values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param n_frames is set to the number of particles in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param stride_length is set to the stride length of the returned data.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_frames != 0 \endcode The pointer to the number of frames
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This does only work for numerical (int, float, double) data.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_vector_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 void **values,
                 int64_t *n_frames,
                 int64_t *stride_length,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Read and retrieve non-particle data, in a specific interval. Obsolete!
 * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_id is the id number of the particle data block to read.
 * @param start_frame_nr is the index number of the first frame to read.
 * @param end_frame_nr is the index number of the last frame to read.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @param values is a pointer to a 2-dimensional array (memory unallocated), which
 * will be filled with data. The array will be sized
 * (n_frames * n_values_per_frame).
 * Since ***values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This function is obsolete and only retained for compatibility. Use
 * tng_data_vector_interval_get() instead.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_interval_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 const int64_t start_frame_nr,
                 const int64_t end_frame_nr,
                 const char hash_mode,
                 union data_values ***values,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Read and retrieve a vector (1D array) of non-particle data,
 * in a specific interval.
 * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_id is the id number of the particle data block to read.
 * @param start_frame_nr is the index number of the first frame to read.
 * @param end_frame_nr is the index number of the last frame to read.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @param values is a pointer to a 1-dimensional array (memory unallocated), which
 * will be filled with data. The length of the array will be (n_frames * n_values_per_frame).
 * Since **values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param stride_length is set to the stride length (writing interval) of
 * the data.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This does only work for numerical (int, float, double) data.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_vector_interval_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 const int64_t start_frame_nr,
                 const int64_t end_frame_nr,
                 const char hash_mode,
                 void **values,
                 int64_t *stride_length,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Retrieve particle data, from the last read frame set. Obsolete!
 * @details The particle dimension of the returned values array is translated
 * to real particle numbering, i.e. the numbering of the actual molecular
 * system.
 * @param tng_data is a trajectory data container. tng_data->input_file_path
 * specifies which file to read from. If the file (input_file) is not open it
 * will be opened.
 * @param block_id is the id number of the particle data block to read.
 * @param values is a pointer to a 3-dimensional array (memory unallocated), which
 * will be filled with data. The array will be sized
 * (n_frames * n_particles * n_values_per_frame).
 * Since ****values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param n_frames is set to the number of frames in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param n_particles is set to the number of particles in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_frames != 0 \endcode The pointer to the number of frames
 * must not be a NULL pointer.
 * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
 * not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This function is obsolete and only retained for compatibility. Use
 * tng_particle_data_vector_get() instead.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_data_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 union data_values ****values,
                 int64_t *n_frames,
                 int64_t *n_particles,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Retrieve a vector (1D array) of particle data, from the last read frame set.
 * @details The particle dimension of the returned values array is translated
 * to real particle numbering, i.e. the numbering of the actual molecular
 * system.
 * @param tng_data is a trajectory data container. tng_data->input_file_path
 * specifies which file to read from. If the file (input_file) is not open it
 * will be opened.
 * @param block_id is the id number of the particle data block to read.
 * @param values is a pointer to a 1-dimensional array (memory unallocated), which
 * will be filled with data. The length of the array will be
 * (n_frames * n_particles * n_values_per_frame).
 * Since **values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param n_frames is set to the number of frames in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param stride_length is set to the stride length of the returned data.
 * @param n_particles is set to the number of particles in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
 * not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This does only work for numerical (int, float, double) data.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 void **values,
                 int64_t *n_frames,
                 int64_t *stride_length,
                 int64_t *n_particles,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Read and retrieve particle data, in a specific interval. Obsolete!
 * @details The particle dimension of the returned values array is translated
 * to real particle numbering, i.e. the numbering of the actual molecular
 * system.
 * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_id is the id number of the particle data block to read.
 * @param start_frame_nr is the index number of the first frame to read.
 * @param end_frame_nr is the index number of the last frame to read.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @param values is a pointer to a 3-dimensional array (memory unallocated), which
 * will be filled with data. The array will be sized
 * (n_frames * n_particles * n_values_per_frame).
 * Since ****values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param n_particles is set to the number of particles in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_frames != 0 \endcode The pointer to the number of frames
 * must not be a NULL pointer.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
 * not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This function is obsolete and only retained for compatibility. Use
 * tng_particle_data_vector_interval_get() instead.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 const int64_t start_frame_nr,
                 const int64_t end_frame_nr,
                 const char hash_mode,
                 union data_values ****values,
                 int64_t *n_particles,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Read and retrieve a vector (1D array) particle data, in a
 * specific interval.
 * @details The particle dimension of the returned values array is translated
 * to real particle numbering, i.e. the numbering of the actual molecular
 * system.
 * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
 * which file to read from. If the file (input_file) is not open it will be
 * opened.
 * @param block_id is the id number of the particle data block to read.
 * @param start_frame_nr is the index number of the first frame to read.
 * @param end_frame_nr is the index number of the last frame to read.
 * @param hash_mode is an option to decide whether to use the md5 hash or not.
 * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
 * compared to the md5 hash of the read contents to ensure valid data.
 * @param values is a pointer to a 1-dimensional array (memory unallocated), which
 * will be filled with data. The length of the array will be
 * (n_frames * n_particles * n_values_per_frame).
 * Since **values is allocated in this function it is the callers
 * responsibility to free the memory.
 * @param stride_length is set to the stride length (writing interval) of
 * the data.
 * @param n_particles is set to the number of particles in the returned data. This is
 * needed to properly reach and/or free the data afterwards.
 * @param n_values_per_frame is set to the number of values per frame in the data.
 * This is needed to properly reach and/or free the data afterwards.
 * @param type is set to the data type of the data in the array.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
 * not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
 * values per frame must not be a NULL pointer.
 * @pre \code type != 0 \endcode The pointer to the data type must not
 * be a NULL pointer.
 * @details This does only work for numerical (int, float, double) data.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 const int64_t start_frame_nr,
                 const int64_t end_frame_nr,
                 const char hash_mode,
                 void **values,
                 int64_t *n_particles,
                 int64_t *stride_length,
                 int64_t *n_values_per_frame,
                 char *type);

/**
 * @brief Get the stride length of a specific data (particle dependency does not matter)
 * block, either in the current frame set or of a specific frame.
 * @param tng_data is the trajectory data container.
 * @param block_id is the block ID of the data block, of which to retrieve the
 * stride length of the data.
 * @param frame is the frame from which to get the stride length. If frame is set to -1
 * no specific frame will be used, but instead the first frame, starting from the last read
 * frame set, containing the data block will be used.
 * @param stride_length is set to the value of the stride length of the data block.
 * @return  TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occurred or TNG_CRITICAL (2) if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
                (const tng_trajectory_t tng_data,
                 const int64_t block_id,
                 int64_t frame,
                 int64_t *stride_length);

/**
 * @brief Get the date and time of initial file creation in ISO format (string).
 * @param tng_data is a trajectory data container.
 * @param time is a pointer to the string in which the date will be stored. Memory
 * must be reserved beforehand.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code time != 0 \endcode The pointer to the time must not be a NULL
 * pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_time_get_str
                (const tng_trajectory_t tng_data,
                 char *time);
/** @} */ /* end of group1 */

/** @defgroup group2 High-level API
 *  These functions make it easier to access and output TNG data. They
 *  are recommended unless there is a special reason to use the more
 *  detailed functions available in the low-level API.
 *  @{
 */

/**
 * @brief High-level function for opening and initializing a TNG trajectory.
 * @param filename is a string containing the name of the trajectory to open.
 * @param mode specifies the file mode of the trajectory. Can be set to 'r',
 * 'w' or 'a' for reading, writing or appending respectively.
 * @param tng_data_p is a pointer to the opened trajectory. This will be
 * allocated by the TNG library. The trajectory must be
 * closed by the user, whereby memory is freed.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code filename != 0 \endcode The pointer to the filename must not be a
 * NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_open
                (const char *filename,
                 const char mode,
                 tng_trajectory_t *tng_data_p);

/**
 * @brief High-level function for closing a TNG trajectory.
 * @param tng_data_p is a pointer to the trajectory to close. The memory
 * will be freed after finalising the writing.
 * @return TNG_SUCCESS (0) if successful.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_close
                (tng_trajectory_t *tng_data_p);

/**
 * @brief High-level function for getting the time (in seconds) of a frame.
 * @param tng_data is the trajectory containing the frame.
 * @param frame_nr is the frame number of which to get the time.
 * @param time is set to the time (in seconds) of the specified frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code time != 0 \endcode The pointer to the time must not be a
 * NULL pointer.
 * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if a
 * minor error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_time_of_frame_get
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 double *time);

/*
 * @brief High-level function for getting the molecules in the mol system.
 * @param tng_data is the trajectory containing the mol system.
 * @param n_mols is set to the number of molecules in the system.
 * @param molecule_cnt_list will be pointing to the list of counts of each molecule
 * in the mol system.
 * @param mols pointing to the list of molecules in the mol system.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_mols != 0 \endcode The pointer to the number of molecules must
 * not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful.
 */
/*tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_molecules_get
                (tng_trajectory_t tng_data,
                 int64_t *n_mols,
                 int64_t **molecule_cnt_list,
                 tng_molecule_t *mols);
*/
/*
 * @brief High-level function for adding a molecule to the mol system.
 * @param tng_data is the trajectory containing the mol system.
 * @param name is the name of the molecule to add.
 * @param cnt is the count of the molecule.
 * @param mol is set to point to the newly created molecule.
 * @pre \code name != 0 \endcode The pointer to the name must not be a
 * NULL pointer.
 * @pre \code cnt >= 0 \endcode The requested count must be >= 0.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured or TNG_CRITICAL (2) if a major error has occured.
 */
/*tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_molecule_add
                (tng_trajectory_t tng_data,
                 const char *name,
                 const int64_t cnt,
                 tng_molecule_t *mol);
*/
/*
// tng_function_status DECLSPECDLLEXPORT tng_util_molecule_particles_get
//                 (tng_trajectory_t tng_data,
//                  const tng_molecule_t mol,
//                  int64_t *n_particles,
//                  char ***names,
//                  char ***types,
//                  char ***res_names,
//                  int64_t **res_ids,
//                  char ***chain_names,
//                  int64_t **chain_ids);
//
// tng_function_status DECLSPECDLLEXPORT tng_util_molecule_particles_set
//                 (tng_trajectory_t tng_data,
//                  tng_molecule_t mol,
//                  const int64_t n_particles,
//                  const char **names,
//                  const char **types,
//                  const char **res_names,
//                  const int64_t *res_ids,
//                  const char **chain_names,
//                  const int64_t *chain_ids);
*/
/**
 * @brief High-level function for reading the positions of all particles
 * from all frames.
 * @param tng_data is the trajectory to read from.
 * @param positions will be set to point at a 1-dimensional array of floats,
 * which will contain the positions. The data is stored sequentially in order
 * of frames. For each frame the positions (x, y and z coordinates) are stored.
 * The variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code positions != 0 \endcode The pointer to the positions array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_read
                (tng_trajectory_t tng_data,
                 float **positions,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the velocities of all particles
 * from all frames.
 * @param tng_data is the trajectory to read from.
 * @param velocities will be set to point at a 1-dimensional array of floats,
 * which will contain the velocities. The data is stored sequentially in order
 * of frames. For each frame the velocities (in x, y and z) are stored. The
 * variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code velocities != 0 \endcode The pointer to the velocities array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_read
                (tng_trajectory_t tng_data,
                 float **velocities,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the forces of all particles
 * from all frames.
 * @param tng_data is the trajectory to read from.
 * @param forces will be set to point at a 1-dimensional array of floats,
 * which will contain the forces. The data is stored sequentially in order
 * of frames. For each frame the forces (in x, y and z) are stored. The
 * variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code forces != 0 \endcode The pointer to the forces array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_read
                (tng_trajectory_t tng_data,
                 float **forces,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the box shape from all frames.
 * @param tng_data is the trajectory to read from.
 * @param box_shape will be set to point at a 1-dimensional array of floats,
 * which will contain the box shape. The data is stored sequentially in order
 * of frames. The variable may point at already allocated memory or be a NULL pointer.
 * If the box shape is not modified during the trajectory, but as general data,
 * that will be returned instead.
 * @param stride_length will be set to the writing interval of the stored data.
 * @details This function should only be used if number of values used to specify
 * the box shape is known (by default TNG uses 9 values) since it does not
 * return the number of values in the array. It is recommended to use
 * tng_data_vector_interval_get() instead.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code box_shape != 0 \endcode The pointer to the box_shape array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read
                (tng_trajectory_t tng_data,
                 float **box_shape,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the next frame of particle-dependent
 * data of a specific type.
 * @param tng_data is the trajectory to read from.
 * @param block_id is the ID number of the block containing the data of interest.
 * @param values will be set to point at a 1-dimensional array containing the
 * requested data. The variable may point at already allocated memory or be a
 * NULL pointer. The memory must be freed afterwards.
 * @param data_type will be pointing to a character indicating the size of the
 * data of the returned values, e.g. TNG_INT_DATA, TNG_FLOAT_DATA or TNG_DOUBLE_DATA.
 * @param retrieved_frame_number will be pointing at the frame number of the
 * returned frame.
 * @param retrieved_time will be pointing at the time stamp of the returned
 * frame.
 * @details If no frame has been read before the first frame of the trajectory
 * is read.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code values != 0 \endcode The pointer to the values array
 * must not be a NULL pointer.
 * @pre \code data_type != 0 \endcode The pointer to the data type of the
 * returned data must not be a NULL pointer.
 * @pre \code retrieved_frame_number != 0 \endcode The pointer to the frame
 * number of the returned data must not be a NULL pointer.
 * @pre \code retrieved_time != 0 \endcode The pointer to the time of the
 * returned data must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_particle_data_next_frame_read
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 void **values,
                 char *data_type,
                 int64_t *retrieved_frame_number,
                 double *retrieved_time);

/**
 * @brief High-level function for reading the next frame of non-particle-dependent
 * data of a specific type.
 * @param tng_data is the trajectory to read from.
 * @param block_id is the ID number of the block containing the data of interest.
 * @param values will be set to point at a 1-dimensional array containing the
 * requested data. The variable may point at already allocated memory or be a
 * NULL pointer. The memory must be freed afterwards.
 * @param data_type will be pointing to a character indicating the size of the
 * data of the returned values, e.g. TNG_INT_DATA, TNG_FLOAT_DATA or TNG_DOUBLE_DATA.
 * @param retrieved_frame_number will be pointing at the frame number of the
 * returned frame.
 * @param retrieved_time will be pointing at the time stamp of the returned
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code values != 0 \endcode The pointer to the values array
 * must not be a NULL pointer.
 * @pre \code data_type != 0 \endcode The pointer to the data type of the
 * returned data must not be a NULL pointer.
 * @pre \code retrieved_frame_number != 0 \endcode The pointer to the frame
 * number of the returned data must not be a NULL pointer.
 * @pre \code retrieved_time != 0 \endcode The pointer to the time of the
 * returned data must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_non_particle_data_next_frame_read
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 void **values,
                 char *data_type,
                 int64_t *retrieved_frame_number,
                 double *retrieved_time);

/**
 * @brief High-level function for reading the positions of all particles
 * from a specific range of frames.
 * @param tng_data is the trajectory to read from.
 * @param first_frame is the first frame to return position data from.
 * @param last_frame is the last frame to return position data from.
 * @param positions will be set to point at a 1-dimensional array of floats,
 * which will contain the positions. The data is stored sequentially in order
 * of frames. For each frame the positions (x, y and z coordinates) are stored.
 * The variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code positions != 0 \endcode The pointer to the positions array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_read_range
                (tng_trajectory_t tng_data,
                 const int64_t first_frame,
                 const int64_t last_frame,
                 float **positions,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the velocities of all particles
 * from a specific range of frames.
 * @param tng_data is the trajectory to read from.
 * @param first_frame is the first frame to return position data from.
 * @param last_frame is the last frame to return position data from.
 * @param velocities will be set to point at a 1-dimensional array of floats,
 * which will contain the velocities. The data is stored sequentially in order
 * of frames. For each frame the velocities (in x, y and z) are stored. The
 * variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code velocities != 0 \endcode The pointer to the velocities array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_read_range
                (tng_trajectory_t tng_data,
                 const int64_t first_frame,
                 const int64_t last_frame,
                 float **velocities,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the forces of all particles
 * from a specific range of frames.
 * @param tng_data is the trajectory to read from.
 * @param first_frame is the first frame to return position data from.
 * @param last_frame is the last frame to return position data from.
 * @param forces will be set to point at a 1-dimensional array of floats,
 * which will contain the forces. The data is stored sequentially in order
 * of frames. For each frame the forces (in x, y and z) are stored. The
 * variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code forces != 0 \endcode The pointer to the forces array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_read_range
                (tng_trajectory_t tng_data,
                 const int64_t first_frame,
                 const int64_t last_frame,
                 float **forces,
                 int64_t *stride_length);

/**
 * @brief High-level function for reading the box shape
 * from a specific range of frames.
 * @param tng_data is the trajectory to read from.
 * @param first_frame is the first frame to return position data from.
 * @param last_frame is the last frame to return position data from.
 * @param box_shape will be set to point at a 1-dimensional array of floats,
 * which will contain the box shape. The data is stored sequentially in order
 * of frames.
 * If the box shape is not modified during the trajectory, but as general data,
 * that will be returned instead. The
 * variable may point at already allocated memory or be a NULL pointer.
 * The memory must be freed afterwards.
 * @param stride_length will be set to the writing interval of the stored data.
 * @details This function should only be used if number of values used to specify
 * the box shape is known (by default TNG uses 9 values) since it does not
 * return the number of values in the array. It is recommended to use
 * tng_data_vector_interval_get() instead.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
 * the last frame.
 * @pre \code box_shape != 0 \endcode The pointer to the box_shape array
 * must not be a NULL pointer.
 * @pre \code stride_length != 0 \endcode The pointer to the stride length
 * must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_range
                (tng_trajectory_t tng_data,
                 const int64_t first_frame,
                 const int64_t last_frame,
                 float **box_shape,
                 int64_t *stride_length);

/**
 * @brief High-level function for setting the writing interval of data blocks.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_interval_set
                (tng_trajectory_t tng_data,
                 const int64_t i,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for setting the writing interval of data blocks
 * containing double precision data.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_interval_double_set
                (tng_trajectory_t tng_data,
                 const int64_t i,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for setting the writing interval of data blocks.
 * Obsolete! Use tng_util_generic_write_interval_set()
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * This function is replaced by the more correcly named
 * tng_util_generic_write_interval_set(), but is kept for compatibility.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set
                (tng_trajectory_t tng_data,
                 const int64_t i,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for setting the writing interval of position
 * data blocks.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a positions data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_interval_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of position
 * data blocks containing double precision data.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a positions data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_interval_double_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of position
 * data blocks. Obsolete! Use tng_util_pos_write_interval_set()
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a positions data block if none exists.
 * This function is replaced by the more correcly named
 * tng_util_pos_write_interval_set(), but is kept for compatibility.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_frequency_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of velocity
 * data blocks.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a velocities data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_interval_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of velocity
 * data blocks containing double precision data.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a velocities data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_interval_double_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of velocity
 * data blocks. Obsolete! Use tng_util_vel_write_interval_set()
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a velocities data block if none exists.
 * This function is replaced by the more correcly named
 * tng_util_vel_write_interval_set(), but is kept for compatibility.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_frequency_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of force
 * data blocks.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a forces data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_write_interval_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of force
 * data blocks containing double precision data.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a forces data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_write_interval_double_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of force
 * data blocks. Obsolete! Use tng_util_force_write_interval_set()
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a forces data block if none exists.
 * This function is replaced by the more correcly named
 * tng_util_force_write_interval_set(), but is kept for compatibility.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_write_frequency_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of box shape
 * data blocks.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a box shape data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_interval_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of box shape
 * data blocks containing double precision data.
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code i >= 0 \endcode The writing interval must be >= 0.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a box shape data block if none exists.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_interval_double_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for setting the writing interval of velocity
 * data blocks. Obsolete! Use tng_util_box_shape_write_interval_set()
 * @param tng_data is the trajectory to use.
 * @param i is the output interval, i.e. i == 10 means data written every 10th
 * frame.
 * @details This function uses tng_util_generic_write_interval_set() and will
 * create a box shape data block if none exists.
 * This function is replaced by the more correcly named
 * tng_util_box_shape_write_interval_set(), but is kept for compatibility.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set
                (tng_trajectory_t tng_data,
                 const int64_t i);

/**
 * @brief High-level function for writing data of one frame to a data block.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param values is a 1D array of data to add. The array should be of length
 * n_particles * n_values_per_frame if writing particle related data, otherwise
 * it should be n_values_per_frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code values != 0 \endcode The pointer to the values array must not
 * be a NULL pointer.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * N.b. Data is written a whole block at a time. The data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const float *values,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for writing data of one frame to a double precision
 * data block.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param values is a 1D array of data to add. The array should be of length
 * n_particles * n_values_per_frame if writing particle related data, otherwise
 * it should be n_values_per_frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code values != 0 \endcode The pointer to the values array must not
 * be a NULL pointer.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * N.b. Data is written a whole block at a time. The data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double *values,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for adding data to positions data blocks.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param positions is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code positions != 0 \endcode The pointer to the positions array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a positions data block if none exists. Positions are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const float *positions);

/**
 * @brief High-level function for adding data to positions data blocks at double
 * precision.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param positions is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code positions != 0 \endcode The pointer to the positions array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a positions data block if none exists. Positions are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double *positions);

/**
 * @brief High-level function for adding data to velocities data blocks.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param velocities is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a velocities data block if none exists. Velocities are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const float *velocities);

/**
 * @brief High-level function for adding data to velocities data blocks at double
 * precision.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param velocities is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a velocities data block if none exists. Velocities are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double *velocities);

/**
 * @brief High-level function for adding data to forces data blocks.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param forces is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code forces != 0 \endcode The pointer to the forces array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a forces data block if none exists. Forces are stored as three
 * values per frame and compressed using gzip compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const float *forces);

/**
 * @brief High-level function for adding data to forces data blocks at double
 * precision.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param forces is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code forces != 0 \endcode The pointer to the forces array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a forces data block if none exists. Forces are stored as three
 * values per frame and compressed using gzip compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double *forces);

/**
 * @brief High-level function for adding data to box shape data blocks.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param box_shape is a 1D array of data to add. The array should be of length 9.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a box shape data block if none exists. Box shapes are stored as 9
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const float *box_shape);

/**
 * @brief High-level function for adding data to box shape data blocks at double
 * precision.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param box_shape is a 1D array of data to add. The array should be of length 9.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_write() and will
 * create a box shape data block if none exists. Box shapes are stored as 9
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double *box_shape);

/**
 * @brief High-level function for writing data of one frame to a data block.
 * If the frame is at the beginning of a frame set the time stamp of the frame
 * set is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param values is a 1D array of data to add. The array should be of length
 * n_particles * n_values_per_frame if writing particle related data, otherwise
 * it should be n_values_per_frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code values != 0 \endcode The pointer to the values array must not
 * be a NULL pointer.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * N.b. Data is written a whole block at a time. The data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_with_time_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const float *values,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for writing data of one frame to a double precision
 * data block. If the frame is at the beginning of a frame set the time stamp of
 * the frame set is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param values is a 1D array of data to add. The array should be of length
 * n_particles * n_values_per_frame if writing particle related data, otherwise
 * it should be n_values_per_frame.
 * @param n_values_per_frame is the number of values to store per frame. If the
 * data is particle dependent there will be n_values_per_frame stored per
 * particle each frame.
 * @param block_id is the ID of the block, of which to set the output interval.
 * @param block_name is a string that will be used as name of the block. Only
 * required if the block did not exist, i.e. a new block is created.
 * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
 * data is not related to specific particles (e.g. box shape) or
 * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
 * positions). Only required if the block did not exist, i.e. a new block is
 * created.
 * @param compression is the compression routine to use when writing the data.
 * Only required if the block did not exist, i.e. a new block is created.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code values != 0 \endcode The pointer to the values array must not
 * be a NULL pointer.
 * @details n_values_per_frame, block_name, particle_dependency and
 * compression are only used if the data block did not exist before calling
 * this function, in which case it is created.
 * N.b. Data is written a whole block at a time. The data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_generic_with_time_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const double *values,
                 const int64_t n_values_per_frame,
                 const int64_t block_id,
                 const char *block_name,
                 const char particle_dependency,
                 const char compression);

/**
 * @brief High-level function for adding data to positions data blocks. If the
 * frame is at the beginning of a frame set the time stamp of the frame set
 * is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param positions is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code positions != 0 \endcode The pointer to the positions array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_write() and will
 * create a positions data block if none exists. Positions are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_with_time_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const float *positions);

/**
 * @brief High-level function for adding data to positions data blocks at double
 * precision. If the frame is at the beginning of a frame set the time stamp of
 * the frame set is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param positions is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code positions != 0 \endcode The pointer to the positions array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_double_write() and will
 * create a positions data block if none exists. Positions are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_pos_with_time_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const double *positions);

/**
 * @brief High-level function for adding data to velocities data blocks. If the
 * frame is at the beginning of a frame set the time stamp of the frame set
 * is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param velocities is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_write() and will
 * create a velocities data block if none exists. Velocities are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_with_time_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const float *velocities);

/**
 * @brief High-level function for adding data to velocities data blocks at
 * double precision. If the frame is at the beginning of a frame set the
 * time stamp of the frame set is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param velocities is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_double_write() and will
 * create a velocities data block if none exists. Velocities are stored as three
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_vel_with_time_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const double *velocities);

/**
 * @brief High-level function for adding data to forces data blocks. If the
 * frame is at the beginning of a frame set the time stamp of the frame set
 * is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param forces is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code forces != 0 \endcode The pointer to the forces array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_write() and will
 * create a forces data block if none exists. Forces are stored as three
 * values per frame and compressed using gzip compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_with_time_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const float *forces);

/**
 * @brief High-level function for adding data to forces data blocks at
 * double precision. If the frame is at the beginning of a frame set
 * the time stamp of the frame set is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param forces is a 1D array of data to add. The array should be of length
 * n_particles * 3.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code forces != 0 \endcode The pointer to the forces array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_double_write() and will
 * create a forces data block if none exists. Forces are stored as three
 * values per frame and compressed using gzip compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_force_with_time_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const double *forces);

/**
 * @brief High-level function for adding data to box shape data blocks. If the
 * frame is at the beginning of a frame set the time stamp of the frame set
 * is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param box_shape is a 1D array of data to add. The array should be of length 9.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_write() and will
 * create a box shape data block if none exists. Box shapes are stored as 9
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const float *box_shape);

/**
 * @brief High-level function for adding data to box shape data blocks at
 * double precision. If the frame is at the beginning of a frame set the
 * time stamp of the frame set is set.
 * @param tng_data is the trajectory to use.
 * @param frame_nr is the frame number of the data.
 * @param time is the time stamp of the frame (in seconds).
 * @param box_shape is a 1D array of data to add. The array should be of length 9.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
 * @pre \code time >= 0 \endcode The time stamp must be >= 0.
 * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
 * be a NULL pointer.
 * @details This function uses tng_util_generic_with_time_double_write() and will
 * create a box shape data block if none exists. Box shapes are stored as 9
 * values per frame and compressed using TNG compression.
 * N.b. Since compressed data is written a whole block at a time the data is not
 * actually written to disk until the frame set is finished or the TNG
 * trajectory is closed.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_double_write
                (tng_trajectory_t tng_data,
                 const int64_t frame_nr,
                 const double time,
                 const double *box_shape);

/**
 * @brief High-level function for getting the compression method and
 * multiplication factor of the last read frame of a specific data block.
 * @param tng_data is the trajectory to use.
 * @param block_id is the ID number of the block containing the data of
 * interest.
 * @param codec_id will be set to the value of the codec_id of the
 * compression of the data block. See tng_compression for more details.
 * @param factor will be set to the multiplication factor applied to
 * the values before compression, in order to get integers from them.
 * factor is 1/precision.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code codec_id != 0 \endcode  The pointer to the returned codec id
 * must not be a NULL pointer.
 * @pre \code factor != 0 \endcode The pointer to the returned multiplication
 * factor must not be a NULL pointer.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
                (tng_trajectory_t tng_data,
                 const int64_t block_id,
                 int64_t *codec_id,
                 float *factor);

/** @brief High-level function for determining the next frame with data and what
 * data blocks have data for that frame. The search can be limited to certain
 * data blocks.
 * @param tng_data is the trajectory to use.
 * @param current_frame is the frame that was last read, from where to start
 * looking for data.
 * @param n_requested_data_block_ids is the number of data blocks listed in
 * requested_data_block_ids. If this is 0 all data blocks will be taken into
 * account.
 * @param requested_data_block_ids is an array of data blocks to look for.
 * @param next_frame will be set to the next frame with data.
 * @param n_data_blocks_in_next_frame is set to the number of data blocks with
 * data for next_frame.
 * @param data_block_ids_in_next_frame is set to an array (of length
 * n_data_blocks_in_next_frame) that lists the data block IDs with data for
 * next_frame. It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code next_frame != 0 \endcode The pointer to the next frame must not
 * be NULL.
 * @pre \code n_data_blocks_in_next_frame != 0 \endcode The pointer to
 * n_data_blocks_in_next_frame must not be NULL.
 * @pre \code *data_block_ids_in_next_frame != 0 \endcode The pointer to the
 * list of data block IDs must not be NULL.
 * @pre \code n_requested_data_block_ids == 0 || requested_data_block_ids != 0 \endcode
 * If the number of requested data blocks != 0 then the array of data block IDs must not be NULL.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured or TNG_CRITICAL (2) if a major error
 * has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_data_blocks_find
                (tng_trajectory_t tng_data,
                 int64_t current_frame,
                 const int64_t n_requested_data_block_ids,
                 const int64_t *requested_data_block_ids,
                 int64_t *next_frame,
                 int64_t *n_data_blocks_in_next_frame,
                 int64_t **data_block_ids_in_next_frame);

/* @brief High-level function for getting all data block ids and their names
 * and stride lengths.
 * @param tng_data is the trajectory to use.
 * @param n_data_blocks is set to the number of data blocks in the trajectory.
 * @param data_block_ids is set to an array (of length
 * n_data_blocks) that lists the data block IDs in the trajectory.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @param data_block_names is set to an array (of length
 * n_data_blocks) that contains the names of the data blocks.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @param stride_lengths is set to an array (of length
 * n_data_blocks) that lists the stride lengths of the data blocks.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @param n_values_per_frame is set to an array (of length
 * n_data_blocks) that lists the number of values per frame of the data blocks.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @param block_types is set to an array (of length
 * n_data_blocks) that lists the block types of the data blocks.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @param dependencies is set to an array (of length
 * n_data_blocks) that lists the dependencies of the data blocks.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @param compressions is set to an array (of length
 * n_data_blocks) that lists the compressions of the data blocks.
 * It must be pointing at NULL or previously allocated memory.
 * Memory for the array is allocated by this function.
 * The memory must be freed by the client afterwards or
 * there will be a memory leak.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code n_data_blocks != 0 \endcode The pointer to
 * n_data_blocks must not be NULL.
 * @pre \code data_block_ids != 0 \endcode The pointer to the
 * list of data block IDs must not be NULL.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured or TNG_CRITICAL (2) if a major error
 * has occured.
 */
/*
tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_all_data_block_types_get
                (tng_trajectory_t tng_data,
                 int64_t *n_data_blocks,
                 int64_t **data_block_ids,
                 char ***data_block_names,
                 int64_t **stride_lengths,
                 int64_t **n_values_per_frame,
                 char **block_types,
                 char **dependencies,
                 char **compressions);
*/

/** @brief Finds the frame set of the specified frame in order to prepare for writing
 * after it.
 * @param tng_data is the trajectory to use.
 * @param prev_frame is the frame after which to start appending.
 * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
 * must be initialised before using it.
 * @pre \code prev_frame >= 0 \endcode The previous frame must not be negative.
 * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
 * has occured (such as not finding the requested frame) or TNG_CRITICAL (2)
 * if a major error has occured.
 */
tng_function_status DECLSPECDLLEXPORT tng_util_prepare_append_after_frame
                (tng_trajectory_t tng_data,
                 const int64_t prev_frame);

/** @} */ /* end of group2 */


#ifdef __cplusplus
}  /* end extern "C" */
#endif

#endif /* TNG_IO_H */
contact: Jan Huwald // Impressum