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
|
/* This code is part of the tng binary trajectory format.
*
* VERSION 1.4
*
* Written by Magnus Lundborg
* Copyright (c) 2012, 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 GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*/
/** @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 LGPL 2.1 and is free to redistribute according
* to that license (or a later version of the LGPL license).
*
* A license file (named COPYING) should be included with each copy of the API.
*
* @section install_sec Installation
*
* mkdir build
*
* cd build
*
* cmake ..
*
* make
*
* Test by running:
*
* bin/tests/tng_testing
*
* @section change_sec Change Log
*
* See git log for full revision history.
*
* Revisions
*
* v. 1.4 - 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 _TNGIO_H
#define _TNGIO_H 1
#include <stdio.h>
#include <stdlib.h>
#include <string.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
//
// #ifndef _STDINT_H
// /* This first part is from stdint.h (GNU C Library) */
// #ifndef __int8_t_defined
// # define __int8_t_defined
// typedef signed char int8_t;
// typedef short int int16_t;
// typedef int int32_t;
// # if __WORDSIZE == 64
// typedef long int int64_t;
// # else
// #ifdef __GNUC__
// __extension__
// #endif
// typedef long long int int64_t;
// # endif
// #endif
//
// typedef unsigned char uint8_t;
// typedef unsigned short int uint16_t;
// #ifndef __uint32_t_defined
// typedef unsigned int uint32_t;
// # define __uint32_t_defined
// #endif
// #if __WORDSIZE == 64
// typedef unsigned long int uint64_t;
// #else
// #ifdef __GNUC__
// __extension__
// #endif
// typedef unsigned long long int uint64_t;
// #endif
// #endif
/* 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. */
# define PRId8 "d"
# define PRId16 "d"
# define PRId32 "d"
# define PRId64 __PRI64_PREFIX "d"
#endif
#endif
#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 */
/** The version of this TNG build */
#define TNG_VERSION 4 /* TNG_VERSION 4 => Api version 1.4 */
/** 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
#if 0
/** Inline function for finding the lowest of two values */
#define tng_min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
/** Inline function for finding the highest of two values */
#define tng_max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#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;
/** Block IDs of standard non trajectory blocks. */
typedef enum {TNG_GENERAL_INFO = 0x0000000000000000L,
TNG_MOLECULES,
TNG_TRAJECTORY_FRAME_SET,
TNG_PARTICLE_MAPPING} tng_non_trajectory_block_ids;
/** Block IDs of standard trajectory blocks. Box shape and partial charges can
* be either trajectory blocks or non-trajectory blocks */
typedef enum {TNG_TRAJ_BOX_SHAPE = 0x0000000010000000L,
TNG_TRAJ_POSITIONS,
TNG_TRAJ_VELOCITIES,
TNG_TRAJ_FORCES,
TNG_TRAJ_PARTIAL_CHARGES,
TNG_TRAJ_FORMAL_CHARGES,
TNG_TRAJ_B_FACTORS,
TNG_TRAJ_ANISOTROPIC_B_FACTORS,
TNG_TRAJ_OCCUPANCY} tng_trajectory_block_ids;
/** 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 */
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;
/** A pointer to the main trajectory data storage. */
typedef struct tng_trajectory *tng_trajectory_t;
/** A pointer to a molecule description. */
typedef struct tng_molecule *tng_molecule_t;
/** A pointer to a molecular chain description. */
typedef struct tng_chain *tng_chain_t;
/** A pointer to a molecular residue description. */
typedef struct tng_residue *tng_residue_t;
/** A pointer to a molecular atom description. */
typedef struct tng_atom *tng_atom_t;
/** A pointer to a bond between two atoms. */
typedef struct tng_bond *tng_bond_t;
/** A pointer to a structure containing data common to all trajectory blocks,
* such as header and contents. */
typedef struct tng_gen_block *tng_gen_block_t;
/** A pointer to particle mapping information. */
typedef struct tng_particle_mapping *tng_particle_mapping_t;
/** A pointer to a structure containing frame set information. */
typedef struct tng_trajectory_frame_set *tng_trajectory_frame_set_t;
/** A pointer to a particle data container. */
typedef struct tng_particle_data *tng_particle_data_t;
/** A pointer to a non-particle data container. */
typedef struct tng_non_particle_data *tng_non_particle_data_t;
/** 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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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 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.
* @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
(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).
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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 the trajectory of which to get the number of frames.
* @param n is pointing to a value set to the number of frames.
* @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 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.
* @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 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.
* @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 exponential 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 exponential.
* @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 exponential used for distances in the trajectory.
* @param tng_data is the trajectory of which to set the unit exponential.
* @param exp is the distance unit exponential to use.
* @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.
* @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.
* @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.
* @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.
* @return TNG_SUCCESS (0) if successful.
*/
tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get
(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.
* @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.
* @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.
* @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.
* @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.
* @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 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.
* @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.
* @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 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.
* @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.
* @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
(tng_trajectory_t tng_data,
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.
* @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.
* @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 is -1 the first molecule 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 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.
* @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 is -1 the first chain 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.
* @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.
* @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 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.
* @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 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.
* @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.
* @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 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.
* @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.
* @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 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.
* @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 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.
* @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.
* @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 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.
* @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 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.
* @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.
* @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 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.
* @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.
* @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 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.
* @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.
* @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 first_particle_number 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.
* @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 first_particle_number,
const int64_t n_particles,
const int64_t *mapping_table);
/**
* @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.
* @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.
* @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.
* @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 (the next) frame set, including 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.
* @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 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.
* @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 Create and initialise a frame set.
* @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.
* @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).
* @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.
* @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 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.
* @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 first_particle_number 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.
* @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 first_particle_number,
const int64_t n_particles,
const int64_t codec_id,
void *new_data);
/**
* @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 data 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.
* @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 *data,
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 data 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.
* @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 *data,
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.
* @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.
* @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.
* @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 frequency) 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.
* @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.
* @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.
* @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.
* @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 frequency) 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.
* @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 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.
* @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 must be
* closed by the user.
* @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);
// 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);
//
// 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 memory must be freed afterwards.
* @param stride_length will be set to the writing frequency of the stored data.
* @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 memory must be freed afterwards.
* @param stride_length will be set to the writing frequency of the stored data.
* @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 memory must be freed afterwards.
* @param stride_length will be set to the writing frequency of the stored data.
* @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. For each frame the box shape is stored as nine values.
* 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 frequency of the stored data.
* @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 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 memory must be freed afterwards.
* @param stride_length will be set to the writing frequency of the stored data.
* @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 memory must be freed afterwards.
* @param stride_length will be set to the writing frequency of the stored data.
* @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 memory must be freed afterwards.
* @param stride_length will be set to the writing frequency of the stored data.
* @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. For each frame the box shape is stored as nine values.
* 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 frequency of the stored data.
* @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 frequency of data blocks.
* @param tng_data is the trajectory to use.
* @param f is the output frequency, i.e. f == 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 frequency.
* @param block_name is a string that will be used as name of the block.
* @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).
* @param compression is the compression routine to use when writing the data.
* @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_frequency_set
(tng_trajectory_t tng_data,
const int64_t f,
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 frequency of position
* data blocks.
* @param tng_data is the trajectory to use.
* @param f is the output frequency, i.e. f == 10 means data written every 10th
* frame.
* @details This function uses tng_util_generic_write_frequency_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_frequency_set
(tng_trajectory_t tng_data,
const int64_t f);
/**
* @brief High-level function for setting the writing frequency of velocity
* data blocks.
* @param tng_data is the trajectory to use.
* @param f is the output frequency, i.e. f == 10 means data written every 10th
* frame.
* @details This function uses tng_util_generic_write_frequency_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_frequency_set
(tng_trajectory_t tng_data,
const int64_t f);
/**
* @brief High-level function for setting the writing frequency of force
* data blocks.
* @param tng_data is the trajectory to use.
* @param f is the output frequency, i.e. f == 10 means data written every 10th
* frame.
* @details This function uses tng_util_generic_write_frequency_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_frequency_set
(tng_trajectory_t tng_data,
const int64_t f);
/**
* @brief High-level function for setting the writing frequency of box shape
* data blocks.
* @param tng_data is the trajectory to use.
* @param f is the output frequency, i.e. f == 10 means data written every 10th
* frame.
* @details This function uses tng_util_generic_write_frequency_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_frequency_set
(tng_trajectory_t tng_data,
const int64_t f);
/**
* @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 frequency.
* @param block_name is a string that will be used as name of the block.
* @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).
* @param compression is the compression routine to use when writing the data.
* @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 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.
* @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 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.
* @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 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.
* @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 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.
* @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 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.
* @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_with_time_write
(tng_trajectory_t tng_data,
const int64_t frame_nr,
const int64_t time,
const float *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.
* @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_with_time_write
(tng_trajectory_t tng_data,
const int64_t frame_nr,
const int64_t time,
const float *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.
* @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_with_time_write
(tng_trajectory_t tng_data,
const int64_t frame_nr,
const int64_t time,
const float *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.
* @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_with_time_write
(tng_trajectory_t tng_data,
const int64_t frame_nr,
const int64_t time,
const float *box_shape);
/** @} */ // end of group2
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* _TNGIO_H */
|