star-hitran

Load line-by-line data from the HITRAN database
git clone git://git.meso-star.fr/star-hitran.git
Log | Files | Refs | README | LICENSE

commit d1fa1ee8839cdbd02b3f3a44323e620fcd076259
parent 9c25a62b22d91ea4d897d8b2327df0827cae3d47
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 10 Feb 2022 10:58:12 +0100

Add and test shitran_isotope_metadata_get_isotopes_count

This function returns the overall number of loaded isotopes.

Diffstat:
Msrc/shitran.h | 5+++++
Msrc/shitran_isotope_metadata.c | 9+++++++++
Msrc/test_shitran_isotope_metadata.c | 6++++++
3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/shitran.h b/src/shitran.h @@ -128,6 +128,11 @@ shitran_isotope_metadata_get_molecules_count size_t* nmolecules); SHITRAN_API res_T +shitran_isotope_metadata_get_isotopes_count + (const struct shitran_isotope_metadata* metadata, + size_t* nisotopes); + +SHITRAN_API res_T shitran_isotope_metadata_get_molecule (const struct shitran_isotope_metadata* metadata, const size_t imolecule, /* Index of the molecule in [0, molecules_count[ */ diff --git a/src/shitran_isotope_metadata.c b/src/shitran_isotope_metadata.c @@ -628,7 +628,16 @@ shitran_isotope_metadata_get_molecules_count if(!metadata || !nmolecules) return RES_BAD_ARG; *nmolecules = darray_molecule_size_get(&metadata->molecules); return RES_OK; +} +res_T +shitran_isotope_metadata_get_isotopes_count + (const struct shitran_isotope_metadata* metadata, + size_t* nisotopes) +{ + if(!metadata || !nisotopes) return RES_BAD_ARG; + *nisotopes = darray_isotope_size_get(&metadata->isotopes); + return RES_OK; } res_T diff --git a/src/test_shitran_isotope_metadata.c b/src/test_shitran_isotope_metadata.c @@ -120,6 +120,7 @@ test_load(struct shitran* shitran) struct shitran_isotope_metadata* mdata = NULL; FILE* fp = NULL; size_t nmolecules = 0; + size_t nisotopes = 0; CHK(fp = fopen(filename, "w+")); @@ -138,6 +139,11 @@ test_load(struct shitran* shitran) CHK(shitran_isotope_metadata_get_molecules_count(mdata, &nmolecules) == RES_OK); CHK(nmolecules == 2); + CHK(shitran_isotope_metadata_get_isotopes_count(NULL, &nisotopes) == RES_BAD_ARG); + CHK(shitran_isotope_metadata_get_isotopes_count(mdata, NULL) == RES_BAD_ARG); + CHK(shitran_isotope_metadata_get_isotopes_count(mdata, &nisotopes) == RES_OK); + CHK(nisotopes == H2O.nisotopes + CO2.nisotopes); + CHK(shitran_isotope_metadata_get_molecule(NULL, 0, &molecule) == RES_BAD_ARG); CHK(shitran_isotope_metadata_get_molecule(mdata, 2, &molecule) == RES_BAD_ARG);