YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
test_param_utils.c
Go to the documentation of this file.
1// Copyright (c) 2026 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5
6
7#include <mpi.h>
8#include <stdlib.h>
9#include <string.h>
10
11#include "parameter/param.h"
14#include "parameter/param_int.h"
16#include "parameter/param_str.h"
19#include "tests.h"
20
29static void utest_scalar_int_roundtrip(MPI_Comm comm);
30static void utest_scalar_dble_roundtrip(MPI_Comm comm);
31static void utest_scalar_str_roundtrip(MPI_Comm comm);
32static void utest_struct_roundtrip(MPI_Comm comm);
33static void utest_list_roundtrip(MPI_Comm comm);
34static void utest_empty_list_roundtrip(MPI_Comm comm);
35
36static int utest_list_default_factory(
37 void ** element_ptr, struct yac_param ** param_ptr) {
38
39 int * value = malloc(sizeof(*value));
40 if (value == NULL) return 1;
41 *value = 0;
42
43 *element_ptr = value;
44 *param_ptr = yac_param_int_new("list_elem", value, 0, -1000, 1000, 1, 1);
45
46 return (*param_ptr == NULL);
47}
48
49static void utest_free_int_list(void ** list) {
50
51 if (list == NULL) return;
52 for (size_t i = 0; list[i] != NULL; ++i) free(list[i]);
53 free(list);
54}
55
56int main(void) {
57
58 // Run all checks with a single local rank.
59 MPI_Init(NULL, NULL);
60
61 utest_scalar_int_roundtrip(MPI_COMM_SELF);
62 utest_scalar_dble_roundtrip(MPI_COMM_SELF);
63 utest_scalar_str_roundtrip(MPI_COMM_SELF);
64 utest_struct_roundtrip(MPI_COMM_SELF);
65 utest_list_roundtrip(MPI_COMM_SELF);
66 utest_empty_list_roundtrip(MPI_COMM_SELF);
67
68 MPI_Finalize();
69
70 return TEST_EXIT_CODE;
71}
72
73static void utest_scalar_int_roundtrip(MPI_Comm comm) {
74
75 { // Test pack/unpack of a single int parameter with default value in defined
76 // state
77 char const * param_name = "ival";
78 int const default_value = 42;
79 int const value_min = -1000;
80 int const value_max = 1000;
81 int const has_default = 1;
82 int const is_defined = 1;
83
84 int value = default_value;
85
86 // Create new int parameter
87 struct yac_param * param =
89 param_name, &value, default_value, value_min, value_max,
90 has_default, is_defined);
91
92 // Get pack size for the parameter
93 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
94 if (pack_size == 0) PUT_ERR("int pack size should be > 0");
95
96 // Allocate buffer for packing
97 void * buffer = malloc(pack_size);
98 int pos = 0;
99
100 // Pack the parameter into the buffer
101 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
102
103 // Create new parameter for unpacking with default value
104 int unpacked_value = default_value;
105 struct yac_param * unpacked_param =
107 param_name, &unpacked_value, default_value, value_min, value_max,
108 has_default, is_defined);
109
110 // Unpack the parameter from the buffer
111 pos = 0;
113 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
114
115 // Check that the unpacked value matches the original value
116 if (unpacked_value != value)
117 PUT_ERR("int unpack should update destination value to source value");
118
119 // Clean up
120 yac_param_delete(param);
121 yac_param_delete(unpacked_param);
122 free(buffer);
123 }
124
125 { // Test pack/unpack of a single int parameter with non-default value in
126 // defined state
127 char const * param_name = "ival";
128 int const default_value = 42;
129 int const value_min = -1000;
130 int const value_max = 1000;
131 int const has_default = 1;
132 int const is_defined = 1;
133
134 int value = default_value + 1;
135
136 // Create new int parameter
137 struct yac_param * param =
139 param_name, &value, default_value, value_min, value_max,
140 has_default, is_defined);
141
142 // Get pack size for the parameter
143 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
144 if (pack_size == 0) PUT_ERR("int pack size should be > 0");
145
146 // Allocate buffer for packing
147 void * buffer = malloc(pack_size);
148 int pos = 0;
149
150 // Pack the parameter into the buffer
151 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
152
153 // Create new parameter for unpacking with default value
154 int unpacked_value = default_value;
155 struct yac_param * unpacked_param =
157 param_name, &unpacked_value, default_value, value_min, value_max,
158 has_default, is_defined);
159
160 // Unpack the parameter from the buffer
161 pos = 0;
163 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
164
165 // Check that the unpacked value matches the original value
166 if (unpacked_value != value)
167 PUT_ERR("int unpack should update destination value to source value");
168
169 // Clean up
170 yac_param_delete(param);
171 yac_param_delete(unpacked_param);
172 free(buffer);
173 }
174}
175
176static void utest_scalar_dble_roundtrip(MPI_Comm comm) {
177
178 { // Test pack/unpack of a single double parameter with default value in
179 // defined state
180 char const * param_name = "dval";
181 double const default_value = 0.0;
182 double const value_min = -1000.0;
183 double const value_max = 1000.0;
184 int const allow_nan = 0;
185 int const allow_inf = 0;
186 int const has_default = 1;
187 int const is_defined = 1;
188
189 double value = default_value;
190
191 // Create new double parameter
192 struct yac_param * param =
194 param_name, &value, default_value, value_min, value_max,
195 allow_nan, allow_inf, has_default, is_defined);
196
197 // Get pack size for the parameter
198 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
199 if (pack_size == 0) PUT_ERR("double pack size should be > 0");
200
201 // Allocate buffer for packing
202 void * buffer = malloc(pack_size);
203 int pos = 0;
204
205 // Pack the parameter into the buffer
206 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
207
208 // Create new parameter for unpacking with default value
209 double unpacked_value = default_value;
210 struct yac_param * unpacked_param =
212 param_name, &unpacked_value, default_value, value_min, value_max,
213 allow_nan, allow_inf, has_default, is_defined);
214
215 // Unpack the parameter from the buffer
216 pos = 0;
218 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
219
220 // Check that the unpacked value matches the original value
221 if (unpacked_value != value)
222 PUT_ERR("double unpack should update destination value to source value");
223
224 // Clean up
225 yac_param_delete(param);
226 yac_param_delete(unpacked_param);
227 free(buffer);
228 }
229
230 { // Test pack/unpack of a single double parameter with non-default value
231 char const * param_name = "dval";
232 double const default_value = 0.0;
233 double const value_min = -1000.0;
234 double const value_max = 1000.0;
235 int const allow_nan = 0;
236 int const allow_inf = 0;
237 int const has_default = 1;
238 int const is_defined = 1;
239
240 double value = 2.75;
241
242 // Create new double parameter
243 struct yac_param * param =
245 param_name, &value, default_value, value_min, value_max,
246 allow_nan, allow_inf, has_default, is_defined);
247
248 // Get pack size for the parameter
249 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
250 if (pack_size == 0) PUT_ERR("double pack size should be > 0");
251
252 // Allocate buffer for packing
253 void * buffer = malloc(pack_size);
254 int pos = 0;
255
256 // Pack the parameter into the buffer
257 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
258
259 // Create new parameter for unpacking with default value
260 double unpacked_value = default_value;
261 struct yac_param * unpacked_param =
263 param_name, &unpacked_value, default_value, value_min, value_max,
264 allow_nan, allow_inf, has_default, is_defined);
265
266 // Unpack the parameter from the buffer
267 pos = 0;
269 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
270
271 // Check that the unpacked value matches the original value
272 if (unpacked_value != value)
273 PUT_ERR("double unpack should update destination value to source value");
274
275 // Clean up
276 yac_param_delete(param);
277 yac_param_delete(unpacked_param);
278 free(buffer);
279 }
280}
281
282static void utest_scalar_str_roundtrip(MPI_Comm comm) {
283
284 { // Test pack/unpack of a single string parameter with default value in
285 // defined state
286 char const * param_name = "sval";
287 char const * default_value = "default";
288 int const allow_null = 0;
289 int const allow_empty = 0;
290 size_t const max_str_len = 128;
291 int const has_default = 1;
292 int const is_defined = 1;
293
294 char * value = strdup(default_value);
295
296 // Create new string parameter
297 struct yac_param * param = yac_param_str_new(
298 param_name, &value, default_value, allow_null, allow_empty,
299 max_str_len, has_default, is_defined);
300
301 // Get pack size for the parameter
302 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
303 if (pack_size == 0) PUT_ERR("string pack size should be > 0");
304
305 // Allocate buffer for packing
306 void * buffer = malloc(pack_size);
307 int pos = 0;
308
309 // Pack the parameter into the buffer
310 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
311
312 // Create new parameter for unpacking with default value
313 char * unpacked_value = strdup(default_value);
314 struct yac_param * unpacked_param = yac_param_str_new(
315 param_name, &unpacked_value, default_value, allow_null, allow_empty,
316 max_str_len, has_default, is_defined);
317
318 // Unpack the parameter from the buffer
319 pos = 0;
321 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
322
323 // Check that the unpacked value matches the original value
324 if (strcmp(unpacked_value, value) != 0)
325 PUT_ERR("string unpack should update destination value to source value");
326
327 // Clean up
328 yac_param_delete(param);
329 yac_param_delete(unpacked_param);
330 free(value);
331 free(unpacked_value);
332 free(buffer);
333 }
334
335 { // Test pack/unpack of a single string parameter with non-default value
336 char const * param_name = "sval";
337 char const * default_value = "default";
338 int const allow_null = 0;
339 int const allow_empty = 0;
340 size_t const max_str_len = 128;
341 int const has_default = 1;
342 int const is_defined = 1;
343
344 // Long value ensures internal string-buffer growth logic is exercised.
345 char * value = strdup(
346 "this-is-a-long-string-value-that-forces-buffer-growth-in-pack-size");
347
348 // Create new string parameter
349 struct yac_param * param = yac_param_str_new(
350 param_name, &value, default_value, allow_null, allow_empty,
351 max_str_len, has_default, is_defined);
352
353 // Get pack size for the parameter
354 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
355 if (pack_size == 0) PUT_ERR("string pack size should be > 0");
356
357 // Allocate buffer for packing
358 void * buffer = malloc(pack_size);
359 int pos = 0;
360
361 // Pack the parameter into the buffer
362 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
363
364 // Create new parameter for unpacking with default value
365 char * unpacked_value = strdup(default_value);
366 struct yac_param * unpacked_param = yac_param_str_new(
367 param_name, &unpacked_value, default_value, allow_null, allow_empty,
368 max_str_len, has_default, is_defined);
369
370 // Unpack the parameter from the buffer
371 pos = 0;
373 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
374
375 // Check that the unpacked value matches the original value
376 if (strcmp(unpacked_value, value) != 0)
377 PUT_ERR("string unpack should update destination value to source value");
378
379 // Clean up
380 yac_param_delete(param);
381 yac_param_delete(unpacked_param);
382 free(value);
383 free(unpacked_value);
384 free(buffer);
385 }
386}
387
388static void utest_struct_roundtrip(MPI_Comm comm) {
389
390 { // Struct path packs only non-default children by name
391
392 char const * param_name = "struct";
393
394 struct test_type {
395 int i, b;
396 double d;
397 char * s;
398 } data = {42, 1, 3.14, strdup("custom")};
399
400 struct yac_param * sub_params[] = {
401 yac_param_int_new("i", &data.i, 0, -1000, 1000, 1, 1),
402 yac_param_bool_new("b", &data.b, 0, 1, 1),
403 yac_param_dble_new("d", &data.d, 0.0, -1000.0, 1000.0, 0, 0, 1, 1),
404 yac_param_str_new("s", &data.s, "default", 0, 0, 128, 1, 1),
405 };
406 enum {NUM_SUB_PARAMS = sizeof(sub_params) / sizeof(sub_params[0])};
407
408 // Create a struct parameter with the sub-parameters
409 struct yac_param * param =
410 yac_param_struct_new(param_name, sub_params, NUM_SUB_PARAMS);
411
412 // Get pack size for the struct parameter
413 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
414 if (pack_size == 0) PUT_ERR("struct pack size should be > 0");
415
416 // Allocate buffer for packing
417 void * buffer = malloc(pack_size);
418 int pos = 0;
419
420 // Pack the struct parameter into the buffer
421 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
422
423 // Create new struct parameter for unpacking with default values
424 struct test_type unpacked_data = {0, 0, 0.0, strdup("default")};
425 struct yac_param * unpacked_param =
427 param_name,
428 (struct yac_param*[]) {
429 yac_param_int_new("i", &unpacked_data.i, 0, -1000, 1000, 1, 1),
430 yac_param_bool_new("b", &unpacked_data.b, 0, 1, 1),
432 "d", &unpacked_data.d, 0.0, -1000.0, 1000.0, 0, 0, 1, 1),
433 yac_param_str_new("s", &unpacked_data.s, "default", 0, 0, 128, 1, 1),
434 }, NUM_SUB_PARAMS);
435
436 // Unpack the struct parameter from the buffer
437 pos = 0;
439 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
440
441 // Check that the unpacked values match the original values
442 if (unpacked_data.i != data.i)
443 PUT_ERR("non-default struct child should remain default after roundtrip");
444 if (unpacked_data.b != data.b)
445 PUT_ERR("non-default bool struct child should be unpacked");
446 if (unpacked_data.d != data.d)
447 PUT_ERR("non-default double struct child should remain default after roundtrip");
448 if (strcmp(unpacked_data.s, data.s) != 0)
449 PUT_ERR("non-default string struct child should be unpacked");
450
451 // Clean up
452 yac_param_delete(param);
453 yac_param_delete(unpacked_param);
454 free(data.s);
455 free(unpacked_data.s);
456 free(buffer);
457 }
458
459 { // Struct path with only default children packs nothing,
460 // and unpacking leaves defaults unchanged
461
462 char const * param_name = "struct";
463
464 struct test_type {
465 int i, b;
466 double d;
467 char * s;
468 } data = {0, 0, 0.0, strdup("default")};
469
470 struct yac_param * sub_params[] = {
471 yac_param_int_new("i", &data.i, 0, -1000, 1000, 1, 1),
472 yac_param_bool_new("b", &data.b, 0, 1, 1),
473 yac_param_dble_new("d", &data.d, 0.0, -1000.0, 1000.0, 0, 0, 1, 1),
474 yac_param_str_new("s", &data.s, "default", 0, 0, 128, 1, 1),
475 };
476 enum {NUM_SUB_PARAMS = sizeof(sub_params) / sizeof(sub_params[0])};
477
478 // Create a struct parameter with the sub-parameters
479 struct yac_param * param =
480 yac_param_struct_new(param_name, sub_params, NUM_SUB_PARAMS);
481
482 // Get pack size for the struct parameter
483 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
484 if (pack_size == 0) PUT_ERR("struct pack size should be > 0");
485
486 // Allocate buffer for packing
487 void * buffer = malloc(pack_size);
488 int pos = 0;
489
490 // Pack the struct parameter into the buffer
491 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
492
493 // Create new struct parameter for unpacking with default values
494 struct test_type unpacked_data = {0, 0, 0.0, strdup("default")};
495 struct yac_param * unpacked_param =
497 param_name,
498 (struct yac_param*[]) {
499 yac_param_int_new("i", &unpacked_data.i, 0, -1000, 1000, 1, 1),
500 yac_param_bool_new("b", &unpacked_data.b, 0, 1, 1),
502 "d", &unpacked_data.d, 0.0, -1000.0, 1000.0, 0, 0, 1, 1),
503 yac_param_str_new("s", &unpacked_data.s, "default", 0, 0, 128, 1, 1),
504 }, NUM_SUB_PARAMS);
505
506 // Unpack the struct parameter from the buffer
507 pos = 0;
509 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
510
511 // Check that the unpacked values match the original values
512 if (unpacked_data.i != data.i)
513 PUT_ERR("default struct child should remain default after roundtrip");
514 if (unpacked_data.b != data.b)
515 PUT_ERR("default bool struct child should remain default after roundtrip");
516 if (unpacked_data.d != data.d)
517 PUT_ERR("default double struct child should remain default after roundtrip");
518 if (strcmp(unpacked_data.s, data.s) != 0)
519 PUT_ERR("default string struct child should remain default after roundtrip");
520
521 // Clean up
522 yac_param_delete(param);
523 yac_param_delete(unpacked_param);
524 free(data.s);
525 free(unpacked_data.s);
526 free(buffer);
527 }
528
529 { // Struct path with partial default children
530 char const * param_name = "struct";
531
532 struct test_type {
533 int i, b;
534 double d;
535 char * s;
536 } data = {42, 0, 3.14, strdup("default")};
537
538 struct yac_param * sub_params[] = {
539 yac_param_int_new("i", &data.i, 0, -1000, 1000, 1, 1),
540 yac_param_bool_new("b", &data.b, 0, 1, 1),
541 yac_param_dble_new("d", &data.d, 0.0, -1000.0, 1000.0, 0, 0, 1, 1),
542 yac_param_str_new("s", &data.s, "default", 0, 0, 128, 1, 1),
543 };
544 enum {NUM_SUB_PARAMS = sizeof(sub_params) / sizeof(sub_params[0])};
545
546 // Create a struct parameter with the sub-parameters
547 struct yac_param * param =
548 yac_param_struct_new(param_name, sub_params, NUM_SUB_PARAMS);
549
550 // Get pack size for the struct parameter
551 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
552 if (pack_size == 0) PUT_ERR("struct pack size should be > 0");
553
554 // Allocate buffer for packing
555 void * buffer = malloc(pack_size);
556 int pos = 0;
557
558 // Pack the struct parameter into the buffer
559 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
560
561 // Create new struct parameter for unpacking with default values
562 struct test_type unpacked_data = {0, 0, 0.0, strdup("default")};
563 struct yac_param * unpacked_param =
565 param_name,
566 (struct yac_param*[]) {
567 yac_param_int_new("i", &unpacked_data.i, 0, -1000, 1000, 1, 1),
568 yac_param_bool_new("b", &unpacked_data.b, 0, 1, 1),
570 "d", &unpacked_data.d, 0.0, -1000.0, 1000.0, 0, 0, 1, 1),
571 yac_param_str_new("s", &unpacked_data.s, "default", 0, 0, 128, 1, 1),
572 }, NUM_SUB_PARAMS);
573
574 // Unpack the struct parameter from the buffer
575 pos = 0;
577 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
578
579 // Check that the unpacked values match the original values
580 if (unpacked_data.i != data.i)
581 PUT_ERR("default struct child should remain default after roundtrip");
582 if (unpacked_data.b != data.b)
583 PUT_ERR("default bool struct child should remain default after roundtrip");
584 if (unpacked_data.d != data.d)
585 PUT_ERR("default double struct child should remain default after roundtrip");
586 if (strcmp(unpacked_data.s, data.s) != 0)
587 PUT_ERR("default string struct child should remain default after roundtrip");
588
589 // Clean up
590 yac_param_delete(param);
591 yac_param_delete(unpacked_param);
592 free(data.s);
593 free(unpacked_data.s);
594 free(buffer);
595 }
596}
597
598static void utest_list_roundtrip(MPI_Comm comm) {
599
600 { // List path serializes element count and element records in order
601 char const * param_name = "list";
602
603 // Create a list parameter with a default factory for elements
604 void ** list = NULL;
605 struct yac_param * param =
606 yac_param_list_new(param_name, &list, utest_list_default_factory, NULL);
607
608 // Add two elements to the list
609 struct yac_param * elem0 = NULL;
610 struct yac_param * elem1 = NULL;
611 if (yac_param_append(param, &elem0) != 0)
612 PUT_ERR("list append for first source element failed");
613 if (yac_param_append(param, &elem1) != 0)
614 PUT_ERR("list append for second source element failed");
615
616 // First element stays at default value, second element is set to a
617 // non-default value
618 yac_param_set_scalar_int(elem1, 22);
619
620 // Get pack size for the list parameter
621 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
622 if (pack_size == 0) PUT_ERR("list pack size should be > 0");
623
624 // Allocate buffer for packing
625 void * buffer = malloc(pack_size);
626 int pos = 0;
627
628 // Pack the list parameter into the buffer
629 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
630
631 // Create new list parameter for unpacking with default factory
632 void ** unpacked_list = NULL;
633 struct yac_param * unpacked_param =
635 param_name, &unpacked_list, utest_list_default_factory, NULL);
636
637 // Unpack the list parameter from the buffer
638 pos = 0;
640 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
641
642 // Check that the unpacked list is identical to the original list in terms
643 // of count and element values
644 size_t count = 0;
645 if (yac_param_get_sub_count(unpacked_param, &count) != 0 || count != 2)
646 PUT_ERR("list unpack should create two destination elements");
647 for (size_t i = 0; i < count; ++i) {
648 if (*(int*)list[i] != *(int*)unpacked_list[i])
649 PUT_ERR("list unpack should preserve elements");
650 }
651
652 // Clean up
653 yac_param_delete(param);
654 yac_param_delete(unpacked_param);
655 utest_free_int_list(list);
656 utest_free_int_list(unpacked_list);
657 free(buffer);
658 }
659}
660
661static void utest_empty_list_roundtrip(MPI_Comm comm) {
662
663 { // Explicitly cover list unpack with sub_count = 0
664 char const * param_name = "list";
665
666 // Create a list parameter with a default factory for elements
667 void ** list = NULL;
668 struct yac_param * param =
669 yac_param_list_new(param_name, &list, utest_list_default_factory, NULL);
670
671 // Get pack size for the list parameter
672 size_t pack_size = yac_param_get_pack_size(param, comm, __func__);
673 if (pack_size == 0) PUT_ERR("empty-list pack size should be > 0");
674
675 // Allocate buffer for packing
676 void * buffer = malloc(pack_size);
677 int pos = 0;
678
679 // Pack the list parameter into the buffer
680 yac_param_pack(param, buffer, (int)pack_size, &pos, comm, __func__);
681
682 // Create new list parameter for unpacking with default factory
683 void ** unpacked_list = NULL;
684 struct yac_param * unpacked_param =
686 param_name, &unpacked_list, utest_list_default_factory, NULL);
687
688 // Unpack the list parameter from the buffer
689 pos = 0;
691 unpacked_param, buffer, (int)pack_size, &pos, comm, __func__);
692
693 // Check that the unpacked list is empty, as expected
694 size_t count = 99;
695 if (yac_param_get_sub_count(unpacked_param, &count) != 0 || count != 0)
696 PUT_ERR("empty list roundtrip should keep destination list empty");
697
698 // Clean up
699 yac_param_delete(param);
700 yac_param_delete(unpacked_param);
701 utest_free_int_list(list);
702 utest_free_int_list(unpacked_list);
703 free(buffer);
704 }
705}
struct @23::@24 value
void yac_param_delete(struct yac_param *param)
Definition param.c:304
int yac_param_append(struct yac_param *param, struct yac_param **sub_param)
Append a new default subparameter to a list parameter and return a handle to it.
Definition param.c:102
int yac_param_set_scalar_int(struct yac_param *param, int value)
Set the value of a scalar parameter as an int.
Definition param.c:147
int yac_param_get_sub_count(const struct yac_param *param, size_t *count)
Get the number of subparameters.
Definition param.c:61
Public interface for YAC parameters.
struct yac_param * yac_param_bool_new(const char *name, int *value_ptr, int default_value, int has_default, int is_defined)
Create a bool parameter (backed by int)
Definition param_bool.c:159
struct yac_param * yac_param_dble_new(const char *name, double *value_ptr, double default_value, double value_min, double value_max, int allow_nan, int allow_inf, int has_default, int is_defined)
Create a double parameter.
Definition param_dble.c:166
struct yac_param * yac_param_int_new(const char *name, int *value_ptr, int default_value, int value_min, int value_max, int has_default, int is_defined)
Create an int parameter.
Definition param_int.c:163
struct yac_param * yac_param_list_new(const char *name, void ***list, yac_param_factory_ptr default_factory, yac_param_element_get_param_ptr element_get_param)
Create a new list parameter.
Definition param_list.c:134
struct yac_param * yac_param_str_new(const char *name, char **value_ptr, const char *default_value, int allow_NULL, int allow_empty, size_t max_str_len, int has_default, int is_defined)
Create a string parameter.
Definition param_str.c:176
struct yac_param * yac_param_struct_new(const char *name, struct yac_param **subparams, size_t subparam_count)
Create a new struct parameter with a given name and subparameters.
void yac_param_pack(struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
Public function to pack a parameter record into a buffer.
size_t yac_param_get_pack_size(struct yac_param *param, MPI_Comm comm, char const *routine)
Public function to get the size in bytes required to pack a parameter record.
void yac_param_unpack(struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
Unpack a parameter from an MPI buffer and apply its values to the given parameter.
double * data
#define TEST_EXIT_CODE
Definition tests.h:15
#define PUT_ERR(string)
Definition tests.h:10
double * buffer