commit c5134eb8f447fe28e60a40ec029ca565e26059ea
parent 51854d4ab04f1b5a102ad1423a91293694c4bc9b
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 Feb 2026 17:51:18 +0100
Check that a mixture molecule has its isotope metadata
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/sln_mixture.c b/src/sln_mixture.c
@@ -146,6 +146,18 @@ parse_molecule_name
}
static INLINE int
+molecule_has_metadata
+ (const enum shtr_molecule_id id,
+ struct shtr_isotope_metadata* molparam)
+{
+ struct shtr_molecule shtr_molecule = SHTR_MOLECULE_NULL;
+ ASSERT(molparam);
+
+ SHTR(isotope_metadata_find_molecule(molparam, id, &shtr_molecule));
+ return !SHTR_MOLECULE_IS_NULL(&shtr_molecule);
+}
+
+static INLINE int
molecule_already_defined
(struct sln_mixture* mixture,
const enum shtr_molecule_id id)
@@ -194,6 +206,11 @@ parse_molecule
LOG(ERROR, "duplicate molecule`%s'\n", tk);
goto error;
}
+ if(!molecule_has_metadata(molecule->id, args->molparam)) {
+ LOG(ERROR, "`%s' does not have isotope metadata\n", tk);
+ res = RES_BAD_ARG;
+ goto error;
+ }
tk = strtok_r(NULL, " \t", &tk_ctx);
res = cstr_to_double(tk, &molecule->param.concentration);