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