Bumped TNG to latest version.
authorMagnus Lundborg <lundborg.magnus@gmail.com>
Wed, 12 Feb 2014 07:59:48 +0000 (08:59 +0100)
committerMagnus Lundborg <lundborg.magnus@gmail.com>
Wed, 12 Feb 2014 07:59:48 +0000 (08:59 +0100)
Change-Id: Iefbb35ce46f0c545a23b8bea6b90ad5e11caeffc

13 files changed:
src/external/tng_io/CMakeLists.txt
src/external/tng_io/include/tng_io.h
src/external/tng_io/include/tng_io.hpp
src/external/tng_io/include/tng_io_fwd.h
src/external/tng_io/src/compression/tng_compress.c
src/external/tng_io/src/lib/tng_io.c
src/external/tng_io/src/lib/tng_io_fortran.c
src/external/tng_io/src/tests/CMakeLists.txt
src/external/tng_io/src/tests/md_openmp.c
src/external/tng_io/src/tests/md_openmp.f
src/external/tng_io/src/tests/md_openmp_util.c
src/external/tng_io/src/tests/tng_io_testing.c
src/gromacs/fileio/tngio_for_tools.cpp

index a0f917d51519c0a1c2aa18a5bea1eb5f33003301..52cf7aa7525e8e54643377842a11022788bbab8e 100644 (file)
@@ -18,16 +18,7 @@ option(TNG_BUILD_EXAMPLES "Build examples showing usage of the TNG API" ON)
 option(TNG_BUILD_TEST "Build TNG testing binary." ON)
 option(TNG_BUILD_COMPRESSION_TESTS "Build tests of the TNG compression library" OFF)
 
-option(TNG_USE_OPENMP "Try to use the OpenMP library (if available)" OFF)
-if(TNG_USE_OPENMP)
-  find_package(OpenMP)
-  if(OPENMP_FOUND)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
-  endif()
-endif()
-
-find_package(ZLIB)
+find_package(ZLIB QUIET)
 
 include(CheckIncludeFile)
 check_include_file(inttypes.h   HAVE_INTTYPES_H)
index a240d3277e7627e20b97d4222eef0fc429c3ba21..45cb1d8d2d17d6df92a7c0c8835b9c96ec7ce7bb 100644 (file)
@@ -1,6 +1,6 @@
 /* This code is part of the tng binary trajectory format.
  *
- *                      VERSION 1.4
+ *                      VERSION 1.5
  *
  * Written by Magnus Lundborg
  * Copyright (c) 2012-2013, The GROMACS development team.
  *
  * Revisions
  *
+ * v. 1.5 - Third stable release of the API.
+ *
+ *        - Fortran wrapper split into separate file
+ *        - Added more block IDs.
+ *        - Some new functions and utility functions added.
+ *        - Improved compression precision settings.
+ *        - Improved tests.
+ *        - Make appending to file work better.
+ *        - Modified CMake settings
+ *        - Bugs fixed
+ *
  * v. 1.4 - Changed from LGPL to the Revised BSD License.
  *
  *        - More flexible support for digital signatures in header.
@@ -334,7 +345,7 @@ typedef unsigned __int64 uint64_t;
 
 
 /** The version of this TNG build */
-#define TNG_VERSION 4 /* TNG_VERSION 4 => Api version 1.4 */
+#define TNG_VERSION 5 /* TNG_VERSION 4 => Api version 1.5 */
 
 /** Flag to indicate frame dependent data. */
 #define TNG_FRAME_DEPENDENT 1
@@ -658,7 +669,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set
  * could not be retrieved.
  */
 tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get
-                (tng_trajectory_t tng_data, tng_file_endianness *endianness);
+                (const tng_trajectory_t tng_data, tng_file_endianness *endianness);
 
 /**
  * @brief Set the endianness of the output file.
@@ -1283,7 +1294,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
  * @return TNG_SUCCESS (0) if successful.
  */
 tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  tng_trajectory_frame_set_t *frame_set_p);
 
 /**
@@ -1516,8 +1527,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set
  * has occurred or TNG_CRITICAL (2) if a major error has occured.
  */
 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
                  int64_t *cnt);
 
 /**
@@ -1601,8 +1612,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_system_copy(tng_trajectory_t
  * @return TNG_SUCCESS (0) if successful.
  */
 tng_function_status DECLSPECDLLEXPORT tng_molecule_num_chains_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
                  int64_t *n);
 
 /**
@@ -1633,8 +1644,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_of_index_get
  * @return TNG_SUCCESS (0) if successful.
  */
 tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
                  int64_t *n);
 
 /**
@@ -1650,9 +1661,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get
  * residue is not found.
  */
 tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
+                 const int64_t index,
                  tng_residue_t *residue);
 
 /**
@@ -1665,8 +1676,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get
  * @return TNG_SUCCESS (0) if successful.
  */
 tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
                  int64_t *n);
 
 /**
@@ -1682,9 +1693,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get
  * atom is not found.
  */
 tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
+                 const int64_t index,
                  tng_atom_t *atom);
 
 /**
@@ -1856,9 +1867,9 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_num_residues_get
  * residue is not found.
  */
 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_chain_t chain,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_chain_t chain,
+                 const int64_t index,
                  tng_residue_t *residue);
 
 /**
@@ -1988,9 +1999,9 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_num_atoms_get
  * atom is not found.
  */
 tng_function_status DECLSPECDLLEXPORT tng_residue_atom_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_residue_t residue,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_residue_t residue,
+                 const int64_t index,
                  tng_atom_t *atom);
 
 /**
@@ -2049,7 +2060,7 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_atom_w_id_add
  * @pre \code atom != 0 \endcode The atom must not be NULL.
  * @return TNG_SUCCESS (0) if successful.
  */
-tng_function_status tng_atom_residue_get(tng_trajectory_t tng_data,
+tng_function_status tng_atom_residue_get(const tng_trajectory_t tng_data,
                                          const tng_atom_t atom,
                                          tng_residue_t *residue);
 
@@ -2600,7 +2611,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set
  * frame set or TNG_CRITICAL(2) if a major error has occured.
  */
 tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  int64_t *frame);
 
 /**
@@ -2725,7 +2736,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_name_get
  * TNG_CRITICAL (2) if a major error has occured.
  */
 tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  int64_t block_id,
                  int *block_dependency);
 
@@ -2742,7 +2753,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get
  * TNG_CRITICAL (2) if a major error has occured.
  */
 tng_function_status DECLSPECDLLEXPORT tng_data_block_num_values_per_frame_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  int64_t block_id,
                  int64_t *n_values_per_frame);
 
@@ -3218,7 +3229,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
  * has occurred or TNG_CRITICAL (2) if a major error has occured.
  */
 tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  const int64_t block_id,
                  int64_t frame,
                  int64_t *stride_length);
@@ -4670,7 +4681,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_double_write
 tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
                 (tng_trajectory_t tng_data,
                  const int64_t block_id,
-                 char *codec_id,
+                 int64_t *codec_id,
                  float *factor);
 
 /** @brief High-level function for determining the next frame with data and what
index 202f9dbcba51b9e211b0440920554140f2674a7f..f3bc32abea9803cf15657eb180ed09a8c8fa5bea 100644 (file)
@@ -1,6 +1,6 @@
 /* This code is part of the tng binary trajectory format.
  *
- *                      VERSION 1.4
+ *                      VERSION 1.5
  *
  * Written by Anders Gärdenäs
  * Copyright (c) 2012-2013, The GROMACS development team.
index 340c264b239ab4940ce425b11aca177396785df0..34ddd87bad3d9233b6c5fc0e2d2a5b50ab5f1814 100644 (file)
@@ -1,6 +1,6 @@
 /* This code is part of the tng binary trajectory format.
  *
- *                      VERSION 1.4
+ *                      VERSION 1.5
  *
  * Written by Magnus Lundborg
  * Copyright (c) 2012-2013, The GROMACS development team.
index 6174e8fcdaffd2c996e41cc02460c709402ade60..b39d7220cb3692a11af098d56734965ae635ae63 100644 (file)
@@ -423,9 +423,12 @@ static void compress_quantized_pos(int *quant, int *quant_inter, int *quant_intr
       if (data)
         bufferfix((unsigned char*)data+bufloc,(fix_t)length,4);
       bufloc+=4;
-      if (data)
-        memcpy(data+bufloc,datablock,length);
-      free(datablock);
+      if (datablock)
+        {
+          if (data)
+            memcpy(data+bufloc,datablock,length);
+          free(datablock);
+        }
       bufloc+=length;
     }
   *nitems=bufloc;
index 4b813124dd5d8d2e25c898532b0b3c1643f98570..b51796adbc133c23c334bdfea90f1833b386778e 100644 (file)
@@ -1,6 +1,6 @@
 /* This code is part of the tng binary trajectory format.
  *
- *                      VERSION 1.4
+ *                      VERSION 1.5
  *
  * Written by Magnus Lundborg
  * Copyright (c) 2012-2013, The GROMACS development team.
@@ -683,7 +683,7 @@ static tng_function_status tng_input_file_init(tng_trajectory_t tng_data)
                    __FILE__, __LINE__);
             return(TNG_CRITICAL);
         }
-        tng_data->input_file = fopen(tng_data->input_file_path, "r");
+        tng_data->input_file = fopen(tng_data->input_file_path, "rb");
         if(!tng_data->input_file)
         {
             fprintf(stderr, "TNG library: Cannot open file %s. %s: %d\n",
@@ -710,7 +710,7 @@ static tng_function_status tng_output_file_init(tng_trajectory_t tng_data)
             return(TNG_CRITICAL);
         }
 
-        tng_data->output_file = fopen(tng_data->output_file_path, "w+");
+        tng_data->output_file = fopen(tng_data->output_file_path, "wb+");
 
         if(!tng_data->output_file)
         {
@@ -733,7 +733,6 @@ static tng_function_status tng_block_init(struct tng_gen_block **block_p)
     tng_gen_block_t block;
 
     *block_p = malloc(sizeof(struct tng_gen_block));
-
     if(!*block_p)
     {
         fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
@@ -3865,7 +3864,7 @@ static tng_function_status tng_compress(tng_trajectory_t tng_data,
         return(TNG_FAILURE);
     }
 
-    f_precision = 1/tng_data->compression_precision;
+    f_precision = 1/(float)tng_data->compression_precision;
     d_precision = 1/tng_data->compression_precision;
 
     if(block->id == TNG_TRAJ_POSITIONS)
@@ -4216,6 +4215,12 @@ static tng_function_status tng_gzip_compress(tng_trajectory_t tng_data,
 
     max_len = compressBound(len);
     dest = malloc(max_len);
+    if(!dest)
+    {
+        fprintf(stderr, "TNG library: Cannot allocate memory (%ld bytes). %s: %d\n",
+               max_len, __FILE__, __LINE__);
+        return(TNG_CRITICAL);
+    }
 
     stat = compress(dest, &max_len, start_pos, len);
     if(stat != (unsigned long)Z_OK)
@@ -4271,6 +4276,12 @@ static tng_function_status tng_gzip_uncompress(tng_trajectory_t tng_data,
     offset = (char *)start_pos - (char *)block->block_contents;
 
     dest = malloc(uncompressed_len);
+    if(!dest)
+    {
+        fprintf(stderr, "TNG library: Cannot allocate memory (%lud bytes). %s: %d\n",
+               uncompressed_len, __FILE__, __LINE__);
+        return(TNG_CRITICAL);
+    }
 
     stat = uncompress(dest, &uncompressed_len, (Bytef *) start_pos,
                       block->block_contents_size - offset);
@@ -5448,6 +5459,11 @@ static tng_function_status tng_allocate_data_mem
     int64_t i, j, size, frame_alloc;
     (void)tng_data;
 
+    if(n_values_per_frame == 0)
+    {
+        return(TNG_FAILURE);
+    }
+
     if(data->strings && data->datatype == TNG_CHAR_DATA)
     {
         for(i = data->n_frames; i--;)
@@ -6242,7 +6258,6 @@ static tng_function_status tng_data_block_meta_information_read
     {
         meta_size = 3 * sizeof(char) + sizeof(double) + 6 * sizeof(int64_t);
         contents = malloc(meta_size);
-
         if(!contents)
         {
             fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
@@ -6528,6 +6543,13 @@ static tng_function_status tng_md5_hash_update(tng_trajectory_t tng_data,
     }
 
     block->block_contents = malloc(block->block_contents_size);
+    if(!block->block_contents)
+    {
+        fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
+               block->block_contents_size, __FILE__, __LINE__);
+        return(TNG_CRITICAL);
+    }
+
     fseek(tng_data->output_file, (long)contents_start_pos, SEEK_SET);
     if(fread(block->block_contents, block->block_contents_size, 1,
             tng_data->output_file) == 0)
@@ -7047,7 +7069,7 @@ static tng_function_status tng_frame_set_finalize
 // }
 */
 
-tng_function_status tng_atom_residue_get(tng_trajectory_t tng_data,
+tng_function_status tng_atom_residue_get(const tng_trajectory_t tng_data,
                                          const tng_atom_t atom,
                                          tng_residue_t *residue)
 {
@@ -7060,7 +7082,7 @@ tng_function_status tng_atom_residue_get(tng_trajectory_t tng_data,
     return(TNG_SUCCESS);
 }
 
-tng_function_status tng_atom_name_get(tng_trajectory_t tng_data,
+tng_function_status tng_atom_name_get(const tng_trajectory_t tng_data,
                                       const tng_atom_t atom,
                                       char *name,
                                       const int max_len)
@@ -7114,7 +7136,7 @@ tng_function_status tng_atom_name_set(tng_trajectory_t tng_data,
     return(TNG_SUCCESS);
 }
 
-tng_function_status tng_atom_type_get(tng_trajectory_t tng_data,
+tng_function_status tng_atom_type_get(const tng_trajectory_t tng_data,
                                       const tng_atom_t atom,
                                       char *type,
                                       const int max_len)
@@ -7384,7 +7406,7 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
     return(TNG_SUCCESS);
 }
 
-tng_function_status tng_molecule_name_get(tng_trajectory_t tng_data,
+tng_function_status tng_molecule_name_get(const tng_trajectory_t tng_data,
                                           const tng_molecule_t molecule,
                                           char *name,
                                           const int max_len)
@@ -7440,8 +7462,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
                  int64_t *cnt)
 {
     int64_t i, index = -1;
@@ -7735,9 +7757,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
+                 const int64_t index,
                  tng_residue_t *residue)
 {
     (void) tng_data;
@@ -7768,9 +7790,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_molecule_t molecule,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t molecule,
+                 const int64_t index,
                  tng_atom_t *atom)
 {
     (void) tng_data;
@@ -8035,9 +8057,9 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_num_residues_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_chain_residue_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_chain_t chain,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_chain_t chain,
+                 const int64_t index,
                  tng_residue_t *residue)
 {
     (void) tng_data;
@@ -8192,7 +8214,7 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_residue_w_id_add
     return(stat);
 }
 
-tng_function_status tng_residue_name_get(tng_trajectory_t tng_data,
+tng_function_status tng_residue_name_get(const tng_trajectory_t tng_data,
                                          const tng_residue_t residue,
                                          char *name,
                                          const int max_len)
@@ -8261,9 +8283,9 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_num_atoms_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_residue_atom_of_index_get
-                (tng_trajectory_t tng_data,
-                 tng_residue_t residue,
-                 int64_t index,
+                (const tng_trajectory_t tng_data,
+                 const tng_residue_t residue,
+                 const int64_t index,
                  tng_atom_t *atom)
 {
     tng_chain_t chain;
@@ -9590,9 +9612,23 @@ tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajector
 
     frame_set = &dest->current_trajectory_frame_set;
 
+    dest->input_file_path = malloc(strlen(src->input_file_path) + 1);
+    if(!dest->input_file_path)
+    {
+        fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
+               (int)strlen(src->input_file_path) + 1, __FILE__, __LINE__);
+        return(TNG_CRITICAL);
+    }
     strcpy(dest->input_file_path, src->input_file_path);
     dest->input_file = 0;
     dest->input_file_len = src->input_file_len;
+    dest->output_file_path = malloc(strlen(src->output_file_path) + 1);
+    if(!dest->output_file_path)
+    {
+        fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n",
+               (int)strlen(src->output_file_path) + 1, __FILE__, __LINE__);
+        return(TNG_CRITICAL);
+    }
     strcpy(dest->output_file_path, src->output_file_path);
     dest->output_file = 0;
 
@@ -9818,7 +9854,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set
 
     strncpy(tng_data->output_file_path, file_name, len);
 
-    tng_data->output_file = fopen(tng_data->output_file_path, "r+");
+    tng_data->output_file = fopen(tng_data->output_file_path, "rb+");
     if(!tng_data->output_file)
     {
         fprintf(stderr, "TNG library: Cannot open file %s. %s: %d\n",
@@ -9830,7 +9866,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get
-                (tng_trajectory_t tng_data, tng_file_endianness *endianness)
+                (const tng_trajectory_t tng_data, tng_file_endianness *endianness)
 {
     tng_endianness_32 end_32;
     tng_endianness_64 end_64;
@@ -10627,7 +10663,12 @@ tng_function_status DECLSPECDLLEXPORT tng_implicit_num_particles_set
     stat = tng_molecule_find(tng_data, "TNG_IMPLICIT_MOL", -1, &mol);
     if(stat == TNG_SUCCESS)
     {
-        tng_molecule_cnt_get(tng_data, mol, &n_impl);
+        if(tng_molecule_cnt_get(tng_data, mol, &n_impl) != TNG_SUCCESS)
+        {
+            fprintf(stderr, "TNG library: Cannot get the number of implicit molecules. %s: %d\n",
+                    __FILE__, __LINE__);
+            return(TNG_FAILURE);
+        }
         diff -= n_impl * mol->n_atoms;
     }
 
@@ -10838,7 +10879,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                  int64_t *n)
 {
     int64_t long_stride_length, medium_stride_length;
-    int64_t file_pos, orig_frame_set_file_pos;
+    long file_pos, orig_frame_set_file_pos;
     tng_trajectory_frame_set_t frame_set;
     struct tng_trajectory_frame_set   orig_frame_set;
     tng_gen_block_t block;
@@ -10853,18 +10894,18 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
     frame_set = &tng_data->current_trajectory_frame_set;
 
     orig_frame_set_file_pos = tng_data->current_trajectory_frame_set_input_file_pos;
-    file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
+    file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos;
 
     tng_block_init(&block);
     fseek(tng_data->input_file,
-          (long)file_pos,
+          file_pos,
           SEEK_SET);
-    tng_data->current_trajectory_frame_set_input_file_pos = (long)file_pos;
+    tng_data->current_trajectory_frame_set_input_file_pos = file_pos;
     /* Read block headers first to see what block is found. */
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n", file_pos,
+        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n", file_pos,
                 __FILE__, __LINE__);
         tng_block_destroy(&block);
         return(TNG_CRITICAL);
@@ -10884,18 +10925,18 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
 
     /* Take long steps forward until a long step forward would be too long or
      * the last frame set is found */
-    file_pos = frame_set->long_stride_next_frame_set_file_pos;
+    file_pos = (long)frame_set->long_stride_next_frame_set_file_pos;
     while(file_pos > 0)
     {
         if(file_pos > 0)
         {
             cnt += long_stride_length;
-            fseek(tng_data->input_file, (long)file_pos, SEEK_SET);
+            fseek(tng_data->input_file, file_pos, SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
                        file_pos, __FILE__, __LINE__);
                 tng_block_destroy(&block);
                 return(TNG_CRITICAL);
@@ -10908,25 +10949,25 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                 return(TNG_CRITICAL);
             }
         }
-        file_pos = frame_set->long_stride_next_frame_set_file_pos;
+        file_pos = (long)frame_set->long_stride_next_frame_set_file_pos;
     }
 
     /* Take medium steps forward until a medium step forward would be too long
      * or the last frame set is found */
-    file_pos = frame_set->medium_stride_next_frame_set_file_pos;
+    file_pos = (long)frame_set->medium_stride_next_frame_set_file_pos;
     while(file_pos > 0)
     {
         if(file_pos > 0)
         {
             cnt += medium_stride_length;
             fseek(tng_data->input_file,
-                  (long)file_pos,
+                  file_pos,
                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
                        file_pos, __FILE__, __LINE__);
                 tng_block_destroy(&block);
                 return(TNG_CRITICAL);
@@ -10939,24 +10980,24 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                 return(TNG_CRITICAL);
             }
         }
-        file_pos = frame_set->medium_stride_next_frame_set_file_pos;
+        file_pos = (long)frame_set->medium_stride_next_frame_set_file_pos;
     }
 
     /* Take one step forward until the last frame set is found */
-    file_pos = frame_set->next_frame_set_file_pos;
+    file_pos = (long)frame_set->next_frame_set_file_pos;
     while(file_pos > 0)
     {
         if(file_pos > 0)
         {
             ++cnt;
             fseek(tng_data->input_file,
-                  (long)file_pos,
+                  file_pos,
                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
                        file_pos, __FILE__, __LINE__);
                 tng_block_destroy(&block);
                 return(TNG_CRITICAL);
@@ -10969,7 +11010,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                 return(TNG_CRITICAL);
             }
         }
-        file_pos = frame_set->next_frame_set_file_pos;
+        file_pos = (long)frame_set->next_frame_set_file_pos;
     }
 
     tng_block_destroy(&block);
@@ -10988,7 +11029,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  tng_trajectory_frame_set_t *frame_set_p)
 {
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
@@ -12621,7 +12662,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  int64_t *frame)
 {
     long file_pos, next_frame_set_file_pos;
@@ -13096,7 +13137,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_name_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  int64_t block_id,
                  int *block_dependency)
 {
@@ -13170,7 +13211,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_data_block_num_values_per_frame_get
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  int64_t block_id,
                  int64_t *n_values_per_frame)
 {
@@ -15958,7 +15999,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
 }
 
 tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
-                (tng_trajectory_t tng_data,
+                (const tng_trajectory_t tng_data,
                  const int64_t block_id,
                  int64_t frame,
                  int64_t *stride_length)
@@ -18104,7 +18145,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_double_write
 tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
                 (tng_trajectory_t tng_data,
                  const int64_t block_id,
-                 char *codec_id,
+                 int64_t *codec_id,
                  float *factor)
 {
     tng_trajectory_frame_set_t frame_set;
@@ -18202,12 +18243,12 @@ tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
     if(block_type == TNG_PARTICLE_BLOCK_DATA)
     {
         *codec_id = p_data->codec_id;
-        *factor   = p_data->compression_multiplier;
+        *factor   = (float)p_data->compression_multiplier;
     }
     else if(block_type == TNG_NON_PARTICLE_BLOCK_DATA)
     {
         *codec_id = np_data->codec_id;
-        *factor   = np_data->compression_multiplier;
+        *factor   = (float)np_data->compression_multiplier;
     }
     return(TNG_SUCCESS);
 }
index f6101bee3ae9610aa91cc108b09577c706265d59..baceef75d1cd51fc05539d1dc6e7f1216897eca7 100644 (file)
@@ -1,6 +1,6 @@
 /* This code is part of the tng binary trajectory format.
  *
- *                      VERSION 1.4
+ *                      VERSION 1.5
  *
  * Written by Magnus Lundborg
  * Copyright (c) 2012-2013, The GROMACS development team.
index a0cfc46c17acd4b358c975f039d7506e9a1992ce..f465b6b7c00b607d8a2b226660f72e6e9328ab5a 100644 (file)
@@ -23,7 +23,10 @@ if(TNG_BUILD_TEST)
 endif()
 
 if(TNG_BUILD_EXAMPLES)
-    if(TNG_USE_OPENMP AND OPENMP_FOUND)
+    find_package(OpenMP)
+    if(OPENMP_FOUND)
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
 
         add_executable(md_openmp md_openmp.c)
         target_link_libraries(md_openmp tng_io ${OpenMP_LIBS})
index 449810de43ef61b4dada098f8431e1450d8cb6c5..b57eff41c8ba8bf5e5a818c180849e3cb5816822 100644 (file)
@@ -127,11 +127,7 @@ int main ()
         printf("  Cannot init trajectory.\n");
         exit(1);
     }
-#ifdef TNG_EXAMPLE_FILES_DIR
     tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_md_out.tng");
-#else
-    tng_output_file_set(traj, "/tmp/tng_md_out.tng");
-#endif
 
 
 
index de05ca27bb3f40efb7625cbc3c6d6f2b150ffead..87b00b8597644ec35ad71c7e4ebc3254905b8fc7 100644 (file)
@@ -161,7 +161,7 @@ c
 c
 c  N.B. The TNG output file should be modified according to needs
 c      
-      call tng_output_file_set(traj, "/tmp/tng_md_out_f77.tng")
+      call tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_md_out_f77.tng")
 
       write ( *, '(a)' ) '  Creating molecules in trajectory.'
       tng_n_particles = np
index 006d2921cced1e66bf11b70bbb2a4812d7d837c0..34b8964144e5a5412a55783a88d80fbc3b1f024a 100644 (file)
@@ -120,11 +120,7 @@ int main ()
     printf("\n");
     printf("  Initializing trajectory storage.\n");
     /* Initialize the TNG trajectory */
-#ifdef TNG_EXAMPLE_FILES_DIR
     tng_util_trajectory_open(TNG_EXAMPLE_FILES_DIR "tng_md_out.tng", 'w', &traj);
-#else
-    tng_util_trajectory_open("/tmp/tng_md_out.tng", 'w', &traj);
-#endif
 
 
 
index 8d8a68aa39664f3a16bd1bbd25b97f99755a9891..973ac4fb7b6268c0c5f2e9133f2133382fb9e7db 100644 (file)
@@ -474,11 +474,7 @@ static tng_function_status tng_test_write_and_read_traj(tng_trajectory_t *traj)
 
     tng_trajectory_destroy(traj);
     tng_trajectory_init(traj);
-#ifdef TNG_EXAMPLE_FILES_DIR
     tng_input_file_set(*traj, TNG_EXAMPLE_FILES_DIR "tng_test.tng");
-#else
-    tng_input_file_set(*traj, "/tmp/tng_test.tng");
-#endif
 
     stat = tng_file_headers_read(*traj, TNG_SKIP_HASH);
 
@@ -592,13 +588,8 @@ int main()
 
     printf("Creation time: %s\n", time_str);
 
-#ifdef TNG_EXAMPLE_FILES_DIR
     tng_input_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_example.tng");
     tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_example_out.tng");
-#else
-    tng_input_file_set(traj, "tng_example.tng");
-    tng_output_file_set(traj, "/tmp/tng_example_out.tng");
-#endif
 
 
     if(tng_test_read_and_write_file(traj) == TNG_CRITICAL)
@@ -633,11 +624,7 @@ int main()
     }
 
 
-#ifdef TNG_EXAMPLE_FILES_DIR
     tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_test.tng");
-#else
-    tng_output_file_set(traj, "/tmp/tng_test.tng");
-#endif
 
     if(tng_test_write_and_read_traj(&traj) == TNG_CRITICAL)
     {
@@ -671,11 +658,8 @@ int main()
     }
 
 
-#ifdef TNG_EXAMPLE_FILES_DIR
     stat = tng_util_trajectory_open(TNG_EXAMPLE_FILES_DIR "tng_test.tng", 'r', &traj);
-#else
-    stat = tng_util_trajectory_open("/tmp/tng_test.tng", 'r', &traj);
-#endif
+
     if(stat != TNG_SUCCESS)
     {
         printf("Test Utility function open:\t\t\tFailed. %s: %d.\n",
index 9d74bcd7e0d0cf8c783f87d8903aa1cdf21b439c..04ac5169d6ea31292ee97650aa5671e1f5d0f675 100644 (file)
@@ -421,8 +421,8 @@ gmx_bool gmx_read_next_tng_frame(tng_trajectory_t            input,
     gmx_bool                bOK = TRUE;
     tng_function_status     stat;
     gmx_int64_t             numberOfAtoms = -1, frameNumber = -1;
-    gmx_int64_t             nBlocks, blockId, *blockIds = NULL;
-    char                    datatype      = -1, codecId;
+    gmx_int64_t             nBlocks, blockId, *blockIds = NULL, codecId;
+    char                    datatype      = -1;
     void                   *values        = NULL;
     double                  frameTime     = -1.0;
     int                     size, blockDependency;
@@ -773,7 +773,8 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(tng_trajectory_t     input,
 {
 #ifdef GMX_USE_TNG
     tng_function_status stat;
-    char                datatype = -1, codecId;
+    char                datatype = -1;
+    gmx_int64_t         codecId;
     int                 blockDependency;
     void               *data = 0;
     float               localPrec;