commit 91ae69195f56c69d1dcd20143e3767b470dcbbd5
parent 329b711edc8f5d8651cd18a0f04641b5b26cc552
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 23 May 2022 14:57:59 +0200
Fix compilation due to Star-HITRAN API updates
Diffstat:
9 files changed, 66 insertions(+), 49 deletions(-)
diff --git a/src/sln.h b/src/sln.h
@@ -50,7 +50,7 @@ struct logger;
struct mem_allocator;
struct shtr_line;
struct shtr_isotope_metadata;
-struct shtr_lines_list;
+struct shtr_line_list;
enum sln_line_profile {
SLN_LINE_PROFILE_VOIGT,
@@ -90,7 +90,7 @@ static const struct sln_molecule SLN_MOLECULE_NULL = SLN_MOLECULE_NULL__;
struct sln_mixture_create_args {
/* Isotope metadata and overall list of spectral lines */
struct shtr_isotope_metadata* metadata;
- struct shtr_lines_list* lines;
+ struct shtr_line_list* lines;
/* List of molecules to be taken into account with its associated
* concentration and cutoff */
@@ -254,6 +254,11 @@ sln_node_get_mesh
const struct sln_node* node,
struct sln_mesh* mesh);
+SLN_API res_T
+sln_tree_write
+ (const struct sln_tree* tree,
+ FILE* stream);
+
/*******************************************************************************
* Helper functions
******************************************************************************/
diff --git a/src/sln_line.c b/src/sln_line.c
@@ -252,7 +252,7 @@ eval_mesh
res = darray_double_resize(values, nvertices);
if(res != RES_OK) goto error;
- SHTR(lines_view_get_line(mixture->lines_view, iline, &shtr_line));
+ SHTR(line_view_get_line(mixture->line_view, iline, &shtr_line));
/* Calculate the spectral range in which the vertices should be evaluated.
* Recall that a line being symmetrical in its center, we will only evaluate
@@ -407,7 +407,7 @@ line_setup(struct sln_mixture* mixture, const size_t iline)
line = darray_line_data_get(&mixture->lines) + iline;
- SHTR(lines_view_get_line(mixture->lines_view, iline, &shtr_line));
+ SHTR(line_view_get_line(mixture->line_view, iline, &shtr_line));
SHTR(isotope_metadata_find_molecule
(mixture->metadata, shtr_line->molecule_id, &molecule));
ASSERT(!SHTR_MOLECULE_IS_NULL(&molecule));
@@ -445,7 +445,7 @@ line_value
ASSERT(mixture && iline < darray_line_size_get(&mixture->lines));
/* Retrieve the molecular parameters of the line to be mesh */
- SHTR(lines_view_get_line(mixture->lines_view, iline, &shtr_line));
+ SHTR(line_view_get_line(mixture->line_view, iline, &shtr_line));
mol_params = mixture_get_molecule_params(mixture, shtr_line->molecule_id);
line = darray_line_cdata_get(&mixture->lines) + iline;
@@ -478,7 +478,7 @@ line_mesh
ASSERT(iline < darray_line_size_get(&tree->mixture->lines));
line = darray_line_cdata_get(&tree->mixture->lines) + iline;
- SHTR(lines_view_get_line(tree->mixture->lines_view, iline, &shtr_line));
+ SHTR(line_view_get_line(tree->mixture->line_view, iline, &shtr_line));
darray_double_init(tree->mixture->sln->allocator, &values);
darray_double_init(tree->mixture->sln->allocator, &wavenumbers);
diff --git a/src/sln_mixture.c b/src/sln_mixture.c
@@ -192,13 +192,13 @@ check_sln_mixture_create_args
}
static res_T
-create_lines_view
+create_line_view
(struct sln_device* sln,
const struct sln_mixture_create_args* mixture_args,
- struct shtr_lines_view** out_view)
+ struct shtr_line_view** out_view)
{
- struct shtr_lines_view_create_args view_args = SHTR_LINES_VIEW_CREATE_ARGS_NULL;
- struct shtr_lines_view* view = NULL;
+ struct shtr_line_view_create_args view_args = SHTR_LINE_VIEW_CREATE_ARGS_NULL;
+ struct shtr_line_view* view = NULL;
size_t imol, iiso;
res_T res = RES_OK;
(void)sln;
@@ -222,14 +222,14 @@ create_lines_view
}
}
- res = shtr_lines_view_create(mixture_args->lines, &view_args, &view);
+ res = shtr_line_view_create(mixture_args->lines, &view_args, &view);
if(res != RES_OK) goto error;
exit:
*out_view = view;
return res;
error:
- if(view) { SHTR(lines_view_ref_put(view)); view = NULL; }
+ if(view) { SHTR(line_view_ref_put(view)); view = NULL; }
goto exit;
}
@@ -304,7 +304,7 @@ setup_lines(struct sln_mixture* mixture, const char* caller)
res_T res = RES_OK;
ASSERT(mixture && caller);
- SHTR(lines_view_get_size(mixture->lines_view, &nlines));
+ SHTR(line_view_get_size(mixture->line_view, &nlines));
res = darray_line_resize(&mixture->lines, nlines);
if(res != RES_OK) {
@@ -335,7 +335,7 @@ release_mixture(ref_T* ref)
ASSERT(ref);
sln = mixture->sln;
if(mixture->metadata) SHTR(isotope_metadata_ref_put(mixture->metadata));
- if(mixture->lines_view) SHTR(lines_view_ref_put(mixture->lines_view));
+ if(mixture->line_view) SHTR(line_view_ref_put(mixture->line_view));
darray_line_release(&mixture->lines);
MEM_RM(sln->allocator, mixture);
SLN(device_ref_put(sln));
@@ -370,7 +370,7 @@ sln_mixture_create
darray_line_init(sln->allocator, &mixture->lines);
#define CALL(Func) { if(RES_OK != (res = Func)) goto error; } (void)0
- CALL(create_lines_view(sln, args, &mixture->lines_view));
+ CALL(create_line_view(sln, args, &mixture->line_view));
CALL(setup_molecule_params(sln, args, mixture->molecules_params));
CALL(store_input_args(sln, args, mixture));
CALL(setup_lines(mixture, FUNC_NAME));
diff --git a/src/sln_mixture_c.h b/src/sln_mixture_c.h
@@ -26,7 +26,7 @@
#include <rsys/ref_count.h>
struct sln_device;
-struct shtr_lines_view;
+struct shtr_line_view;
/* Generate the dynamic array of lines */
#define DARRAY_DATA struct line
@@ -47,7 +47,7 @@ struct sln_mixture {
struct molecule_params molecules_params[SLN_MAX_MOLECULES_COUNT];
struct shtr_isotope_metadata* metadata;
- struct shtr_lines_view* lines_view; /* Set of lines */
+ struct shtr_line_view* line_view; /* Set of lines */
/* Store per line precomputed data */
struct darray_line lines;
diff --git a/src/sln_tree.c b/src/sln_tree.c
@@ -202,8 +202,8 @@ sln_node_get_line
if(!tree || !node || iline > sln_node_get_lines_count(node))
return RES_BAD_ARG;
- return shtr_lines_view_get_line
- (tree->mixture->lines_view, node->range[0] + iline, line);
+ return shtr_line_view_get_line
+ (tree->mixture->line_view, node->range[0] + iline, line);
}
res_T
@@ -217,3 +217,9 @@ sln_node_get_mesh
mesh->nvertices = node->nvertices;
return RES_OK;
}
+
+res_T
+sln_tree_write(const struct sln_tree* tree, FILE* stream)
+{
+}
+
diff --git a/src/sln_tree_build.c b/src/sln_tree_build.c
@@ -256,7 +256,7 @@ partition_lines
res_T res = RES_OK;
ASSERT(tree && args);
- SHTR(lines_view_get_size(tree->mixture->lines_view, &nlines));
+ SHTR(line_view_get_size(tree->mixture->line_view, &nlines));
#define NODE(Id) (darray_node_data_get(&tree->nodes) + (Id))
#define CREATE_NODE { \
diff --git a/src/sln_tree_c.h b/src/sln_tree_c.h
@@ -25,9 +25,15 @@
#include <rsys/dynamic_array.h>
#include <rsys/ref_count.h>
+/* Current version of the serialized tree data. One should increment it and
+ * perform a version management onto serialized data when these data are
+ * updated. */
+static const int SLN_TREE_VERSION = 0;
+
+/* Forward declaration */
struct sln_mixture;
struct sln_tree_create_args;
-struct shtr_lines_view;
+struct shtr_line_view;
struct sln_node { /* 32 Bytes */
/* Range of the line indices corresponding to the node */
diff --git a/src/test_sln_mixture.c b/src/test_sln_mixture.c
@@ -30,7 +30,7 @@ static void
test_mixture
(struct sln_device* sln,
struct shtr_isotope_metadata* metadata,
- struct shtr_lines_list* lines_list)
+ struct shtr_line_list* line_list)
{
struct sln_mixture_create_args mixture_args = SLN_MIXTURE_CREATE_ARGS_DEFAULT;
struct sln_mixture_desc desc = SLN_MIXTURE_DESC_NULL;
@@ -38,7 +38,7 @@ test_mixture
size_t nlines = 0;
mixture_args.metadata = metadata;
- mixture_args.lines = lines_list;
+ mixture_args.lines = line_list;
mixture_args.molecules[0].nisotopes = 0; /* Handle all isotopes */
mixture_args.molecules[0].concentration = 1.0/3.0;
mixture_args.molecules[0].cutoff = 25;
@@ -65,7 +65,7 @@ test_mixture
CHK(sln_mixture_get_desc(mixture, NULL) == RES_BAD_ARG);
CHK(sln_mixture_get_desc(mixture, &desc) == RES_OK);
- CHK(shtr_lines_list_get_size(lines_list, &nlines) == RES_OK);
+ CHK(shtr_line_list_get_size(line_list, &nlines) == RES_OK);
CHK(desc.wavenumber_range[0] == mixture_args.wavenumber_range[0]);
CHK(desc.wavenumber_range[1] == mixture_args.wavenumber_range[1]);
@@ -90,7 +90,7 @@ test_mixture
mixture_args.lines = NULL;
CHK(sln_mixture_create(sln, &mixture_args, &mixture) == RES_BAD_ARG);
- mixture_args.lines = lines_list;
+ mixture_args.lines = line_list;
mixture_args.molecules[0].concentration = 1;
CHK(sln_mixture_create(sln, &mixture_args, &mixture) == RES_BAD_ARG);
@@ -140,7 +140,7 @@ main(int argc, char** argv)
struct shtr_create_args shtr_args = SHTR_CREATE_ARGS_DEFAULT;
struct shtr* shtr = NULL;
- struct shtr_lines_list* lines_list = NULL;
+ struct shtr_line_list* line_list = NULL;
struct shtr_isotope_metadata* metadata = NULL;
FILE* fp_lines = NULL;
@@ -164,7 +164,7 @@ main(int argc, char** argv)
shtr_args.verbose = 1;
CHK(shtr_create(&shtr_args, &shtr) == RES_OK);
CHK(shtr_isotope_metadata_load_stream(shtr, fp_mdata, NULL, &metadata) == RES_OK);
- CHK(shtr_lines_list_load_stream(shtr, fp_lines, NULL, &lines_list) == RES_OK);
+ CHK(shtr_line_list_load_stream(shtr, fp_lines, NULL, &line_list) == RES_OK);
CHK(fclose(fp_lines) == 0);
CHK(fclose(fp_mdata) == 0);
@@ -172,11 +172,11 @@ main(int argc, char** argv)
dev_args.verbose = 1;
CHK(sln_device_create(&dev_args, &sln) == RES_OK);
- test_mixture(sln, metadata, lines_list);
+ test_mixture(sln, metadata, line_list);
CHK(sln_device_ref_put(sln) == RES_OK);
CHK(shtr_ref_put(shtr) == RES_OK);
- CHK(shtr_lines_list_ref_put(lines_list) == RES_OK);
+ CHK(shtr_line_list_ref_put(line_list) == RES_OK);
CHK(shtr_isotope_metadata_ref_put(metadata) == RES_OK);
CHK(mem_allocated_size() == 0);
return 0;
diff --git a/src/test_sln_tree.c b/src/test_sln_tree.c
@@ -39,19 +39,19 @@ cmp_line(const void* key, const void* item)
else return 0;
}
-/* Return the index of the line in the lines_list or SIZE_MAX if the line does
+/* Return the index of the line in the line_list or SIZE_MAX if the line does
* not exist */
static INLINE size_t
find_line
- (const struct shtr_lines_list* lines_list,
+ (const struct shtr_line_list* line_list,
const struct shtr_line* line)
{
const struct shtr_line* list = NULL;
const struct shtr_line* found = NULL;
size_t iline, nlines;
- CHK(shtr_lines_list_get(lines_list, &list) == RES_OK);
- CHK(shtr_lines_list_get_size(lines_list, &nlines) == RES_OK);
+ CHK(shtr_line_list_get(line_list, &list) == RES_OK);
+ CHK(shtr_line_list_get_size(line_list, &nlines) == RES_OK);
/* Dichotomous search wrt the wavenumber of lines */
found = search_lower_bound
@@ -80,7 +80,7 @@ find_line
static void
check_tree
(const struct sln_tree* tree,
- const struct shtr_lines_list* lines_list)
+ const struct shtr_line_list* line_list)
{
#define STACK_SIZE 64
const struct shtr_line* list = NULL;
@@ -91,12 +91,12 @@ check_tree
char* found_lines = NULL;
size_t found_nlines = 0;
- size_t lines_list_sz;
+ size_t line_list_sz;
- CHK(shtr_lines_list_get_size(lines_list, &lines_list_sz) == RES_OK);
- CHK(shtr_lines_list_get(lines_list, &list) == RES_OK);
+ CHK(shtr_line_list_get_size(line_list, &line_list_sz) == RES_OK);
+ CHK(shtr_line_list_get(line_list, &list) == RES_OK);
- CHK(found_lines = mem_calloc(lines_list_sz, sizeof(char)));
+ CHK(found_lines = mem_calloc(line_list_sz, sizeof(char)));
CHK(sln_tree_get_desc(tree, &desc) == RES_OK);
@@ -118,7 +118,7 @@ check_tree
const struct shtr_line* line = NULL;
size_t found_iline = 0;
CHK(sln_node_get_line(tree, node, iline, &line) == RES_OK);
- found_iline = find_line(lines_list, line);
+ found_iline = find_line(line_list, line);
CHK(found_iline != SIZE_MAX); /* Line is found */
if(!found_lines[found_iline]) {
@@ -132,7 +132,7 @@ check_tree
}
/* Check that all lines are found */
- CHK(found_nlines == lines_list_sz);
+ CHK(found_nlines == line_list_sz);
mem_rm(found_lines);
#undef STACK_SIZE
@@ -151,7 +151,7 @@ dump_line(FILE* stream, const struct sln_mesh* mesh)
}
static void
-test_tree(struct sln_mixture* mixture, const struct shtr_lines_list* lines_list)
+test_tree(struct sln_mixture* mixture, const struct shtr_line_list* line_list)
{
struct sln_tree_create_args tree_args = SLN_TREE_CREATE_ARGS_DEFAULT;
struct sln_tree_desc desc = SLN_TREE_DESC_NULL;
@@ -161,14 +161,14 @@ test_tree(struct sln_mixture* mixture, const struct shtr_lines_list* lines_list)
const struct shtr_line* line = NULL;
size_t nlines = 0;
- CHK(mixture && lines_list);
+ CHK(mixture && line_list);
CHK(sln_tree_create(NULL, &tree_args, &tree) == RES_BAD_ARG);
CHK(sln_tree_create(mixture, NULL, &tree) == RES_BAD_ARG);
CHK(sln_tree_create(mixture, &tree_args, NULL) == RES_BAD_ARG);
CHK(sln_tree_create(mixture, &tree_args, &tree) == RES_OK);
- CHK(shtr_lines_list_get_size(lines_list, &nlines) == RES_OK);
+ CHK(shtr_line_list_get_size(line_list, &nlines) == RES_OK);
CHK(sln_tree_get_desc(NULL, &desc) == RES_BAD_ARG);
CHK(sln_tree_get_desc(tree, NULL) == RES_BAD_ARG);
@@ -200,7 +200,7 @@ test_tree(struct sln_mixture* mixture, const struct shtr_lines_list* lines_list)
CHK(sln_node_get_mesh(tree, node, &mesh) == RES_OK);
dump_line(stdout, &mesh);
- check_tree(tree, lines_list);
+ check_tree(tree, line_list);
CHK(sln_tree_ref_get(NULL) == RES_BAD_ARG);
CHK(sln_tree_ref_get(tree) == RES_OK);
@@ -237,7 +237,7 @@ main(int argc, char** argv)
struct shtr_create_args shtr_args = SHTR_CREATE_ARGS_DEFAULT;
struct shtr* shtr = NULL;
- struct shtr_lines_list* lines_list = NULL;
+ struct shtr_line_list* line_list = NULL;
struct shtr_isotope_metadata* metadata = NULL;
FILE* fp_lines = NULL;
@@ -261,7 +261,7 @@ main(int argc, char** argv)
shtr_args.verbose = 1;
CHK(shtr_create(&shtr_args, &shtr) == RES_OK);
CHK(shtr_isotope_metadata_load_stream(shtr, fp_mdata, NULL, &metadata) == RES_OK);
- CHK(shtr_lines_list_load_stream(shtr, fp_lines, NULL, &lines_list) == RES_OK);
+ CHK(shtr_line_list_load_stream(shtr, fp_lines, NULL, &line_list) == RES_OK);
CHK(fclose(fp_lines) == 0);
CHK(fclose(fp_mdata) == 0);
@@ -271,7 +271,7 @@ main(int argc, char** argv)
/* Create the mixture */
mixture_args.metadata = metadata;
- mixture_args.lines = lines_list;
+ mixture_args.lines = line_list;
mixture_args.molecules[0].nisotopes = 0; /* Handle all isotopes */
mixture_args.molecules[0].concentration = 1.0/3.0;
mixture_args.molecules[0].cutoff = 25;
@@ -291,12 +291,12 @@ main(int argc, char** argv)
mixture_args.temperature = 296;
CHK(sln_mixture_create(sln, &mixture_args, &mixture) == RES_OK);
- test_tree(mixture, lines_list);
+ test_tree(mixture, line_list);
CHK(sln_device_ref_put(sln) == RES_OK);
CHK(sln_mixture_ref_put(mixture) == RES_OK);
CHK(shtr_ref_put(shtr) == RES_OK);
- CHK(shtr_lines_list_ref_put(lines_list) == RES_OK);
+ CHK(shtr_line_list_ref_put(line_list) == RES_OK);
CHK(shtr_isotope_metadata_ref_put(metadata) == RES_OK);
CHK(mem_allocated_size() == 0);
return 0;