diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-08-22 08:49:28 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-08-22 08:49:28 (GMT) |
commit | d6d0a37df4e39b5258569545da1e70c0fbc664c3 (patch) | |
tree | 9aeff16446747e13afc2631f60face3ccc06b742 /src | |
parent | beb5670008b09d73e37ab25e17e036ac62f31621 (diff) |
Added tng_molecule_find for finding a molecule
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/tng_io.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 805e7eb..e3a50f6 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -6951,6 +6951,33 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set return(TNG_SUCCESS); } +tng_function_status DECLSPECDLLEXPORT tng_molecule_find + (tng_trajectory_t tng_data, + const char *name, + int64_t nr, + tng_molecule_t *molecule) +{ + int i, n_molecules; + + n_molecules = tng_data->n_molecules; + + for(i = 0; i < n_molecules; i++) + { + *molecule = &tng_data->molecules[i]; + if(name[0] != 0 || strcmp(name, (*molecule)->name) == 0) + { + if(nr == -1 || nr == (*molecule)->id) + { + return(TNG_SUCCESS); + } + } + } + + *molecule = 0; + + return(TNG_FAILURE); +} + tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find (tng_trajectory_t tng_data, tng_molecule_t molecule, |