summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tng_io.h5
-rw-r--r--src/lib/tng_io.c16
2 files changed, 16 insertions, 5 deletions
diff --git a/include/tng_io.h b/include/tng_io.h
index 660ddfc..3c20240 100644
--- a/include/tng_io.h
+++ b/include/tng_io.h
@@ -1442,7 +1442,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_w_id_add
/**
* @brief Add an existing molecule (from a molecule container) to the trajectory.
* @param tng_data is the trajectory data container containing the block..
- * @param molecule is the molecule to add to the trajectory.
+ * @param molecule is a pointer to the molecule to add to the trajectory and will
+ * afterwards point to the molecule in the trajectory.
* @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
* must be initialised before using it.
* @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major error
@@ -1450,7 +1451,7 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_w_id_add
*/
tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
(tng_trajectory_t tng_data,
- tng_molecule_t molecule);
+ tng_molecule_t *molecule);
/**
* @brief Set the name of a molecule.
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index f00810c..d224679 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -7069,10 +7069,10 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_w_id_add
tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
(tng_trajectory_t tng_data,
- tng_molecule_t molecule)
+ tng_molecule_t *molecule_p)
{
tng_bool found_id = TNG_TRUE;
- tng_molecule_t new_molecules;
+ tng_molecule_t new_molecules, molecule;
int64_t *new_molecule_cnt_list, i, id;
TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
@@ -7125,6 +7125,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
return(TNG_CRITICAL);
}
+ molecule = *molecule_p;
+
tng_data->molecules = new_molecules;
tng_data->molecule_cnt_list = new_molecule_cnt_list;
@@ -7132,6 +7134,12 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add
tng_data->molecule_cnt_list[tng_data->n_molecules] = 0;
+ free(*molecule_p);
+
+ molecule = &new_molecules[tng_data->n_molecules];
+
+ *molecule_p = molecule;
+
molecule->id = id;
tng_data->n_molecules++;
@@ -7221,6 +7229,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set
}
if(index == -1)
{
+ printf("TNG library: Could not find molecule in TNG trajectory. %s: %d\n",
+ __FILE__, __LINE__);
return(TNG_FAILURE);
}
old_cnt = tng_data->molecule_cnt_list[index];
@@ -7736,7 +7746,7 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_atom_w_id_add
if(molecule->atoms[i].id == id)
{
stat = TNG_FAILURE;
- printf("TNG library: Atom ID already in use. %s: %d\n", __FILE__, __LINE__);
+ printf("TNG library: Atom ID %"PRId64" already in use. %s: %d\n", id, __FILE__, __LINE__);
break;
}
}
contact: Jan Huwald // Impressum