Bumped the TNG library to the latest version.
[alexxy/gromacs.git] / src / external / tng_io / src / lib / tng_io_fortran.c
1 /* This code is part of the tng binary trajectory format.
2  *
3  * Written by Magnus Lundborg
4  * Copyright (c) 2012-2013, 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 #include "../../include/tng_io.h"
13
14 /* The following is for calling the library from fortran */
15
16 tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_(tng_trajectory_t *tng_data_p)
17 {
18     return(tng_trajectory_init(tng_data_p));
19 }
20
21 tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy_(tng_trajectory_t *tng_data_p)
22 {
23     return(tng_trajectory_destroy(tng_data_p));
24 }
25
26 tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src_(tng_trajectory_t src,
27                                                    tng_trajectory_t *dest_p)
28 {
29     return(tng_trajectory_init_from_src(src, dest_p));
30 }
31
32 tng_function_status DECLSPECDLLEXPORT tng_input_file_get_(const tng_trajectory_t tng_data,
33                                         char *file_name, const int max_len)
34 {
35     return(tng_input_file_get(tng_data, file_name, max_len));
36 }
37
38 tng_function_status DECLSPECDLLEXPORT tng_input_file_set_(tng_trajectory_t tng_data,
39                                         const char *file_name, int name_len)
40 {
41     char *name = malloc(name_len + 1);
42     tng_function_status stat;
43
44     strncpy(name, file_name, name_len);
45     name[name_len] = 0;
46     stat = tng_input_file_set(tng_data, name);
47     free(name);
48     return(stat);
49 }
50
51 tng_function_status DECLSPECDLLEXPORT tng_output_file_get_(const tng_trajectory_t tng_data,
52                                          char *file_name, const int max_len)
53 {
54     return(tng_output_file_get(tng_data, file_name, max_len));
55 }
56
57 tng_function_status DECLSPECDLLEXPORT tng_output_file_set_(tng_trajectory_t tng_data,
58                                          const char *file_name, int name_len)
59 {
60     char *name = malloc(name_len + 1);
61     tng_function_status stat;
62
63     strncpy(name, file_name, name_len);
64     name[name_len] = 0;
65     stat = tng_output_file_set(tng_data, name);
66     free(name);
67     return(stat);
68 }
69
70 tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get_(const tng_trajectory_t tng_data,
71                                                 char *name, const int max_len)
72 {
73     return(tng_first_program_name_get(tng_data, name, max_len));
74 }
75
76 tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get_
77                 (tng_trajectory_t tng_data, tng_file_endianness *endianness)
78 {
79     return(tng_output_file_endianness_get(tng_data, endianness));
80 }
81
82 tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set_
83                 (tng_trajectory_t tng_data, const tng_file_endianness *endianness)
84 {
85     return(tng_output_file_endianness_set(tng_data, *endianness));
86 }
87
88 tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set_(tng_trajectory_t tng_data,
89                                                 const char *new_name,
90                                                 int name_len)
91 {
92     char *name = malloc(name_len + 1);
93     tng_function_status stat;
94
95     strncpy(name, new_name, name_len);
96     name[name_len] = 0;
97     stat = tng_first_program_name_set(tng_data, name);
98     free(name);
99     return(stat);
100 }
101
102 tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get_(const tng_trajectory_t tng_data,
103                                                 char *name, const int max_len)
104 {
105     return(tng_last_program_name_get(tng_data, name, max_len));
106 }
107
108 tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set_(tng_trajectory_t tng_data,
109                                                const char *new_name,
110                                                int name_len)
111 {
112     char *name = malloc(name_len + 1);
113     tng_function_status stat;
114
115     strncpy(name, new_name, name_len);
116     name[name_len] = 0;
117     stat = tng_last_program_name_set(tng_data, name);
118     free(name);
119     return(stat);
120 }
121
122 tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get_(const tng_trajectory_t tng_data,
123                                              char *name, const int max_len)
124 {
125     return(tng_first_user_name_get(tng_data, name, max_len));
126 }
127
128 tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set_(tng_trajectory_t tng_data,
129                                              const char *new_name,
130                                              int name_len)
131 {
132     char *name = malloc(name_len + 1);
133     tng_function_status stat;
134
135     strncpy(name, new_name, name_len);
136     name[name_len] = 0;
137     stat = tng_first_user_name_set(tng_data, name);
138     free(name);
139     return(stat);
140 }
141
142 tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get_(const tng_trajectory_t tng_data,
143                                             char *name, const int max_len)
144 {
145     return(tng_last_user_name_get(tng_data, name, max_len));
146 }
147
148 tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set_(tng_trajectory_t tng_data,
149                                             const char *new_name,
150                                             int name_len)
151 {
152     char *name = malloc(name_len + 1);
153     tng_function_status stat;
154
155     strncpy(name, new_name, name_len);
156     name[name_len] = 0;
157     stat = tng_last_user_name_set(tng_data, name);
158     free(name);
159     return(stat);
160 }
161
162 tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get_(const tng_trajectory_t tng_data,
163                                                  char *name, const int max_len)
164 {
165     return(tng_first_computer_name_get(tng_data, name, max_len));
166 }
167
168 tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set_(tng_trajectory_t tng_data,
169                                                  const char *new_name,
170                                                  int name_len)
171 {
172     char *name = malloc(name_len + 1);
173     tng_function_status stat;
174
175     strncpy(name, new_name, name_len);
176     name[name_len] = 0;
177     stat = tng_first_computer_name_set(tng_data, name);
178     free(name);
179     return(stat);
180 }
181
182 tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get_(const tng_trajectory_t tng_data,
183                                                  char *name, const int max_len)
184 {
185     return(tng_last_computer_name_get(tng_data, name, max_len));
186 }
187
188 tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set_(tng_trajectory_t tng_data,
189                                                 const char *new_name,
190                                                 int name_len)
191 {
192     char *name = malloc(name_len + 1);
193     tng_function_status stat;
194
195     strncpy(name, new_name, name_len);
196     name[name_len] = 0;
197     stat = tng_last_computer_name_set(tng_data, name);
198     free(name);
199     return(stat);
200 }
201
202 tng_function_status DECLSPECDLLEXPORT tng_first_signature_get_
203                 (const tng_trajectory_t tng_data,
204                  char *signature, const int max_len)
205 {
206     return(tng_first_signature_get(tng_data, signature, max_len));
207 }
208
209 tng_function_status DECLSPECDLLEXPORT tng_first_signature_set_(tng_trajectory_t tng_data,
210                                              const char *signature,
211                                              int sign_len)
212 {
213     char *sign = malloc(sign_len + 1);
214     tng_function_status stat;
215
216     strncpy(sign, signature, sign_len);
217     sign[sign_len] = 0;
218     stat = tng_first_signature_set(tng_data, sign);
219     free(sign);
220     return(stat);
221 }
222
223 tng_function_status DECLSPECDLLEXPORT tng_last_signature_get_
224                 (const tng_trajectory_t tng_data,
225                  char *signature, const int max_len)
226 {
227     return(tng_last_signature_get(tng_data, signature, max_len));
228 }
229
230 tng_function_status DECLSPECDLLEXPORT tng_last_signature_set_
231                 (tng_trajectory_t tng_data,
232                  const char *signature,
233                  int sign_len)
234 {
235     char *sign = malloc(sign_len + 1);
236     tng_function_status stat;
237
238     strncpy(sign, signature, sign_len);
239     sign[sign_len] = 0;
240     stat = tng_last_signature_set(tng_data, sign);
241     free(sign);
242     return(stat);
243 }
244
245 tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get_
246                 (const tng_trajectory_t tng_data,
247                  char *name, const int max_len)
248 {
249     return(tng_forcefield_name_get(tng_data, name, max_len));
250 }
251
252 tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set_
253                 (tng_trajectory_t tng_data,
254                  const char *new_name,
255                  int name_len)
256 {
257     char *name = malloc(name_len + 1);
258     tng_function_status stat;
259
260     strncpy(name, new_name, name_len);
261     name[name_len] = 0;
262     stat = tng_forcefield_name_set(tng_data, name);
263     free(name);
264     return(stat);
265 }
266
267 tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get_
268                 (const tng_trajectory_t tng_data,
269                  int64_t *len)
270 {
271     return(tng_medium_stride_length_get(tng_data, len));
272 }
273
274 tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set_
275                 (tng_trajectory_t tng_data,
276                  const int64_t *len)
277 {
278     return(tng_medium_stride_length_set(tng_data, *len));
279 }
280
281 tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get_
282                 (const tng_trajectory_t tng_data,
283                  int64_t *len)
284 {
285     return(tng_long_stride_length_get(tng_data, len));
286 }
287
288 tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set_
289                 (tng_trajectory_t tng_data,
290                  const int64_t *len)
291 {
292     return(tng_long_stride_length_set(tng_data, *len));
293 }
294
295 tng_function_status DECLSPECDLLEXPORT tng_time_per_frame_get_
296                 (const tng_trajectory_t tng_data,
297                  double *time)
298 {
299     return(tng_time_per_frame_get(tng_data, time));
300 }
301
302 tng_function_status DECLSPECDLLEXPORT tng_time_per_frame_set_
303                 (tng_trajectory_t tng_data,
304                  const double *time)
305 {
306     return(tng_time_per_frame_set(tng_data, *time));
307 }
308
309 tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get_
310                 (const tng_trajectory_t tng_data,
311                  int64_t *len)
312 {
313     return(tng_input_file_len_get(tng_data, len));
314 }
315
316 tng_function_status DECLSPECDLLEXPORT tng_num_frames_get_
317                 (const tng_trajectory_t tng_data,
318                  int64_t *n)
319 {
320     return(tng_num_frames_get(tng_data, n));
321 }
322
323 tng_function_status DECLSPECDLLEXPORT tng_num_particles_get_
324                 (const tng_trajectory_t tng_data,
325                  int64_t *n)
326 {
327     return(tng_num_particles_get(tng_data, n));
328 }
329
330 tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get_
331                 (const tng_trajectory_t tng_data,
332                  int64_t *n)
333 {
334     return(tng_num_molecules_get(tng_data, n));
335 }
336
337 tng_function_status DECLSPECDLLEXPORT tng_distance_unit_exponential_get_
338                 (const tng_trajectory_t tng_data,
339                  int64_t *exp)
340 {
341     return(tng_distance_unit_exponential_get(tng_data, exp));
342 }
343
344 tng_function_status DECLSPECDLLEXPORT tng_distance_unit_exponential_set_
345                 (const tng_trajectory_t tng_data,
346                  const int64_t *exp)
347 {
348     return(tng_distance_unit_exponential_set(tng_data, *exp));
349 }
350
351 tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get_
352                 (const tng_trajectory_t tng_data,
353                  int64_t *n)
354 {
355     return(tng_num_frames_per_frame_set_get(tng_data, n));
356 }
357
358 tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set_
359                 (const tng_trajectory_t tng_data,
360                  int64_t *n)
361 {
362     return(tng_num_frames_per_frame_set_set(tng_data, *n));
363 }
364
365 tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get_
366                 (const tng_trajectory_t tng_data,
367                  int64_t *n)
368 {
369     return(tng_num_frame_sets_get(tng_data, n));
370 }
371
372 tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get_
373                 (tng_trajectory_t tng_data,
374                  tng_trajectory_frame_set_t *frame_set_p)
375 {
376     return(tng_current_frame_set_get(tng_data, frame_set_p));
377 }
378
379 tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find_(tng_trajectory_t tng_data,
380                                                              const int64_t *nr)
381 {
382     return(tng_frame_set_nr_find(tng_data, *nr));
383 }
384
385 tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find_
386                 (tng_trajectory_t tng_data,
387                  const int64_t *frame)
388 {
389     return(tng_frame_set_of_frame_find(tng_data, *frame));
390 }
391
392 tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get_
393                 (const tng_trajectory_t tng_data,
394                  const tng_trajectory_frame_set_t frame_set,
395                  int64_t *pos)
396 {
397     return(tng_frame_set_next_frame_set_file_pos_get(tng_data, frame_set, pos));
398 }
399
400 tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get_
401                 (const tng_trajectory_t tng_data,
402                  const tng_trajectory_frame_set_t frame_set,
403                  int64_t *pos)
404 {
405     return(tng_frame_set_prev_frame_set_file_pos_get(tng_data, frame_set, pos));
406 }
407
408 tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get_
409                 (const tng_trajectory_t tng_data,
410                  const tng_trajectory_frame_set_t frame_set,
411                  int64_t *first_frame,
412                  int64_t *last_frame)
413 {
414     return(tng_frame_set_frame_range_get(tng_data, frame_set, first_frame,
415                                          last_frame));
416 }
417
418 tng_function_status DECLSPECDLLEXPORT tng_molecule_init_(const tng_trajectory_t tng_data,
419                                        tng_molecule_t molecule)
420 {
421     return(tng_molecule_init(tng_data, molecule));
422 }
423
424 tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy_
425                 (const tng_trajectory_t tng_data,
426                  tng_molecule_t molecule)
427 {
428     return(tng_molecule_destroy(tng_data, molecule));
429 }
430
431 tng_function_status DECLSPECDLLEXPORT tng_molecule_add_(tng_trajectory_t tng_data,
432                                                         const char *name,
433                                                         tng_molecule_t *molecule,
434                                                         int name_len)
435 {
436     char *n = malloc(name_len + 1);
437     tng_function_status stat;
438
439     strncpy(n, name, name_len);
440     n[name_len] = 0;
441     stat = tng_molecule_add(tng_data, n, molecule);
442     free(n);
443     return(stat);
444 }
445
446 tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set_(tng_trajectory_t tng_data,
447                                                              tng_molecule_t molecule,
448                                                              const char *new_name,
449                                                              int name_len)
450 {
451     char *name = malloc(name_len + 1);
452     tng_function_status stat;
453
454     strncpy(name, new_name, name_len);
455     name[name_len] = 0;
456     stat = tng_molecule_name_set(tng_data, molecule, name);
457     free(name);
458     return(stat);
459 }
460
461 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get_(tng_trajectory_t tng_data,
462                                                             tng_molecule_t molecule,
463                                                             int64_t *cnt)
464 {
465     return(tng_molecule_cnt_get(tng_data, molecule, cnt));
466 }
467
468 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set_(tng_trajectory_t tng_data,
469                                                             tng_molecule_t molecule,
470                                                             int64_t *cnt)
471 {
472     return(tng_molecule_cnt_set(tng_data, molecule, *cnt));
473 }
474
475 tng_function_status DECLSPECDLLEXPORT tng_molecule_find_(tng_trajectory_t tng_data,
476                                                          const char *name,
477                                                          int64_t nr,
478                                                          tng_molecule_t *molecule,
479                                                          int name_len)
480 {
481     char *n = malloc(name_len + 1);
482     tng_function_status stat;
483
484     strncpy(n, name, name_len);
485     n[name_len] = 0;
486     stat = tng_molecule_find(tng_data, n, nr, molecule);
487     free(n);
488     return(stat);
489 }
490
491 tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find_(tng_trajectory_t tng_data,
492                                                                tng_molecule_t molecule,
493                                                                const char *name,
494                                                                int64_t id,
495                                                                tng_chain_t *chain,
496                                                                int name_len)
497 {
498     char *n = malloc(name_len + 1);
499     tng_function_status stat;
500
501     strncpy(n, name, name_len);
502     n[name_len] = 0;
503     stat = tng_molecule_chain_find(tng_data, molecule, n, id, chain);
504     free(n);
505     return(stat);
506 }
507
508 tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add_(tng_trajectory_t tng_data,
509                                                               tng_molecule_t molecule,
510                                                               const char *name,
511                                                               tng_chain_t *chain,
512                                                               int name_len)
513 {
514     char *n = malloc(name_len + 1);
515     tng_function_status stat;
516
517     strncpy(n, name, name_len);
518     n[name_len] = 0;
519     stat = tng_molecule_chain_add(tng_data, molecule, n, chain);
520     free(n);
521     return(stat);
522 }
523
524 tng_function_status DECLSPECDLLEXPORT tng_chain_name_set_(tng_trajectory_t tng_data,
525                                                           tng_chain_t chain,
526                                                           const char *new_name,
527                                                           int name_len)
528 {
529     char *name = malloc(name_len + 1);
530     tng_function_status stat;
531
532     strncpy(name, new_name, name_len);
533     name[name_len] = 0;
534     stat = tng_chain_name_set(tng_data, chain, name);
535     free(name);
536     return(stat);
537 }
538
539 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add_(tng_trajectory_t tng_data,
540                                                              tng_chain_t chain,
541                                                              const char *name,
542                                                              tng_residue_t *residue,
543                                                              int name_len)
544 {
545     char *n = malloc(name_len + 1);
546     tng_function_status stat;
547
548     strncpy(n, name, name_len);
549     n[name_len] = 0;
550     stat = tng_chain_residue_add(tng_data, chain, n, residue);
551     free(n);
552     return(stat);
553 }
554
555 tng_function_status DECLSPECDLLEXPORT tng_residue_name_set_(tng_trajectory_t tng_data,
556                                                             tng_residue_t residue,
557                                                             const char *new_name,
558                                                             int name_len)
559 {
560     char *name = malloc(name_len + 1);
561     tng_function_status stat;
562
563     strncpy(name, new_name, name_len);
564     name[name_len] = 0;
565     stat = tng_residue_name_set(tng_data, residue, name);
566     free(name);
567     return(stat);
568 }
569
570 tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add_(tng_trajectory_t tng_data,
571                                                             tng_residue_t residue,
572                                                             const char *atom_name,
573                                                             const char *atom_type,
574                                                             tng_atom_t *atom,
575                                                             int name_len,
576                                                             int type_len)
577 {
578     char *name = malloc(name_len + 1);
579     char *type = malloc(type_len + 1);
580     tng_function_status stat;
581
582     strncpy(name, atom_name, name_len);
583     strncpy(type, atom_type, type_len);
584     name[name_len] = 0;
585     type[type_len] = 0;
586     stat = tng_residue_atom_add(tng_data, residue, name, type, atom);
587     free(name);
588     free(type);
589     return(stat);
590 }
591
592 tng_function_status DECLSPECDLLEXPORT tng_atom_name_set_(tng_trajectory_t tng_data,
593                                                          tng_atom_t atom,
594                                                          const char *new_name,
595                                                          int name_len)
596 {
597     char *name = malloc(name_len + 1);
598     tng_function_status stat;
599
600     strncpy(name, new_name, name_len);
601     name[name_len] = 0;
602     stat = tng_atom_name_set(tng_data, atom, name);
603     free(name);
604     return(stat);
605 }
606
607 tng_function_status DECLSPECDLLEXPORT tng_atom_type_set_(tng_trajectory_t tng_data,
608                                                          tng_atom_t atom,
609                                                          const char *new_type,
610                                                          int type_len)
611 {
612     char *type = malloc(type_len + 1);
613     tng_function_status stat;
614
615     strncpy(type, new_type, type_len);
616     type[type_len] = 0;
617     stat = tng_atom_type_set(tng_data, atom, type);
618     free(type);
619     return(stat);
620 }
621
622 tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get_
623                 (const tng_trajectory_t tng_data,
624                  const int64_t nr,
625                  char *name,
626                  int max_len)
627 {
628     return(tng_molecule_name_of_particle_nr_get(tng_data, nr, name, max_len));
629 }
630
631 tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get_
632                 (const tng_trajectory_t tng_data,
633                  const int64_t nr,
634                  char *name,
635                  int max_len)
636 {
637     return(tng_chain_name_of_particle_nr_get(tng_data, nr, name, max_len));
638 }
639
640 tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get_
641                 (const tng_trajectory_t tng_data,
642                  const int64_t nr,
643                  char *name,
644                  int max_len)
645 {
646     return(tng_residue_name_of_particle_nr_get(tng_data, nr, name, max_len));
647 }
648
649 tng_function_status DECLSPECDLLEXPORT tng_residue_id_of_particle_nr_get_
650                 (const tng_trajectory_t tng_data,
651                  const int64_t nr,
652                  int64_t *id)
653 {
654     return(tng_residue_id_of_particle_nr_get(tng_data, nr, id));
655 }
656
657 tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get_
658                 (const tng_trajectory_t tng_data,
659                  const int64_t nr,
660                  char *name,
661                  int max_len)
662 {
663     return(tng_atom_name_of_particle_nr_get(tng_data, nr, name, max_len));
664 }
665
666 tng_function_status DECLSPECDLLEXPORT tng_atom_type_of_particle_nr_get_
667                 (const tng_trajectory_t tng_data,
668                  const int64_t nr,
669                  char *type,
670                  int max_len)
671 {
672     return(tng_atom_type_of_particle_nr_get(tng_data, nr, type, max_len));
673 }
674
675 tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add_
676                 (tng_trajectory_t tng_data,
677                  const int64_t *first_particle_number,
678                  const int64_t *n_particles,
679                  const int64_t *mapping_table)
680 {
681     return(tng_particle_mapping_add(tng_data, *first_particle_number,
682                                     *n_particles, mapping_table));
683 }
684
685 tng_function_status DECLSPECDLLEXPORT tng_file_headers_read_(tng_trajectory_t tng_data,
686                                                              const char *hash_mode)
687 {
688     return(tng_file_headers_read(tng_data, *hash_mode));
689 }
690
691 tng_function_status DECLSPECDLLEXPORT tng_file_headers_write_
692                 (tng_trajectory_t tng_data,
693                  const char *hash_mode)
694 {
695     return(tng_file_headers_write(tng_data, *hash_mode));
696 }
697
698 tng_function_status DECLSPECDLLEXPORT tng_block_read_next_
699                 (tng_trajectory_t tng_data,
700                  tng_gen_block_t block_data,
701                  const char *hash_mode)
702 {
703     return(tng_block_read_next(tng_data, block_data, *hash_mode));
704 }
705
706 tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_
707                 (tng_trajectory_t tng_data,
708                  const char *hash_mode)
709 {
710     return(tng_frame_set_read_next(tng_data, *hash_mode));
711 }
712
713 tng_function_status DECLSPECDLLEXPORT tng_frame_set_write_(tng_trajectory_t tng_data,
714                                                            const char *hash_mode)
715 {
716     return(tng_frame_set_write(tng_data, *hash_mode));
717 }
718
719 tng_function_status DECLSPECDLLEXPORT tng_frame_set_new_(tng_trajectory_t tng_data,
720                                                          const int64_t *first_frame,
721                                                          const int64_t *n_frames)
722 {
723     return(tng_frame_set_new(tng_data, *first_frame, *n_frames));
724 }
725
726 tng_function_status DECLSPECDLLEXPORT tng_frame_set_with_time_new_
727                 (tng_trajectory_t tng_data,
728                  const int64_t *first_frame,
729                  const int64_t *n_frames,
730                  const double *first_frame_time)
731 {
732     return(tng_frame_set_with_time_new(tng_data, *first_frame, *n_frames,
733                              *first_frame_time));
734 }
735
736 tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set_
737                 (tng_trajectory_t tng_data,
738                  const double *first_frame_time)
739 {
740     return(tng_frame_set_first_frame_time_set(tng_data, *first_frame_time));
741 }
742
743 tng_function_status DECLSPECDLLEXPORT tng_data_block_add_
744                 (tng_trajectory_t tng_data,
745                  const int64_t *id,
746                  const char *block_name,
747                  const char *datatype,
748                  const char *block_type_flag,
749                  int64_t *n_frames,
750                  const int64_t *n_values_per_frame,
751                  const int64_t *stride_length,
752                  const int64_t *codec_id,
753                  void *new_data,
754                  int name_len)
755 {
756     char *name = malloc(name_len + 1);
757     tng_function_status stat;
758
759     strncpy(name, block_name, name_len);
760     name[name_len] = 0;
761     stat = tng_data_block_add(tng_data, *id, name, *datatype, *block_type_flag,
762                               *n_frames, *n_values_per_frame, *stride_length,
763                               *codec_id, new_data);
764     free(name);
765     return(stat);
766 }
767
768 tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add_
769                 (tng_trajectory_t tng_data,
770                  const int64_t *id,
771                  const char *block_name,
772                  const char *datatype,
773                  const char *block_type_flag,
774                  int64_t *n_frames,
775                  const int64_t *n_values_per_frame,
776                  const int64_t *stride_length,
777                  const int64_t *first_particle_number,
778                  const int64_t *n_particles,
779                  const int64_t *codec_id,
780                  void *new_data,
781                  int name_len)
782 {
783     char *name = malloc(name_len + 1);
784     tng_function_status stat;
785
786     strncpy(name, block_name, name_len);
787     name[name_len] = 0;
788     stat = tng_particle_data_block_add(tng_data, *id, name, *datatype,
789                                        *block_type_flag, *n_frames,
790                                        *n_values_per_frame, *stride_length,
791                                        *first_particle_number, *n_particles,
792                                        *codec_id, new_data);
793     free(name);
794     return(stat);
795 }
796
797 tng_function_status DECLSPECDLLEXPORT tng_frame_data_write_
798                 (tng_trajectory_t tng_data,
799                  const int64_t *frame_nr,
800                  const int64_t *block_id,
801                  const void *data,
802                  const char *hash_mode)
803 {
804     return(tng_frame_data_write(tng_data, *frame_nr, *block_id, data,
805                                 *hash_mode));
806 }
807
808 tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write_
809                 (tng_trajectory_t tng_data,
810                  const int64_t *frame_nr,
811                  const int64_t *block_id,
812                  const int64_t *val_first_particle,
813                  const int64_t *val_n_particles,
814                  const void *data,
815                  const char *hash_mode)
816 {
817     return(tng_frame_particle_data_write(tng_data, *frame_nr, *block_id,
818                                          *val_first_particle, *val_n_particles,
819                                          data, *hash_mode));
820 }
821
822 tng_function_status DECLSPECDLLEXPORT tng_data_values_free_
823                 (const tng_trajectory_t tng_data,
824                  union data_values **values,
825                  const int64_t *n_frames,
826                  const int64_t *n_values_per_frame,
827                  const char *type)
828 {
829     return(tng_data_values_free(tng_data, values, *n_frames,
830                                 *n_values_per_frame, *type));
831 }
832
833 tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free_
834                 (const tng_trajectory_t tng_data,
835                  union data_values ***values,
836                  const int64_t *n_frames,
837                  const int64_t *n_particles,
838                  const int64_t *n_values_per_frame,
839                  const char *type)
840 {
841     return(tng_particle_data_values_free(tng_data, values, *n_frames, *n_particles,
842                                          *n_values_per_frame, *type));
843 }
844
845 tng_function_status DECLSPECDLLEXPORT tng_data_get_
846                 (tng_trajectory_t tng_data,
847                  const int64_t *block_id,
848                  union data_values ***values,
849                  int64_t *n_frames,
850                  int64_t *n_values_per_frame,
851                  char *type)
852 {
853     return(tng_data_get(tng_data, *block_id, values, n_frames,
854                         n_values_per_frame, type));
855 }
856
857 tng_function_status DECLSPECDLLEXPORT tng_data_interval_get_
858                 (tng_trajectory_t tng_data,
859                  const int64_t *block_id,
860                  const int64_t *start_frame_nr,
861                  const int64_t *end_frame_nr,
862                  const char *hash_mode,
863                  union data_values ***values,
864                  int64_t *n_values_per_frame,
865                  char *type)
866 {
867     return(tng_data_interval_get(tng_data, *block_id, *start_frame_nr,
868                                  *end_frame_nr, *hash_mode, values,
869                                  n_values_per_frame, type));
870 }
871
872 tng_function_status DECLSPECDLLEXPORT tng_particle_data_get_
873                 (tng_trajectory_t tng_data,
874                  const int64_t *block_id,
875                  union data_values ****values,
876                  int64_t *n_frames,
877                  int64_t *n_particles,
878                  int64_t *n_values_per_frame,
879                  char *type)
880 {
881     return(tng_particle_data_get(tng_data, *block_id, values, n_frames,
882                                  n_particles, n_values_per_frame, type));
883 }
884
885 tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get_
886                 (tng_trajectory_t tng_data,
887                  const int64_t *block_id,
888                  const int64_t *start_frame_nr,
889                  const int64_t *end_frame_nr,
890                  const char *hash_mode,
891                  union data_values ****values,
892                  int64_t *n_particles,
893                  int64_t *n_values_per_frame,
894                  char *type)
895 {
896     return(tng_particle_data_interval_get(tng_data, *block_id, *start_frame_nr,
897                                           *end_frame_nr, *hash_mode, values,
898                                           n_particles, n_values_per_frame,
899                                           type));
900 }
901
902 tng_function_status DECLSPECDLLEXPORT tng_time_get_str_
903                 (const tng_trajectory_t tng_data,
904                  char *time, int64_t str_len)
905 {
906     return(tng_time_get_str(tng_data, time));
907 }
908
909 tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_open_
910                 (const char *filename, const char *mode,
911                  tng_trajectory_t *tng_data_p)
912 {
913     return(tng_util_trajectory_open(filename, *mode, tng_data_p));
914 }
915
916 tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_close_
917                 (tng_trajectory_t *tng_data_p)
918 {
919     return(tng_util_trajectory_close(tng_data_p));
920 }
921
922 tng_function_status DECLSPECDLLEXPORT tng_util_pos_read_
923                 (tng_trajectory_t tng_data,
924                  float **positions,
925                  int64_t *stride_length)
926 {
927     return(tng_util_pos_read(tng_data, positions, stride_length));
928 }
929
930 tng_function_status DECLSPECDLLEXPORT tng_util_vel_read_
931                 (tng_trajectory_t tng_data,
932                  float **velocities,
933                  int64_t *stride_length)
934 {
935     return(tng_util_vel_read(tng_data, velocities, stride_length));
936 }
937
938 tng_function_status DECLSPECDLLEXPORT tng_util_force_read_
939                 (tng_trajectory_t tng_data,
940                  float **forces,
941                  int64_t *stride_length)
942 {
943     return(tng_util_force_read(tng_data, forces, stride_length));
944 }
945
946 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_
947                 (tng_trajectory_t tng_data,
948                  float **box_shape,
949                  int64_t *stride_length)
950 {
951     return(tng_util_box_shape_read(tng_data, box_shape, stride_length));
952 }
953
954 tng_function_status DECLSPECDLLEXPORT tng_util_pos_read_range_
955                 (tng_trajectory_t tng_data,
956                  const int64_t *first_frame,
957                  const int64_t *last_frame,
958                  float **positions,
959                  int64_t *stride_length)
960 {
961     return(tng_util_pos_read_range(tng_data, *first_frame, *last_frame,
962                                          positions, stride_length));
963 }
964
965 tng_function_status DECLSPECDLLEXPORT tng_util_vel_read_range_
966                 (tng_trajectory_t tng_data,
967                  const int64_t *first_frame,
968                  const int64_t *last_frame,
969                  float **velocities,
970                  int64_t *stride_length)
971 {
972     return(tng_util_vel_read_range(tng_data, *first_frame, *last_frame,
973                                          velocities, stride_length));
974 }
975
976 tng_function_status DECLSPECDLLEXPORT tng_util_force_read_range_
977                 (tng_trajectory_t tng_data,
978                  const int64_t *first_frame,
979                  const int64_t *last_frame,
980                  float **forces,
981                  int64_t *stride_length)
982 {
983     return(tng_util_force_read_range(tng_data, *first_frame, *last_frame,
984                                          forces, stride_length));
985 }
986
987 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_read_range_
988                 (tng_trajectory_t tng_data,
989                  const int64_t *first_frame,
990                  const int64_t *last_frame,
991                  float **box_shape,
992                  int64_t *stride_length)
993 {
994     return(tng_util_box_shape_read_range(tng_data, *first_frame, *last_frame,
995                                          box_shape, stride_length));
996 }
997
998 tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_frequency_set_
999                 (tng_trajectory_t tng_data,
1000                  const int64_t *f,
1001                  const int64_t *n_values_per_frame,
1002                  const int64_t *block_id,
1003                  const char *block_name,
1004                  const char *particle_dependency,
1005                  const char *compression)
1006 {
1007     return(tng_util_generic_write_frequency_set(tng_data, *f,
1008                                                 *n_values_per_frame, *block_id,
1009                                                 block_name,
1010                                                 *particle_dependency,
1011                                                 *compression));
1012 }
1013
1014 tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_frequency_set_
1015                 (tng_trajectory_t tng_data,
1016                  const int64_t *f)
1017 {
1018     return(tng_util_pos_write_frequency_set(tng_data, *f));
1019 }
1020
1021 tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_frequency_set_
1022                 (tng_trajectory_t tng_data,
1023                  const int64_t *f)
1024 {
1025     return(tng_util_vel_write_frequency_set(tng_data, *f));
1026 }
1027
1028 tng_function_status DECLSPECDLLEXPORT tng_util_force_write_frequency_set_
1029                 (tng_trajectory_t tng_data,
1030                  const int64_t *f)
1031 {
1032     return(tng_util_force_write_frequency_set(tng_data, *f));
1033 }
1034
1035 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_frequency_set_
1036                 (tng_trajectory_t tng_data,
1037                  const int64_t *f)
1038 {
1039     return(tng_util_box_shape_write_frequency_set(tng_data, *f));
1040 }
1041
1042 tng_function_status DECLSPECDLLEXPORT tng_util_generic_write_
1043                 (tng_trajectory_t tng_data,
1044                  const int64_t *frame_nr,
1045                  const float *values,
1046                  const int64_t *n_values_per_frame,
1047                  const int64_t *block_id,
1048                  const char *block_name,
1049                  const char *particle_dependency,
1050                  const char *compression)
1051 {
1052     return(tng_util_generic_write(tng_data, *frame_nr, values,
1053                                   *n_values_per_frame, *block_id, block_name,
1054                                   *particle_dependency, *compression));
1055 }
1056
1057 tng_function_status DECLSPECDLLEXPORT tng_util_pos_write_
1058                 (tng_trajectory_t tng_data,
1059                  const int64_t *frame_nr,
1060                  const float *positions)
1061 {
1062     return(tng_util_vel_write(tng_data, *frame_nr, positions));
1063 }
1064
1065 tng_function_status DECLSPECDLLEXPORT tng_util_vel_write_
1066                 (tng_trajectory_t tng_data,
1067                  const int64_t *frame_nr,
1068                  const float *velocities)
1069 {
1070     return(tng_util_vel_write(tng_data, *frame_nr, velocities));
1071 }
1072
1073 tng_function_status DECLSPECDLLEXPORT tng_util_force_write_
1074                 (tng_trajectory_t tng_data,
1075                  const int64_t *frame_nr,
1076                  const float *forces)
1077 {
1078     return(tng_util_force_write(tng_data, *frame_nr, forces));
1079 }
1080
1081 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_write_
1082                 (tng_trajectory_t tng_data,
1083                  const int64_t *frame_nr,
1084                  const float *box_shape)
1085 {
1086     return(tng_util_box_shape_write(tng_data, *frame_nr, box_shape));
1087 }
1088
1089 tng_function_status DECLSPECDLLEXPORT tng_util_pos_with_time_write_
1090                 (tng_trajectory_t tng_data,
1091                  const int64_t *frame_nr,
1092                  const int64_t *time,
1093                  const float *positions)
1094 {
1095     return(tng_util_pos_with_time_write(tng_data, *frame_nr, *time,
1096                                         positions));
1097 }
1098
1099 tng_function_status DECLSPECDLLEXPORT tng_util_vel_with_time_write_
1100                 (tng_trajectory_t tng_data,
1101                  const int64_t *frame_nr,
1102                  const int64_t *time,
1103                  const float *velocities)
1104 {
1105     return(tng_util_vel_with_time_write(tng_data, *frame_nr, *time,
1106                                         velocities));
1107 }
1108
1109 tng_function_status DECLSPECDLLEXPORT tng_util_force_with_time_write_
1110                 (tng_trajectory_t tng_data,
1111                  const int64_t *frame_nr,
1112                  const int64_t *time,
1113                  const float *forces)
1114 {
1115     return(tng_util_force_with_time_write(tng_data, *frame_nr, *time,
1116                                           forces));
1117 }
1118
1119 tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_write_
1120                 (tng_trajectory_t tng_data,
1121                  const int64_t *frame_nr,
1122                  const int64_t *time,
1123                  const float *box_shape)
1124 {
1125     return(tng_util_box_shape_with_time_write(tng_data, *frame_nr, *time,
1126                                               box_shape));
1127 }