Update to TNG v 1.8.1
authorMagnus Lundborg <lundborg.magnus@gmail.com>
Mon, 23 Oct 2017 11:20:00 +0000 (13:20 +0200)
committerErik Lindahl <erik.lindahl@gmail.com>
Wed, 8 Nov 2017 17:05:47 +0000 (18:05 +0100)
Fixes #2187 and #2250.

Change-Id: Icf81d5f3ce916e984750e1511d32e16ebc45b6f9

src/external/tng_io/BuildTNG.cmake
src/external/tng_io/src/lib/tng_io.c

index 30d8b1935934bd8c9419a463b4ff4c29215fc96f..0b70c4d99f2629ec90d0738e7894de96d4f934f1 100644 (file)
@@ -5,11 +5,12 @@ if ("${TNG_ROOT_BINARY_DIR}" MATCHES "^\.\.")
 endif()
 set(TNG_ROOT_BINARY_DIR ${CMAKE_BINARY_DIR}/${TNG_ROOT_BINARY_DIR})
 
+set(TNG_MAJOR_VERSION "1")
+set(TNG_MINOR_VERSION "8")
+set(TNG_VERSION_PATCH_LEVEL "1")
+set(TNG_IO_VERSION "${TNG_MAJOR_VERSION}.${TNG_MINOR_VERSION}.${TNG_VERSION_PATCH_LEVEL}")
+
 function (TNG_GENERATE_VERSION_H)
-    set(TNG_MAJOR_VERSION "1")
-    set(TNG_MINOR_VERSION "8")
-    set(TNG_VERSION_PATCH_LEVEL "0")
-    set(TNG_IO_VERSION "${TNG_MAJOR_VERSION}.${TNG_MINOR_VERSION}.${TNG_VERSION_PATCH_LEVEL}")
     set(TNG_API_VERSION "8")
     configure_file(${TNG_ROOT_SOURCE_DIR}/include/tng/version.h.in
                    ${TNG_ROOT_BINARY_DIR}/include/tng/version.h)
index d5e14a64804d06ae299fa679b99a31d3fdda884f..207b1a2c5a19803ee6c03734190cda7c61f9b098 100644 (file)
@@ -6838,6 +6838,36 @@ static tng_function_status tng_molecule_chains_residue_pointers_update
     return(TNG_SUCCESS);
 }
 
+/**
+ * @brief Update atoms->residue pointers (after new memory for
+ * molecule->residues has been allocated).
+ * @param tng_data The trajectory container containing the molecule.
+ * @param mol The molecule that contains the chains that need to be
+ * updated.
+ * @returns TNG_SUCCESS (0) if successful.
+ */
+static tng_function_status tng_molecule_atoms_residue_pointers_update
+                (const tng_trajectory_t tng_data,
+                 const tng_molecule_t mol)
+{
+    tng_atom_t atom;
+    tng_residue_t residue;
+    int64_t i, j, atom_offset = 0;
+    (void)tng_data;
+
+    for(i = 0; i < mol->n_residues; i++)
+    {
+        residue = &mol->residues[i];
+        for(j = 0; j < residue->n_atoms; j++)
+        {
+            atom = &mol->atoms[j + atom_offset];
+            atom->residue = residue;
+        }
+        atom_offset += residue->n_atoms;
+    }
+    return(TNG_SUCCESS);
+}
+
 tng_function_status DECLSPECDLLEXPORT tng_version_major
                 (const tng_trajectory_t tng_data,
                  int *version)
@@ -7810,6 +7840,7 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_residue_w_id_add
     *residue = &molecule->residues[curr_index + chain->n_residues];
 
     tng_molecule_chains_residue_pointers_update(tng_data, molecule);
+    tng_molecule_atoms_residue_pointers_update(tng_data, molecule);
 
     (*residue)->name = 0;
     tng_residue_name_set(tng_data, *residue, name);