TNG version 1.7.5
[alexxy/gromacs.git] / src / external / tng_io / include / tng / tng_io.h
1 /* This code is part of the tng binary trajectory format.
2  *
3  * Written by Magnus Lundborg
4  * Copyright (c) 2012-2014, The GROMACS development team.
5  * Check out http://www.gromacs.org for more information.
6  *
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the Revised BSD License.
10  */
11
12 /** @file tng_io.h
13  *  @brief API for input and output of tng trajectory files
14  *  @mainpage TNG: A flexible binary trajectory format
15  *  @section intro_sec Introduction
16  *
17  * The TNG format is developed as part of the ScalaLife EU project.
18  * It is flexible by design to allow parallel writing, custom data blocks,
19  * different output frequencies and different compression algorithms.
20  *
21  * Each block can contain MD5 hashes to verify data integrity and the file
22  * can be signed by the user to ensure that the origin is correct.
23  *
24  * The intention is that the API and ABI should be stable, but it is
25  * still possible that future changes might make that impossible, in which
26  * case that will be clarified.
27  *
28  * The API and all examples are released without any warranties. Use them at
29  * your own risk.
30  *
31  * @section authors_sec Authors
32  *
33  * The TNG trajectory format is developed by:
34  *
35  * Magnus Lundborg magnus.lundborg@scilifelab.se
36  *
37  * Daniel SpĂ„ngberg daniels@mkem.uu.se
38  *
39  * Rossen Apostolov rossen@kth.se
40  *
41  * The API is implemented mainly by:
42  *
43  * Magnus Lundborg
44  *
45  * @section License
46  *
47  * Copyright (c) 2012, The GROMACS development team.
48  * check out http://www.gromacs.org for more information.
49  *
50  * The TNG API is released under the Revised BSD License and is free to
51  * redistribute according to that license.
52  *
53  * A license file (named COPYING) should be included with each copy of the API.
54  *
55  * @section install_sec Installation
56  *
57  * \code
58  * mkdir build
59  *
60  * cd build
61  *
62  * cmake ..
63  *
64  * make
65  *
66  * make install
67  * \endcode
68  * Test by running:
69  * \code
70  * bin/tests/tng_testing
71  * \endcode
72  *
73  * @section change_sec Change Log
74  *
75  * See git log for full revision history.
76  *
77  * Revisions
78  *
79  * v. 1.7 - Fifth stable release of the API
80  *
81  *        - Added function tng_util_num_frames_with_data_of_block_id_get().
82  *        - Merged some functions and data structures
83  *          to make less difference between data blocks.
84  *        - Bugs fixed
85  *
86  * v. 1.6 - Fourth stable release of the API.
87  *
88  *        - Removed OpenMP option when building.
89  *        - Functionality for migrating data blocks.
90  *        - Improved handling of molecules.
91  *        - Improved installation of TNG documentation.
92  *        - Enhancements to CMake usage.
93  *        - Required CMake version raised to 2.8.8.
94  *        - Bugs fixed.
95  *
96  * v. 1.5 - Third stable release of the API.
97  *
98  *        - Fortran wrapper split into separate file
99  *        - Added more block IDs.
100  *        - Some new functions and utility functions added.
101  *        - Improved compression precision settings.
102  *        - Improved tests.
103  *        - Make appending to file work better.
104  *        - Modified CMake settings
105  *        - Bugs fixed
106  *
107  * v. 1.4 - Changed from LGPL to the Revised BSD License.
108  *
109  *        - More flexible support for digital signatures in header.
110  *        - Block ID numbers changed.
111  *
112  * v. 1.3 - Second stable release of the API.
113  *
114  *      - Added multiplication factor for coordinate units to general info.
115  *      - Added time stamps and time per frame in frame sets.
116  *      - High-level API functions added (not for managing molecules yet)
117  *      - Added functions for reading data blocks into 1D arrays.
118  *      - TNG compression added.
119  *      - C++ interface added.
120  *      - Avoid memory allocation if no data is submitted when adding data
121  *        blocks.
122  *      - Added function tng_num_frames_per_frame_set_set
123  *      - Added data block IDs for charges, b-factors and occupancy.
124  *      - GZIP compression added.
125  *      - Fixed bug when updating MD5 hashes of data blocks.
126  *      - Fixed bug in chain_name_of_particle_get(...)
127  *      - Update frame set pointers properly.
128  *      - Moved fortran wrapper from header file to source file.
129  *      - Write sparse data in mdrun examples.
130  *      - Fixed bugs related to reading and writing sparse data.
131  *      - Fixed memory leak for non-trajectory particle data blocks.
132  *      - Fixed bug when writing data blocks.
133  *      - Fixed wrong values in dependency constants
134  *      - Write box shape, partial charges and annotation data in tng_testing
135  *      - Bug fixes in tng_testing (frame sets not written before)
136  *
137  * v. 1.0 - First stable release of the API.
138  *
139  *
140  * @section examples_sec Examples
141  *
142  * There are some examples of how to use the library located in src/tests/
143  *
144  * @subsection tng_subsec TNG files
145  *
146  * The build directory contains an example_files directory, which in turn
147  * contains a very short example of a TNG file containing a few water molecules,
148  * a box shape description and positions in 10 frames.
149  *
150  * It is also possible to run the bin/examples/md_openmp_util
151  * (see src/tests/md_openmp_util.c)
152  * testing program, which will save MD simulations output to a new file
153  * (saved in the example_files directory).
154  *
155  * These files can be read using the bin/examples/tng_io_read_pos_util
156  * program.
157  *
158  * @subsection c_subsec C
159  *
160  * Example writing data to a TNG file (just an excerpt):
161  * \code
162  *     for ( step = 1; step < step_num; step++ )
163  *     {
164  *         compute ( np, nd, pos, vel, mass, force, &potential, &kinetic );
165  *
166  *         if(step % step_save == 0)
167  *         {
168  *             // Write positions, velocities and forces
169  *             if(tng_util_pos_write(traj, step, pos) != TNG_SUCCESS)
170  *             {
171  *                 printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
172  *                 break;
173  *             }
174  *             if(tng_util_vel_write(traj, step, vel) != TNG_SUCCESS)
175  *             {
176  *                 printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
177  *                 break;
178  *             }
179  *             if(tng_util_force_write(traj, step, force) != TNG_SUCCESS)
180  *             {
181  *                 printf("Error adding data. %s: %d\n", __FILE__, __LINE__);
182  *                 break;
183  *             }
184  *         }
185  *         update ( np, nd, pos, vel, force, acc, mass, dt );
186  *     }
187  * \endcode
188  *
189  * Example reading positions from a TNG file:
190  * \code
191  * #include <stdlib.h>
192  * #include <stdio.h>
193  * #include "tng/tng_io.h"
194  *
195  * int main(int argc, char **argv)
196  * {
197  *     tng_trajectory_t traj;
198  *     // Assume that the data is stored as floats. The data is placed in 1-D
199  *     // arrays
200  *     float *positions = 0, *box_shape = 0;
201  *     int64_t n_particles, n_frames, tot_n_frames, stride_length, i, j;
202  *     // Set a default frame range
203  *     int64_t first_frame = 0, last_frame = 5000;
204  *     int k;
205  *
206  *     // A reference must be passed to allocate memory
207  *     tng_util_trajectory_open(argv[1], 'r', &traj);
208  *
209  *     if(tng_num_frames_get(traj, &tot_n_frames) != TNG_SUCCESS)
210  *     {
211  *         printf("Cannot determine the number of frames in the file\n");
212  *         tng_util_trajectory_close(&traj);
213  *         exit(1);
214  *     }
215  *
216  *     if(tng_num_particles_get(traj, &n_particles) != TNG_SUCCESS)
217  *     {
218  *         printf("Cannot determine the number of particles in the file\n");
219  *         tng_util_trajectory_close(&traj);
220  *         exit(1);
221  *     }
222  *
223  *     printf("%"PRId64" frames in file\n", tot_n_frames);
224  *
225  *     if(last_frame > tot_n_frames - 1)
226  *     {
227  *         last_frame = tot_n_frames - 1;
228  *     }
229  *
230  *     if(tng_util_box_shape_read(traj, &box_shape, &stride_length) ==
231  *         TNG_SUCCESS)
232  *     {
233  *         printf("Simulation box shape: ");
234  *         for(i=0; i < 9; i++)
235  *         {
236  *             printf("%f ", box_shape[i]);
237  *         }
238  *         printf("\n");
239  *     }
240  *     else
241  *     {
242  *         printf("Simulation box shape not set in the file (or could not be read)\n");
243  *     }
244  *
245  *     n_frames = last_frame - first_frame + 1;
246  *
247  *
248  *     // Get the positions of all particles in the requested frame range.
249  *     // The positions are stored in the positions array.
250  *     // N.B. No proper error checks.
251  *     if(tng_util_pos_read_range(traj, 0, last_frame, &positions, &stride_length)
252  *        == TNG_SUCCESS)
253  *     {
254  *         // Print the positions of the wanted particle (zero based)
255  *         for(i=0; i < n_frames; i += stride_length)
256  *         {
257  *             printf("\nFrame %"PRId64":\n", first_frame + i);
258  *             for(j=0; j < n_particles; j++)
259  *             {
260  *                 printf("Atom nr: %"PRId64"", j);
261  *                 for(k=0; k < 3; k++)
262  *                 {
263  *                     printf("\t%f", positions[i/stride_length*n_particles*
264  *                                              3+j*3+k]);
265  *                 }
266  *                 printf("\n");
267  *             }
268  *         }
269  *     }
270  *     else
271  *     {
272  *         printf("Cannot read positions\n");
273  *     }
274  *
275  *     // Free memory
276  *     if(positions)
277  *     {
278  *         free(positions);
279  *     }
280  *     tng_util_trajectory_close(&traj);
281  *
282  *     return(0);
283  * }
284  *
285  * \endcode
286  *
287  * @subsection fortran_subsec Fortran
288  *
289  * The TNG library can be used from Fortran. It requires cray pointers, which
290  * are not part of the Fortran 77 standard, but available in most compilers.
291  *
292  * To compile the fortran example -DTNG_BUILD_FORTRAN=ON needs to be specified when
293  * running cmake.
294  *
295  */
296
297 #ifndef TNG_IO_H
298 #define TNG_IO_H     1
299
300 #include <stdio.h>
301 #include <stdlib.h>
302 #include <string.h>
303 #include <assert.h>
304 #include "tng_io_fwd.h"
305
306 #ifdef USE_STD_INTTYPES_H
307 #include <inttypes.h>
308 #else
309 /* Visual Studio does not contain inttypes.h and stdint.h. Some defines and
310  * typedefs are used from the GNU C Library */
311 #ifdef _MSC_VER
312
313 typedef __int32 int32_t;
314 typedef unsigned __int32 uint32_t;
315 typedef __int64 int64_t;
316 typedef unsigned __int64 uint64_t;
317
318 #else
319 #include <stdint.h>
320 #endif /* _MSC_VER */
321
322 /* This is from inttypes.h  (GNU C Library) */
323 /* The ISO C99 standard specifies that these macros must only be
324    defined if explicitly requested.  */
325 #if !defined __cplusplus || defined __STDC_FORMAT_MACROS
326
327 # if __WORDSIZE == 64
328 #  define __PRI64_PREFIX        "l"
329 #  define __PRIPTR_PREFIX       "l"
330 # else
331 #  define __PRI64_PREFIX        "ll"
332 #  define __PRIPTR_PREFIX
333 # endif
334
335 /* From stdint.h (GNU C Library) */
336 /* Macros for printing format specifiers. */
337 /* Decimal notation.  */
338 #ifndef PRId64
339 # define PRId64         __PRI64_PREFIX "d"
340 #endif
341
342 #ifndef PRIu64
343 # define PRIu64         __PRI64_PREFIX "u"
344 #endif
345
346 #ifndef PRIuPTR
347 # define PRIuPTR         __PRIPTR_PREFIX "u"
348 #endif
349
350 #endif
351
352 #endif /* USE_STD_INTTYPES_H */
353
354 #ifndef USE_WINDOWS
355 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
356 #define USE_WINDOWS
357 #endif /* win32... */
358 #endif /* not defined USE_WINDOWS */
359
360 #ifndef DECLSPECDLLEXPORT
361 #ifdef USE_WINDOWS
362 #define DECLSPECDLLEXPORT __declspec(dllexport)
363 #else /* USE_WINDOWS */
364 #define DECLSPECDLLEXPORT
365 #endif /* USE_WINDOWS */
366 #endif /* DECLSPECDLLEXPORT */
367
368 /** Flag to indicate frame dependent data. */
369 #define TNG_FRAME_DEPENDENT 1
370 /** Flag to indicate particle dependent data. */
371 #define TNG_PARTICLE_DEPENDENT 2
372
373 /** The maximum length of a date string */
374 #define TNG_MAX_DATE_STR_LEN 24
375 /** The length of an MD5 hash */
376 #define TNG_MD5_HASH_LEN 16
377 /** The maximum allowed length of a string */
378 #define TNG_MAX_STR_LEN 1024
379
380 #ifndef NDEBUG
381 #define TNG_ASSERT(cnd, msg) if(!(cnd)) {printf("%s\n", msg); assert(cnd);}
382 #else
383 #define TNG_ASSERT(cnd, msg) (void)0;
384 #endif
385
386 /** Flag to specify the endianness of a TNG file */
387 typedef enum {TNG_BIG_ENDIAN,
388               TNG_LITTLE_ENDIAN} tng_file_endianness;
389
390 /** Flag to specify the endianness of 32 bit values of the current architecture. */
391 typedef enum {TNG_BIG_ENDIAN_32,
392               TNG_LITTLE_ENDIAN_32,
393               TNG_BYTE_PAIR_SWAP_32} tng_endianness_32;
394
395 /** Flag to specify the endianness of 64 bit values of the current architecture. */
396 typedef enum {TNG_BIG_ENDIAN_64,
397               TNG_LITTLE_ENDIAN_64,
398               TNG_QUAD_SWAP_64,
399               TNG_BYTE_PAIR_SWAP_64,
400               TNG_BYTE_SWAP_64} tng_endianness_64;
401
402 /** Compression mode is specified in each data block */
403 typedef enum {TNG_UNCOMPRESSED,
404               TNG_XTC_COMPRESSION,
405               TNG_TNG_COMPRESSION,
406               TNG_GZIP_COMPRESSION} tng_compression;
407
408 /** Hash types */
409 typedef enum {TNG_NO_HASH,
410               TNG_MD5,
411               TNG_SHA256} tng_hash_type;
412
413 /** Non trajectory blocks come before the first frame set block */
414 typedef enum {TNG_NON_TRAJECTORY_BLOCK, TNG_TRAJECTORY_BLOCK} tng_block_type;
415
416 /** @defgroup def1 Standard non-trajectory blocks
417  *  Block IDs of standard non-trajectory blocks.
418  * @{
419  */
420 #define TNG_GENERAL_INFO                0x0000000000000000LL
421 #define TNG_MOLECULES                   0x0000000000000001LL
422 #define TNG_TRAJECTORY_FRAME_SET        0x0000000000000002LL
423 #define TNG_PARTICLE_MAPPING            0x0000000000000003LL
424 /** @} */
425
426 /** @defgroup def2 Standard trajectory blocks
427  * Block IDs of standard trajectory blocks. Box shape and partial charges can
428  * be either trajectory blocks or non-trajectory blocks
429  * @{
430  */
431 #define TNG_TRAJ_BOX_SHAPE              0x0000000010000000LL
432 #define TNG_TRAJ_POSITIONS              0x0000000010000001LL
433 #define TNG_TRAJ_VELOCITIES             0x0000000010000002LL
434 #define TNG_TRAJ_FORCES                 0x0000000010000003LL
435 #define TNG_TRAJ_PARTIAL_CHARGES        0x0000000010000004LL
436 #define TNG_TRAJ_FORMAL_CHARGES         0x0000000010000005LL
437 #define TNG_TRAJ_B_FACTORS              0x0000000010000006LL
438 #define TNG_TRAJ_ANISOTROPIC_B_FACTORS  0x0000000010000007LL
439 #define TNG_TRAJ_OCCUPANCY              0x0000000010000008LL
440 #define TNG_TRAJ_GENERAL_COMMENTS       0x0000000010000009LL
441 /** @} */
442
443
444 /** @defgroup def3 GROMACS data block IDs
445  *  Block IDs of data blocks specific to GROMACS.
446  * @{
447  */
448 #define TNG_GMX_LAMBDA                  0x1000000010000000LL
449 #define TNG_GMX_ENERGY_ANGLE            0x1000000010000001LL
450 #define TNG_GMX_ENERGY_RYCKAERT_BELL    0x1000000010000002LL
451 #define TNG_GMX_ENERGY_LJ_14            0x1000000010000003LL
452 #define TNG_GMX_ENERGY_COULOMB_14       0x1000000010000004LL
453 #define TNG_GMX_ENERGY_LJ_(SR)          0x1000000010000005LL
454 #define TNG_GMX_ENERGY_COULOMB_(SR)     0x1000000010000006LL
455 #define TNG_GMX_ENERGY_COUL_RECIP       0x1000000010000007LL
456 #define TNG_GMX_ENERGY_POTENTIAL        0x1000000010000008LL
457 #define TNG_GMX_ENERGY_KINETIC_EN       0x1000000010000009LL
458 #define TNG_GMX_ENERGY_TOTAL_ENERGY     0x1000000010000010LL
459 #define TNG_GMX_ENERGY_TEMPERATURE      0x1000000010000011LL
460 #define TNG_GMX_ENERGY_PRESSURE         0x1000000010000012LL
461 #define TNG_GMX_ENERGY_CONSTR_RMSD      0x1000000010000013LL
462 #define TNG_GMX_ENERGY_BOX_X            0x1000000010000014LL
463 #define TNG_GMX_ENERGY_BOX_Y            0x1000000010000015LL
464 #define TNG_GMX_ENERGY_BOX_Z            0x1000000010000016LL
465 #define TNG_GMX_ENERGY_VOLUME           0x1000000010000017LL
466 #define TNG_GMX_ENERGY_DENSITY          0x1000000010000018LL
467 #define TNG_GMX_ENERGY_PV               0x1000000010000019LL
468 #define TNG_GMX_ENERGY_ENTHALPY         0x1000000010000020LL
469 #define TNG_GMX_ENERGY_VIR_XX           0x1000000010000021LL
470 #define TNG_GMX_ENERGY_VIR_XY           0x1000000010000022LL
471 #define TNG_GMX_ENERGY_VIR_XZ           0x1000000010000023LL
472 #define TNG_GMX_ENERGY_VIR_YX           0x1000000010000024LL
473 #define TNG_GMX_ENERGY_VIR_YY           0x1000000010000025LL
474 #define TNG_GMX_ENERGY_VIR_YZ           0x1000000010000026LL
475 #define TNG_GMX_ENERGY_VIR_ZX           0x1000000010000027LL
476 #define TNG_GMX_ENERGY_VIR_ZY           0x1000000010000028LL
477 #define TNG_GMX_ENERGY_VIR_ZZ           0x1000000010000029LL
478 #define TNG_GMX_ENERGY_PRES_XX          0x1000000010000030LL
479 #define TNG_GMX_ENERGY_PRES_XY          0x1000000010000031LL
480 #define TNG_GMX_ENERGY_PRES_XZ          0x1000000010000032LL
481 #define TNG_GMX_ENERGY_PRES_YX          0x1000000010000033LL
482 #define TNG_GMX_ENERGY_PRES_YY          0x1000000010000034LL
483 #define TNG_GMX_ENERGY_PRES_YZ          0x1000000010000035LL
484 #define TNG_GMX_ENERGY_PRES_ZX          0x1000000010000036LL
485 #define TNG_GMX_ENERGY_PRES_ZY          0x1000000010000037LL
486 #define TNG_GMX_ENERGY_PRES_ZZ          0x1000000010000038LL
487 #define TNG_GMX_ENERGY_SURFXSURFTEN     0x1000000010000039LL
488 #define TNG_GMX_ENERGY_T_SYSTEM         0x1000000010000040LL
489 #define TNG_GMX_ENERGY_LAMB_SYSTEM      0x1000000010000041LL
490 #define TNG_GMX_SELECTION_GROUP_NAMES   0x1000000010000042LL
491 #define TNG_GMX_ATOM_SELECTION_GROUP    0x1000000010000043LL
492 /** @} */
493
494 /** Flag to specify if a data block contains data related to particles or not.*/
495 typedef enum {TNG_NON_PARTICLE_BLOCK_DATA,
496               TNG_PARTICLE_BLOCK_DATA} tng_particle_dependency;
497
498
499 typedef enum {TNG_FALSE, TNG_TRUE} tng_bool;
500
501 /** Flag to specify if the number of atoms change throughout the trajectory or
502  *  if it is constant. */
503 typedef enum {TNG_CONSTANT_N_ATOMS, TNG_VARIABLE_N_ATOMS}
504              tng_variable_n_atoms_flag;
505
506 /** Return values of API functions. TNG_SUCCESS means that the operation
507  *  was successful. TNG_FAILURE means that the operation failed for some
508  *  reason, but it is possible to try to continue anyhow. TNG_CRITICAL
509  *  means that the error is irrecoverable. */
510 typedef enum {TNG_SUCCESS, TNG_FAILURE, TNG_CRITICAL} tng_function_status;
511
512 /** If tng_hash_mode == TNG_USE_HASH md5 hashes will be written to output files
513  *  and when reading a file the md5 hashes of the contents will be compared to
514  *  those in the file (for each block) in order to ensure data integrity */
515 typedef enum {TNG_SKIP_HASH, TNG_USE_HASH} tng_hash_mode;
516
517 /** Possible formats of data block contents */
518 typedef enum {TNG_CHAR_DATA,
519               TNG_INT_DATA,
520               TNG_FLOAT_DATA,
521               TNG_DOUBLE_DATA} tng_data_type;
522
523
524 struct tng_trajectory;
525 struct tng_molecule;
526 struct tng_chain;
527 struct tng_residue;
528 struct tng_atom;
529 struct tng_bond;
530 struct tng_gen_block;
531 struct tng_particle_mapping;
532 struct tng_trajectory_frame_set;
533 struct tng_particle_data;
534 struct tng_non_particle_data;
535
536 /** Data can be either double, float, int or a string */
537 union data_values {
538     double d;
539     float f;
540     int64_t i;
541     char *c;
542 };
543
544
545 #ifdef __cplusplus
546 extern "C"
547 {
548 #endif
549
550 /** @defgroup group1 Low-level API
551  *  These functions give detailed control of the TNG data management. Most
552  *  things can be done using the more convenient high-level API functions
553  *  instead.
554  *  @{
555  */
556
557 /**
558  * @brief Get the major version of the TNG library.
559  * @param tng_data is a trajectory data container, it does not have
560  * to be initialized beforehand.
561  * @param version is pointing to a value set to the major version of
562  * the library.
563  * @return TNG_SUCCESS (0) if successful.
564  */
565 tng_function_status DECLSPECDLLEXPORT tng_version_major
566                 (const tng_trajectory_t tng_data,
567                  int *version);
568
569 /**
570  * @brief Get the minor version of the TNG library.
571  * @param tng_data is a trajectory data container, it does not have
572  * to be initialized beforehand.
573  * @param version is pointing to a value set to the minor version of
574  * the library.
575  * @return TNG_SUCCESS (0) if successful.
576  */
577 tng_function_status DECLSPECDLLEXPORT tng_version_minor
578                 (const tng_trajectory_t tng_data,
579                  int *version);
580
581 /**
582  * @brief Get the patch level of the TNG library.
583  * @param tng_data is a trajectory data container, it does not have
584  * to be initialized beforehand.
585  * @param patch_level is the string to fill with the full version,
586  * memory must be allocated before.
587  * @return TNG_SUCCESS (0) if successful.
588  */
589 tng_function_status DECLSPECDLLEXPORT tng_version_patchlevel
590                 (const tng_trajectory_t tng_data,
591                  int *patch_level);
592
593 /**
594  * @brief Get the full version string of the TNG library.
595  * @param tng_data is a trajectory data container, it does not have
596  * to be initialized beforehand.
597  * @param version is pointing to a value set to the major version of
598  * the library.
599  * @param max_len maximum char length of the string, i.e. how much memory has
600  * been reserved for version. This includes \0 terminating character.
601  * @pre \code version != 0 \endcode The pointer to the name string
602  * must not be a NULL pointer.
603  * @return TNG_SUCCESS (0) if successful.
604  */
605 tng_function_status DECLSPECDLLEXPORT tng_version
606                 (const tng_trajectory_t tng_data,
607                  char *version,
608                  const int max_len);
609
610 /**
611  * @brief Setup a trajectory data container.
612  * @param tng_data_p a pointer to memory to initialise as a trajectory.
613  * @pre tng_data_p must not be pointing at a reserved memory block.
614  * @details Memory is allocated during initialisation.
615  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
616  * error has occured.
617  */
618 tng_function_status DECLSPECDLLEXPORT tng_trajectory_init
619                 (tng_trajectory_t *tng_data_p);
620
621 /**
622  * @brief Clean up a trajectory data container.
623  * @param tng_data_p a pointer to the trajectory data to destroy.
624  * @details All allocated memory in the data structure is freed, as well as
625  * tng_data_p itself.
626  * @return TNG_SUCCESS (0) if successful.
627  */
628 tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy
629                 (tng_trajectory_t *tng_data_p);
630
631 /**
632  * @brief Copy a trajectory data container (dest is setup as well).
633  * @details This initialises dest and copies only what is absolute necessary for
634  * parallel i/o. This can be used inside pragma omp for setting up a thread
635  * local copy of src. It can be freed (using tng_trajectory_destroy) at the
636  * end of the parallel block.
637  * @param src the original trajectory.
638  * @param dest_p a pointer to memory to initialise as a trajectory.
639  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
640  * must be initialised before using it.
641  * @pre tng_data_p must not be pointing at a reserved memory block.
642  * @details Memory is allocated during initialisation.
643  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
644  * error has occured.
645  */
646 tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src
647                 (const tng_trajectory_t src, tng_trajectory_t *dest_p);
648
649 /**
650  * @brief Get the name of the input file.
651  * @param tng_data the trajectory of which to get the input file name.
652  * @param file_name the string to fill with the name of the input file,
653  * memory must be allocated before.
654  * @param max_len maximum char length of the string, i.e. how much memory has
655  * been reserved for file_name. This includes \0 terminating character.
656  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
657  * must be initialised before using it.
658  * @pre \code file_name != 0 \endcode The pointer to the file name string
659  * must not be a NULL pointer.
660  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
661  * has occurred (source string longer than destination string).
662  */
663 tng_function_status DECLSPECDLLEXPORT tng_input_file_get
664                 (const tng_trajectory_t tng_data,
665                  char *file_name, const int max_len);
666
667 /**
668  * @brief Set the name of the input file.
669  * @param tng_data the trajectory of which to set the input file name.
670  * @param file_name the name of the input file.
671  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
672  * must be initialised before using it.
673  * @pre \code file_name != 0 \endcode The pointer to the file name string
674  * must not be a NULL pointer.
675  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
676  * error has occured.
677  */
678 tng_function_status DECLSPECDLLEXPORT tng_input_file_set
679                 (const tng_trajectory_t tng_data,
680                  const char *file_name);
681
682 /**
683  * @brief Get the name of the output file.
684  * @param tng_data the trajectory of which to get the input file name.
685  * @param file_name the string to fill with the name of the output file,
686  * memory must be allocated before.
687  * @param max_len maximum char length of the string, i.e. how much memory has
688  * been reserved for file_name. This includes \0 terminating character.
689  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
690  * must be initialised before using it.
691  * @pre \code file_name != 0 \endcode The pointer to the file name string
692  * must not be a NULL pointer.
693  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
694  * has occurred (source string longer than destination string).
695  */
696 tng_function_status DECLSPECDLLEXPORT tng_output_file_get
697                 (const tng_trajectory_t tng_data,
698                  char *file_name, const int max_len);
699
700 /**
701  * @brief Set the name of the output file.
702  * @param tng_data the trajectory of which to set the output file name.
703  * @param file_name the name of the output file.
704  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
705  * must be initialised before using it.
706  * @pre \code file_name != 0 \endcode The pointer to the file name string
707  * must not be a NULL pointer.
708  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
709  * error has occured.
710  */
711 tng_function_status DECLSPECDLLEXPORT tng_output_file_set
712                 (const tng_trajectory_t tng_data,
713                  const char *file_name);
714
715 /**
716  * @brief Set the name of the output file for appending. The output file
717  * will not be overwritten.
718  * @param tng_data the trajectory of which to set the output file name.
719  * @param file_name the name of the output file to append to.
720  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
721  * must be initialised before using it.
722  * @pre \code file_name != 0 \endcode The pointer to the file name string
723  * must not be a NULL pointer.
724  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
725  * error has occured.
726  */
727 tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set
728                 (const tng_trajectory_t tng_data,
729                  const char *file_name);
730
731 /**
732  * @brief Get the endianness of the output file.
733  * @param tng_data the trajectory of which to get the endianness of the current
734  * output file.
735  * @param endianness will contain the enumeration of the endianness.
736  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
737  * must be initialised before using it.
738  * @pre \code endianness != 0 \endcode The pointer to the endianness container
739  * must not be a NULL pointer.
740  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness
741  * could not be retrieved.
742  */
743 tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get
744                 (const tng_trajectory_t tng_data, tng_file_endianness *endianness);
745
746 /**
747  * @brief Set the endianness of the output file.
748  * @param tng_data the trajectory of which to set the endianness of the current
749  * output file.
750  * @param endianness the enumeration of the endianness, can be either
751  * TNG_BIG_ENDIAN (0) or TNG_LITTLE_ENDIAN (1).
752  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
753  * must be initialised before using it.
754  * @details The endianness cannot be changed after file output has started.
755  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness
756  * could not be set.
757  */
758 tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set
759                 (const tng_trajectory_t tng_data,
760                  const tng_file_endianness endianness);
761
762 /**
763  * @brief Get the name of the program used when creating the trajectory.
764  * @param tng_data the trajectory of which to get the program name.
765  * @param name the string to fill with the name of the program,
766  * memory must be allocated before.
767  * @param max_len maximum char length of the string, i.e. how much memory has
768  * been reserved for name. This includes \0 terminating character.
769  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
770  * must be initialised before using it.
771  * @pre \code name != 0 \endcode The pointer to the name string
772  * must not be a NULL pointer.
773  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
774  * has occurred (source string longer than destination string).
775  */
776 tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get
777                 (const tng_trajectory_t tng_data,
778                  char *name, const int max_len);
779
780 /**
781  * @brief Set the name of the program used when creating the trajectory.
782  * @param tng_data the trajectory of which to set the program name.
783  * @param new_name is a string containing the wanted name.
784  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
785  * must be initialised before using it.
786  * @pre \code new_name != 0 \endcode The pointer to the new_name string
787  * must not be a NULL pointer.
788  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
789  * error has occured.
790  */
791 tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set
792                 (const tng_trajectory_t tng_data,
793                  const char *new_name);
794
795 /**
796  * @brief Get the name of the program used when last modifying the trajectory.
797  * @param tng_data the trajectory of which to get the program name.
798  * @param name the string to fill with the name of the program,
799  * memory must be allocated before.
800  * @param max_len maximum char length of the string, i.e. how much memory has
801  * been reserved for name. This includes \0 terminating character.
802  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
803  * must be initialised before using it.
804  * @pre \code name != 0 \endcode The pointer to the name string
805  * must not be a NULL pointer.
806  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
807  * has occurred (source string longer than destination string).
808  */
809 tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get
810                 (const tng_trajectory_t tng_data,
811                  char *name, const int max_len);
812
813 /**
814  * @brief Set the name of the program used when last modifying the trajectory.
815  * @param tng_data the trajectory of which to set the program name.
816  * @param new_name is a string containing the wanted name.
817  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
818  * must be initialised before using it.
819  * @pre \code new_name != 0 \endcode The pointer to the new_name string
820  * must not be a NULL pointer.
821  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
822  * error has occured.
823  */
824 tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set
825                 (const tng_trajectory_t tng_data,
826                  const char *new_name);
827
828 /**
829  * @brief Get the name of the user who created the trajectory.
830  * @param tng_data the trajectory of which to get the user name.
831  * @param name the string to fill with the name of the user,
832  * memory must be allocated before.
833  * @param max_len maximum char length of the string, i.e. how much memory has
834  * been reserved for name. This includes \0 terminating character.
835  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
836  * must be initialised before using it.
837  * @pre \code name != 0 \endcode The pointer to the name string
838  * must not be a NULL pointer.
839  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
840  * has occurred (source string longer than destination string).
841  */
842 tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get
843                 (const tng_trajectory_t tng_data,
844                  char *name, const int max_len);
845
846 /**
847  * @brief Set the name of the user who created the trajectory.
848  * @param tng_data the trajectory of which to set the user name.
849  * @param new_name is a string containing the wanted name.
850  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
851  * must be initialised before using it.
852  * @pre \code new_name != 0 \endcode The pointer to the new_name string
853  * must not be a NULL pointer.
854  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
855  * error has occured.
856  */
857 tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set
858                 (const tng_trajectory_t tng_data,
859                  const char *new_name);
860
861 /**
862  * @brief Get the name of the user who last modified the trajectory.
863  * @param tng_data the trajectory of which to get the user name.
864  * @param name the string to fill with the name of the user,
865  * memory must be allocated before.
866  * @param max_len maximum char length of the string, i.e. how much memory has
867  * been reserved for name. This includes \0 terminating character.
868  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
869  * must be initialised before using it.
870  * @pre \code name != 0 \endcode The pointer to the name string
871  * must not be a NULL pointer.
872  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
873  * has occurred (source string longer than destination string).
874  */
875 tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get
876                 (const tng_trajectory_t tng_data,
877                  char *name, const int max_len);
878
879 /**
880  * @brief Set the name of the user who last modified the trajectory.
881  * @param tng_data the trajectory of which to set the user name.
882  * @param new_name is a string containing the wanted name.
883  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
884  * must be initialised before using it.
885  * @pre \code new_name != 0 \endcode The pointer to the new_name string
886  * must not be a NULL pointer.
887  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
888  * error has occured.
889  */
890 tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set
891                 (const tng_trajectory_t tng_data,
892                  const char *new_name);
893
894 /**
895  * @brief Get the name of the computer used when creating the trajectory.
896  * @param tng_data the trajectory of which to get the computer name.
897  * @param name the string to fill with the name of the computer,
898  * memory must be allocated before.
899  * @param max_len maximum char length of the string, i.e. how much memory has
900  * been reserved for name. This includes \0 terminating character.
901  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
902  * must be initialised before using it.
903  * @pre \code name != 0 \endcode The pointer to the name string
904  * must not be a NULL pointer.
905  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
906  * has occurred (source string longer than destination string).
907  */
908 tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get
909                 (const tng_trajectory_t tng_data,
910                  char *name, const int max_len);
911
912 /**
913  * @brief Set the name of the computer used when creating the trajectory.
914  * @param tng_data the trajectory of which to set the computer name.
915  * @param new_name is a string containing the wanted name.
916  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
917  * must be initialised before using it.
918  * @pre \code new_name != 0 \endcode The pointer to the new_name string
919  * must not be a NULL pointer.
920  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
921  * error has occured.
922  */
923 tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set
924                 (const tng_trajectory_t tng_data,
925                  const char *new_name);
926
927 /**
928  * @brief Get the name of the computer used when last modifying the trajectory.
929  * @param tng_data the trajectory of which to get the computer name.
930  * @param name the string to fill with the name of the computer,
931  * memory must be allocated before.
932  * @param max_len maximum char length of the string, i.e. how much memory has
933  * been reserved for name. This includes \0 terminating character.
934  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
935  * must be initialised before using it.
936  * @pre \code name != 0 \endcode The pointer to the name string
937  * must not be a NULL pointer.
938  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
939  * has occurred (source string longer than destination string).
940  */
941 tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get
942                 (const tng_trajectory_t tng_data,
943                  char *name, const int max_len);
944
945 /**
946  * @brief Set the name of the computer used when last modifying the trajectory.
947  * @param tng_data the trajectory of which to set the computer name.
948  * @param new_name is a string containing the wanted name.
949  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
950  * must be initialised before using it.
951  * @pre \code new_name != 0 \endcode The pointer to the new_name string
952  * must not be a NULL pointer.
953  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
954  * error has occured.
955  */
956 tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set
957                 (const tng_trajectory_t tng_data,
958                  const char *new_name);
959
960 /**
961  * @brief Get the pgp_signature of the user creating the trajectory.
962  * @param tng_data the trajectory of which to get the computer name.
963  * @param signature the string to fill with the signature,
964  * memory must be allocated before.
965  * @param max_len maximum char length of the string, i.e. how much memory has
966  * been reserved for name. This includes \0 terminating character.
967  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
968  * must be initialised before using it.
969  * @pre \code signature != 0 \endcode The pointer to the signature
970  * must not be a NULL pointer.
971  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
972  * has occurred (source string longer than destination string).
973  */
974 tng_function_status DECLSPECDLLEXPORT tng_first_signature_get
975                 (const tng_trajectory_t tng_data,
976                  char *signature, const int max_len);
977
978 /**
979  * @brief Set the pgp_signature of the user creating the trajectory.
980  * @param tng_data the trajectory of which to set the computer name.
981  * @param signature is a string containing the pgp_signature.
982  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
983  * must be initialised before using it.
984  * @pre \code signature != 0 \endcode The pointer to the signature
985  * must not be a NULL pointer.
986  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
987  * error has occured.
988  */
989 tng_function_status DECLSPECDLLEXPORT tng_first_signature_set
990                 (const tng_trajectory_t tng_data,
991                  const char *signature);
992
993 /**
994  * @brief Get the pgp_signature of the user last modifying the trajectory.
995  * @param tng_data the trajectory of which to get the computer name.
996  * @param signature the string to fill with the signature,
997  * memory must be allocated before.
998  * @param max_len maximum char length of the string, i.e. how much memory has
999  * been reserved for name. This includes \0 terminating character.
1000  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1001  * must be initialised before using it.
1002  * @pre \code signature != 0 \endcode The pointer to the signature
1003  * must not be a NULL pointer.
1004  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1005  * has occurred (source string longer than destination string).
1006  */
1007 tng_function_status DECLSPECDLLEXPORT tng_last_signature_get
1008                 (const tng_trajectory_t tng_data,
1009                  char *signature, const int max_len);
1010
1011 /**
1012  * @brief Set the pgp_signature of the user last modifying the trajectory.
1013  * @param tng_data the trajectory of which to set the computer name.
1014  * @param signature is a string containing the pgp_signature.
1015  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1016  * must be initialised before using it.
1017  * @pre \code signature != 0 \endcode The pointer to the signature
1018  * must not be a NULL pointer.
1019  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1020  * error has occured.
1021  */
1022 tng_function_status DECLSPECDLLEXPORT tng_last_signature_set
1023                 (const tng_trajectory_t tng_data,
1024                  const char *signature);
1025
1026 /**
1027  * @brief Get the name of the forcefield used in the trajectory.
1028  * @param tng_data the trajectory of which to get the forcefield name.
1029  * @param name the string to fill with the name of the forcefield,
1030  * memory must be allocated before.
1031  * @param max_len maximum char length of the string, i.e. how much memory has
1032  * been reserved for name. This includes \0 terminating character.
1033  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1034  * must be initialised before using it.
1035  * @pre \code name != 0 \endcode The pointer to the name string
1036  * must not be a NULL pointer.
1037  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1038  * has occurred (source string longer than destination string).
1039  */
1040 tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get
1041                 (const tng_trajectory_t tng_data,
1042                  char *name, const int max_len);
1043
1044 /**
1045  * @brief Set the name of the forcefield used in the trajectory.
1046  * @param tng_data the trajectory of which to set the forcefield name.
1047  * @param new_name is a string containing the wanted name.
1048  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1049  * must be initialised before using it.
1050  * @pre \code new_name != 0 \endcode The pointer to the new_name string
1051  * must not be a NULL pointer.
1052  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1053  * error has occured.
1054  */
1055 tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set
1056                 (const tng_trajectory_t tng_data,
1057                  const char *new_name);
1058
1059 /**
1060  * @brief Get the medium stride length of the trajectory.
1061  * @param tng_data is the trajectory from which to get the stride length.
1062  * @param len is pointing to a value set to the stride length.
1063  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1064  * must be initialised before using it.
1065  * @pre \code len != 0 \endcode The pointer to len must not be a NULL pointer.
1066  * @return TNG_SUCCESS (0) if successful.
1067  */
1068 tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get
1069                 (const tng_trajectory_t tng_data,
1070                  int64_t *len);
1071
1072 /**
1073  * @brief Set the medium stride length of the trajectory.
1074  * @param tng_data is the trajectory of which to set the stride length.
1075  * @param len is the wanted medium stride length.
1076  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1077  * must be initialised before using it.
1078  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1079  * has occurred.
1080  */
1081 tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set
1082                 (const tng_trajectory_t tng_data,
1083                  const int64_t len);
1084
1085 /**
1086  * @brief Get the long stride length of the trajectory.
1087  * @param tng_data is the trajectory from which to get the stride length.
1088  * @param len is pointing to a value set to the stride length.
1089  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1090  * must be initialised before using it.
1091  * @pre \code len != 0 \endcode The pointer to len must not be a NULL pointer.
1092  * @return TNG_SUCCESS (0) if successful.
1093  */
1094 tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get
1095                 (const tng_trajectory_t tng_data,
1096                  int64_t *len);
1097
1098 /**
1099  * @brief Set the long stride length of the trajectory.
1100  * @param tng_data is the trajectory of which to set the stride length.
1101  * @param len is the wanted long stride length.
1102  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1103  * must be initialised before using it.
1104  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1105  * has occurred.
1106  */
1107 tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set
1108                 (const tng_trajectory_t tng_data,
1109                  const int64_t len);
1110
1111 /**
1112  * @brief Get the current time per frame of the trajectory.
1113  * @param tng_data is the trajectory from which to get the time per frame.
1114  * @param time is pointing to a value set to the time per frame.
1115  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1116  * must be initialised before using it.
1117  * @pre \code time != 0 \endcode The pointer to time must not be a NULL pointer.
1118  * @return TNG_SUCCESS (0) if successful.
1119  */
1120 tng_function_status DECLSPECDLLEXPORT tng_time_per_frame_get
1121                 (const tng_trajectory_t tng_data,
1122                  double *time);
1123
1124 /**
1125  * @brief Set the time per frame of the trajectory.
1126  * @param tng_data is the trajectory of which to set the time per frame.
1127  * @param time is the new time per frame.
1128  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1129  * must be initialised before using it.
1130  * @pre \code time > 0 \endcode The time per frame must be >= 0.
1131  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1132  * has occurred.
1133  */
1134 tng_function_status DECLSPECDLLEXPORT tng_time_per_frame_set
1135                 (const tng_trajectory_t tng_data,
1136                  const double time);
1137
1138 /**
1139  * @brief Get the length of the input file.
1140  * @param tng_data is the trajectory from which to get the input file length.
1141  * @param len is pointing to a value set to the file length.
1142  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1143  * must be initialised before using it.
1144  * @pre \code len != 0 \endcode The pointer to len must not be a NULL pointer.
1145  * @return TNG_SUCCESS (0) if successful.
1146  */
1147 tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get
1148                 (const tng_trajectory_t tng_data,
1149                  int64_t *len);
1150
1151 /**
1152  * @brief Get the number of frames in the trajectory
1153  * @param tng_data is the trajectory of which to get the number of frames.
1154  * @param n is pointing to a value set to the number of frames.
1155  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1156  * must be initialised before using it.
1157  * @pre \code tng_data->input_file != 0 \endcode An input file must be open
1158  * to find the next frame set.
1159  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1160  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1161  * has occurred (could not find last frame set).
1162  */
1163 tng_function_status DECLSPECDLLEXPORT tng_num_frames_get
1164                 (const tng_trajectory_t tng_data,
1165                  int64_t *n);
1166
1167 /**
1168  * @brief Get the precision of lossy compression.
1169  * @param tng_data is the trajectory of which to get the compression precision.
1170  * @param precision will be pointing to the retrieved compression precision.
1171  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1172  * must be initialised before using it.
1173  * @details A compression precision of 0.001 (the default) means that the
1174  * compressed values are accurate to the third decimal. This function does
1175  * not check actual precision of compressed data, but just returns what has
1176  * previously been set using tng_compression_precision_set().
1177  * @return TNG_SUCCESS (0) if successful.
1178  */
1179 tng_function_status DECLSPECDLLEXPORT tng_compression_precision_get
1180                 (const tng_trajectory_t tng_data,
1181                  double *precision);
1182
1183 /**
1184  * @brief Set the precision of lossy compression.
1185  * @param tng_data is the trajectory of which to set the compression precision.
1186  * @param precision is the new compression precision.
1187  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1188  * must be initialised before using it.
1189  * @details A compression precision of 0.001 (the default) means that the
1190  * compressed values are accurate to the third decimal.
1191  * @return TNG_SUCCESS (0) if successful.
1192  */
1193 tng_function_status DECLSPECDLLEXPORT tng_compression_precision_set
1194                 (const tng_trajectory_t tng_data,
1195                  const double precision);
1196
1197 /**
1198  * @brief Set the number of particles, in the case no molecular system is used.
1199  * @param tng_data is the trajectory of which to get the number of particles.
1200  * @param n is the number of particles to use.
1201  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1202  * must be initialised before using it.
1203  * @details When creating a molecular system the number of particles are set
1204  * automatically. This should only be used when there is no molecular system
1205  * specified or if the number of atoms needs to be overridden for some reason.
1206  * @return TNG_SUCCESS (0) if successful.
1207  */
1208 tng_function_status DECLSPECDLLEXPORT tng_implicit_num_particles_set
1209                 (const tng_trajectory_t tng_data,
1210                  const int64_t n);
1211
1212 /**
1213  * @brief Get the current number of particles.
1214  * @param tng_data is the trajectory from which to get the number of particles.
1215  * @param n is pointing to a value set to the number of particles.
1216  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1217  * must be initialised before using it.
1218  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1219  * @details If variable number of particles are used this function will return
1220  * the number of particles in the current frame set.
1221  * @return TNG_SUCCESS (0) if successful.
1222  */
1223 tng_function_status DECLSPECDLLEXPORT tng_num_particles_get
1224                 (const tng_trajectory_t tng_data,
1225                  int64_t *n);
1226
1227 /**
1228  * @brief Get if the number of particle can be varied during the simulation.
1229  * @param tng_data is the trajectory from which to get the number of particles.
1230  * @param variable is pointing to a value set to TNG_CONSTANT_N_ATOMS if the
1231  * number of particles cannot change or TNG_VARIABLE_N_ATOMS if the number of
1232  * particles can change.
1233  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1234  * must be initialised before using it.
1235  * @pre \code variable != 0 \endcode The pointer to variable must not be
1236  * a NULL pointer.
1237  * @return TNG_SUCCESS (0) if successful.
1238  */
1239 tng_function_status DECLSPECDLLEXPORT tng_num_particles_variable_get
1240                 (const tng_trajectory_t tng_data,
1241                  char *variable);
1242
1243 /**
1244  * @brief Get the number of molecule types (length of tng_data->molecules).
1245  * @param tng_data is the trajectory from which to get the number of molecules.
1246  * @param n is pointing to a value set to the number of molecule types.
1247  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1248  * must be initialised before using it.
1249  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1250  * @return TNG_SUCCESS (0) if successful.
1251  */
1252 tng_function_status DECLSPECDLLEXPORT tng_num_molecule_types_get
1253                 (const tng_trajectory_t tng_data,
1254                  int64_t *n);
1255
1256 /**
1257  * @brief Get the current total number of molecules.
1258  * @param tng_data is the trajectory from which to get the number of molecules.
1259  * @param n is pointing to a value set to the number of molecules.
1260  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1261  * must be initialised before using it.
1262  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1263  * @details If variable number of particles are used this function will return
1264  * the total number of molecules in the current frame set.
1265  * @return TNG_SUCCESS (0) if successful.
1266  */
1267 tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get
1268                 (const tng_trajectory_t tng_data,
1269                  int64_t *n);
1270
1271 /** @brief Get the list of the count of each molecule.
1272  * @param tng_data is the trajectory from which to get the molecule count list.
1273  * @param mol_cnt_list is a list of the count of each molecule in the
1274  * mol system. This is a pointer to the list in the TNG container, which
1275  * means that it should be handled carefully, e.g. not freed.
1276  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1277  * must be initialised before using it.
1278  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE(1) if the list of
1279  * molecule counts was not valid.
1280  */
1281 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_list_get
1282                 (const tng_trajectory_t tng_data,
1283                  int64_t **mol_cnt_list);
1284
1285 /**
1286  * @brief Get the exponent used for distances in the trajectory.
1287  * @param tng_data is the trajectory from which to get the information.
1288  * @param exp is pointing to a value set to the distance unit exponent.
1289  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1290  * must be initialised before using it.
1291  * @pre \code exp != 0 \endcode The pointer to exp must not be a NULL pointer.
1292  * @details Example: If the distances are specified in nm (default) exp is -9.
1293  * If the distances are specified in Ă… exp is -10.
1294  * @return TNG_SUCCESS (0) if successful.
1295  */
1296 tng_function_status DECLSPECDLLEXPORT tng_distance_unit_exponential_get
1297                 (const tng_trajectory_t tng_data,
1298                  int64_t *exp);
1299
1300 /**
1301  * @brief Set the exponent used for distances in the trajectory.
1302  * @param tng_data is the trajectory of which to set the unit exponent.
1303  * @param exp is the distance unit exponent to use.
1304  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1305  * must be initialised before using it.
1306  * @details Example: If the distances are specified in nm (default) exp is -9.
1307  * If the distances are specified in Ă… exp is -10.
1308  * @return TNG_SUCCESS (0) if successful.
1309  */
1310 tng_function_status DECLSPECDLLEXPORT tng_distance_unit_exponential_set
1311                 (const tng_trajectory_t tng_data,
1312                  const int64_t exp);
1313
1314 /**
1315  * @brief Get the number of frames per frame set.
1316  * @param tng_data is the trajectory from which to get the number of frames
1317  * per frame set.
1318  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1319  * must be initialised before using it.
1320  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1321  * @param n is pointing to a value set to the number of frames per frame set.
1322  * @return TNG_SUCCESS (0) if successful.
1323  */
1324 tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get
1325                 (const tng_trajectory_t tng_data,
1326                  int64_t *n);
1327
1328 /**
1329  * @brief Set the number of frames per frame set.
1330  * @param tng_data is the trajectory of which to set the number of frames
1331  * per frame set.
1332  * @param n is the number of frames per frame set.
1333  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1334  * must be initialised before using it.
1335  * @details This does not affect already existing frame sets. For
1336  * consistency the number of frames per frame set should be set
1337  * betfore creating any frame sets.
1338  * @return TNG_SUCCESS (0) if successful.
1339  */
1340 tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set
1341                 (const tng_trajectory_t tng_data,
1342                  const int64_t n);
1343
1344 /**
1345  * @brief Get the number of frame sets.
1346  * @details This updates tng_data->n_trajectory_frame_sets before returning it.
1347  * @param tng_data is the trajectory from which to get the number of frame sets.
1348  * @param n is pointing to a value set to the number of frame sets.
1349  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1350  * must be initialised before using it.
1351  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1352  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1353  * has occurred or TNG_CRITICAL (2) if a major error has occured.
1354  */
1355 tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
1356                 (const tng_trajectory_t tng_data,
1357                  int64_t *n);
1358
1359 /**
1360  * @brief Get the current trajectory frame set.
1361  * @param tng_data is the trajectory from which to get the frame set.
1362  * @param frame_set_p will be set to point at the memory position of
1363  * the found frame set.
1364  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1365  * must be initialised before using it.
1366  * @return TNG_SUCCESS (0) if successful.
1367  */
1368 tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get
1369                 (const tng_trajectory_t tng_data,
1370                  tng_trajectory_frame_set_t *frame_set_p);
1371
1372 /**
1373  * @brief Find the requested frame set number.
1374  * @param tng_data is the trajectory from which to get the frame set.
1375  * @param nr is the frame set number to search for.
1376  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1377  * must be initialised before using it.
1378  * @pre \code nr >= 0 \endcode The frame set number (nr) must be >= 0.
1379  * @details tng_data->current_trajectory_frame_set will contain the
1380  * found trajectory if successful.
1381  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1382  * has occurred or TNG_CRITICAL (2) if a major error has occured.
1383  */
1384 tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
1385                 (const tng_trajectory_t tng_data,
1386                  const int64_t nr);
1387
1388 /**
1389  * @brief Find the frame set containing a specific frame.
1390  * @param tng_data is the trajectory from which to get the frame set.
1391  * @param frame is the frame number to search for.
1392  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1393  * must be initialised before using it.
1394  * @pre \code frame >= 0 \endcode The frame number must be >= 0.
1395  * @details tng_data->current_trajectory_frame_set will contain the
1396  * found trajectory if successful.
1397  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1398  * has occurred or TNG_CRITICAL (2) if a major error has occured.
1399  */
1400 tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
1401                 (const tng_trajectory_t tng_data,
1402                  const int64_t frame);
1403
1404 /**
1405  * @brief Get the file position of the next frame set in the input file.
1406  * @param tng_data is a trajectory data container.
1407  * @param frame_set is the frame set of which to get the position of the
1408  * following frame set.
1409  * @param pos is pointing to a value set to the file position.
1410  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1411  * must be initialised before using it.
1412  * @pre \code pos != 0 \endcode The pointer to pos must not be a NULL pointer.
1413  * @return TNG_SUCCESS (0) if successful.
1414  */
1415 tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get
1416                 (const tng_trajectory_t tng_data,
1417                  const tng_trajectory_frame_set_t frame_set,
1418                  int64_t *pos);
1419
1420 /**
1421  * @brief Get the file position of the previous frame set in the input file.
1422  * @param tng_data is a trajectory data container.
1423  * @param frame_set is the frame set of which to get the position of the
1424  * previous frame set.
1425  * @param pos is pointing to a value set to the file position.
1426  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1427  * must be initialised before using it.
1428  * @pre \code pos != 0 \endcode The pointer to pos must not be a NULL pointer.
1429  * @return TNG_SUCCESS (0) if successful.
1430  */
1431 tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get
1432                 (const tng_trajectory_t tng_data,
1433                  const tng_trajectory_frame_set_t frame_set,
1434                  int64_t *pos);
1435
1436 /**
1437  * @brief Get the first and last frames of the frame set.
1438  * @param tng_data is a trajectory data container.
1439  * @param frame_set is the frame set of which to get the frame range.
1440  * @param first_frame is set to the first frame of the frame set.
1441  * @param last_frame is set to the last frame of the frame set.
1442  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1443  * must be initialised before using it.
1444  * @pre \code first_frame != 0 \endcode The pointer to first_frame must
1445  * not be a NULL pointer.
1446  * @pre \code last_frame != 0 \endcode The pointer to last_frame must
1447  * not be a NULL pointer.
1448  * @return TNG_SUCCESS (0) if successful.
1449  */
1450 tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get
1451                 (const tng_trajectory_t tng_data,
1452                  const tng_trajectory_frame_set_t frame_set,
1453                  int64_t *first_frame,
1454                  int64_t *last_frame);
1455
1456 /**
1457  * @brief Allocate memory for and setup a molecule container.
1458  * @param tng_data is a trajectory data container.
1459  * @param molecule_p is a pointer to molecule to allocate and initialise.
1460  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1461  * error has occured.
1462  */
1463 tng_function_status DECLSPECDLLEXPORT tng_molecule_alloc(const tng_trajectory_t tng_data,
1464                                                          tng_molecule_t *molecule_p);
1465
1466 /**
1467  * @brief Clean up a molecule container and free its allocated memory.
1468  * @param tng_data is a trajectory data container.
1469  * @param molecule_p is the molecule to destroy.
1470  * @details All allocated memory in the data structure is freed and also the memory
1471  * of the molecule itself.
1472  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1473  * error has occured.
1474  */
1475 tng_function_status DECLSPECDLLEXPORT tng_molecule_free(const tng_trajectory_t tng_data,
1476                                                         tng_molecule_t *molecule_p);
1477
1478 /**
1479  * @brief Setup a molecule container.
1480  * @param tng_data is a trajectory data container.
1481  * @param molecule is the molecule to initialise. Memory must be preallocated.
1482  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1483  * error has occured.
1484  */
1485 tng_function_status DECLSPECDLLEXPORT tng_molecule_init
1486                 (const tng_trajectory_t tng_data,
1487                  const tng_molecule_t molecule);
1488
1489 /**
1490  * @brief Clean up a molecule container.
1491  * @param tng_data is a trajectory data container.
1492  * @param molecule is the molecule to destroy.
1493  * @details All allocated memory in the data structure is freed, but not the
1494  * memory of molecule itself.
1495  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1496  * error has occured.
1497  */
1498 tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy
1499                 (const tng_trajectory_t tng_data,
1500                  const tng_molecule_t molecule);
1501
1502 /**
1503  * @brief Add a molecule to the trajectory.
1504  * @param tng_data is the trajectory data container containing the block..
1505  * @param name is a pointer to the string containing the name of the new molecule.
1506  * @param molecule is a pointer to the newly created molecule.
1507  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1508  * must be initialised before using it.
1509  * @pre \code name != 0 \endcode The pointer to the name string
1510  * must not be a NULL pointer.
1511  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
1512  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
1513  */
1514 tng_function_status DECLSPECDLLEXPORT tng_molecule_add
1515                 (const tng_trajectory_t tng_data,
1516                  const char *name,
1517                  tng_molecule_t *molecule);
1518
1519 /**
1520  * @brief Add a molecule with a specific ID to the trajectory.
1521  * @param tng_data is the trajectory data container containing the block..
1522  * @param name is a pointer to the string containing the name of the new molecule.
1523  * @param id is the ID of the created molecule.
1524  * @param molecule is a pointer to the newly created molecule.
1525  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1526  * must be initialised before using it.
1527  * @pre \code name != 0 \endcode The pointer to the name string
1528  * must not be a NULL pointer.
1529  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
1530  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
1531  */
1532 tng_function_status DECLSPECDLLEXPORT tng_molecule_w_id_add
1533                 (const tng_trajectory_t tng_data,
1534                  const char *name,
1535                  const int64_t id,
1536                  tng_molecule_t *molecule);
1537
1538 /**
1539  * @brief Add an existing molecule (from a molecule container) to the trajectory.
1540  * @param tng_data is the trajectory data container containing the block..
1541  * @param molecule is a pointer to the molecule to add to the trajectory and will
1542  * afterwards point to the molecule in the trajectory.
1543  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1544  * must be initialised before using it.
1545  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major error
1546  * has occured.
1547  */
1548 tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
1549                 (const tng_trajectory_t tng_data,
1550                  tng_molecule_t *molecule);
1551
1552 /**
1553  * @brief Get the name of a molecule.
1554  * @param tng_data the trajectory containing the molecule.
1555  * @param molecule the molecule of which to get the name.
1556  * @param name the string to fill with the name of the molecule,
1557  * memory must be allocated before.
1558  * @param max_len maximum char length of the string, i.e. how much memory has
1559  * been reserved for name. This includes \0 terminating character.
1560  * @pre \code molecule != 0 \endcode The molecule must not be NULL.
1561  * @pre \code name != 0 \endcode The pointer to the name string
1562  * must not be a NULL pointer.
1563  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1564  * has occurred (source string longer than destination string).
1565  */
1566 tng_function_status DECLSPECDLLEXPORT tng_molecule_name_get
1567                 (const tng_trajectory_t tng_data,
1568                  const tng_molecule_t molecule,
1569                  char *name,
1570                  const int max_len);
1571
1572 /**
1573  * @brief Set the name of a molecule.
1574  * @param tng_data is the trajectory data container containing the molecule..
1575  * @param molecule is the molecule to rename.
1576  * @param new_name is a string containing the wanted name.
1577  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1578  * must be initialised before using it.
1579  * @pre \code new_name != 0 \endcode The pointer to the name string
1580  * must not be a NULL pointer.
1581  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1582  * error has occured.
1583  */
1584 tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set
1585                 (const tng_trajectory_t tng_data,
1586                  const tng_molecule_t molecule,
1587                  const char *new_name);
1588
1589 /**
1590  * @brief Get the count of a molecule.
1591  * @param tng_data is the trajectory data container containing the molecule..
1592  * @param molecule is the molecule of which to get the count.
1593  * @param cnt is a pointer to the variable to be populated with the count.
1594  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1595  * must be initialised before using it.
1596  * @pre \code cnt != 0 \endcode The pointer to the molecule count
1597  * must not be a NULL pointer.
1598  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1599  * has occurred or TNG_CRITICAL (2) if a major error has occured.
1600  */
1601 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get
1602                 (const tng_trajectory_t tng_data,
1603                  const tng_molecule_t molecule,
1604                  int64_t *cnt);
1605
1606 /**
1607  * @brief Set the count of a molecule.
1608  * @param tng_data is the trajectory data container containing the molecule..
1609  * @param molecule is the molecule of which to set the count.
1610  * @param cnt is the number of instances of this molecule.
1611  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1612  * must be initialised before using it.
1613  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1614  * has occurred or TNG_CRITICAL (2) if a major error has occured.
1615  */
1616 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set
1617                 (const tng_trajectory_t tng_data,
1618                  const tng_molecule_t molecule,
1619                  const int64_t cnt);
1620
1621 /**
1622  * @brief Find a molecule.
1623  * @param tng_data is the trajectory data container containing the molecule.
1624  * @param name is a string containing the name of the molecule. If name is empty
1625  * only id will be used for finding the molecule.
1626  * @param id is the id of the molecule to look for. If id is -1 only the name of
1627  * the molecule will be used for finding the molecule.
1628  * @param molecule is a pointer to the molecule if it was found - otherwise 0.
1629  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1630  * must be initialised before using it.
1631  * @pre \code name != 0 \endcode The pointer to the name string
1632  * must not be a NULL pointer.
1633  * @return TNG_SUCCESS (0) if the molecule is found or TNG_FAILURE (1) if the
1634  * molecule is not found.
1635  * @details If name is an empty string and id == -1 the first residue will
1636  * be found.
1637  */
1638 tng_function_status DECLSPECDLLEXPORT tng_molecule_find
1639                 (const tng_trajectory_t tng_data,
1640                  const char *name,
1641                  const int64_t id,
1642                  tng_molecule_t *molecule);
1643
1644 /**
1645  * @brief Retrieve the molecule with specified index in the list of molecules.
1646  * @param tng_data is the trajectory data container containing the molecule.
1647  * @param index is the index (in tng_data->molecules) of the molecule to return
1648  * @param molecule is a pointer to the molecule if it was found - otherwise 0.
1649  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1650  * must be initialised before using it.
1651  * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
1652  * @return TNG_SUCCESS (0) if the molecule is found or TNG_FAILURE (1) if the
1653  * molecule is not found.
1654  */
1655 tng_function_status DECLSPECDLLEXPORT tng_molecule_of_index_get
1656                 (const tng_trajectory_t tng_data,
1657                  const int64_t index,
1658                  tng_molecule_t *molecule);
1659
1660 /**
1661  * @brief Copy all molecules and the molecule counts from one TNG trajectory
1662  * to another.
1663  * @param tng_data_src is the source trajectory containing the molecular
1664  * system to copy.
1665  * @param tng_data_dest is the destination trajectory.
1666  * @pre \code tng_data_src != 0 \endcode The trajectory container (tng_data_src)
1667  * must be initialised before using it.
1668  * @pre \code tng_data_dest != 0 \endcode The trajectory container (tng_data_dest)
1669  * must be initialised before using it.
1670  * @details The molecular system in tng_data_dest will be overwritten.
1671  * @return TNG_SUCCESS(0) if the copying is successful, TNG_FAILURE if a minor
1672  * error has occured or TNG_CRITICAL(2) if a major error has occured.
1673  */
1674 tng_function_status DECLSPECDLLEXPORT tng_molecule_system_copy(const tng_trajectory_t tng_data_src,
1675                                                                const tng_trajectory_t tng_data_dest);
1676
1677 /**
1678  * @brief Get the number of chains in a molecule.
1679  * @param tng_data is the trajectory containing the molecule.
1680  * @param molecule is the molecule of which to get the number of chains.
1681  * @param n is pointing to a value set to the number of chains.
1682  * @pre \code molecule != 0 \endcode The molecule must not be NULL.
1683  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1684  * @return TNG_SUCCESS (0) if successful.
1685  */
1686 tng_function_status DECLSPECDLLEXPORT tng_molecule_num_chains_get
1687                 (const tng_trajectory_t tng_data,
1688                  const tng_molecule_t molecule,
1689                  int64_t *n);
1690
1691 /**
1692  * @brief Retrieve the chain of a molecule with specified index in the list
1693  * of chains.
1694  * @param tng_data is the trajectory data container containing the molecule.
1695  * @param index is the index (in molecule->chains) of the chain to return
1696  * @param molecule is the molecule from which to get the chain.
1697  * @param chain is a pointer to the chain if it was found - otherwise 0.
1698  * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
1699  * @pre \code chain != 0 \endcode chain must not be a NULL pointer.
1700  * @return TNG_SUCCESS (0) if the chain is found or TNG_FAILURE (1) if the
1701  * chain is not found.
1702  */
1703 tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_of_index_get
1704                 (const tng_trajectory_t tng_data,
1705                  const tng_molecule_t molecule,
1706                  const int64_t index,
1707                  tng_chain_t *chain);
1708
1709 /**
1710  * @brief Get the number of residues in a molecule.
1711  * @param tng_data is the trajectory containing the molecule.
1712  * @param molecule is the molecule of which to get the number residues.
1713  * @param n is pointing to a value set to the number of residues.
1714  * @pre \code molecule != 0 \endcode The molecule must not be NULL.
1715  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1716  * @return TNG_SUCCESS (0) if successful.
1717  */
1718 tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get
1719                 (const tng_trajectory_t tng_data,
1720                  const tng_molecule_t molecule,
1721                  int64_t *n);
1722
1723 /**
1724  * @brief Retrieve the residue of a molecule with specified index in the list
1725  * of chains.
1726  * @param tng_data is the trajectory data container containing the molecule.
1727  * @param index is the index (in molecule->residues) of the residue to return
1728  * @param molecule is the molecule from which to get the residue.
1729  * @param residue is a pointer to the residue if it was found - otherwise 0.
1730  * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
1731  * @pre \code residue != 0 \endcode residue must not be a NULL pointer.
1732  * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
1733  * residue is not found.
1734  */
1735 tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get
1736                 (const tng_trajectory_t tng_data,
1737                  const tng_molecule_t molecule,
1738                  const int64_t index,
1739                  tng_residue_t *residue);
1740
1741 /**
1742  * @brief Get the number of atoms in a molecule.
1743  * @param tng_data is the trajectory containing the molecule.
1744  * @param molecule is the molecule of which to get the number of atoms.
1745  * @param n is pointing to a value set to the number of atoms.
1746  * @pre \code molecule != 0 \endcode The molecule must not be NULL.
1747  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1748  * @return TNG_SUCCESS (0) if successful.
1749  */
1750 tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get
1751                 (const tng_trajectory_t tng_data,
1752                  const tng_molecule_t molecule,
1753                  int64_t *n);
1754
1755 /**
1756  * @brief Retrieve the atom of a molecule with specified index in the list
1757  * of atoms.
1758  * @param tng_data is the trajectory data container containing the molecule.
1759  * @param index is the index (in molecule->atoms) of the atom to return
1760  * @param molecule is the molecule from which to get the atom.
1761  * @param atom is a pointer to the atom if it was found - otherwise 0.
1762  * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
1763  * @pre \code atom != 0 \endcode atom must not be a NULL pointer.
1764  * @return TNG_SUCCESS (0) if the atom is found or TNG_FAILURE (1) if the
1765  * atom is not found.
1766  */
1767 tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_of_index_get
1768                 (const tng_trajectory_t tng_data,
1769                  const tng_molecule_t molecule,
1770                  const int64_t index,
1771                  tng_atom_t *atom);
1772
1773 /**
1774  * @brief Find a chain in a molecule.
1775  * @param tng_data is the trajectory data container containing the molecule.
1776  * @param molecule is the molecule in which to search for the chain.
1777  * @param name is a string containing the name of the chain. If name is empty
1778  * only id will be used for finding the chain.
1779  * @param id is the id of the chain to look for. If id is -1 only the name of
1780  * the chain will be used for finding the chain.
1781  * @param chain is a pointer to the chain if it was found - otherwise 0.
1782  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1783  * must be initialised before using it.
1784  * @pre \code name != 0 \endcode The pointer to the name string
1785  * must not be a NULL pointer.
1786  * @return TNG_SUCCESS (0) if the chain is found or TNG_FAILURE (1) if the
1787  * chain is not found.
1788  * @details If name is an empty string and id == -1 the first residue will
1789  * be found.
1790  */
1791 tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find
1792                 (const tng_trajectory_t tng_data,
1793                  const tng_molecule_t molecule,
1794                  const char *name,
1795                  const int64_t id,
1796                  tng_chain_t *chain);
1797
1798 /**
1799  * @brief Add a chain to a molecule.
1800  * @param tng_data is the trajectory data container containing the molecule..
1801  * @param molecule is the molecule to add a chain to.
1802  * @param name is a string containing the name of the chain.
1803  * @param chain is a pointer to the newly created chain.
1804  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1805  * must be initialised before using it.
1806  * @pre \code name != 0 \endcode The pointer to the name string
1807  * must not be a NULL pointer.
1808  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
1809  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
1810  */
1811 tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add
1812                 (const tng_trajectory_t tng_data,
1813                  const tng_molecule_t molecule,
1814                  const char *name,
1815                  tng_chain_t *chain);
1816
1817 /**
1818  * @brief Add a chain with a specific id to a molecule.
1819  * @param tng_data is the trajectory data container containing the molecule..
1820  * @param molecule is the molecule to add a chain to.
1821  * @param name is a string containing the name of the chain.
1822  * @param id is the ID of the created chain.
1823  * @param chain is a pointer to the newly created chain.
1824  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1825  * must be initialised before using it.
1826  * @pre \code name != 0 \endcode The pointer to the name string
1827  * must not be a NULL pointer.
1828  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
1829  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
1830  */
1831 tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_w_id_add
1832                 (const tng_trajectory_t tng_data,
1833                  const tng_molecule_t molecule,
1834                  const char *name,
1835                  const int64_t id,
1836                  tng_chain_t *chain);
1837
1838 /**
1839  * @brief Add a bond between two atoms to a molecule.
1840  * @param tng_data is the trajectory data container containing the molecule.
1841  * @param molecule is the molecule containing the atoms to connect.
1842  * @param from_atom_id is the id of one of the two atoms in the bond.
1843  * @param to_atom_id is the id of the other atom in the bond.
1844  * @param bond is a pointer to the newly created bond.
1845  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1846  * must be initialised before using it.
1847  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (!) if a minor error
1848  * has occured or TNG_CRITICAL (2) if a major error has occured.
1849  */
1850 tng_function_status DECLSPECDLLEXPORT tng_molecule_bond_add
1851                 (const tng_trajectory_t tng_data,
1852                  const tng_molecule_t molecule,
1853                  const int64_t from_atom_id,
1854                  const int64_t to_atom_id,
1855                  tng_bond_t *bond);
1856
1857 /**
1858  * @brief Find an atom in a molecule.
1859  * @param tng_data is the trajectory data container containing the molecule.
1860  * @param molecule is the molecule in which to search for the atom.
1861  * @param name is a string containing the name of the atom. If name is an
1862  * empty string only id will be used for searching.
1863  * @param id is the id of the atom to find. If id == -1 the first atom
1864  * that matches the specified name will be found.
1865  * @param atom is a pointer to the atom if it was found - otherwise 0.
1866  * @pre \code name != 0 \endcode The pointer to the name string
1867  * must not be a NULL pointer.
1868  * @return TNG_SUCCESS (0) if the atom is found or TNG_FAILURE (1) if the
1869  * atom is not found.
1870  * @details If name is an empty string and id == -1 the first residue will
1871  * be found.
1872  */
1873 tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_find
1874                 (const tng_trajectory_t tng_data,
1875                  const tng_molecule_t molecule,
1876                  const char *name,
1877                  const int64_t id,
1878                  tng_atom_t *atom);
1879
1880 /**
1881  * @brief Get the name of a chain.
1882  * @param tng_data the trajectory containing the chain.
1883  * @param chain the chain of which to get the name.
1884  * @param name the string to fill with the name of the chain,
1885  * memory must be allocated before.
1886  * @param max_len maximum char length of the string, i.e. how much memory has
1887  * been reserved for name. This includes \0 terminating character.
1888  * @pre \code chain != 0 \endcode The chain must not be NULL.
1889  * @pre \code name != 0 \endcode The pointer to the name string
1890  * must not be a NULL pointer.
1891  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
1892  * has occurred (source string longer than destination string).
1893  */
1894 tng_function_status DECLSPECDLLEXPORT tng_chain_name_get
1895                 (const tng_trajectory_t tng_data,
1896                  const tng_chain_t chain,
1897                  char *name,
1898                  const int max_len);
1899
1900 /**
1901  * @brief Set the name of a chain.
1902  * @param tng_data is the trajectory data container containing the atom..
1903  * @param chain is the chain to rename.
1904  * @param new_name is a string containing the wanted name.
1905  * @pre \code new_name != 0 \endcode The pointer to the name string
1906  * must not be a NULL pointer.
1907  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
1908  * error has occured.
1909  */
1910 tng_function_status DECLSPECDLLEXPORT tng_chain_name_set
1911                 (const tng_trajectory_t tng_data,
1912                  const tng_chain_t chain,
1913                  const char *new_name);
1914
1915 /**
1916  * @brief Get the number of residues in a molecule chain.
1917  * @param tng_data is the trajectory containing the chain.
1918  * @param chain is the chain of which to get the number of residues.
1919  * @param n is pointing to a value set to the number of residues.
1920  * @pre \code chain != 0 \endcode The chain must not be NULL.
1921  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
1922  * @return TNG_SUCCESS (0) if successful.
1923  */
1924 tng_function_status DECLSPECDLLEXPORT tng_chain_num_residues_get
1925                 (const tng_trajectory_t tng_data,
1926                  const tng_chain_t chain,
1927                  int64_t *n);
1928
1929 /**
1930  * @brief Retrieve the residue of a chain with specified index in the list
1931  * of residues.
1932  * @param tng_data is the trajectory data container containing the chain.
1933  * @param index is the index (in chain->residues) of the residue to return
1934  * @param chain is the chain from which to get the residue.
1935  * @param residue is a pointer to the residue if it was found - otherwise 0.
1936  * @pre \code chain != 0 \endcode chain must not be a NULL pointer.
1937  * @pre \code residue != 0 \endcode residue must not be a NULL pointer.
1938  * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
1939  * residue is not found.
1940  */
1941 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_of_index_get
1942                 (const tng_trajectory_t tng_data,
1943                  const tng_chain_t chain,
1944                  const int64_t index,
1945                  tng_residue_t *residue);
1946
1947 /**
1948  * @brief Find a residue in a chain.
1949  * @param tng_data is the trajectory data container containing the chain.
1950  * @param chain is the chain in which to search for the residue.
1951  * @param name is a string containing the name of the residue.  If name is an
1952  * empty string only id will be used for searching.
1953  * @param id is the id of the residue to find. If id == -1 the first residue
1954  * that matches the specified name will be found.
1955  * @param residue is a pointer to the residue if it was found - otherwise 0.
1956  * @pre \code name != 0 \endcode The pointer to the name string
1957  * must not be a NULL pointer.
1958  * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
1959  * residue is not found.
1960  * @details If name is an empty string and id == -1 the first residue will
1961  * be found.
1962  */
1963 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_find
1964                 (const tng_trajectory_t tng_data,
1965                  const tng_chain_t chain,
1966                  const char *name,
1967                  const int64_t id,
1968                  tng_residue_t *residue);
1969
1970 /**
1971  * @brief Add a residue to a chain.
1972  * @param tng_data is the trajectory data container containing the chain..
1973  * @param chain is the chain to add a residue to.
1974  * @param name is a string containing the name of the residue.
1975  * @param residue is a pointer to the newly created residue.
1976  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1977  * must be initialised before using it.
1978  * @pre \code name != 0 \endcode The pointer to the name string
1979  * must not be a NULL pointer.
1980  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
1981  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
1982  */
1983 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add
1984                 (const tng_trajectory_t tng_data,
1985                  const tng_chain_t chain,
1986                  const char *name,
1987                  tng_residue_t *residue);
1988
1989 /**
1990  * @brief Add a residue with a specific ID to a chain.
1991  * @param tng_data is the trajectory data container containing the chain..
1992  * @param chain is the chain to add a residue to.
1993  * @param name is a string containing the name of the residue.
1994  * @param id is the ID of the created residue.
1995  * @param residue is a pointer to the newly created residue.
1996  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
1997  * must be initialised before using it.
1998  * @pre \code name != 0 \endcode The pointer to the name string
1999  * must not be a NULL pointer.
2000  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
2001  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
2002  */
2003 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_w_id_add
2004                 (const tng_trajectory_t tng_data,
2005                  const tng_chain_t chain,
2006                  const char *name,
2007                  const int64_t id,
2008                  tng_residue_t *residue);
2009
2010 /**
2011  * @brief Get the name of a residue.
2012  * @param tng_data the trajectory containing the residue.
2013  * @param residue the residue of which to get the name.
2014  * @param name the string to fill with the name of the residue,
2015  * memory must be allocated before.
2016  * @param max_len maximum char length of the string, i.e. how much memory has
2017  * been reserved for name. This includes \0 terminating character.
2018  * @pre \code residue != 0 \endcode The residue must not be NULL.
2019  * @pre \code name != 0 \endcode The pointer to the name string
2020  * must not be a NULL pointer.
2021  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2022  * has occurred (source string longer than destination string).
2023  */
2024 tng_function_status DECLSPECDLLEXPORT tng_residue_name_get
2025                 (const tng_trajectory_t tng_data,
2026                  const tng_residue_t residue,
2027                  char *name,
2028                  const int max_len);
2029
2030 /**
2031  * @brief Set the name of a residue.
2032  * @param tng_data is the trajectory data container containing the residue.
2033  * @param residue is the residue to rename.
2034  * @param new_name is a string containing the wanted name.
2035  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2036  * must be initialised before using it.
2037  * @pre \code new_name != 0 \endcode The new name to set (new_name) must
2038  * not be a NULL pointer.
2039  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
2040  * error has occured.
2041  */
2042 tng_function_status DECLSPECDLLEXPORT tng_residue_name_set
2043                 (const tng_trajectory_t tng_data,
2044                  const tng_residue_t residue,
2045                  const char *new_name);
2046
2047 /**
2048  * @brief Get the number of atoms in a residue.
2049  * @param tng_data is the trajectory containing the residue.
2050  * @param residue is the residue of which to get the number atoms.
2051  * @param n is pointing to a value set to the number of atoms.
2052  * @pre \code residue != 0 \endcode The residue must not be NULL.
2053  * @pre \code n != 0 \endcode The pointer to n must not be a NULL pointer.
2054  * @return TNG_SUCCESS (0) if successful.
2055  */
2056 tng_function_status DECLSPECDLLEXPORT tng_residue_num_atoms_get
2057                 (const tng_trajectory_t tng_data,
2058                  const tng_residue_t residue,
2059                  int64_t *n);
2060
2061 /**
2062  * @brief Retrieve the atom of a residue with specified index in the list
2063  * of atoms.
2064  * @param tng_data is the trajectory data container containing the residue.
2065  * @param index is the index (in residue->atoms) of the atom to return
2066  * @param residue is the residue from which to get the atom.
2067  * @param atom is a pointer to the atom if it was found - otherwise 0.
2068  * @pre \code residue != 0 \endcode residue must not be a NULL pointer.
2069  * @pre \code atom != 0 \endcode atom must not be a NULL pointer.
2070  * @return TNG_SUCCESS (0) if the atom is found or TNG_FAILURE (1) if the
2071  * atom is not found.
2072  */
2073 tng_function_status DECLSPECDLLEXPORT tng_residue_atom_of_index_get
2074                 (const tng_trajectory_t tng_data,
2075                  const tng_residue_t residue,
2076                  const int64_t index,
2077                  tng_atom_t *atom);
2078
2079 /**
2080  * @brief Add an atom to a residue.
2081  * @param tng_data is the trajectory containing the residue.
2082  * @param residue is the residue to add an atom to.
2083  * @param atom_name is a string containing the name of the atom.
2084  * @param atom_type is a string containing the atom type of the atom.
2085  * @param atom is a pointer to the newly created atom.
2086  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2087  * must be initialised before using it.
2088  * @pre \code atom_name != 0 \endcode The pointer to the atom name string
2089  * must not be a NULL pointer.
2090  * @pre \code atom_type != 0 \endcode The pointer to the atom_type string
2091  * must not be a NULL pointer.
2092  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
2093  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
2094  */
2095 tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add
2096                 (const tng_trajectory_t tng_data,
2097                  const tng_residue_t residue,
2098                  const char *atom_name,
2099                  const char *atom_type,
2100                  tng_atom_t *atom);
2101
2102 /**
2103  * @brief Add an atom with a specific ID to a residue.
2104  * @param tng_data is the trajectory containing the residue.
2105  * @param residue is the residue to add an atom to.
2106  * @param atom_name is a string containing the name of the atom.
2107  * @param atom_type is a string containing the atom type of the atom.
2108  * @param id is the ID of the created atom.
2109  * @param atom is a pointer to the newly created atom.
2110  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2111  * must be initialised before using it.
2112  * @pre \code atom_name != 0 \endcode The pointer to the atom name string
2113  * must not be a NULL pointer.
2114  * @pre \code atom_type != 0 \endcode The pointer to the atom_type string
2115  * must not be a NULL pointer.
2116  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
2117  * not be set properly or TNG_CRITICAL (2) if a major error has occured.
2118  */
2119 tng_function_status DECLSPECDLLEXPORT tng_residue_atom_w_id_add
2120                 (const tng_trajectory_t tng_data,
2121                  const tng_residue_t residue,
2122                  const char *atom_name,
2123                  const char *atom_type,
2124                  const int64_t id,
2125                  tng_atom_t *atom);
2126
2127 /**
2128  * @brief Get the residue of an atom.
2129  * @param tng_data the trajectory containing the atom.
2130  * @param atom the atom of which to get the name.
2131  * @param residue is set to the residue of the atom.
2132  * @pre \code atom != 0 \endcode The atom must not be NULL.
2133  * @return TNG_SUCCESS (0) if successful.
2134  */
2135 tng_function_status DECLSPECDLLEXPORT tng_atom_residue_get
2136                 (const tng_trajectory_t tng_data,
2137                  const tng_atom_t atom,
2138                  tng_residue_t *residue);
2139
2140 /**
2141  * @brief Get the name of an atom.
2142  * @param tng_data the trajectory containing the atom.
2143  * @param atom the atom of which to get the name.
2144  * @param name the string to fill with the name of the atom,
2145  * memory must be allocated before.
2146  * @param max_len maximum char length of the string, i.e. how much memory has
2147  * been reserved for name. This includes \0 terminating character.
2148  * @pre \code atom != 0 \endcode The atom must not be NULL.
2149  * @pre \code name != 0 \endcode The pointer to the name string
2150  * must not be a NULL pointer.
2151  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2152  * has occurred (source string longer than destination string).
2153  */
2154 tng_function_status DECLSPECDLLEXPORT tng_atom_name_get
2155                 (const tng_trajectory_t tng_data,
2156                  const tng_atom_t atom,
2157                  char *name,
2158                  const int max_len);
2159
2160 /**
2161  * @brief Set the name of an atom.
2162  * @param tng_data is the trajectory data container containing the atom.
2163  * @param atom is the atom to rename.
2164  * @param new_name is a string containing the wanted name.
2165  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2166  * must be initialised before using it.
2167  * @pre \code new_name != 0 \endcode The pointer to the name string
2168  * must not be a NULL pointer.
2169  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
2170  * error has occured.
2171  */
2172 tng_function_status DECLSPECDLLEXPORT tng_atom_name_set
2173                 (const tng_trajectory_t tng_data,
2174                  const tng_atom_t atom,
2175                  const char *new_name);
2176
2177 /**
2178  * @brief Get the type of an atom.
2179  * @param tng_data the trajectory containing the atom.
2180  * @param atom the atom of which to get the type.
2181  * @param type the string to fill with the type of the atom,
2182  * memory must be allocated before.
2183  * @param max_len maximum char length of the string, i.e. how much memory has
2184  * been reserved for type. This includes \0 terminating character.
2185  * @pre \code atom != 0 \endcode The atom must not be NULL.
2186  * @pre \code type != 0 \endcode The pointer to the type string
2187  * must not be a NULL pointer.
2188  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2189  * has occurred (source string longer than destination string).
2190  */
2191 tng_function_status DECLSPECDLLEXPORT tng_atom_type_get
2192                 (const tng_trajectory_t tng_data,
2193                  const tng_atom_t atom,
2194                  char *type,
2195                  const int max_len);
2196
2197 /**
2198  * @brief Set the atom type of an atom.
2199  * @param tng_data is the trajectory data container containing the atom.
2200  * @param atom is the atom to change.
2201  * @param new_type is a string containing the atom type.
2202  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2203  * must be initialised before using it.
2204  * @pre \code new_type != 0 \endcode The pointer to the atom type string
2205  * must not be a NULL pointer.
2206  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
2207  * error has occured.
2208  */
2209 tng_function_status DECLSPECDLLEXPORT tng_atom_type_set
2210                 (const tng_trajectory_t tng_data,
2211                  const tng_atom_t atom,
2212                  const char *new_type);
2213
2214 /**
2215  * @brief Get the molecule name of real particle number (number in mol system).
2216  * @param tng_data is the trajectory data container containing the atom.
2217  * @param nr is the real number of the particle in the molecular system.
2218  * @param name is a string, which is set to the name of the molecule. Memory
2219  * must be reserved beforehand.
2220  * @param max_len is the maximum length of name.
2221  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2222  * must be initialised before using it.
2223  * @pre \code name != 0 \endcode The pointer to the name string
2224  * must not be a NULL pointer.
2225  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2226  * has occured.
2227  */
2228 tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get
2229                 (const tng_trajectory_t tng_data,
2230                  const int64_t nr,
2231                  char *name,
2232                  const int max_len);
2233
2234 /**
2235  * @brief Get the molecule id of real particle number (number in mol system).
2236  * @param tng_data is the trajectory data container containing the atom.
2237  * @param nr is the real number of the particle in the molecular system.
2238  * @param id is will be set to the id of the molecule.
2239  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2240  * must be initialised before using it.
2241  * @pre \code id != 0 \endcode The pointer to id must not be a NULL pointer.
2242  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2243  * has occured.
2244  */
2245 tng_function_status DECLSPECDLLEXPORT tng_molecule_id_of_particle_nr_get
2246                 (const tng_trajectory_t tng_data,
2247                  const int64_t nr,
2248                  int64_t *id);
2249
2250 /**
2251  * @brief Get the bonds of the current molecular system.
2252  * @param tng_data is the trajectory data container containing the molecular
2253  * system.
2254  * @param n_bonds is set to the number of bonds in the molecular system and
2255  * thereby also the lengths of the two lists: from_atoms and to_atoms.
2256  * @param from_atoms is a list (memory reserved by this function) of atoms
2257  * (number of atom in mol system) in bonds.
2258  * @param to_atoms is a list (memory reserved by this function) of atoms
2259  * (number of atom in mol system) in bonds.
2260  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2261  * must be initialised before using it.
2262  * @pre \code n_bonds != 0 \endcode The pointer to n_bonds must not be a
2263  * NULL pointer.
2264  * @pre \code from_atoms != 0 \endcode The pointer to from_atoms must not
2265  * be a NULL pointer.
2266  * @pre \code to_atoms != 0 \endcode The pointer to to_atoms must not
2267  * be a NULL pointer.
2268  * @details The two lists of atoms use the same index, i.e. from_atoms[0]
2269  * and to_atoms[0] are linked with a bond. Since memory is reserved in
2270  * this function it must be freed afterwards.
2271  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2272  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2273  */
2274 tng_function_status DECLSPECDLLEXPORT tng_molsystem_bonds_get
2275                 (const tng_trajectory_t tng_data,
2276                  int64_t *n_bonds,
2277                  int64_t **from_atoms,
2278                  int64_t **to_atoms);
2279
2280 /**
2281  * @brief Get the chain name of real particle number (number in mol system).
2282  * @param tng_data is the trajectory data container containing the atom.
2283  * @param nr is the real number of the particle in the molecular system.
2284  * @param name is a string, which is set to the name of the chain. Memory
2285  * must be reserved beforehand.
2286  * @param max_len is the maximum length of name.
2287  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2288  * must be initialised before using it.
2289  * @pre \code name != 0 \endcode The pointer to the name string
2290  * must not be a NULL pointer.
2291  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2292  * has occured.
2293  */
2294 tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get
2295                 (const tng_trajectory_t tng_data,
2296                  const int64_t nr,
2297                  char *name,
2298                  const int max_len);
2299
2300 /**
2301  * @brief Get the residue name of real particle number (number in mol system).
2302  * @param tng_data is the trajectory data container containing the atom.
2303  * @param nr is the real number of the particle in the molecular system.
2304  * @param name is a string, which is set to the name of the residue. Memory
2305  * must be reserved beforehand.
2306  * @param max_len is the maximum length of name.
2307  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2308  * must be initialised before using it.
2309  * @pre \code name != 0 \endcode The pointer to the name string
2310  * must not be a NULL pointer.
2311  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2312  * has occured.
2313  */
2314 tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get
2315                 (const tng_trajectory_t tng_data,
2316                  const int64_t nr,
2317                  char *name,
2318                  const int max_len);
2319
2320 /**
2321  * @brief Get the residue id (local to molecule) of real particle number
2322  * (number in mol system).
2323  * @param tng_data is the trajectory data container containing the atom.
2324  * @param nr is the real number of the particle in the molecular system.
2325  * @param id is a pointer to the variable, which will be set to the ID.
2326  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2327  * must be initialised before using it.
2328  * @pre \code id != 0 \endcode The pointer to id must not be a NULL pointer.
2329  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2330  * has occured.
2331  */
2332 tng_function_status DECLSPECDLLEXPORT tng_residue_id_of_particle_nr_get
2333                 (const tng_trajectory_t tng_data,
2334                  const int64_t nr,
2335                  int64_t *id);
2336
2337 /**
2338  * @brief Get the residue id (based on other molecules and molecule counts)
2339  * of real particle number (number in mol system).
2340  * @param tng_data is the trajectory data container containing the atom.
2341  * @param nr is the real number of the particle in the molecular system.
2342  * @param id is a pointer to the variable, which will be set to the ID.
2343  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2344  * must be initialised before using it.
2345  * @pre \code id != 0 \endcode The pointer to id must not be a NULL pointer.
2346  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2347  * has occured.
2348  */
2349 tng_function_status DECLSPECDLLEXPORT tng_global_residue_id_of_particle_nr_get
2350                 (const tng_trajectory_t tng_data,
2351                  const int64_t nr,
2352                  int64_t *id);
2353
2354 /**
2355  * @brief Get the atom name of real particle number (number in mol system).
2356  * @param tng_data is the trajectory data container containing the atom.
2357  * @param nr is the real number of the particle in the molecular system.
2358  * @param name is a string, which is set to the name of the atom. Memory
2359  * must be reserved beforehand.
2360  * @param max_len is the maximum length of name.
2361  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2362  * must be initialised before using it.
2363  * @pre \code name != 0 \endcode The pointer to the name string
2364  * must not be a NULL pointer.
2365  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2366  * has occured.
2367  */
2368 tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get
2369                 (const tng_trajectory_t tng_data,
2370                  const int64_t nr,
2371                  char *name,
2372                  const int max_len);
2373
2374 /**
2375  * @brief Get the atom type of real particle number (number in mol system).
2376  * @param tng_data is the trajectory data container containing the atom.
2377  * @param nr is the real number of the particle in the molecular system.
2378  * @param type is a string, which is set to the type of the atom. Memory
2379  * must be reserved beforehand.
2380  * @param max_len is the maximum length of type.
2381  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2382  * must be initialised before using it.
2383  * @pre \code type != 0 \endcode The pointer to the type string
2384  * must not be a NULL pointer.
2385  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
2386  * has occured.
2387  */
2388 tng_function_status DECLSPECDLLEXPORT tng_atom_type_of_particle_nr_get
2389                 (const tng_trajectory_t tng_data,
2390                  const int64_t nr,
2391                  char *type,
2392                  const int max_len);
2393
2394 /**
2395  * @brief Add a particle mapping table.
2396  * @details Each particle mapping table will be written as a separate block,
2397  * followed by the data blocks for the corresponding particles. In most cases
2398  * there is one particle mapping block for each thread writing the trajectory.
2399  * @param tng_data is the trajectory, with the frame set to which to add
2400  * the mapping block.
2401  * @details The mapping information is added to the currently active frame set
2402  * of tng_data
2403  * @param num_first_particle is the first particle number of this mapping
2404  * block.
2405  * @param n_particles is the number of particles in this mapping block.
2406  * @param mapping_table is a list of the real particle numbers (i.e. the numbers
2407  * used in the molecular system). The list is n_particles long.
2408  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2409  * must be initialised before using it.
2410  * @details mapping_table[0] is the real particle number of the first particle
2411  * in the following data blocks.
2412  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2413  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2414  */
2415 tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add
2416                 (const tng_trajectory_t tng_data,
2417                  const int64_t num_first_particle,
2418                  const int64_t n_particles,
2419                  const int64_t *mapping_table);
2420
2421 /**
2422  * @brief Remove all particle mappings (in memory) from the current frame set.
2423  * @details Clears the currently setup particle mappings of the current frame
2424  * set.
2425  * @param tng_data is the trajectory, with the frame set of which to clear
2426  * all particle mappings.
2427  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2428  * must be initialised before using it.
2429  * @return TNG_SUCCESS (0) if successful.
2430  */
2431 tng_function_status DECLSPECDLLEXPORT tng_frame_set_particle_mapping_free
2432                 (const tng_trajectory_t tng_data);
2433
2434 /**
2435  * @brief Read the header blocks from the input_file of tng_data.
2436  * @details The trajectory blocks must be read separately and iteratively in chunks
2437  * to fit in memory.
2438  * @param tng_data is a trajectory data container.
2439  * @details tng_data->input_file_path specifies
2440  * which file to read from. If the file (input_file) is not open it will be
2441  * opened.
2442  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2443  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2444  * compared to the md5 hash of the read contents to ensure valid data.
2445  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2446  * must be initialised before using it.
2447  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
2448  * error has occured.
2449  */
2450 tng_function_status DECLSPECDLLEXPORT tng_file_headers_read
2451                 (const tng_trajectory_t tng_data,
2452                  const char hash_mode);
2453
2454 /**
2455  * @brief Write the header blocks to the output_file of tng_data.
2456  * @details The trajectory blocks must be written separately and iteratively in chunks
2457  * to fit in memory.
2458  * @param tng_data is a trajectory data container.
2459  * @details tng_data->output_file_path
2460  * specifies which file to write to. If the file (output_file) is not open it
2461  * will be opened.
2462  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2463  * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
2464  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2465  * must be initialised before using it.
2466  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
2467  * error has occured.
2468  */
2469 tng_function_status DECLSPECDLLEXPORT tng_file_headers_write
2470                 (const tng_trajectory_t tng_data,
2471                  const char hash_mode);
2472
2473 /**
2474  * @brief Read one (the next) block (of any kind) from the input_file of tng_data.
2475  * @param tng_data is a trajectory data container.
2476  * @details tng_data->input_file_path specifies
2477  * which file to read from. If the file (input_file) is not open it will be
2478  * opened.
2479  * @param block_data is a pointer to the struct which will be populated with the
2480  * data.
2481  * @details If block_data->input_file_pos > 0 it is the position from where the
2482  * reading starts otherwise it starts from the current position.
2483  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2484  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2485  * compared to the md5 hash of the read contents to ensure valid data.
2486  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2487  * must be initialised before using it.
2488  * @pre \code block != 0 \endcode The block container (block) must be
2489  * initialised before using it.
2490  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2491  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2492  */
2493 tng_function_status DECLSPECDLLEXPORT tng_block_read_next
2494                 (const tng_trajectory_t tng_data,
2495                  const tng_gen_block_t block_data,
2496                  const char hash_mode);
2497
2498 /**
2499  * @brief Read one frame set, including all particle mapping blocks and data
2500  * blocks, starting from the current file position.
2501  * @param tng_data is a trajectory data container.
2502  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2503  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2504  * compared to the md5 hash of the read contents to ensure valid data.
2505  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2506  * must be initialised before using it.
2507  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2508  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2509  */
2510 tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
2511                 (const tng_trajectory_t tng_data,
2512                  const char hash_mode);
2513
2514 /**
2515  * @brief Read data from the current frame set from the input_file. Only read
2516  * particle mapping and data blocks matching the specified block_id.
2517  * @param tng_data is a trajectory data container.
2518  * @details  tng_data->input_file_path specifies
2519  * which file to read from. If the file (input_file) is not open it will be
2520  * opened.
2521  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2522  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2523  * compared to the md5 hash of the read contents to ensure valid data.
2524  * @param block_id is the ID of the data block to read from file.
2525  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2526  * must be initialised before using it.
2527  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2528  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2529  */
2530 tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_block_id
2531                 (const tng_trajectory_t tng_data,
2532                  const char hash_mode,
2533                  const int64_t block_id);
2534
2535 /**
2536  * @brief Read one (the next) frame set, including particle mapping and related data blocks
2537  * from the input_file of tng_data.
2538  * @param tng_data is a trajectory data container.
2539  * @details  tng_data->input_file_path specifies
2540  * which file to read from. If the file (input_file) is not open it will be
2541  * opened.
2542  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2543  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2544  * compared to the md5 hash of the read contents to ensure valid data.
2545  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2546  * must be initialised before using it.
2547  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2548  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2549  */
2550 tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next
2551                 (const tng_trajectory_t tng_data,
2552                  const char hash_mode);
2553
2554 /**
2555  * @brief Read one (the next) frame set, including particle mapping and data blocks with a
2556  * specific block id from the input_file of tng_data.
2557  * @param tng_data is a trajectory data container.
2558  * @details  tng_data->input_file_path specifies
2559  * which file to read from. If the file (input_file) is not open it will be
2560  * opened.
2561  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2562  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2563  * compared to the md5 hash of the read contents to ensure valid data.
2564  * @param block_id is the ID number of the blocks that should be read from file.
2565  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2566  * must be initialised before using it.
2567  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2568  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2569  */
2570 tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_only_data_from_block_id
2571                 (const tng_trajectory_t tng_data,
2572                  const char hash_mode,
2573                  const int64_t block_id);
2574
2575 /**
2576  * @brief Write one frame set, including mapping and related data blocks
2577  * to the output_file of tng_data.
2578  * @param tng_data is a trajectory data container.
2579  * @details  tng_data->output_file_path specifies
2580  * which file to write to. If the file (output_file) is not open it will be
2581  * opened.
2582  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2583  * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
2584  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2585  * must be initialised before using it.
2586  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2587  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2588  */
2589 tng_function_status DECLSPECDLLEXPORT tng_frame_set_write
2590                 (const tng_trajectory_t tng_data,
2591                  const char hash_mode);
2592
2593 /**
2594  * @brief Write one frame set even if it does not have as many frames as
2595  * expected. The function also writes mapping and related data blocks
2596  * to the output_file of tng_data.
2597  * @param tng_data is a trajectory data container.
2598  * @details  tng_data->output_file_path specifies
2599  * which file to write to. If the file (output_file) is not open it will be
2600  * opened.
2601  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2602  * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
2603  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2604  * must be initialised before using it.
2605  * @details The number of frames in the frame set is set to the number of
2606  * frames of the data blocks before writing it to disk.
2607  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2608  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2609  */
2610 tng_function_status DECLSPECDLLEXPORT tng_frame_set_premature_write
2611                 (const tng_trajectory_t tng_data,
2612                  const char hash_mode);
2613
2614 /**
2615  * @brief Create and initialise a frame set.
2616  * @details Particle mappings are retained from previous frame set (if any).
2617  * To explicitly clear particle mappings use tng_frame_set_particle_mapping_free().
2618  * @param tng_data is the trajectory data container in which to add the frame
2619  * set.
2620  * @param first_frame is the first frame of the frame set.
2621  * @param n_frames is the number of frames in the frame set.
2622  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2623  * must be initialised before using it.
2624  * @pre \code first_frame >= 0 \endcode The first frame must not be negative.
2625  * @pre \code n_frames >= 0 \endcode The number of frames must not be negative.
2626  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2627  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2628  */
2629 tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
2630                 (const tng_trajectory_t tng_data,
2631                  const int64_t first_frame,
2632                  const int64_t n_frames);
2633
2634 /**
2635  * @brief Create and initialise a frame set with the time of the first frame
2636  * specified.
2637  * @param tng_data is the trajectory data container in which to add the frame
2638  * set.
2639  * @param first_frame is the first frame of the frame set.
2640  * @param n_frames is the number of frames in the frame set.
2641  * @param first_frame_time is the time stamp of the first frame (in seconds).
2642  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2643  * must be initialised before using it.
2644  * @pre \code first_frame >= 0 \endcode The first frame must not be negative.
2645  * @pre \code n_frames >= 0 \endcode The number of frames must not be negative.
2646  * @pre \code first_frame_time >= 0 \endcode The time stamp of the first frame
2647  * must not be negative.
2648  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2649  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2650  */
2651 tng_function_status DECLSPECDLLEXPORT tng_frame_set_with_time_new
2652                 (const tng_trajectory_t tng_data,
2653                  const int64_t first_frame,
2654                  const int64_t n_frames,
2655                  const double first_frame_time);
2656
2657 /**
2658  * @brief Set the time stamp of the first frame of the current frame set.
2659  * @param tng_data is the trajectory containing the frame set.
2660  * @param first_frame_time is the time stamp of the first frame in the
2661  * frame set.
2662  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2663  * must be initialised before using it.
2664  * @pre \code first_frame_time >= 0 \endcode The time stamp of the first frame
2665  * must not be negative.
2666  * @return TNG_SUCCESS (0) if successful.
2667  */
2668 tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set
2669                 (const tng_trajectory_t tng_data,
2670                  const double first_frame_time);
2671
2672 /**
2673  * @brief Read the number of the first frame of the next frame set.
2674  * @param tng_data is the trajectory containing the frame set.
2675  * @param frame is set to the frame number of the first frame in the
2676  * next frame set.
2677  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2678  * must be initialised before using it.
2679  * @pre \code tng_data->input_file != 0 \endcode An input file must be open
2680  * to find the next frame set.
2681  * @pre \code frame != 0 \endcode The pointer to the frame must not be a NULL
2682  * pointer.
2683  * @return TNG_SUCCESS(0) if successful, TNG_FAILURE(1) if there is no next
2684  * frame set or TNG_CRITICAL(2) if a major error has occured.
2685  */
2686 tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
2687                 (const tng_trajectory_t tng_data,
2688                  int64_t *frame);
2689
2690 /**
2691  * @brief Add a non-particle dependent data block.
2692  * @param tng_data is the trajectory data container in which to add the data
2693  * block
2694  * @param id is the block ID of the block to add.
2695  * @param block_name is a descriptive name of the block to add
2696  * @param datatype is the datatype of the data in the block (e.g. int/float)
2697  * @param block_type_flag indicates if this is a non-trajectory block (added
2698  * directly to tng_data) or if it is a trajectory block (added to the
2699  * frame set)
2700  * @param n_frames is the number of frames of the data block (automatically
2701  * set to 1 if adding a non-trajectory data block)
2702  * @param n_values_per_frame is how many values a stored each frame (e.g. 9
2703  * for a box shape block)
2704  * @param stride_length is how many frames are between each entry in the
2705  * data block
2706  * @param codec_id is the ID of the codec to compress the data.
2707  * @param new_data is an array of data values to add.
2708  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2709  * must be initialised before using it.
2710  * @pre \code block_name != 0 \endcode The pointer to the block name must
2711  * not be a NULL pointer.
2712  * @pre \code n_values_per_frame > 0 \endcode n_values_per_frame must be
2713  * a positive integer.
2714  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2715  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2716  */
2717 tng_function_status DECLSPECDLLEXPORT tng_data_block_add
2718                 (const tng_trajectory_t tng_data,
2719                  const int64_t id,
2720                  const char *block_name,
2721                  const char datatype,
2722                  const char block_type_flag,
2723                  int64_t n_frames,
2724                  const int64_t n_values_per_frame,
2725                  int64_t stride_length,
2726                  const int64_t codec_id,
2727                  void *new_data);
2728
2729 /**
2730  * @brief Add a particle dependent data block.
2731  * @param tng_data is the trajectory data container in which to add the data
2732  * block
2733  * @param id is the block ID of the block to add.
2734  * @param block_name is a descriptive name of the block to add
2735  * @param datatype is the datatype of the data in the block (e.g. int/float)
2736  * @param block_type_flag indicates if this is a non-trajectory block (added
2737  * directly to tng_data) or if it is a trajectory block (added to the
2738  * frame set)
2739  * @param n_frames is the number of frames of the data block (automatically
2740  * set to 1 if adding a non-trajectory data block)
2741  * @param n_values_per_frame is how many values a stored each frame (e.g. 9
2742  * for a box shape block)
2743  * @param stride_length is how many frames are between each entry in the
2744  * data block
2745  * @param num_first_particle is the number of the first particle stored
2746  * in this data block
2747  * @param n_particles is the number of particles stored in this data block
2748  * @param codec_id is the ID of the codec to compress the data.
2749  * @param new_data is an array of data values to add.
2750  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2751  * must be initialised before using it.
2752  * @pre \code block_name != 0 \endcode The pointer to the block name must
2753  * not be a NULL pointer.
2754  * @pre \code n_values_per_frame > 0 \endcode n_values_per_frame must be
2755  * a positive integer.
2756  * @pre \code num_first_particle >= 0 \endcode The number of the
2757  * first particle must be >= 0.
2758  * @pre \code n_particles >= 0 \endcode n_particles must be >= 0.
2759  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2760  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2761  */
2762 tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add
2763                 (const tng_trajectory_t tng_data,
2764                  const int64_t id,
2765                  const char *block_name,
2766                  const char datatype,
2767                  const char block_type_flag,
2768                  int64_t n_frames,
2769                  const int64_t n_values_per_frame,
2770                  int64_t stride_length,
2771                  const int64_t num_first_particle,
2772                  const int64_t n_particles,
2773                  const int64_t codec_id,
2774                  void *new_data);
2775
2776 /** @brief Get the name of a data block of a specific ID.
2777  * @param tng_data is the trajectory data container.
2778  * @param block_id is the ID of the data block of which to get the name.
2779  * @param name is a string, which is set to the name of the data block.
2780  * Memory must be reserved beforehand.
2781  * @param max_len is the maximum length of name.
2782  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2783  * must be initialised before using it.
2784  * @pre \code name != 0 \endcode The pointer to the name string
2785  * must not be a NULL pointer.
2786  * @return TNG_SUCCESS (0) if the data block is found, TNG_FAILURE (1)
2787  * if a minor error has occured or the data block is not found or
2788  * TNG_CRITICAL (2) if a major error has occured.
2789  */
2790 tng_function_status DECLSPECDLLEXPORT tng_data_block_name_get
2791                 (const tng_trajectory_t tng_data,
2792                  const int64_t block_id,
2793                  char *name,
2794                  const int max_len);
2795
2796 /** @brief Get the dependency of a data block of a specific ID.
2797  * @param tng_data is the trajectory data container.
2798  * @param block_id is the ID of the data block of which to get the name.
2799  * @param block_dependency is a pointer to the dependency of the data block.
2800  * If the block is frame dependent it will be set to TNG_FRAME_DEPENDENT,
2801  * if it is particle dependent it will be set to TNG_PARTICLE_DEPENDENT and
2802  * if it is both it will be set to TNG_FRAME_DEPENDENT & TNG_PARTICLE_DEPENDENT.
2803  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2804  * must be initialised before using it.
2805  * @pre \code block_dependency != 0 \endcode The pointer to the block dependency
2806  * must not be a NULL pointer.
2807  * @return TNG_SUCCESS (0) if the data block is found, TNG_FAILURE (1)
2808  * if a minor error has occured or the data block is not found or
2809  * TNG_CRITICAL (2) if a major error has occured.
2810  */
2811 tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get
2812                 (const tng_trajectory_t tng_data,
2813                  const int64_t block_id,
2814                  int *block_dependency);
2815
2816 /** @brief Get the number of values per frame of a data block of a specific ID.
2817  * @param tng_data is the trajectory data container.
2818  * @param block_id is the ID of the data block of which to get the name.
2819  * @param n_values_per_frame is a pointer set to the number of values per frame.
2820  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2821  * must be initialised before using it.
2822  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of values
2823  * per frame must not be a NULL pointer.
2824  * @return TNG_SUCCESS (0) if the data block is found, TNG_FAILURE (1)
2825  * if a minor error has occured or the data block is not found or
2826  * TNG_CRITICAL (2) if a major error has occured.
2827  */
2828 tng_function_status DECLSPECDLLEXPORT tng_data_block_num_values_per_frame_get
2829                 (const tng_trajectory_t tng_data,
2830                  const int64_t block_id,
2831                  int64_t *n_values_per_frame);
2832
2833 /**
2834  * @brief Write data of one trajectory frame to the output_file of tng_data.
2835  * @param tng_data is a trajectory data container. tng_data->output_file_path
2836  * specifies which file to write to. If the file (output_file) is not open it
2837  * will be opened.
2838  * @param frame_nr is the index number of the frame to write.
2839  * @param block_id is the ID of the data block to write the data to.
2840  * @param values is an array of data to write. The length of the array should
2841  * equal n_values_per_frame.
2842  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2843  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2844  * compared to the md5 hash of the read contents to ensure valid data.
2845  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2846  * must be initialised before using it.
2847  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
2848  * @pre \code values != 0 \endcode The pointer to the values must not be a NULL
2849  * pointer.
2850  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2851  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2852  */
2853 tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
2854                 (const tng_trajectory_t tng_data,
2855                  const int64_t frame_nr,
2856                  const int64_t block_id,
2857                  const void *values,
2858                  const char hash_mode);
2859
2860 /**
2861  * @brief Write particle data of one trajectory frame to the output_file of
2862  * tng_data.
2863  * @param tng_data is a trajectory data container. tng_data->output_file_path
2864  * specifies which file to write to. If the file (output_file) is not open it
2865  * will be opened.
2866  * @param frame_nr is the index number of the frame to write.
2867  * @param block_id is the ID of the data block to write the data to.
2868  * @param val_first_particle is the number of the first particle in the data
2869  * array.
2870  * @param val_n_particles is the number of particles in the data array.
2871  * @param values is a 1D-array of data to write. The length of the array should
2872  * equal n_particles * n_values_per_frame.
2873  * @param hash_mode is an option to decide whether to use the md5 hash or not.
2874  * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
2875  * compared to the md5 hash of the read contents to ensure valid data.
2876  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2877  * must be initialised before using it.
2878  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
2879  * @pre \code val_first_particle >= 0 \endcode The number of the
2880  * first particle must be >= 0.
2881  * @pre \code val_n_particles >= 0 \endcode The number of particles must be >= 0.
2882  * @pre \code values != 0 \endcode The pointer to the values must not be a NULL
2883  * pointer.
2884  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2885  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2886  */
2887 tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
2888                 (const tng_trajectory_t tng_data,
2889                  const int64_t frame_nr,
2890                  const int64_t block_id,
2891                  const int64_t val_first_particle,
2892                  const int64_t val_n_particles,
2893                  const void *values,
2894                  const char hash_mode);
2895
2896 /**
2897  * @brief Free data of an array of values (2D).
2898  * @param tng_data is a trajectory data container.
2899  * @param values is the 2D array to free and will be set to 0 afterwards.
2900  * @param n_frames is the number of frames in the data array.
2901  * @param n_values_per_frame is the number of values per frame in the data array.
2902  * @param type is the data type of the data in the array (e.g. int/float/char).
2903  * @details This function should not be used. The data_values union is obsolete.
2904  * This function also causes memory leaks, but its signature cannot be changed
2905  * without disturbing the API.
2906  * @return TNG_SUCCESS (0) if successful.
2907  */
2908 tng_function_status DECLSPECDLLEXPORT tng_data_values_free
2909                 (const tng_trajectory_t tng_data,
2910                  union data_values **values,
2911                  const int64_t n_frames,
2912                  const int64_t n_values_per_frame,
2913                  const char type);
2914
2915 /**
2916  * @brief Free data of an array of values (3D).
2917  * @param tng_data is a trajectory data container.
2918  * @param values is the array to free and will be set to 0 afterwards.
2919  * @param n_frames is the number of frames in the data array.
2920  * @param n_particles is the number of particles in the data array.
2921  * @param n_values_per_frame is the number of values per frame in the data array.
2922  * @param type is the data type of the data in the array (e.g. int/float/char).
2923  * @details This function should not be used. The data_values union is obsolete.
2924  * This function also causes memory leaks, but its signature cannot be changed
2925  * without disturbing the API.
2926  * @return TNG_SUCCESS (0) if successful.
2927  */
2928 tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free
2929                 (const tng_trajectory_t tng_data,
2930                  union data_values ***values,
2931                  const int64_t n_frames,
2932                  const int64_t n_particles,
2933                  const int64_t n_values_per_frame,
2934                  const char type);
2935
2936 /**
2937  * @brief Retrieve non-particle data, from the last read frame set. Obsolete!
2938  * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
2939  * which file to read from. If the file (input_file) is not open it will be
2940  * opened.
2941  * @param block_id is the id number of the particle data block to read.
2942  * @param values is a pointer to a 2-dimensional array (memory unallocated), which
2943  * will be filled with data. The array will be sized
2944  * (n_frames * n_values_per_frame).
2945  * Since ***values is allocated in this function it is the callers
2946  * responsibility to free the memory.
2947  * @param n_frames is set to the number of frames in the returned data. This is
2948  * needed to properly reach and/or free the data afterwards.
2949  * @param n_values_per_frame is set to the number of values per frame in the data.
2950  * This is needed to properly reach and/or free the data afterwards.
2951  * @param type is set to the data type of the data in the array.
2952  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2953  * must be initialised before using it.
2954  * @pre \code n_frames != 0 \endcode The pointer to the number of frames
2955  * must not be a NULL pointer.
2956  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
2957  * values per frame must not be a NULL pointer.
2958  * @pre \code type != 0 \endcode The pointer to the data type must not
2959  * be a NULL pointer.
2960  * @details This function is obsolete and only retained for compatibility. Use
2961  * tng_data_vector_get() instead.
2962  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
2963  * has occurred or TNG_CRITICAL (2) if a major error has occured.
2964  */
2965 tng_function_status DECLSPECDLLEXPORT tng_data_get(const tng_trajectory_t tng_data,
2966                                                    const int64_t block_id,
2967                                                    union data_values ***values,
2968                                                    int64_t *n_frames,
2969                                                    int64_t *n_values_per_frame,
2970                                                    char *type);
2971
2972 /**
2973  * @brief Retrieve a vector (1D array) of non-particle data, from the last read frame set.
2974  * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
2975  * which file to read from. If the file (input_file) is not open it will be
2976  * opened.
2977  * @param block_id is the id number of the particle data block to read.
2978  * @param values is a pointer to a 1-dimensional array (memory unallocated), which
2979  * will be filled with data. The length of the array will be (n_frames * n_values_per_frame).
2980  * Since **values is allocated in this function it is the callers
2981  * responsibility to free the memory.
2982  * @param n_frames is set to the number of particles in the returned data. This is
2983  * needed to properly reach and/or free the data afterwards.
2984  * @param stride_length is set to the stride length of the returned data.
2985  * @param n_values_per_frame is set to the number of values per frame in the data.
2986  * This is needed to properly reach and/or free the data afterwards.
2987  * @param type is set to the data type of the data in the array.
2988  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
2989  * must be initialised before using it.
2990  * @pre \code n_frames != 0 \endcode The pointer to the number of frames
2991  * must not be a NULL pointer.
2992  * @pre \code stride_length != 0 \endcode The pointer to the stride length
2993  * must not be a NULL pointer.
2994  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
2995  * values per frame must not be a NULL pointer.
2996  * @pre \code type != 0 \endcode The pointer to the data type must not
2997  * be a NULL pointer.
2998  * @details This does only work for numerical (int, float, double) data.
2999  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3000  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3001  */
3002 tng_function_status DECLSPECDLLEXPORT tng_data_vector_get
3003                 (const tng_trajectory_t tng_data,
3004                  const int64_t block_id,
3005                  void **values,
3006                  int64_t *n_frames,
3007                  int64_t *stride_length,
3008                  int64_t *n_values_per_frame,
3009                  char *type);
3010
3011 /**
3012  * @brief Read and retrieve non-particle data, in a specific interval. Obsolete!
3013  * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
3014  * which file to read from. If the file (input_file) is not open it will be
3015  * opened.
3016  * @param block_id is the id number of the particle data block to read.
3017  * @param start_frame_nr is the index number of the first frame to read.
3018  * @param end_frame_nr is the index number of the last frame to read.
3019  * @param hash_mode is an option to decide whether to use the md5 hash or not.
3020  * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
3021  * compared to the md5 hash of the read contents to ensure valid data.
3022  * @param values is a pointer to a 2-dimensional array (memory unallocated), which
3023  * will be filled with data. The array will be sized
3024  * (n_frames * n_values_per_frame).
3025  * Since ***values is allocated in this function it is the callers
3026  * responsibility to free the memory.
3027  * @param n_values_per_frame is set to the number of values per frame in the data.
3028  * This is needed to properly reach and/or free the data afterwards.
3029  * @param type is set to the data type of the data in the array.
3030  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3031  * must be initialised before using it.
3032  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3033  * the last frame.
3034  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
3035  * values per frame must not be a NULL pointer.
3036  * @pre \code type != 0 \endcode The pointer to the data type must not
3037  * be a NULL pointer.
3038  * @details This function is obsolete and only retained for compatibility. Use
3039  * tng_data_vector_interval_get() instead.
3040  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3041  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3042  */
3043 tng_function_status DECLSPECDLLEXPORT tng_data_interval_get
3044                 (const tng_trajectory_t tng_data,
3045                  const int64_t block_id,
3046                  const int64_t start_frame_nr,
3047                  const int64_t end_frame_nr,
3048                  const char hash_mode,
3049                  union data_values ***values,
3050                  int64_t *n_values_per_frame,
3051                  char *type);
3052
3053 /**
3054  * @brief Read and retrieve a vector (1D array) of non-particle data,
3055  * in a specific interval.
3056  * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
3057  * which file to read from. If the file (input_file) is not open it will be
3058  * opened.
3059  * @param block_id is the id number of the particle data block to read.
3060  * @param start_frame_nr is the index number of the first frame to read.
3061  * @param end_frame_nr is the index number of the last frame to read.
3062  * @param hash_mode is an option to decide whether to use the md5 hash or not.
3063  * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
3064  * compared to the md5 hash of the read contents to ensure valid data.
3065  * @param values is a pointer to a 1-dimensional array (memory unallocated), which
3066  * will be filled with data. The length of the array will be (n_frames * n_values_per_frame).
3067  * Since **values is allocated in this function it is the callers
3068  * responsibility to free the memory.
3069  * @param stride_length is set to the stride length (writing interval) of
3070  * the data.
3071  * @param n_values_per_frame is set to the number of values per frame in the data.
3072  * This is needed to properly reach and/or free the data afterwards.
3073  * @param type is set to the data type of the data in the array.
3074  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3075  * must be initialised before using it.
3076  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3077  * the last frame.
3078  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3079  * must not be a NULL pointer.
3080  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
3081  * values per frame must not be a NULL pointer.
3082  * @pre \code type != 0 \endcode The pointer to the data type must not
3083  * be a NULL pointer.
3084  * @details This does only work for numerical (int, float, double) data.
3085  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3086  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3087  */
3088 tng_function_status DECLSPECDLLEXPORT tng_data_vector_interval_get
3089                 (const tng_trajectory_t tng_data,
3090                  const int64_t block_id,
3091                  const int64_t start_frame_nr,
3092                  const int64_t end_frame_nr,
3093                  const char hash_mode,
3094                  void **values,
3095                  int64_t *stride_length,
3096                  int64_t *n_values_per_frame,
3097                  char *type);
3098
3099 /**
3100  * @brief Retrieve particle data, from the last read frame set. Obsolete!
3101  * @details The particle dimension of the returned values array is translated
3102  * to real particle numbering, i.e. the numbering of the actual molecular
3103  * system.
3104  * @param tng_data is a trajectory data container. tng_data->input_file_path
3105  * specifies which file to read from. If the file (input_file) is not open it
3106  * will be opened.
3107  * @param block_id is the id number of the particle data block to read.
3108  * @param values is a pointer to a 3-dimensional array (memory unallocated), which
3109  * will be filled with data. The array will be sized
3110  * (n_frames * n_particles * n_values_per_frame).
3111  * Since ****values is allocated in this function it is the callers
3112  * responsibility to free the memory.
3113  * @param n_frames is set to the number of frames in the returned data. This is
3114  * needed to properly reach and/or free the data afterwards.
3115  * @param n_particles is set to the number of particles in the returned data. This is
3116  * needed to properly reach and/or free the data afterwards.
3117  * @param n_values_per_frame is set to the number of values per frame in the data.
3118  * This is needed to properly reach and/or free the data afterwards.
3119  * @param type is set to the data type of the data in the array.
3120  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3121  * must be initialised before using it.
3122  * @pre \code n_frames != 0 \endcode The pointer to the number of frames
3123  * must not be a NULL pointer.
3124  * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
3125  * not be a NULL pointer.
3126  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
3127  * values per frame must not be a NULL pointer.
3128  * @pre \code type != 0 \endcode The pointer to the data type must not
3129  * be a NULL pointer.
3130  * @details This function is obsolete and only retained for compatibility. Use
3131  * tng_particle_data_vector_get() instead.
3132  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3133  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3134  */
3135 tng_function_status DECLSPECDLLEXPORT tng_particle_data_get
3136                 (const tng_trajectory_t tng_data,
3137                  const int64_t block_id,
3138                  union data_values ****values,
3139                  int64_t *n_frames,
3140                  int64_t *n_particles,
3141                  int64_t *n_values_per_frame,
3142                  char *type);
3143
3144 /**
3145  * @brief Retrieve a vector (1D array) of particle data, from the last read frame set.
3146  * @details The particle dimension of the returned values array is translated
3147  * to real particle numbering, i.e. the numbering of the actual molecular
3148  * system.
3149  * @param tng_data is a trajectory data container. tng_data->input_file_path
3150  * specifies which file to read from. If the file (input_file) is not open it
3151  * will be opened.
3152  * @param block_id is the id number of the particle data block to read.
3153  * @param values is a pointer to a 1-dimensional array (memory unallocated), which
3154  * will be filled with data. The length of the array will be
3155  * (n_frames * n_particles * n_values_per_frame).
3156  * Since **values is allocated in this function it is the callers
3157  * responsibility to free the memory.
3158  * @param n_frames is set to the number of frames in the returned data. This is
3159  * needed to properly reach and/or free the data afterwards.
3160  * @param stride_length is set to the stride length of the returned data.
3161  * @param n_particles is set to the number of particles in the returned data. This is
3162  * needed to properly reach and/or free the data afterwards.
3163  * @param n_values_per_frame is set to the number of values per frame in the data.
3164  * This is needed to properly reach and/or free the data afterwards.
3165  * @param type is set to the data type of the data in the array.
3166  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3167  * must be initialised before using it.
3168  * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
3169  * not be a NULL pointer.
3170  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3171  * must not be a NULL pointer.
3172  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
3173  * values per frame must not be a NULL pointer.
3174  * @pre \code type != 0 \endcode The pointer to the data type must not
3175  * be a NULL pointer.
3176  * @details This does only work for numerical (int, float, double) data.
3177  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3178  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3179  */
3180 tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_get
3181                 (const tng_trajectory_t tng_data,
3182                  const int64_t block_id,
3183                  void **values,
3184                  int64_t *n_frames,
3185                  int64_t *stride_length,
3186                  int64_t *n_particles,
3187                  int64_t *n_values_per_frame,
3188                  char *type);
3189
3190 /**
3191  * @brief Read and retrieve particle data, in a specific interval. Obsolete!
3192  * @details The particle dimension of the returned values array is translated
3193  * to real particle numbering, i.e. the numbering of the actual molecular
3194  * system.
3195  * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
3196  * which file to read from. If the file (input_file) is not open it will be
3197  * opened.
3198  * @param block_id is the id number of the particle data block to read.
3199  * @param start_frame_nr is the index number of the first frame to read.
3200  * @param end_frame_nr is the index number of the last frame to read.
3201  * @param hash_mode is an option to decide whether to use the md5 hash or not.
3202  * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
3203  * compared to the md5 hash of the read contents to ensure valid data.
3204  * @param values is a pointer to a 3-dimensional array (memory unallocated), which
3205  * will be filled with data. The array will be sized
3206  * (n_frames * n_particles * n_values_per_frame).
3207  * Since ****values is allocated in this function it is the callers
3208  * responsibility to free the memory.
3209  * @param n_particles is set to the number of particles in the returned data. This is
3210  * needed to properly reach and/or free the data afterwards.
3211  * @param n_values_per_frame is set to the number of values per frame in the data.
3212  * This is needed to properly reach and/or free the data afterwards.
3213  * @param type is set to the data type of the data in the array.
3214  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3215  * must be initialised before using it.
3216  * @pre \code n_frames != 0 \endcode The pointer to the number of frames
3217  * must not be a NULL pointer.
3218  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3219  * the last frame.
3220  * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
3221  * not be a NULL pointer.
3222  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
3223  * values per frame must not be a NULL pointer.
3224  * @pre \code type != 0 \endcode The pointer to the data type must not
3225  * be a NULL pointer.
3226  * @details This function is obsolete and only retained for compatibility. Use
3227  * tng_particle_data_vector_interval_get() instead.
3228  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3229  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3230  */
3231 tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get
3232                 (const tng_trajectory_t tng_data,
3233                  const int64_t block_id,
3234                  const int64_t start_frame_nr,
3235                  const int64_t end_frame_nr,
3236                  const char hash_mode,
3237                  union data_values ****values,
3238                  int64_t *n_particles,
3239                  int64_t *n_values_per_frame,
3240                  char *type);
3241
3242 /**
3243  * @brief Read and retrieve a vector (1D array) particle data, in a
3244  * specific interval.
3245  * @details The particle dimension of the returned values array is translated
3246  * to real particle numbering, i.e. the numbering of the actual molecular
3247  * system.
3248  * @param tng_data is a trajectory data container. tng_data->input_file_path specifies
3249  * which file to read from. If the file (input_file) is not open it will be
3250  * opened.
3251  * @param block_id is the id number of the particle data block to read.
3252  * @param start_frame_nr is the index number of the first frame to read.
3253  * @param end_frame_nr is the index number of the last frame to read.
3254  * @param hash_mode is an option to decide whether to use the md5 hash or not.
3255  * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
3256  * compared to the md5 hash of the read contents to ensure valid data.
3257  * @param values is a pointer to a 1-dimensional array (memory unallocated), which
3258  * will be filled with data. The length of the array will be
3259  * (n_frames * n_particles * n_values_per_frame).
3260  * Since **values is allocated in this function it is the callers
3261  * responsibility to free the memory.
3262  * @param stride_length is set to the stride length (writing interval) of
3263  * the data.
3264  * @param n_particles is set to the number of particles in the returned data. This is
3265  * needed to properly reach and/or free the data afterwards.
3266  * @param n_values_per_frame is set to the number of values per frame in the data.
3267  * This is needed to properly reach and/or free the data afterwards.
3268  * @param type is set to the data type of the data in the array.
3269  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3270  * must be initialised before using it.
3271  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3272  * the last frame.
3273  * @pre \code n_particles != 0 \endcode The pointer to the number of particles must
3274  * not be a NULL pointer.
3275  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3276  * must not be a NULL pointer.
3277  * @pre \code n_values_per_frame != 0 \endcode The pointer to the number of
3278  * values per frame must not be a NULL pointer.
3279  * @pre \code type != 0 \endcode The pointer to the data type must not
3280  * be a NULL pointer.
3281  * @details This does only work for numerical (int, float, double) data.
3282  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3283  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3284  */
3285 tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
3286                 (const tng_trajectory_t tng_data,
3287                  const int64_t block_id,
3288                  const int64_t start_frame_nr,
3289                  const int64_t end_frame_nr,
3290                  const char hash_mode,
3291                  void **values,
3292                  int64_t *n_particles,
3293                  int64_t *stride_length,
3294                  int64_t *n_values_per_frame,
3295                  char *type);
3296
3297 /**
3298  * @brief Get the stride length of a specific data (particle dependency does not matter)
3299  * block, either in the current frame set or of a specific frame.
3300  * @param tng_data is the trajectory data container.
3301  * @param block_id is the block ID of the data block, of which to retrieve the
3302  * stride length of the data.
3303  * @param frame is the frame from which to get the stride length. If frame is set to -1
3304  * no specific frame will be used, but instead the first frame, starting from the last read
3305  * frame set, containing the data block will be used.
3306  * @param stride_length is set to the value of the stride length of the data block.
3307  * @return  TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3308  * has occurred or TNG_CRITICAL (2) if a major error has occured.
3309  */
3310 tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
3311                 (const tng_trajectory_t tng_data,
3312                  const int64_t block_id,
3313                  int64_t frame,
3314                  int64_t *stride_length);
3315
3316 /**
3317  * @brief Get the date and time of initial file creation in ISO format (string).
3318  * @param tng_data is a trajectory data container.
3319  * @param time is a pointer to the string in which the date will be stored. Memory
3320  * must be reserved beforehand.
3321  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3322  * must be initialised before using it.
3323  * @pre \code time != 0 \endcode The pointer to the time must not be a NULL
3324  * pointer.
3325  * @return TNG_SUCCESS (0) if successful.
3326  */
3327 tng_function_status DECLSPECDLLEXPORT tng_time_get_str
3328                 (const tng_trajectory_t tng_data,
3329                  char *time);
3330 /** @} */ /* end of group1 */
3331
3332 /** @defgroup group2 High-level API
3333  *  These functions make it easier to access and output TNG data. They
3334  *  are recommended unless there is a special reason to use the more
3335  *  detailed functions available in the low-level API.
3336  *  @{
3337  */
3338
3339 /**
3340  * @brief High-level function for opening and initializing a TNG trajectory.
3341  * @param filename is a string containing the name of the trajectory to open.
3342  * @param mode specifies the file mode of the trajectory. Can be set to 'r',
3343  * 'w' or 'a' for reading, writing or appending respectively.
3344  * @param tng_data_p is a pointer to the opened trajectory. This will be
3345  * allocated by the TNG library. The trajectory must be
3346  * closed by the user, whereby memory is freed.
3347  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3348  * must be initialised before using it.
3349  * @pre \code filename != 0 \endcode The pointer to the filename must not be a
3350  * NULL pointer.
3351  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3352  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3353  * has occured.
3354  */
3355 tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_open
3356                 (const char *filename,
3357                  const char mode,
3358                  tng_trajectory_t *tng_data_p);
3359
3360 /**
3361  * @brief High-level function for closing a TNG trajectory.
3362  * @param tng_data_p is a pointer to the trajectory to close. The memory
3363  * will be freed after finalising the writing.
3364  * @return TNG_SUCCESS (0) if successful.
3365  */
3366 tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_close
3367                 (tng_trajectory_t *tng_data_p);
3368
3369 /**
3370  * @brief High-level function for getting the time (in seconds) of a frame.
3371  * @param tng_data is the trajectory containing the frame.
3372  * @param frame_nr is the frame number of which to get the time.
3373  * @param time is set to the time (in seconds) of the specified frame.
3374  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3375  * must be initialised before using it.
3376  * @pre \code time != 0 \endcode The pointer to the time must not be a
3377  * NULL pointer.
3378  * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if a
3379  * minor error has occured.
3380  */
3381 tng_function_status DECLSPECDLLEXPORT tng_util_time_of_frame_get
3382                 (const tng_trajectory_t tng_data,
3383                  const int64_t frame_nr,
3384                  double *time);
3385
3386 /*
3387  * @brief High-level function for getting the molecules in the mol system.
3388  * @param tng_data is the trajectory containing the mol system.
3389  * @param n_mols is set to the number of molecules in the system.
3390  * @param molecule_cnt_list will be pointing to the list of counts of each molecule
3391  * in the mol system.
3392  * @param mols pointing to the list of molecules in the mol system.
3393  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3394  * must be initialised before using it.
3395  * @pre \code n_mols != 0 \endcode The pointer to the number of molecules must
3396  * not be a NULL pointer.
3397  * @return TNG_SUCCESS (0) if successful.
3398  */
3399 /*tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_molecules_get
3400                 (const tng_trajectory_t tng_data,
3401                  int64_t *n_mols,
3402                  int64_t **molecule_cnt_list,
3403                  tng_molecule_t *mols);
3404 */
3405 /*
3406  * @brief High-level function for adding a molecule to the mol system.
3407  * @param tng_data is the trajectory containing the mol system.
3408  * @param name is the name of the molecule to add.
3409  * @param cnt is the count of the molecule.
3410  * @param mol is set to point to the newly created molecule.
3411  * @pre \code name != 0 \endcode The pointer to the name must not be a
3412  * NULL pointer.
3413  * @pre \code cnt >= 0 \endcode The requested count must be >= 0.
3414  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3415  * has occured or TNG_CRITICAL (2) if a major error has occured.
3416  */
3417 /*tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_molecule_add
3418                 (const tng_trajectory_t tng_data,
3419                  const char *name,
3420                  const int64_t cnt,
3421                  tng_molecule_t *mol);
3422 */
3423 /*
3424 // tng_function_status DECLSPECDLLEXPORT tng_util_molecule_particles_get
3425 //                 (const tng_trajectory_t tng_data,
3426 //                  const tng_molecule_t mol,
3427 //                  int64_t *n_particles,
3428 //                  char ***names,
3429 //                  char ***types,
3430 //                  char ***res_names,
3431 //                  int64_t **res_ids,
3432 //                  char ***chain_names,
3433 //                  int64_t **chain_ids);
3434 //
3435 // tng_function_status DECLSPECDLLEXPORT tng_util_molecule_particles_set
3436 //                 (const tng_trajectory_t tng_data,
3437 //                  tng_molecule_t mol,
3438 //                  const int64_t n_particles,
3439 //                  const char **names,
3440 //                  const char **types,
3441 //                  const char **res_names,
3442 //                  const int64_t *res_ids,
3443 //                  const char **chain_names,
3444 //                  const int64_t *chain_ids);
3445 */
3446 /**
3447  * @brief High-level function for reading the positions of all particles
3448  * from all frames.
3449  * @param tng_data is the trajectory to read from.
3450  * @param positions will be set to point at a 1-dimensional array of floats,
3451  * which will contain the positions. The data is stored sequentially in order
3452  * of frames. For each frame the positions (x, y and z coordinates) are stored.
3453  * The variable may point at already allocated memory or be a NULL pointer.
3454  * The memory must be freed afterwards.
3455  * @param stride_length will be set to the writing interval of the stored data.
3456  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3457  * must be initialised before using it.
3458  * @pre \code positions != 0 \endcode The pointer to the positions array
3459  * must not be a NULL pointer.
3460  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3461  * must not be a NULL pointer.
3462  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3463  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3464  * has occured.
3465  */
3466 tng_function_status DECLSPECDLLEXPORT tng_util_pos_read
3467                 (const tng_trajectory_t tng_data,
3468                  float **positions,
3469                  int64_t *stride_length);
3470
3471 /**
3472  * @brief High-level function for reading the velocities of all particles
3473  * from all frames.
3474  * @param tng_data is the trajectory to read from.
3475  * @param velocities will be set to point at a 1-dimensional array of floats,
3476  * which will contain the velocities. The data is stored sequentially in order
3477  * of frames. For each frame the velocities (in x, y and z) are stored. The
3478  * variable may point at already allocated memory or be a NULL pointer.
3479  * The memory must be freed afterwards.
3480  * @param stride_length will be set to the writing interval of the stored data.
3481  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3482  * must be initialised before using it.
3483  * @pre \code velocities != 0 \endcode The pointer to the velocities array
3484  * must not be a NULL pointer.
3485  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3486  * must not be a NULL pointer.
3487  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3488  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3489  * has occured.
3490  */
3491 tng_function_status DECLSPECDLLEXPORT tng_util_vel_read
3492                 (const tng_trajectory_t tng_data,
3493                  float **velocities,
3494                  int64_t *stride_length);
3495
3496 /**
3497  * @brief High-level function for reading the forces of all particles
3498  * from all frames.
3499  * @param tng_data is the trajectory to read from.
3500  * @param forces will be set to point at a 1-dimensional array of floats,
3501  * which will contain the forces. The data is stored sequentially in order
3502  * of frames. For each frame the forces (in x, y and z) are stored. The
3503  * variable may point at already allocated memory or be a NULL pointer.
3504  * The memory must be freed afterwards.
3505  * @param stride_length will be set to the writing interval of the stored data.
3506  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3507  * must be initialised before using it.
3508  * @pre \code forces != 0 \endcode The pointer to the forces array
3509  * must not be a NULL pointer.
3510  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3511  * must not be a NULL pointer.
3512  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3513  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3514  * has occured.
3515  */
3516 tng_function_status DECLSPECDLLEXPORT tng_util_force_read
3517                 (const tng_trajectory_t tng_data,
3518                  float **forces,
3519                  int64_t *stride_length);
3520
3521 /**
3522  * @brief High-level function for reading the box shape from all frames.
3523  * @param tng_data is the trajectory to read from.
3524  * @param box_shape will be set to point at a 1-dimensional array of floats,
3525  * which will contain the box shape. The data is stored sequentially in order
3526  * of frames. The variable may point at already allocated memory or be a NULL pointer.
3527  * If the box shape is not modified during the trajectory, but as general data,
3528  * that will be returned instead.
3529  * @param stride_length will be set to the writing interval of the stored data.
3530  * @details This function should only be used if number of values used to specify
3531  * the box shape is known (by default TNG uses 9 values) since it does not
3532  * return the number of values in the array. It is recommended to use
3533  * tng_data_vector_interval_get() instead.
3534  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3535  * must be initialised before using it.
3536  * @pre \code box_shape != 0 \endcode The pointer to the box_shape array
3537  * must not be a NULL pointer.
3538  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3539  * must not be a NULL pointer.
3540  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3541  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3542  * has occured.
3543  */
3544 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read
3545                 (const tng_trajectory_t tng_data,
3546                  float **box_shape,
3547                  int64_t *stride_length);
3548
3549 /**
3550  * @brief High-level function for reading the next frame of particle-dependent
3551  * data of a specific type.
3552  * @param tng_data is the trajectory to read from.
3553  * @param block_id is the ID number of the block containing the data of interest.
3554  * @param values will be set to point at a 1-dimensional array containing the
3555  * requested data. The variable may point at already allocated memory or be a
3556  * NULL pointer. The memory must be freed afterwards.
3557  * @param data_type will be pointing to a character indicating the size of the
3558  * data of the returned values, e.g. TNG_INT_DATA, TNG_FLOAT_DATA or TNG_DOUBLE_DATA.
3559  * @param retrieved_frame_number will be pointing at the frame number of the
3560  * returned frame.
3561  * @param retrieved_time will be pointing at the time stamp of the returned
3562  * frame.
3563  * @details If no frame has been read before the first frame of the trajectory
3564  * is read.
3565  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3566  * must be initialised before using it.
3567  * @pre \code values != 0 \endcode The pointer to the values array
3568  * must not be a NULL pointer.
3569  * @pre \code data_type != 0 \endcode The pointer to the data type of the
3570  * returned data must not be a NULL pointer.
3571  * @pre \code retrieved_frame_number != 0 \endcode The pointer to the frame
3572  * number of the returned data must not be a NULL pointer.
3573  * @pre \code retrieved_time != 0 \endcode The pointer to the time of the
3574  * returned data must not be a NULL pointer.
3575  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3576  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3577  * has occured.
3578  */
3579 tng_function_status DECLSPECDLLEXPORT tng_util_particle_data_next_frame_read
3580                 (const tng_trajectory_t tng_data,
3581                  const int64_t block_id,
3582                  void **values,
3583                  char *data_type,
3584                  int64_t *retrieved_frame_number,
3585                  double *retrieved_time);
3586
3587 /**
3588  * @brief High-level function for reading the next frame of non-particle-dependent
3589  * data of a specific type.
3590  * @param tng_data is the trajectory to read from.
3591  * @param block_id is the ID number of the block containing the data of interest.
3592  * @param values will be set to point at a 1-dimensional array containing the
3593  * requested data. The variable may point at already allocated memory or be a
3594  * NULL pointer. The memory must be freed afterwards.
3595  * @param data_type will be pointing to a character indicating the size of the
3596  * data of the returned values, e.g. TNG_INT_DATA, TNG_FLOAT_DATA or TNG_DOUBLE_DATA.
3597  * @param retrieved_frame_number will be pointing at the frame number of the
3598  * returned frame.
3599  * @param retrieved_time will be pointing at the time stamp of the returned
3600  * frame.
3601  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3602  * must be initialised before using it.
3603  * @pre \code values != 0 \endcode The pointer to the values array
3604  * must not be a NULL pointer.
3605  * @pre \code data_type != 0 \endcode The pointer to the data type of the
3606  * returned data must not be a NULL pointer.
3607  * @pre \code retrieved_frame_number != 0 \endcode The pointer to the frame
3608  * number of the returned data must not be a NULL pointer.
3609  * @pre \code retrieved_time != 0 \endcode The pointer to the time of the
3610  * returned data must not be a NULL pointer.
3611  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3612  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3613  * has occured.
3614  */
3615 tng_function_status DECLSPECDLLEXPORT tng_util_non_particle_data_next_frame_read
3616                 (const tng_trajectory_t tng_data,
3617                  const int64_t block_id,
3618                  void **values,
3619                  char *data_type,
3620                  int64_t *retrieved_frame_number,
3621                  double *retrieved_time);
3622
3623 /**
3624  * @brief High-level function for reading the positions of all particles
3625  * from a specific range of frames.
3626  * @param tng_data is the trajectory to read from.
3627  * @param first_frame is the first frame to return position data from.
3628  * @param last_frame is the last frame to return position data from.
3629  * @param positions will be set to point at a 1-dimensional array of floats,
3630  * which will contain the positions. The data is stored sequentially in order
3631  * of frames. For each frame the positions (x, y and z coordinates) are stored.
3632  * The variable may point at already allocated memory or be a NULL pointer.
3633  * The memory must be freed afterwards.
3634  * @param stride_length will be set to the writing interval of the stored data.
3635  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3636  * must be initialised before using it.
3637  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3638  * the last frame.
3639  * @pre \code positions != 0 \endcode The pointer to the positions array
3640  * must not be a NULL pointer.
3641  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3642  * must not be a NULL pointer.
3643  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3644  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3645  * has occured.
3646  */
3647 tng_function_status DECLSPECDLLEXPORT tng_util_pos_read_range
3648                 (const tng_trajectory_t tng_data,
3649                  const int64_t first_frame,
3650                  const int64_t last_frame,
3651                  float **positions,
3652                  int64_t *stride_length);
3653
3654 /**
3655  * @brief High-level function for reading the velocities of all particles
3656  * from a specific range of frames.
3657  * @param tng_data is the trajectory to read from.
3658  * @param first_frame is the first frame to return position data from.
3659  * @param last_frame is the last frame to return position data from.
3660  * @param velocities will be set to point at a 1-dimensional array of floats,
3661  * which will contain the velocities. The data is stored sequentially in order
3662  * of frames. For each frame the velocities (in x, y and z) are stored. The
3663  * variable may point at already allocated memory or be a NULL pointer.
3664  * The memory must be freed afterwards.
3665  * @param stride_length will be set to the writing interval of the stored data.
3666  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3667  * must be initialised before using it.
3668  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3669  * the last frame.
3670  * @pre \code velocities != 0 \endcode The pointer to the velocities array
3671  * must not be a NULL pointer.
3672  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3673  * must not be a NULL pointer.
3674  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3675  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3676  * has occured.
3677  */
3678 tng_function_status DECLSPECDLLEXPORT tng_util_vel_read_range
3679                 (const tng_trajectory_t tng_data,
3680                  const int64_t first_frame,
3681                  const int64_t last_frame,
3682                  float **velocities,
3683                  int64_t *stride_length);
3684
3685 /**
3686  * @brief High-level function for reading the forces of all particles
3687  * from a specific range of frames.
3688  * @param tng_data is the trajectory to read from.
3689  * @param first_frame is the first frame to return position data from.
3690  * @param last_frame is the last frame to return position data from.
3691  * @param forces will be set to point at a 1-dimensional array of floats,
3692  * which will contain the forces. The data is stored sequentially in order
3693  * of frames. For each frame the forces (in x, y and z) are stored. The
3694  * variable may point at already allocated memory or be a NULL pointer.
3695  * The memory must be freed afterwards.
3696  * @param stride_length will be set to the writing interval of the stored data.
3697  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3698  * must be initialised before using it.
3699  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3700  * the last frame.
3701  * @pre \code forces != 0 \endcode The pointer to the forces array
3702  * must not be a NULL pointer.
3703  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3704  * must not be a NULL pointer.
3705  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3706  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3707  * has occured.
3708  */
3709 tng_function_status DECLSPECDLLEXPORT tng_util_force_read_range
3710                 (const tng_trajectory_t tng_data,
3711                  const int64_t first_frame,
3712                  const int64_t last_frame,
3713                  float **forces,
3714                  int64_t *stride_length);
3715
3716 /**
3717  * @brief High-level function for reading the box shape
3718  * from a specific range of frames.
3719  * @param tng_data is the trajectory to read from.
3720  * @param first_frame is the first frame to return position data from.
3721  * @param last_frame is the last frame to return position data from.
3722  * @param box_shape will be set to point at a 1-dimensional array of floats,
3723  * which will contain the box shape. The data is stored sequentially in order
3724  * of frames.
3725  * If the box shape is not modified during the trajectory, but as general data,
3726  * that will be returned instead. The
3727  * variable may point at already allocated memory or be a NULL pointer.
3728  * The memory must be freed afterwards.
3729  * @param stride_length will be set to the writing interval of the stored data.
3730  * @details This function should only be used if number of values used to specify
3731  * the box shape is known (by default TNG uses 9 values) since it does not
3732  * return the number of values in the array. It is recommended to use
3733  * tng_data_vector_interval_get() instead.
3734  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3735  * must be initialised before using it.
3736  * @pre \code start_frame_nr <= end_frame_nr \endcode The first frame must be before
3737  * the last frame.
3738  * @pre \code box_shape != 0 \endcode The pointer to the box_shape array
3739  * must not be a NULL pointer.
3740  * @pre \code stride_length != 0 \endcode The pointer to the stride length
3741  * must not be a NULL pointer.
3742  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3743  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3744  * has occured.
3745  */
3746 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_range
3747                 (const tng_trajectory_t tng_data,
3748                  const int64_t first_frame,
3749                  const int64_t last_frame,
3750                  float **box_shape,
3751                  int64_t *stride_length);
3752
3753 /**
3754  * @brief High-level function for setting the writing interval of data blocks.
3755  * @param tng_data is the trajectory to use.
3756  * @param i is the output interval, i.e. i == 10 means data written every 10th
3757  * frame.
3758  * @param n_values_per_frame is the number of values to store per frame. If the
3759  * data is particle dependent there will be n_values_per_frame stored per
3760  * particle each frame.
3761  * @param block_id is the ID of the block, of which to set the output interval.
3762  * @param block_name is a string that will be used as name of the block. Only
3763  * required if the block did not exist, i.e. a new block is created.
3764  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
3765  * data is not related to specific particles (e.g. box shape) or
3766  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
3767  * positions). Only required if the block did not exist, i.e. a new block is
3768  * created.
3769  * @param compression is the compression routine to use when writing the data.
3770  * Only required if the block did not exist, i.e. a new block is created.
3771  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3772  * must be initialised before using it.
3773  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3774  * @details n_values_per_frame, block_name, particle_dependency and
3775  * compression are only used if the data block did not exist before calling
3776  * this function, in which case it is created.
3777  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3778  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3779  * has occured.
3780  */
3781 tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_interval_set
3782                 (const tng_trajectory_t tng_data,
3783                  const int64_t i,
3784                  const int64_t n_values_per_frame,
3785                  const int64_t block_id,
3786                  const char *block_name,
3787                  const char particle_dependency,
3788                  const char compression);
3789
3790 /**
3791  * @brief High-level function for setting the writing interval of data blocks
3792  * containing double precision data.
3793  * @param tng_data is the trajectory to use.
3794  * @param i is the output interval, i.e. i == 10 means data written every 10th
3795  * frame.
3796  * @param n_values_per_frame is the number of values to store per frame. If the
3797  * data is particle dependent there will be n_values_per_frame stored per
3798  * particle each frame.
3799  * @param block_id is the ID of the block, of which to set the output interval.
3800  * @param block_name is a string that will be used as name of the block. Only
3801  * required if the block did not exist, i.e. a new block is created.
3802  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
3803  * data is not related to specific particles (e.g. box shape) or
3804  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
3805  * positions). Only required if the block did not exist, i.e. a new block is
3806  * created.
3807  * @param compression is the compression routine to use when writing the data.
3808  * Only required if the block did not exist, i.e. a new block is created.
3809  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3810  * must be initialised before using it.
3811  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3812  * @details n_values_per_frame, block_name, particle_dependency and
3813  * compression are only used if the data block did not exist before calling
3814  * this function, in which case it is created.
3815  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3816  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3817  * has occured.
3818  */
3819 tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_interval_double_set
3820                 (const tng_trajectory_t tng_data,
3821                  const int64_t i,
3822                  const int64_t n_values_per_frame,
3823                  const int64_t block_id,
3824                  const char *block_name,
3825                  const char particle_dependency,
3826                  const char compression);
3827
3828 /**
3829  * @brief High-level function for setting the writing interval of data blocks.
3830  * Obsolete! Use tng_util_generic_write_interval_set()
3831  * @param tng_data is the trajectory to use.
3832  * @param i is the output interval, i.e. i == 10 means data written every 10th
3833  * frame.
3834  * @param n_values_per_frame is the number of values to store per frame. If the
3835  * data is particle dependent there will be n_values_per_frame stored per
3836  * particle each frame.
3837  * @param block_id is the ID of the block, of which to set the output interval.
3838  * @param block_name is a string that will be used as name of the block. Only
3839  * required if the block did not exist, i.e. a new block is created.
3840  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
3841  * data is not related to specific particles (e.g. box shape) or
3842  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
3843  * positions). Only required if the block did not exist, i.e. a new block is
3844  * created.
3845  * @param compression is the compression routine to use when writing the data.
3846  * Only required if the block did not exist, i.e. a new block is created.
3847  * @details n_values_per_frame, block_name, particle_dependency and
3848  * compression are only used if the data block did not exist before calling
3849  * this function, in which case it is created.
3850  * This function is replaced by the more correcly named
3851  * tng_util_generic_write_interval_set(), but is kept for compatibility.
3852  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3853  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3854  * has occured.
3855  */
3856 tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set
3857                 (const tng_trajectory_t tng_data,
3858                  const int64_t i,
3859                  const int64_t n_values_per_frame,
3860                  const int64_t block_id,
3861                  const char *block_name,
3862                  const char particle_dependency,
3863                  const char compression);
3864
3865 /**
3866  * @brief High-level function for setting the writing interval of position
3867  * data blocks.
3868  * @param tng_data is the trajectory to use.
3869  * @param i is the output interval, i.e. i == 10 means data written every 10th
3870  * frame.
3871  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3872  * must be initialised before using it.
3873  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3874  * @details This function uses tng_util_generic_write_interval_set() and will
3875  * create a positions data block if none exists.
3876  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3877  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3878  * has occured.
3879  */
3880 tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_interval_set
3881                 (const tng_trajectory_t tng_data,
3882                  const int64_t i);
3883
3884 /**
3885  * @brief High-level function for setting the writing interval of position
3886  * data blocks containing double precision data.
3887  * @param tng_data is the trajectory to use.
3888  * @param i is the output interval, i.e. i == 10 means data written every 10th
3889  * frame.
3890  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3891  * must be initialised before using it.
3892  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3893  * @details This function uses tng_util_generic_write_interval_set() and will
3894  * create a positions data block if none exists.
3895  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3896  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3897  * has occured.
3898  */
3899 tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_interval_double_set
3900                 (const tng_trajectory_t tng_data,
3901                  const int64_t i);
3902
3903 /**
3904  * @brief High-level function for setting the writing interval of position
3905  * data blocks. Obsolete! Use tng_util_pos_write_interval_set()
3906  * @param tng_data is the trajectory to use.
3907  * @param i is the output interval, i.e. i == 10 means data written every 10th
3908  * frame.
3909  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3910  * must be initialised before using it.
3911  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3912  * @details This function uses tng_util_generic_write_interval_set() and will
3913  * create a positions data block if none exists.
3914  * This function is replaced by the more correcly named
3915  * tng_util_pos_write_interval_set(), but is kept for compatibility.
3916  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3917  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3918  * has occured.
3919  */
3920 tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_frequency_set
3921                 (const tng_trajectory_t tng_data,
3922                  const int64_t i);
3923
3924 /**
3925  * @brief High-level function for setting the writing interval of velocity
3926  * data blocks.
3927  * @param tng_data is the trajectory to use.
3928  * @param i is the output interval, i.e. i == 10 means data written every 10th
3929  * frame.
3930  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3931  * must be initialised before using it.
3932  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3933  * @details This function uses tng_util_generic_write_interval_set() and will
3934  * create a velocities data block if none exists.
3935  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3936  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3937  * has occured.
3938  */
3939 tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_interval_set
3940                 (const tng_trajectory_t tng_data,
3941                  const int64_t i);
3942
3943 /**
3944  * @brief High-level function for setting the writing interval of velocity
3945  * data blocks containing double precision data.
3946  * @param tng_data is the trajectory to use.
3947  * @param i is the output interval, i.e. i == 10 means data written every 10th
3948  * frame.
3949  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3950  * must be initialised before using it.
3951  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3952  * @details This function uses tng_util_generic_write_interval_set() and will
3953  * create a velocities data block if none exists.
3954  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3955  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3956  * has occured.
3957  */
3958 tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_interval_double_set
3959                 (const tng_trajectory_t tng_data,
3960                  const int64_t i);
3961
3962 /**
3963  * @brief High-level function for setting the writing interval of velocity
3964  * data blocks. Obsolete! Use tng_util_vel_write_interval_set()
3965  * @param tng_data is the trajectory to use.
3966  * @param i is the output interval, i.e. i == 10 means data written every 10th
3967  * frame.
3968  * @details This function uses tng_util_generic_write_interval_set() and will
3969  * create a velocities data block if none exists.
3970  * This function is replaced by the more correcly named
3971  * tng_util_vel_write_interval_set(), but is kept for compatibility.
3972  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3973  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3974  * has occured.
3975  */
3976 tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_frequency_set
3977                 (const tng_trajectory_t tng_data,
3978                  const int64_t i);
3979
3980 /**
3981  * @brief High-level function for setting the writing interval of force
3982  * data blocks.
3983  * @param tng_data is the trajectory to use.
3984  * @param i is the output interval, i.e. i == 10 means data written every 10th
3985  * frame.
3986  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
3987  * must be initialised before using it.
3988  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
3989  * @details This function uses tng_util_generic_write_interval_set() and will
3990  * create a forces data block if none exists.
3991  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
3992  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
3993  * has occured.
3994  */
3995 tng_function_status DECLSPECDLLEXPORT tng_util_force_write_interval_set
3996                 (const tng_trajectory_t tng_data,
3997                  const int64_t i);
3998
3999 /**
4000  * @brief High-level function for setting the writing interval of force
4001  * data blocks containing double precision data.
4002  * @param tng_data is the trajectory to use.
4003  * @param i is the output interval, i.e. i == 10 means data written every 10th
4004  * frame.
4005  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4006  * must be initialised before using it.
4007  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
4008  * @details This function uses tng_util_generic_write_interval_set() and will
4009  * create a forces data block if none exists.
4010  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4011  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4012  * has occured.
4013  */
4014 tng_function_status DECLSPECDLLEXPORT tng_util_force_write_interval_double_set
4015                 (const tng_trajectory_t tng_data,
4016                  const int64_t i);
4017
4018 /**
4019  * @brief High-level function for setting the writing interval of force
4020  * data blocks. Obsolete! Use tng_util_force_write_interval_set()
4021  * @param tng_data is the trajectory to use.
4022  * @param i is the output interval, i.e. i == 10 means data written every 10th
4023  * frame.
4024  * @details This function uses tng_util_generic_write_interval_set() and will
4025  * create a forces data block if none exists.
4026  * This function is replaced by the more correcly named
4027  * tng_util_force_write_interval_set(), but is kept for compatibility.
4028  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4029  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4030  * has occured.
4031  */
4032 tng_function_status DECLSPECDLLEXPORT tng_util_force_write_frequency_set
4033                 (const tng_trajectory_t tng_data,
4034                  const int64_t i);
4035
4036 /**
4037  * @brief High-level function for setting the writing interval of box shape
4038  * data blocks.
4039  * @param tng_data is the trajectory to use.
4040  * @param i is the output interval, i.e. i == 10 means data written every 10th
4041  * frame.
4042  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4043  * must be initialised before using it.
4044  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
4045  * @details This function uses tng_util_generic_write_interval_set() and will
4046  * create a box shape data block if none exists.
4047  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4048  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4049  * has occured.
4050  */
4051 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_interval_set
4052                 (const tng_trajectory_t tng_data,
4053                  const int64_t i);
4054
4055 /**
4056  * @brief High-level function for setting the writing interval of box shape
4057  * data blocks containing double precision data.
4058  * @param tng_data is the trajectory to use.
4059  * @param i is the output interval, i.e. i == 10 means data written every 10th
4060  * frame.
4061  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4062  * must be initialised before using it.
4063  * @pre \code i >= 0 \endcode The writing interval must be >= 0.
4064  * @details This function uses tng_util_generic_write_interval_set() and will
4065  * create a box shape data block if none exists.
4066  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4067  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4068  * has occured.
4069  */
4070 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_interval_double_set
4071                 (const tng_trajectory_t tng_data,
4072                  const int64_t i);
4073
4074 /**
4075  * @brief High-level function for setting the writing interval of velocity
4076  * data blocks. Obsolete! Use tng_util_box_shape_write_interval_set()
4077  * @param tng_data is the trajectory to use.
4078  * @param i is the output interval, i.e. i == 10 means data written every 10th
4079  * frame.
4080  * @details This function uses tng_util_generic_write_interval_set() and will
4081  * create a box shape data block if none exists.
4082  * This function is replaced by the more correcly named
4083  * tng_util_box_shape_write_interval_set(), but is kept for compatibility.
4084  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4085  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4086  * has occured.
4087  */
4088 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set
4089                 (const tng_trajectory_t tng_data,
4090                  const int64_t i);
4091
4092 /**
4093  * @brief High-level function for writing data of one frame to a data block.
4094  * @param tng_data is the trajectory to use.
4095  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4096  * data is written as non-trajectory data.
4097  * @param values is a 1D array of data to add. The array should be of length
4098  * n_particles * n_values_per_frame if writing particle related data, otherwise
4099  * it should be n_values_per_frame.
4100  * @param n_values_per_frame is the number of values to store per frame. If the
4101  * data is particle dependent there will be n_values_per_frame stored per
4102  * particle each frame.
4103  * @param block_id is the ID of the block, of which to set the output interval.
4104  * @param block_name is a string that will be used as name of the block. Only
4105  * required if the block did not exist, i.e. a new block is created.
4106  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
4107  * data is not related to specific particles (e.g. box shape) or
4108  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
4109  * positions). Only required if the block did not exist, i.e. a new block is
4110  * created.
4111  * @param compression is the compression routine to use when writing the data.
4112  * Only required if the block did not exist, i.e. a new block is created.
4113  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4114  * must be initialised before using it.
4115  * @pre \code values != 0 \endcode The pointer to the values array must not
4116  * be a NULL pointer.
4117  * @details n_values_per_frame, block_name, particle_dependency and
4118  * compression are only used if the data block did not exist before calling
4119  * this function, in which case it is created.
4120  * N.b. Data is written a whole block at a time. The data is not
4121  * actually written to disk until the frame set is finished or the TNG
4122  * trajectory is closed.
4123  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4124  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4125  * has occured.
4126  */
4127 tng_function_status DECLSPECDLLEXPORT tng_util_generic_write
4128                 (const tng_trajectory_t tng_data,
4129                  const int64_t frame_nr,
4130                  const float *values,
4131                  const int64_t n_values_per_frame,
4132                  const int64_t block_id,
4133                  const char *block_name,
4134                  const char particle_dependency,
4135                  const char compression);
4136
4137 /**
4138  * @brief High-level function for writing data of one frame to a double precision
4139  * data block.
4140  * @param tng_data is the trajectory to use.
4141  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4142  * data is written as non-trajectory data.
4143  * @param values is a 1D array of data to add. The array should be of length
4144  * n_particles * n_values_per_frame if writing particle related data, otherwise
4145  * it should be n_values_per_frame.
4146  * @param n_values_per_frame is the number of values to store per frame. If the
4147  * data is particle dependent there will be n_values_per_frame stored per
4148  * particle each frame.
4149  * @param block_id is the ID of the block, of which to set the output interval.
4150  * @param block_name is a string that will be used as name of the block. Only
4151  * required if the block did not exist, i.e. a new block is created.
4152  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
4153  * data is not related to specific particles (e.g. box shape) or
4154  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
4155  * positions). Only required if the block did not exist, i.e. a new block is
4156  * created.
4157  * @param compression is the compression routine to use when writing the data.
4158  * Only required if the block did not exist, i.e. a new block is created.
4159  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4160  * must be initialised before using it.
4161  * @pre \code values != 0 \endcode The pointer to the values array must not
4162  * be a NULL pointer.
4163  * @details n_values_per_frame, block_name, particle_dependency and
4164  * compression are only used if the data block did not exist before calling
4165  * this function, in which case it is created.
4166  * N.b. Data is written a whole block at a time. The data is not
4167  * actually written to disk until the frame set is finished or the TNG
4168  * trajectory is closed.
4169  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4170  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4171  * has occured.
4172  */
4173 tng_function_status DECLSPECDLLEXPORT tng_util_generic_double_write
4174                 (const tng_trajectory_t tng_data,
4175                  const int64_t frame_nr,
4176                  const double *values,
4177                  const int64_t n_values_per_frame,
4178                  const int64_t block_id,
4179                  const char *block_name,
4180                  const char particle_dependency,
4181                  const char compression);
4182
4183 /**
4184  * @brief High-level function for adding data to positions data blocks.
4185  * @param tng_data is the trajectory to use.
4186  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4187  * data is written as non-trajectory data.
4188  * @param positions is a 1D array of data to add. The array should be of length
4189  * n_particles * 3.
4190  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4191  * must be initialised before using it.
4192  * @pre \code positions != 0 \endcode The pointer to the positions array must not
4193  * be a NULL pointer.
4194  * @details This function uses tng_util_generic_write() and will
4195  * create a positions data block if none exists. Positions are stored as three
4196  * values per frame and compressed using TNG compression.
4197  * N.b. Since compressed data is written a whole block at a time the data is not
4198  * actually written to disk until the frame set is finished or the TNG
4199  * trajectory is closed.
4200  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4201  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4202  * has occured.
4203  */
4204 tng_function_status DECLSPECDLLEXPORT tng_util_pos_write
4205                 (const tng_trajectory_t tng_data,
4206                  const int64_t frame_nr,
4207                  const float *positions);
4208
4209 /**
4210  * @brief High-level function for adding data to positions data blocks at double
4211  * precision.
4212  * @param tng_data is the trajectory to use.
4213  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4214  * data is written as non-trajectory data.
4215  * @param positions is a 1D array of data to add. The array should be of length
4216  * n_particles * 3.
4217  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4218  * must be initialised before using it.
4219  * @pre \code positions != 0 \endcode The pointer to the positions array must not
4220  * be a NULL pointer.
4221  * @details This function uses tng_util_generic_write() and will
4222  * create a positions data block if none exists. Positions are stored as three
4223  * values per frame and compressed using TNG compression.
4224  * N.b. Since compressed data is written a whole block at a time the data is not
4225  * actually written to disk until the frame set is finished or the TNG
4226  * trajectory is closed.
4227  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4228  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4229  * has occured.
4230  */
4231 tng_function_status DECLSPECDLLEXPORT tng_util_pos_double_write
4232                 (const tng_trajectory_t tng_data,
4233                  const int64_t frame_nr,
4234                  const double *positions);
4235
4236 /**
4237  * @brief High-level function for adding data to velocities data blocks.
4238  * @param tng_data is the trajectory to use.
4239  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4240  * data is written as non-trajectory data.
4241  * @param velocities is a 1D array of data to add. The array should be of length
4242  * n_particles * 3.
4243  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4244  * must be initialised before using it.
4245  * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
4246  * be a NULL pointer.
4247  * @details This function uses tng_util_generic_write() and will
4248  * create a velocities data block if none exists. Velocities are stored as three
4249  * values per frame and compressed using TNG compression.
4250  * N.b. Since compressed data is written a whole block at a time the data is not
4251  * actually written to disk until the frame set is finished or the TNG
4252  * trajectory is closed.
4253  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4254  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4255  * has occured.
4256  */
4257 tng_function_status DECLSPECDLLEXPORT tng_util_vel_write
4258                 (const tng_trajectory_t tng_data,
4259                  const int64_t frame_nr,
4260                  const float *velocities);
4261
4262 /**
4263  * @brief High-level function for adding data to velocities data blocks at double
4264  * precision.
4265  * @param tng_data is the trajectory to use.
4266  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4267  * data is written as non-trajectory data.
4268  * @param velocities is a 1D array of data to add. The array should be of length
4269  * n_particles * 3.
4270  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4271  * must be initialised before using it.
4272  * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
4273  * be a NULL pointer.
4274  * @details This function uses tng_util_generic_write() and will
4275  * create a velocities data block if none exists. Velocities are stored as three
4276  * values per frame and compressed using TNG compression.
4277  * N.b. Since compressed data is written a whole block at a time the data is not
4278  * actually written to disk until the frame set is finished or the TNG
4279  * trajectory is closed.
4280  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4281  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4282  * has occured.
4283  */
4284 tng_function_status DECLSPECDLLEXPORT tng_util_vel_double_write
4285                 (const tng_trajectory_t tng_data,
4286                  const int64_t frame_nr,
4287                  const double *velocities);
4288
4289 /**
4290  * @brief High-level function for adding data to forces data blocks.
4291  * @param tng_data is the trajectory to use.
4292  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4293  * data is written as non-trajectory data.
4294  * @param forces is a 1D array of data to add. The array should be of length
4295  * n_particles * 3.
4296  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4297  * must be initialised before using it.
4298  * @pre \code forces != 0 \endcode The pointer to the forces array must not
4299  * be a NULL pointer.
4300  * @details This function uses tng_util_generic_write() and will
4301  * create a forces data block if none exists. Forces are stored as three
4302  * values per frame and compressed using gzip compression.
4303  * N.b. Since compressed data is written a whole block at a time the data is not
4304  * actually written to disk until the frame set is finished or the TNG
4305  * trajectory is closed.
4306  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4307  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4308  * has occured.
4309  */
4310 tng_function_status DECLSPECDLLEXPORT tng_util_force_write
4311                 (const tng_trajectory_t tng_data,
4312                  const int64_t frame_nr,
4313                  const float *forces);
4314
4315 /**
4316  * @brief High-level function for adding data to forces data blocks at double
4317  * precision.
4318  * @param tng_data is the trajectory to use.
4319  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4320  * data is written as non-trajectory data.
4321  * @param forces is a 1D array of data to add. The array should be of length
4322  * n_particles * 3.
4323  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4324  * must be initialised before using it.
4325  * @pre \code forces != 0 \endcode The pointer to the forces array must not
4326  * be a NULL pointer.
4327  * @details This function uses tng_util_generic_write() and will
4328  * create a forces data block if none exists. Forces are stored as three
4329  * values per frame and compressed using gzip compression.
4330  * N.b. Since compressed data is written a whole block at a time the data is not
4331  * actually written to disk until the frame set is finished or the TNG
4332  * trajectory is closed.
4333  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4334  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4335  * has occured.
4336  */
4337 tng_function_status DECLSPECDLLEXPORT tng_util_force_double_write
4338                 (const tng_trajectory_t tng_data,
4339                  const int64_t frame_nr,
4340                  const double *forces);
4341
4342 /**
4343  * @brief High-level function for adding data to box shape data blocks.
4344  * @param tng_data is the trajectory to use.
4345  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4346  * data is written as non-trajectory data.
4347  * @param box_shape is a 1D array of data to add. The array should be of length 9.
4348  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4349  * must be initialised before using it.
4350  * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
4351  * be a NULL pointer.
4352  * @details This function uses tng_util_generic_write() and will
4353  * create a box shape data block if none exists. Box shapes are stored as 9
4354  * values per frame and compressed using TNG compression.
4355  * N.b. Since compressed data is written a whole block at a time the data is not
4356  * actually written to disk until the frame set is finished or the TNG
4357  * trajectory is closed.
4358  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4359  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4360  * has occured.
4361  */
4362 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write
4363                 (const tng_trajectory_t tng_data,
4364                  const int64_t frame_nr,
4365                  const float *box_shape);
4366
4367 /**
4368  * @brief High-level function for adding data to box shape data blocks at double
4369  * precision.
4370  * @param tng_data is the trajectory to use.
4371  * @param frame_nr is the frame number of the data. If frame_nr < 0 the
4372  * data is written as non-trajectory data.
4373  * @param box_shape is a 1D array of data to add. The array should be of length 9.
4374  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4375  * must be initialised before using it.
4376  * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
4377  * be a NULL pointer.
4378  * @details This function uses tng_util_generic_write() and will
4379  * create a box shape data block if none exists. Box shapes are stored as 9
4380  * values per frame and compressed using TNG compression.
4381  * N.b. Since compressed data is written a whole block at a time the data is not
4382  * actually written to disk until the frame set is finished or the TNG
4383  * trajectory is closed.
4384  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4385  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4386  * has occured.
4387  */
4388 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_double_write
4389                 (const tng_trajectory_t tng_data,
4390                  const int64_t frame_nr,
4391                  const double *box_shape);
4392
4393 /**
4394  * @brief High-level function for writing data of one frame to a data block.
4395  * If the frame is at the beginning of a frame set the time stamp of the frame
4396  * set is set.
4397  * @param tng_data is the trajectory to use.
4398  * @param frame_nr is the frame number of the data.
4399  * @param time is the time stamp of the frame (in seconds).
4400  * @param values is a 1D array of data to add. The array should be of length
4401  * n_particles * n_values_per_frame if writing particle related data, otherwise
4402  * it should be n_values_per_frame.
4403  * @param n_values_per_frame is the number of values to store per frame. If the
4404  * data is particle dependent there will be n_values_per_frame stored per
4405  * particle each frame.
4406  * @param block_id is the ID of the block, of which to set the output interval.
4407  * @param block_name is a string that will be used as name of the block. Only
4408  * required if the block did not exist, i.e. a new block is created.
4409  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
4410  * data is not related to specific particles (e.g. box shape) or
4411  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
4412  * positions). Only required if the block did not exist, i.e. a new block is
4413  * created.
4414  * @param compression is the compression routine to use when writing the data.
4415  * Only required if the block did not exist, i.e. a new block is created.
4416  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4417  * must be initialised before using it.
4418  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4419  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4420  * @pre \code values != 0 \endcode The pointer to the values array must not
4421  * be a NULL pointer.
4422  * @details n_values_per_frame, block_name, particle_dependency and
4423  * compression are only used if the data block did not exist before calling
4424  * this function, in which case it is created.
4425  * N.b. Data is written a whole block at a time. The data is not
4426  * actually written to disk until the frame set is finished or the TNG
4427  * trajectory is closed.
4428  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4429  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4430  * has occured.
4431  */
4432 tng_function_status DECLSPECDLLEXPORT tng_util_generic_with_time_write
4433                 (const tng_trajectory_t tng_data,
4434                  const int64_t frame_nr,
4435                  const double time,
4436                  const float *values,
4437                  const int64_t n_values_per_frame,
4438                  const int64_t block_id,
4439                  const char *block_name,
4440                  const char particle_dependency,
4441                  const char compression);
4442
4443 /**
4444  * @brief High-level function for writing data of one frame to a double precision
4445  * data block. If the frame is at the beginning of a frame set the time stamp of
4446  * the frame set is set.
4447  * @param tng_data is the trajectory to use.
4448  * @param frame_nr is the frame number of the data.
4449  * @param time is the time stamp of the frame (in seconds).
4450  * @param values is a 1D array of data to add. The array should be of length
4451  * n_particles * n_values_per_frame if writing particle related data, otherwise
4452  * it should be n_values_per_frame.
4453  * @param n_values_per_frame is the number of values to store per frame. If the
4454  * data is particle dependent there will be n_values_per_frame stored per
4455  * particle each frame.
4456  * @param block_id is the ID of the block, of which to set the output interval.
4457  * @param block_name is a string that will be used as name of the block. Only
4458  * required if the block did not exist, i.e. a new block is created.
4459  * @param particle_dependency should be TNG_NON_PARTICLE_BLOCK_DATA (0) if the
4460  * data is not related to specific particles (e.g. box shape) or
4461  * TNG_PARTICLE_BLOCK_DATA (1) is it is related to specific particles (e.g.
4462  * positions). Only required if the block did not exist, i.e. a new block is
4463  * created.
4464  * @param compression is the compression routine to use when writing the data.
4465  * Only required if the block did not exist, i.e. a new block is created.
4466  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4467  * must be initialised before using it.
4468  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4469  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4470  * @pre \code values != 0 \endcode The pointer to the values array must not
4471  * be a NULL pointer.
4472  * @details n_values_per_frame, block_name, particle_dependency and
4473  * compression are only used if the data block did not exist before calling
4474  * this function, in which case it is created.
4475  * N.b. Data is written a whole block at a time. The data is not
4476  * actually written to disk until the frame set is finished or the TNG
4477  * trajectory is closed.
4478  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4479  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4480  * has occured.
4481  */
4482 tng_function_status DECLSPECDLLEXPORT tng_util_generic_with_time_double_write
4483                 (const tng_trajectory_t tng_data,
4484                  const int64_t frame_nr,
4485                  const double time,
4486                  const double *values,
4487                  const int64_t n_values_per_frame,
4488                  const int64_t block_id,
4489                  const char *block_name,
4490                  const char particle_dependency,
4491                  const char compression);
4492
4493 /**
4494  * @brief High-level function for adding data to positions data blocks. If the
4495  * frame is at the beginning of a frame set the time stamp of the frame set
4496  * is set.
4497  * @param tng_data is the trajectory to use.
4498  * @param frame_nr is the frame number of the data.
4499  * @param time is the time stamp of the frame (in seconds).
4500  * @param positions is a 1D array of data to add. The array should be of length
4501  * n_particles * 3.
4502  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4503  * must be initialised before using it.
4504  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4505  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4506  * @pre \code positions != 0 \endcode The pointer to the positions array must not
4507  * be a NULL pointer.
4508  * @details This function uses tng_util_generic_with_time_write() and will
4509  * create a positions data block if none exists. Positions are stored as three
4510  * values per frame and compressed using TNG compression.
4511  * N.b. Since compressed data is written a whole block at a time the data is not
4512  * actually written to disk until the frame set is finished or the TNG
4513  * trajectory is closed.
4514  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4515  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4516  * has occured.
4517  */
4518 tng_function_status DECLSPECDLLEXPORT tng_util_pos_with_time_write
4519                 (const tng_trajectory_t tng_data,
4520                  const int64_t frame_nr,
4521                  const double time,
4522                  const float *positions);
4523
4524 /**
4525  * @brief High-level function for adding data to positions data blocks at double
4526  * precision. If the frame is at the beginning of a frame set the time stamp of
4527  * the frame set is set.
4528  * @param tng_data is the trajectory to use.
4529  * @param frame_nr is the frame number of the data.
4530  * @param time is the time stamp of the frame (in seconds).
4531  * @param positions is a 1D array of data to add. The array should be of length
4532  * n_particles * 3.
4533  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4534  * must be initialised before using it.
4535  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4536  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4537  * @pre \code positions != 0 \endcode The pointer to the positions array must not
4538  * be a NULL pointer.
4539  * @details This function uses tng_util_generic_with_time_double_write() and will
4540  * create a positions data block if none exists. Positions are stored as three
4541  * values per frame and compressed using TNG compression.
4542  * N.b. Since compressed data is written a whole block at a time the data is not
4543  * actually written to disk until the frame set is finished or the TNG
4544  * trajectory is closed.
4545  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4546  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4547  * has occured.
4548  */
4549 tng_function_status DECLSPECDLLEXPORT tng_util_pos_with_time_double_write
4550                 (const tng_trajectory_t tng_data,
4551                  const int64_t frame_nr,
4552                  const double time,
4553                  const double *positions);
4554
4555 /**
4556  * @brief High-level function for adding data to velocities data blocks. If the
4557  * frame is at the beginning of a frame set the time stamp of the frame set
4558  * is set.
4559  * @param tng_data is the trajectory to use.
4560  * @param frame_nr is the frame number of the data.
4561  * @param time is the time stamp of the frame (in seconds).
4562  * @param velocities is a 1D array of data to add. The array should be of length
4563  * n_particles * 3.
4564  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4565  * must be initialised before using it.
4566  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4567  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4568  * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
4569  * be a NULL pointer.
4570  * @details This function uses tng_util_generic_with_time_write() and will
4571  * create a velocities data block if none exists. Velocities are stored as three
4572  * values per frame and compressed using TNG compression.
4573  * N.b. Since compressed data is written a whole block at a time the data is not
4574  * actually written to disk until the frame set is finished or the TNG
4575  * trajectory is closed.
4576  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4577  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4578  * has occured.
4579  */
4580 tng_function_status DECLSPECDLLEXPORT tng_util_vel_with_time_write
4581                 (const tng_trajectory_t tng_data,
4582                  const int64_t frame_nr,
4583                  const double time,
4584                  const float *velocities);
4585
4586 /**
4587  * @brief High-level function for adding data to velocities data blocks at
4588  * double precision. If the frame is at the beginning of a frame set the
4589  * time stamp of the frame set is set.
4590  * @param tng_data is the trajectory to use.
4591  * @param frame_nr is the frame number of the data.
4592  * @param time is the time stamp of the frame (in seconds).
4593  * @param velocities is a 1D array of data to add. The array should be of length
4594  * n_particles * 3.
4595  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4596  * must be initialised before using it.
4597  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4598  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4599  * @pre \code velocities != 0 \endcode The pointer to the velocities array must not
4600  * be a NULL pointer.
4601  * @details This function uses tng_util_generic_with_time_double_write() and will
4602  * create a velocities data block if none exists. Velocities are stored as three
4603  * values per frame and compressed using TNG compression.
4604  * N.b. Since compressed data is written a whole block at a time the data is not
4605  * actually written to disk until the frame set is finished or the TNG
4606  * trajectory is closed.
4607  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4608  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4609  * has occured.
4610  */
4611 tng_function_status DECLSPECDLLEXPORT tng_util_vel_with_time_double_write
4612                 (const tng_trajectory_t tng_data,
4613                  const int64_t frame_nr,
4614                  const double time,
4615                  const double *velocities);
4616
4617 /**
4618  * @brief High-level function for adding data to forces data blocks. If the
4619  * frame is at the beginning of a frame set the time stamp of the frame set
4620  * is set.
4621  * @param tng_data is the trajectory to use.
4622  * @param frame_nr is the frame number of the data.
4623  * @param time is the time stamp of the frame (in seconds).
4624  * @param forces is a 1D array of data to add. The array should be of length
4625  * n_particles * 3.
4626  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4627  * must be initialised before using it.
4628  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4629  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4630  * @pre \code forces != 0 \endcode The pointer to the forces array must not
4631  * be a NULL pointer.
4632  * @details This function uses tng_util_generic_with_time_write() and will
4633  * create a forces data block if none exists. Forces are stored as three
4634  * values per frame and compressed using gzip compression.
4635  * N.b. Since compressed data is written a whole block at a time the data is not
4636  * actually written to disk until the frame set is finished or the TNG
4637  * trajectory is closed.
4638  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4639  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4640  * has occured.
4641  */
4642 tng_function_status DECLSPECDLLEXPORT tng_util_force_with_time_write
4643                 (const tng_trajectory_t tng_data,
4644                  const int64_t frame_nr,
4645                  const double time,
4646                  const float *forces);
4647
4648 /**
4649  * @brief High-level function for adding data to forces data blocks at
4650  * double precision. If the frame is at the beginning of a frame set
4651  * the time stamp of the frame set is set.
4652  * @param tng_data is the trajectory to use.
4653  * @param frame_nr is the frame number of the data.
4654  * @param time is the time stamp of the frame (in seconds).
4655  * @param forces is a 1D array of data to add. The array should be of length
4656  * n_particles * 3.
4657  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4658  * must be initialised before using it.
4659  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4660  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4661  * @pre \code forces != 0 \endcode The pointer to the forces array must not
4662  * be a NULL pointer.
4663  * @details This function uses tng_util_generic_with_time_double_write() and will
4664  * create a forces data block if none exists. Forces are stored as three
4665  * values per frame and compressed using gzip compression.
4666  * N.b. Since compressed data is written a whole block at a time the data is not
4667  * actually written to disk until the frame set is finished or the TNG
4668  * trajectory is closed.
4669  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4670  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4671  * has occured.
4672  */
4673 tng_function_status DECLSPECDLLEXPORT tng_util_force_with_time_double_write
4674                 (const tng_trajectory_t tng_data,
4675                  const int64_t frame_nr,
4676                  const double time,
4677                  const double *forces);
4678
4679 /**
4680  * @brief High-level function for adding data to box shape data blocks. If the
4681  * frame is at the beginning of a frame set the time stamp of the frame set
4682  * is set.
4683  * @param tng_data is the trajectory to use.
4684  * @param frame_nr is the frame number of the data.
4685  * @param time is the time stamp of the frame (in seconds).
4686  * @param box_shape is a 1D array of data to add. The array should be of length 9.
4687  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4688  * must be initialised before using it.
4689  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4690  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4691  * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
4692  * be a NULL pointer.
4693  * @details This function uses tng_util_generic_with_time_write() and will
4694  * create a box shape data block if none exists. Box shapes are stored as 9
4695  * values per frame and compressed using TNG compression.
4696  * N.b. Since compressed data is written a whole block at a time the data is not
4697  * actually written to disk until the frame set is finished or the TNG
4698  * trajectory is closed.
4699  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4700  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4701  * has occured.
4702  */
4703 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_write
4704                 (const tng_trajectory_t tng_data,
4705                  const int64_t frame_nr,
4706                  const double time,
4707                  const float *box_shape);
4708
4709 /**
4710  * @brief High-level function for adding data to box shape data blocks at
4711  * double precision. If the frame is at the beginning of a frame set the
4712  * time stamp of the frame set is set.
4713  * @param tng_data is the trajectory to use.
4714  * @param frame_nr is the frame number of the data.
4715  * @param time is the time stamp of the frame (in seconds).
4716  * @param box_shape is a 1D array of data to add. The array should be of length 9.
4717  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4718  * must be initialised before using it.
4719  * @pre \code frame_nr >= 0 \endcode The frame number to write must be >= 0.
4720  * @pre \code time >= 0 \endcode The time stamp must be >= 0.
4721  * @pre \code box_shape != 0 \endcode The pointer to the box_shape array must not
4722  * be a NULL pointer.
4723  * @details This function uses tng_util_generic_with_time_double_write() and will
4724  * create a box shape data block if none exists. Box shapes are stored as 9
4725  * values per frame and compressed using TNG compression.
4726  * N.b. Since compressed data is written a whole block at a time the data is not
4727  * actually written to disk until the frame set is finished or the TNG
4728  * trajectory is closed.
4729  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4730  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4731  * has occured.
4732  */
4733 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_double_write
4734                 (const tng_trajectory_t tng_data,
4735                  const int64_t frame_nr,
4736                  const double time,
4737                  const double *box_shape);
4738
4739 /**
4740  * @brief High-level function for getting the compression method and
4741  * multiplication factor of the last read frame of a specific data block.
4742  * @param tng_data is the trajectory to use.
4743  * @param block_id is the ID number of the block containing the data of
4744  * interest.
4745  * @param codec_id will be set to the value of the codec_id of the
4746  * compression of the data block. See tng_compression for more details.
4747  * @param factor will be set to the multiplication factor applied to
4748  * the values before compression, in order to get integers from them.
4749  * factor is 1/precision.
4750  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4751  * must be initialised before using it.
4752  * @pre \code codec_id != 0 \endcode  The pointer to the returned codec id
4753  * must not be a NULL pointer.
4754  * @pre \code factor != 0 \endcode The pointer to the returned multiplication
4755  * factor must not be a NULL pointer.
4756  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4757  * has occured (such as invalid mode) or TNG_CRITICAL (2) if a major error
4758  * has occured.
4759  */
4760 tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
4761                 (const tng_trajectory_t tng_data,
4762                  const int64_t block_id,
4763                  int64_t *codec_id,
4764                  double  *factor);
4765
4766 /** @brief High-level function for determining the next frame with data and what
4767  * data blocks have data for that frame. The search can be limited to certain
4768  * data blocks.
4769  * @param tng_data is the trajectory to use.
4770  * @param current_frame is the frame that was last read, from where to start
4771  * looking for data.
4772  * @param n_requested_data_block_ids is the number of data blocks listed in
4773  * requested_data_block_ids. If this is 0 all data blocks will be taken into
4774  * account.
4775  * @param requested_data_block_ids is an array of data blocks to look for.
4776  * @param next_frame will be set to the next frame with data.
4777  * @param n_data_blocks_in_next_frame is set to the number of data blocks with
4778  * data for next_frame.
4779  * @param data_block_ids_in_next_frame is set to an array (of length
4780  * n_data_blocks_in_next_frame) that lists the data block IDs with data for
4781  * next_frame. It must be pointing at NULL or previously allocated memory.
4782  * Memory for the array is allocated by this function.
4783  * The memory must be freed by the client afterwards or
4784  * there will be a memory leak.
4785  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4786  * must be initialised before using it.
4787  * @pre \code next_frame != 0 \endcode The pointer to the next frame must not
4788  * be NULL.
4789  * @pre \code n_data_blocks_in_next_frame != 0 \endcode The pointer to
4790  * n_data_blocks_in_next_frame must not be NULL.
4791  * @pre \code *data_block_ids_in_next_frame != 0 \endcode The pointer to the
4792  * list of data block IDs must not be NULL.
4793  * @pre \code n_requested_data_block_ids == 0 || requested_data_block_ids != 0 \endcode
4794  * If the number of requested data blocks != 0 then the array of data block IDs must not be NULL.
4795  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4796  * has occured or TNG_CRITICAL (2) if a major error
4797  * has occured.
4798  */
4799 tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_data_blocks_find
4800                 (const tng_trajectory_t tng_data,
4801                  int64_t current_frame,
4802                  const int64_t n_requested_data_block_ids,
4803                  const int64_t *requested_data_block_ids,
4804                  int64_t *next_frame,
4805                  int64_t *n_data_blocks_in_next_frame,
4806                  int64_t **data_block_ids_in_next_frame);
4807
4808 /* @brief High-level function for getting all data block ids and their names
4809  * and stride lengths.
4810  * @param tng_data is the trajectory to use.
4811  * @param n_data_blocks is set to the number of data blocks in the trajectory.
4812  * @param data_block_ids is set to an array (of length
4813  * n_data_blocks) that lists the data block IDs in the trajectory.
4814  * It must be pointing at NULL or previously allocated memory.
4815  * Memory for the array is allocated by this function.
4816  * The memory must be freed by the client afterwards or
4817  * there will be a memory leak.
4818  * @param data_block_names is set to an array (of length
4819  * n_data_blocks) that contains the names of the data blocks.
4820  * It must be pointing at NULL or previously allocated memory.
4821  * Memory for the array is allocated by this function.
4822  * The memory must be freed by the client afterwards or
4823  * there will be a memory leak.
4824  * @param stride_lengths is set to an array (of length
4825  * n_data_blocks) that lists the stride lengths of the data blocks.
4826  * It must be pointing at NULL or previously allocated memory.
4827  * Memory for the array is allocated by this function.
4828  * The memory must be freed by the client afterwards or
4829  * there will be a memory leak.
4830  * @param n_values_per_frame is set to an array (of length
4831  * n_data_blocks) that lists the number of values per frame of the data blocks.
4832  * It must be pointing at NULL or previously allocated memory.
4833  * Memory for the array is allocated by this function.
4834  * The memory must be freed by the client afterwards or
4835  * there will be a memory leak.
4836  * @param block_types is set to an array (of length
4837  * n_data_blocks) that lists the block types of the data blocks.
4838  * It must be pointing at NULL or previously allocated memory.
4839  * Memory for the array is allocated by this function.
4840  * The memory must be freed by the client afterwards or
4841  * there will be a memory leak.
4842  * @param dependencies is set to an array (of length
4843  * n_data_blocks) that lists the dependencies of the data blocks.
4844  * It must be pointing at NULL or previously allocated memory.
4845  * Memory for the array is allocated by this function.
4846  * The memory must be freed by the client afterwards or
4847  * there will be a memory leak.
4848  * @param compressions is set to an array (of length
4849  * n_data_blocks) that lists the compressions of the data blocks.
4850  * It must be pointing at NULL or previously allocated memory.
4851  * Memory for the array is allocated by this function.
4852  * The memory must be freed by the client afterwards or
4853  * there will be a memory leak.
4854  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4855  * must be initialised before using it.
4856  * @pre \code n_data_blocks != 0 \endcode The pointer to
4857  * n_data_blocks must not be NULL.
4858  * @pre \code data_block_ids != 0 \endcode The pointer to the
4859  * list of data block IDs must not be NULL.
4860  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4861  * has occured or TNG_CRITICAL (2) if a major error
4862  * has occured.
4863  */
4864 /*
4865 tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_all_data_block_types_get
4866                 (const tng_trajectory_t tng_data,
4867                  int64_t *n_data_blocks,
4868                  int64_t **data_block_ids,
4869                  char ***data_block_names,
4870                  int64_t **stride_lengths,
4871                  int64_t **n_values_per_frame,
4872                  char **block_types,
4873                  char **dependencies,
4874                  char **compressions);
4875 */
4876
4877 /** @brief Finds the frame set of the specified frame in order to prepare for writing
4878  * after it.
4879  * @param tng_data is the trajectory to use.
4880  * @param prev_frame is the frame after which to start appending.
4881  * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
4882  * must be initialised before using it.
4883  * @pre \code prev_frame >= 0 \endcode The previous frame must not be negative.
4884  * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
4885  * has occured (such as not finding the requested frame) or TNG_CRITICAL (2)
4886  * if a major error has occured.
4887  */
4888 tng_function_status DECLSPECDLLEXPORT tng_util_prepare_append_after_frame
4889                 (const tng_trajectory_t tng_data,
4890                  const int64_t prev_frame);
4891
4892
4893 /** @brief Get the number of frames containing data of a specific type.
4894  * @param tng_data is the trajectory to use.
4895  * @param block_id is the id of the block of the data type.
4896  * @param n_frames is set to the number of frames containing data of
4897  * the requested data type.
4898  * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
4899  * error has occured.
4900  */
4901 tng_function_status DECLSPECDLLEXPORT tng_util_num_frames_with_data_of_block_id_get
4902                 (const tng_trajectory_t tng_data,
4903                  const int64_t block_id,
4904                  int64_t *n_frames);
4905 /** @} */ /* end of group2 */
4906
4907
4908 #ifdef __cplusplus
4909 }  /* end extern "C" */
4910 #endif
4911
4912 #endif /* TNG_IO_H */