commit fb842f8643ca187a6f5c8ae6f8c9ed0dbaeaf7a5
parent 24ee1cbd5594af39bb006609b29a71dab84da4a1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 26 Jan 2026 14:32:47 +0100
Add the shtr_molecule_id enumeration
It defines the symbolic constants of molecules, whose values are those
of the HITRAN database. This makes the source code easier to read by
identifying the name of the molecule rather than just its integer value,
which is nevertheless retained as the value of the constant.
Diffstat:
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/shtr.h b/src/shtr.h
@@ -42,8 +42,25 @@
#define SHTR(Func) shtr_ ## Func
#endif
-#define SHTR_MAX_MOLECULES_COUNT 100
-#define SHTR_MAX_ISOTOPES_COUNT 10
+/* List of HITRAN species. They are classified as in the HITRAN database ,i.e.
+ * their value corresponds to that of HITRAN. Note that they start at 1 rather
+ * than zero and therefore do not strictly correspond to a C array index */
+enum shtr_molecule_id {
+ SHTR_MOLECULE_ID_NULL__ = 0,
+
+ SHTR_H2O, SHTR_CO2, SHTR_O3, SHTR_N2O, SHTR_CO, SHTR_CH4,
+ SHTR_O2, SHTR_NO, SHTR_SO2, SHTR_NO2, SHTR_NH3, SHTR_HNO3,
+ SHTR_OH, SHTR_HF, SHTR_HCl, SHTR_HBr, SHTR_HI, SHTR_ClO,
+ SHTR_OCS, SHTR_H2CO, SHTR_HOCl, SHTR_N2, SHTR_HCN, SHTR_CH3Cl,
+ SHTR_H2O2, SHTR_C2H2, SHTR_C2H6, SHTR_PH3, SHTR_COF2, SHTR_SF6,
+ SHTR_H2S, SHTR_HCOOH, SHTR_HO2, SHTR_O, SHTR_ClONO2, SHTR_NOplus,
+ SHTR_HOBr, SHTR_C2H4, SHTR_CH3OH, SHTR_CH3Br, SHTR_CH3CN, SHTR_CF4,
+ SHTR_C4H2, SHTR_HC3N, SHTR_H2, SHTR_CS, SHTR_SO3, SHTR_C2N2,
+ SHTR_COCl2, SHTR_SO, SHTR_CH3F, SHTR_GeH4, SHTR_CS2, SHTR_CH3I,
+ SHTR_NF3,
+
+ SHTR_MAX_MOLECULES_COUNT = SHTR_NF3
+};
struct shtr_isotope {
double abundance; /* in ]0, 1] */
@@ -64,9 +81,9 @@ struct shtr_molecule {
const char* name;
size_t nisotopes; /* Number of isotopes */
const struct shtr_isotope* isotopes;
- int id; /* Unique identifier */
+ enum shtr_molecule_id id; /* Unique identifier */
};
-#define SHTR_MOLECULE_NULL__ {NULL, 0, NULL, -1}
+#define SHTR_MOLECULE_NULL__ {NULL, 0, NULL, SHTR_MOLECULE_ID_NULL__}
static const struct shtr_molecule SHTR_MOLECULE_NULL =
SHTR_MOLECULE_NULL__;