YetAnotherCoupler 3.5.2
Loading...
Searching...
No Matches
config_yaml.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9// libfyaml is not very clean...so we have to suppress some warnings
10
11#if defined(__NVCOMPILER)
12# pragma diag_suppress unsigned_compare_with_zero
13#elif defined(__GNUC__)
14# pragma GCC diagnostic push
15# pragma GCC diagnostic ignored "-Wpedantic"
16# pragma GCC diagnostic ignored "-Wall"
17# pragma GCC diagnostic ignored "-Wextra"
18#endif
19#include <libfyaml.h>
20#if defined(__NVCOMPILER)
21# pragma diag_default unsigned_compare_with_zero
22#elif defined(__GNUC__)
23# pragma GCC diagnostic pop
24#endif
25
26#include <stdlib.h>
27#include <string.h>
28#include <stdbool.h>
29
30#include "yac.h"
31#include "utils_mci.h"
32#include "config_yaml.h"
33#include "mtime_calendar.h"
34#include "geometry.h"
35#include "io_utils.h"
36#include "interp_method_avg.h"
38#include "interp_method_check.h"
40#include "interp_method_creep.h"
41#include "interp_method_file.h"
42#include "interp_method_fixed.h"
43#include "interp_method_hcsbb.h"
44#include "interp_method_ncc.h"
45#include "interp_method_nnn.h"
46#include "interp_method_spmap.h"
47#include "interp_stack_config.h"
48#include "instance.h"
49#include "fields.h"
50
51typedef struct fy_document * fy_document_t;
52typedef struct fy_node * fy_node_t;
53typedef struct fy_node_pair * fy_node_pair_t;
54
55enum {
56 EMITTER_DEFAULT = FYECF_DEFAULT,
57 EMITTER_JSON = FYECF_MODE_JSON,
59 PARSER_JSON_AUTO = FYPCF_JSON_AUTO,
60 PARSER_JSON_FORCE = FYPCF_JSON_FORCE,
61};
62
68
69char const * yac_time_to_ISO(
70 char const * time, enum yac_time_unit_type time_unit);
71
73 struct {
74 char const * comp_name;
75 struct {
76 char const ** name;
77 size_t count;
79 int lag;
80 } src, tgt;
81 char const * coupling_period;
84 char const * weight_file_name;
87
89 char const * src, * tgt;
92
93 char const ** src_mask_names;
95 char const * tgt_mask_name;
96
97 char const * yaxt_exchanger_name;
98};
99
108
131
138
145
150
159
164
165#define CAST_NAME_TYPE_PAIRS(...) (struct yac_name_type_pair[]) {__VA_ARGS__}
166#define COUNT_NAME_TYPE_PAIRS(...) \
167 sizeof(CAST_NAME_TYPE_PAIRS(__VA_ARGS__)) / sizeof(struct yac_name_type_pair)
168#define DEF_NAME_TYPE_PAIR(NAME, TYPE) {.name = #NAME, .type = (int)(TYPE)}
169#define DEF_NAME_TYPE_PAIRS(NAME, ...) \
170 static const struct yac_name_type_pair NAME [] = {__VA_ARGS__}; \
171 static const size_t num_ ## NAME = COUNT_NAME_TYPE_PAIRS(__VA_ARGS__);
172
174 yaml_base_keys,
175 DEF_NAME_TYPE_PAIR(start_date, START_DATE),
176 DEF_NAME_TYPE_PAIR(end_date, END_DATE),
177 DEF_NAME_TYPE_PAIR(calendar, CALENDAR),
178 DEF_NAME_TYPE_PAIR(timestep_unit, TIMESTEP_UNIT),
179 DEF_NAME_TYPE_PAIR(coupling, COUPLING),
181
183 yaml_couple_keys,
185 DEF_NAME_TYPE_PAIR(src_component, SOURCE_COMPONENT),
188 DEF_NAME_TYPE_PAIR(tgt_component, TARGET_COMPONENT),
191 DEF_NAME_TYPE_PAIR(coupling_period, COUPLING_PERIOD),
192 DEF_NAME_TYPE_PAIR(time_reduction, TIME_REDUCTION),
195 DEF_NAME_TYPE_PAIR(weight_file_name, WEIGHT_FILE_NAME),
196 DEF_NAME_TYPE_PAIR(mapping_side, MAPPING_SIDE),
197 DEF_NAME_TYPE_PAIR(scale_factor, SCALE_FACTOR),
198 DEF_NAME_TYPE_PAIR(scale_summand, SCALE_SUMMAND),
199 DEF_NAME_TYPE_PAIR(interpolation, INTERPOLATION),
200 DEF_NAME_TYPE_PAIR(src_mask_name, SOURCE_MASK_NAME),
201 DEF_NAME_TYPE_PAIR(src_mask_names, SOURCE_MASK_NAMES),
202 DEF_NAME_TYPE_PAIR(tgt_mask_name, TARGET_MASK_NAME),
204 DEF_NAME_TYPE_PAIR(yaxt_exchanger_name, YAXT_EXCHANGER_NAME))
205
207 yaml_debug_sync_loc_keys,
216
218 yaml_debug_output_grid_keys,
221
223 bool_names,
224 DEF_NAME_TYPE_PAIR(true, true),
225 DEF_NAME_TYPE_PAIR(TRUE, true),
226 DEF_NAME_TYPE_PAIR(yes, true),
227 DEF_NAME_TYPE_PAIR(YES, true),
228 DEF_NAME_TYPE_PAIR(false, false),
229 DEF_NAME_TYPE_PAIR(FALSE, false),
230 DEF_NAME_TYPE_PAIR(no, false),
231 DEF_NAME_TYPE_PAIR(NO, false))
232
234 timestep_units,
235 DEF_NAME_TYPE_PAIR(millisecond, C_MILLISECOND),
242 DEF_NAME_TYPE_PAIR(ISO_format, C_ISO_FORMAT))
243
245 time_operations,
251
253 calendar_types,
254 DEF_NAME_TYPE_PAIR(proleptic-gregorian, PROLEPTIC_GREGORIAN),
255 DEF_NAME_TYPE_PAIR(360d, YEAR_OF_360_DAYS),
256 DEF_NAME_TYPE_PAIR(365d, YEAR_OF_365_DAYS))
257
259 mapping_sides,
260 DEF_NAME_TYPE_PAIR(source, 1),
261 DEF_NAME_TYPE_PAIR(target, 0))
262
264 yaml_debug_keys,
265 DEF_NAME_TYPE_PAIR(global_config, GLOBAL_CONFIG),
266 DEF_NAME_TYPE_PAIR(output_grids, OUTPUT_GRIDS),
267 DEF_NAME_TYPE_PAIR(missing_definition_is_fatal, MISSING_DEF))
268
270 config_filetypes,
275
277 role_types,
278 DEF_NAME_TYPE_PAIR(target, TARGET),
279 DEF_NAME_TYPE_PAIR(source, SOURCE),
280 DEF_NAME_TYPE_PAIR(nothing, NOTHING))
281
283 yaml_comp_grid_names_keys,
284 DEF_NAME_TYPE_PAIR(component, COMP_NAME),
286
287typedef
288#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 23 || __NVCOMPILER_MAJOR__ == 24 && __NVCOMPILER_MINOR__ <= 3)
289// Older versions of NVHPC have serious problems with unions that contain
290// pointers that are not the first members: versions 23.7 and older fail with
291// 'Internal compiler error. unhandled type', the newer versions produce code
292// that fails at the runtime with
293// 'Segmentation fault: address not mapped to object'.
294struct
295#else
296union
297#endif
299 int enum_value;
300 int int_value;
301 double dble_value;
302 int bool_value;
303 char const * str_value;
305
314
316
317 char const * name;
319
320#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 23 || __NVCOMPILER_MAJOR__ == 24 && __NVCOMPILER_MINOR__ <= 3)
321 // Older versions of NVHPC generate invalid LLVM IR for unions that contain
322 // structures with doubles: an attempt to initialize a member of type double
323 // that is not the first member of the respective structure will lead to a
324 // type mismatch.
325 struct
326#else
327 union
328#endif
329 {
330 struct { // enum
334 struct { // integer
335 int valid_min, valid_max;
337 struct { // double
340 struct { // string
343 struct { // bool
344 int dummy;
348};
349
350#define DEF_INTERP_METHOD_ADD_FUNC(NAME, FUNC) \
351 static void add_interp_method_ ## NAME ( \
352 struct yac_interp_stack_config * interp_stack, \
353 interp_method_parameter_value * parameters, \
354 char const * yaml_filename) { \
355 char const * routine_name = "add_interp_method_" #NAME; \
356 (void)parameters; \
357 (void)yaml_filename; \
358 (void)routine_name; \
359 {FUNC} }
360#define DEF_INTERP_METHOD_GET_FUNC(NAME, FUNC) \
361 static void get_interp_method_ ## NAME ( \
362 union yac_interp_stack_config_entry const * interp_stack_entry, \
363 interp_method_parameter_value * parameter_values) { \
364 char const * routine_name = "get_interp_method_" #NAME; \
365 (void)interp_stack_entry; \
366 (void)parameter_values; \
367 (void)routine_name; \
368 {FUNC} }
369
370#define DEF_ENUM_PARAM(NAME, DEFAULT, ...) \
371 {.name = #NAME, \
372 .type = ENUM_PARAM, \
373 .data.enum_param = \
374 {.valid_values = CAST_NAME_TYPE_PAIRS(__VA_ARGS__), \
375 .num_valid_values = COUNT_NAME_TYPE_PAIRS(__VA_ARGS__)}, \
376 .default_value.enum_value = (int)(DEFAULT)}
377#define DEF_INT_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX) \
378 {.name = #NAME, \
379 .type = INT_PARAM, \
380 .data.int_param = \
381 {.valid_min = (int)(VALID_MIN), \
382 .valid_max = (int)(VALID_MAX)}, \
383 .default_value.int_value = (int)(DEFAULT)}
384#define DEF_DBLE_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX) \
385 {.name = #NAME, \
386 .type = DBLE_PARAM, \
387 .data.dble_param = \
388 {.valid_min = (double)(VALID_MIN), \
389 .valid_max = (double)(VALID_MAX)}, \
390 .default_value.dble_value = (double)(DEFAULT)}
391#define DEF_DEG_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX) \
392 {.name = #NAME, \
393 .type = DEG_PARAM, \
394 .data.dble_param = \
395 {.valid_min = (double)(VALID_MIN), \
396 .valid_max = (double)(VALID_MAX)}, \
397 .default_value.dble_value = (double)(DEFAULT)}
398#define DEF_BOOL_PARAM(NAME, DEFAULT) \
399 {.name = #NAME, \
400 .type = BOOL_PARAM, \
401 .default_value.bool_value = (int)(DEFAULT)}
402#define DEF_STR_PARAM(NAME, DEFAULT, MAX_STR_LEN) \
403 {.name = #NAME, \
404 .type = STR_PARAM, \
405 .data.str_param.max_str_len = (MAX_STR_LEN), \
406 .default_value.str_value = (DEFAULT)}
407#define DEF_INTERP_METHOD_PARAM(NAME, ...) \
408 static struct interp_method_parameter \
409 interp_method_parameters_ ## NAME [] = {__VA_ARGS__};
410
411#define YAML_ASSERT(CHECK, MSG) \
412 YAC_ASSERT_F((CHECK), \
413 "ERROR(%s): " MSG " in YAML configuration file \"%s\"", \
414 routine_name, yaml_filename)
415#define YAML_ASSERT_F(CHECK, MSG, ...) \
416 YAC_ASSERT_F((CHECK), \
417 "ERROR(%s): " MSG " in YAML configuration file \"%s\"", \
418 routine_name, __VA_ARGS__, yaml_filename)
419
420#define DEF_INTERP_STACK_ADD(NAME, ...) \
421 yac_interp_stack_config_add_ ## NAME ( \
422 interp_stack, __VA_ARGS__);
423
424#define DEF_INTERP_STACK_ADD_NO_PARAM(NAME) \
425 yac_interp_stack_config_add_ ## NAME ( \
426 interp_stack);
427
428#define DEF_INTERP_STACK_GET(NAME, ...) \
429 yac_interp_stack_config_entry_get_ ## NAME ( \
430 interp_stack_entry, __VA_ARGS__);
431
432#define DEF_INTERP_STACK_GET_NO_PARAM(NAME) \
433 {}
434
435#define DEF_INTERP_METHOD(NAME, FUNC_ADD, FUNC_GET, ...) \
436 DEF_INTERP_METHOD_ADD_FUNC(NAME, FUNC_ADD) \
437 DEF_INTERP_METHOD_GET_FUNC(NAME, FUNC_GET) \
438 DEF_INTERP_METHOD_PARAM(NAME, __VA_ARGS__)
439
440// interpolation method average
442 DEF_INTERP_STACK_ADD(average,
443 (enum yac_interp_avg_weight_type)parameters[0].enum_value,
444 parameters[1].bool_value),
445 enum yac_interp_avg_weight_type reduction_type;
446 DEF_INTERP_STACK_GET(average,
447 &reduction_type, &parameter_values[1].bool_value)
448 parameter_values[0].enum_value = (int)reduction_type;,
451 DEF_NAME_TYPE_PAIR(distance_weighted, YAC_INTERP_AVG_DIST),
453 DEF_NAME_TYPE_PAIR(barycentric_coordinate, YAC_INTERP_AVG_BARY)),
456
457// interpolation method nearest corner cells
460 (enum yac_interp_ncc_weight_type)parameters[0].enum_value,
461 parameters[1].bool_value),
464 &weight_type, &parameter_values[1].bool_value)
465 parameter_values[0].enum_value = (int)weight_type;,
468 DEF_NAME_TYPE_PAIR(arithmetic_average, YAC_INTERP_NCC_AVG),
469 DEF_NAME_TYPE_PAIR(distance_weighted, YAC_INTERP_NCC_DIST)),
472
473// interpolation method n-nearest neighbor
476 (enum yac_interp_nnn_weight_type)parameters[0].enum_value,
477 (size_t)parameters[1].int_value,
478 parameters[2].dble_value,
479 parameters[3].dble_value),
481 size_t n;
483 &type, &n, &parameter_values[2].dble_value,
484 &parameter_values[3].dble_value)
485 parameter_values[0].enum_value = (int)type;
486 parameter_values[1].int_value = (int)n;
487 parameter_values[2].dble_value /= YAC_RAD;,
490 DEF_NAME_TYPE_PAIR(distance_weighted, YAC_INTERP_NNN_DIST),
492 DEF_NAME_TYPE_PAIR(arithmetic_average, YAC_INTERP_NNN_AVG),
497 0.0, 179.9999),
499 gauss_scale, YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT, -DBL_MAX, DBL_MAX))
500
501// interpolation method conservative
502DEF_INTERP_METHOD(conservative,
503 DEF_INTERP_STACK_ADD(conservative,
504 parameters[0].int_value,
505 parameters[1].bool_value,
506 parameters[2].bool_value,
507 (enum yac_interp_method_conserv_normalisation)parameters[3].enum_value),
509 DEF_INTERP_STACK_GET(conservative,
510 &parameter_values[0].int_value,
511 &parameter_values[1].bool_value,
512 &parameter_values[2].bool_value, &normalisation)
513 parameter_values[3].enum_value = (int)normalisation;,
516 enforced_conservation, YAC_INTERP_CONSERV_ENFORCED_CONSERV_DEFAULT),
523
524static void get_spmap_parameters(
525 double * sphere_radius, char const * filename, char const * varname,
526 char const * routine_name, char const * yaml_filename, char const * type) {
527
528 // if no cell area configuration is provided
529 if ((*sphere_radius == 0.0) && (filename == NULL) && (varname == NULL)) {
531 }
532 // ensure that only one cell area provider type is given
534 (*sphere_radius != 0.0) ^ ((filename != NULL) || (varname != NULL)),
535 "configurations for the computation and reading of %s cell areas "
536 "were provided (only one is allowed)", type);
537 // ensure that both file name and variable name are provided
539 (*sphere_radius != 0.0) || ((filename != NULL) && (varname != NULL)),
540 "incomplete information for read of %s cell areas "
541 "(filename: \"%s\" varname: \"%s\")",
542 type, filename?filename:"missing", varname?varname:"missing");
543}
544
545// interpolation method source to target mapping
546DEF_INTERP_METHOD(source_to_target_map,
547 double src_sphere_radius = parameters[4].dble_value;
548 char const * src_filename = parameters[5].str_value;
549 char const * src_varname = parameters[6].str_value;
550 int src_min_global_id = parameters[7].int_value;
551 double tgt_sphere_radius = parameters[8].dble_value;
552 char const * tgt_filename = parameters[9].str_value;
553 char const * tgt_varname = parameters[10].str_value;
554 int tgt_min_global_id = parameters[11].int_value;
555 get_spmap_parameters(
556 &src_sphere_radius, src_filename, src_varname,
557 routine_name, yaml_filename, "source");
558 get_spmap_parameters(
559 &tgt_sphere_radius, tgt_filename, tgt_varname,
560 routine_name, yaml_filename, "target");
562 parameters[0].dble_value,
563 parameters[1].dble_value,
564 (enum yac_interp_spmap_weight_type)parameters[2].enum_value,
565 (enum yac_interp_spmap_scale_type)parameters[3].enum_value,
566 src_sphere_radius, src_filename, src_varname, src_min_global_id,
567 tgt_sphere_radius, tgt_filename, tgt_varname, tgt_min_global_id),
569 enum yac_interp_spmap_scale_type scale_type;
571 &parameter_values[0].dble_value,
572 &parameter_values[1].dble_value,
573 &weight_type, &scale_type,
574 &parameter_values[4].dble_value,
575 &parameter_values[5].str_value,
576 &parameter_values[6].str_value,
577 &parameter_values[7].int_value,
578 &parameter_values[8].dble_value,
579 &parameter_values[9].str_value,
580 &parameter_values[10].str_value,
581 &parameter_values[11].int_value)
582 parameter_values[0].dble_value /= YAC_RAD;
583 parameter_values[1].dble_value /= YAC_RAD;
584 parameter_values[2].enum_value = (int)weight_type;
585 parameter_values[3].enum_value = (int)scale_type;,
587 spread_distance, YAC_INTERP_SPMAP_SPREAD_DISTANCE_DEFAULT, 0.0, 89.9999),
589 max_search_distance,
593 DEF_NAME_TYPE_PAIR(distance_weighted, YAC_INTERP_SPMAP_DIST),
594 DEF_NAME_TYPE_PAIR(arithmetic_average, YAC_INTERP_SPMAP_AVG)),
602 src_cell_area:yac:sphere_radius, 0.0, 1e-9, DBL_MAX),
604 src_cell_area:file:filename, NULL, YAC_MAX_FILE_NAME_LENGTH),
605 DEF_STR_PARAM(src_cell_area:file:varname, NULL, 128),
607 src_cell_area:file:min_global_id, YAC_INTERP_SPMAP_MIN_GLOBAL_ID_DEFAULT,
608 -INT_MAX, INT_MAX),
610 tgt_cell_area:yac:sphere_radius, 0.0, 1e-9, DBL_MAX),
612 tgt_cell_area:file:filename, NULL, YAC_MAX_FILE_NAME_LENGTH),
613 DEF_STR_PARAM(tgt_cell_area:file:varname, NULL, 128),
615 tgt_cell_area:file:min_global_id, YAC_INTERP_SPMAP_MIN_GLOBAL_ID_DEFAULT,
616 -INT_MAX, INT_MAX))
617
618// interpolation method fixed
621 parameters[0].dble_value != DBL_MAX,
622 "parameter 'user_value' of interpolation method 'fixed' is unset");
623 DEF_INTERP_STACK_ADD(fixed, parameters[0].dble_value),
625 &parameter_values[0].dble_value),
627 user_value, YAC_INTERP_FIXED_VALUE_DEFAULT, -DBL_MAX, DBL_MAX))
628
629// interpolation method user file
630DEF_INTERP_METHOD(user_file,
632 parameters[0].str_value,
633 "parameter \"filename\" of interpolation method \"user file\" is unset")
634 DEF_INTERP_STACK_ADD(user_file,
635 (char*)(parameters[0].str_value)),
637 &parameter_values[0].str_value),
641
642// interpolation method check
645 (char*)(parameters[0].str_value),
646 (char*)(parameters[1].str_value)),
648 &parameter_values[0].str_value,
649 &parameter_values[1].str_value),
656
657// interpolation method Bernstein Bezier
658DEF_INTERP_METHOD(bernstein_bezier,
661 DEF_BOOL_PARAM(dummy, 0))
662
663// interpolation method radial basis function
667 (size_t)parameters[0].int_value,
668 parameters[1].dble_value,
669 parameters[2].dble_value),
671 size_t n;
673 &type, &n, &parameter_values[1].dble_value,
674 &parameter_values[2].dble_value)
677 "ERROR(get_interp_method_nnn): n-nearest-neighbor type missmatch");
678 parameter_values[0].int_value = (int)n;
679 parameter_values[1].dble_value /= YAC_RAD;
680 parameter_values[3].enum_value = (int)0;,
684 0.0, 179.9999),
685 DEF_DBLE_PARAM(rbf_scale, YAC_INTERP_RBF_SCALE_DEFAULT, -DBL_MAX, DBL_MAX),
688 DEF_NAME_TYPE_PAIR(gauss_kernel, 0)))
689
690// interpolation method creep
692 DEF_INTERP_STACK_ADD(creep, parameters[0].int_value),
694 &parameter_values[0].int_value),
696 creep_distance, YAC_INTERP_CREEP_DISTANCE_DEFAULT, -1, INT_MAX))
697
698// interpolation method user_callback
699DEF_INTERP_METHOD(user_callback,
701 parameters[0].str_value,
702 "parameter \"func_compute_weights\" "
703 "of interpolation method \"user callback\" is unset")
704 DEF_INTERP_STACK_ADD(user_callback, (char*)(parameters[0].str_value)),
705 DEF_INTERP_STACK_GET(user_callback,
706 &parameter_values[0].str_value),
710
711
712#define ADD_INTERPOLATION(NAME, TYPE) \
713 {.name = #NAME , \
714 .type = TYPE , \
715 .add_interpolation = add_interp_method_ ## NAME , \
716 .get_interpolation = get_interp_method_ ## NAME , \
717 .parameters = interp_method_parameters_ ## NAME , \
718 .num_parameters = \
719 sizeof(interp_method_parameters_ ## NAME ) / \
720 sizeof(interp_method_parameters_ ## NAME [0])}
721#define ADD_INTERPOLATION_NO_PARAM(NAME, TYPE) \
722 {.name = #NAME , \
723 .type = TYPE , \
724 .add_interpolation = add_interp_method_ ## NAME , \
725 .get_interpolation = get_interp_method_ ## NAME , \
726 .parameters = interp_method_parameters_ ## NAME , \
727 .num_parameters = 0}
728
729struct yac_interpolation_method {
730 char const * name;
732 void(*add_interpolation)(
733 struct yac_interp_stack_config * interp_stack,
735 char const * yaml_filename);
736 void(*get_interpolation)(
737 union yac_interp_stack_config_entry const * interp_stack_entry,
738 interp_method_parameter_value * parameter_values);
739 struct interp_method_parameter const * parameters;
740 size_t num_parameters;
745 ADD_INTERPOLATION(conservative, YAC_CONSERVATIVE),
746 ADD_INTERPOLATION(source_to_target_map, YAC_SOURCE_TO_TARGET_MAP),
753 ADD_INTERPOLATION(user_callback, YAC_USER_CALLBACK)};
754enum {
757};
758
759static char const * yaml_parse_string_value(
760 fy_node_t value_node, char const * name, char const * yaml_filename) {
761 char const * routine_name = "yaml_parse_string_value";
762
764 value_node && fy_node_is_scalar(value_node),
765 "unsupported node type for \"%s\" (the node is expected to be scalar)",
766 name);
767
768 return fy_node_get_scalar0(value_node);
769}
770
771static calendarType yaml_parse_calendar_value(
772 fy_node_t value_node, char const * key_name, char const * yaml_filename) {
773 char const * routine_name = "yaml_parse_calendar_value";
774
775 char const * calendar_name =
776 yaml_parse_string_value(value_node, key_name, yaml_filename);
777
778 int calendar_type =
780 calendar_types, num_calendar_types, calendar_name);
781
783 calendar_type != INT_MAX,
784 "\"%s\" is not a valid calendar name", calendar_name);
785
786 return (calendarType)calendar_type;
787}
788
789static char const * yaml_parse_timestep_value(
790 fy_node_t value_node, char const * key_name, char const * yaml_filename,
791 enum yac_time_unit_type time_unit) {
792 char const * routine_name = "yaml_parse_timestep_value";
793
795 time_unit != TIME_UNIT_UNDEFINED, "time unit is not yet defined");
797 value_node && fy_node_is_scalar(value_node),
798 "unsupported node type for \"%s\" (the node is expected to be scalar)",
799 key_name);
800 char const * timestep =
801 yaml_parse_string_value(value_node, key_name, yaml_filename);
802 char const * timestep_iso =
803 yac_time_to_ISO(timestep, time_unit);
804
806 timestep_iso, "valid to convert timestep \"%s\" to ISO 8601 format",
807 timestep);
808
809 return strdup(timestep_iso);
810}
811
813 fy_node_t value_node, char const * key_name, char const * yaml_filename) {
814 char const * routine_name = "yaml_parse_timestep_unit_value";
815
816 char const * timestep_unit_str =
817 yaml_parse_string_value(value_node, key_name, yaml_filename);
818
819 int timestep_unit =
821 timestep_units, num_timestep_units, timestep_unit_str);
822
824 timestep_unit != INT_MAX,
825 "\"%s\" is not a valid time step unit", timestep_unit_str);
826
827 return (enum yac_time_unit_type)timestep_unit;
828}
829
831 fy_node_t value_node, char const * key_name, char const * yaml_filename) {
832 char const * routine_name = "yaml_parse_time_reduction_value";
833
834 char const * time_reduction_str =
835 yaml_parse_string_value(value_node, key_name, yaml_filename);
836
837 int time_reduction =
839 time_operations, num_time_operations, time_reduction_str);
840
842 time_reduction != INT_MAX,
843 "\"%s\" is not a valid time reduction type in", time_reduction_str);
844
845 return (enum yac_reduction_type)time_reduction;
846}
847
849 fy_node_t value_node, char const * key_name, char const * yaml_filename) {
850 char const * routine_name = "yaml_parse_integer_value";
851
852 char const * integer_str =
853 yaml_parse_string_value(value_node, key_name, yaml_filename);
854
855 char * endptr;
856 long int long_value = strtol(integer_str, &endptr, 10);
857
859 (endptr != integer_str) && (*endptr == '\0') &&
860 (long_value >= INT_MIN) && (long_value <= INT_MAX),
861 "\"%s\" is not a valid integer value", integer_str);
862
863 return (int)long_value;
864}
865
867 fy_node_t value_node, char const * key_name, char const * yaml_filename) {
868 char const * routine_name = "yaml_parse_double_value";
869
870 char const * double_str =
871 yaml_parse_string_value(value_node, key_name, yaml_filename);
872
873 char * endptr;
874 double dble_value = strtod(double_str, &endptr);
875
877 (endptr != double_str) && (*endptr == '\0'),
878 "\"%s\" is not a valid double value", double_str);
879
880 return dble_value;
881}
882
884 struct yac_name_type_pair const * valid_values, size_t num_valid_values,
885 fy_node_t value_node, char const * key_name, char const * yaml_filename) {
886 char const * routine_name = "yaml_parse_enum_value";
887
888 char const * value_str =
889 yaml_parse_string_value(value_node, key_name, yaml_filename);
890
891 int value =
893 valid_values, num_valid_values, value_str);
894
896 value != INT_MAX,
897 "\"%s\" is not a valid enum value for \"%s\" ", value_str, key_name);
898
899 return value;
900}
901
903 char const ** interpolation_type_str, fy_node_t * parameter_node,
904 fy_node_t interp_method_node, char const * yaml_filename) {
905 char const * routine_name = "yaml_parse_base_interp_method_node";
906
908 fy_node_is_scalar(interp_method_node) ||
909 fy_node_is_mapping(interp_method_node),
910 "unsupported interpolation method node type "
911 "(interpolation methods are expected to be defined as either scalar "
912 "or maps)");
913
914 switch(fy_node_get_type(interp_method_node)) {
915 default:
916 case (FYNT_SCALAR):
917 *interpolation_type_str =
919 interp_method_node, "interpolation method name", yaml_filename);
920 *parameter_node = NULL;
921 break;
922
923 case (FYNT_MAPPING):
924
926 fy_node_mapping_item_count(interp_method_node) == 1,
927 "base interpolation method node is only allowed to have one pair ");
928
929 fy_node_pair_t base_interp_method_pair =
930 fy_node_mapping_get_by_index(interp_method_node, 0);
931
932 fy_node_t base_interp_method_key_node =
933 fy_node_pair_key(base_interp_method_pair);
934
935 *interpolation_type_str =
937 base_interp_method_key_node, "interpolation method name",
938 yaml_filename);
939
940 fy_node_t base_interp_method_value_node =
941 fy_node_pair_value(base_interp_method_pair);
942
944 fy_node_is_mapping(base_interp_method_value_node),
945 "unsupported base interpolation method value node type "
946 "for interpolation method \"%s\" "
947 "(interpolation method parameters are expected to be "
948 "defined as maps)", *interpolation_type_str);
949
950 *parameter_node = base_interp_method_value_node;
951 break;
952 }
953}
954
957 struct interp_method_parameter const * parameter,
958 fy_node_t value_node, char const * interpolation_name,
959 char const * yaml_filename) {
960 char const * routine_name = "yaml_parse_interp_method_parameter_value";
961
963 (parameter->type == ENUM_PARAM) ||
964 (parameter->type == INT_PARAM) ||
965 (parameter->type == DBLE_PARAM) ||
966 (parameter->type == DEG_PARAM) ||
967 (parameter->type == BOOL_PARAM) ||
968 (parameter->type == STR_PARAM),
969 "unsupported parameter type for interpolation method \"%s\"",
970 interpolation_name);
971
972 interp_method_parameter_value parameter_value;
973
974 switch(parameter->type) {
975 default:
976 case (ENUM_PARAM):
977 parameter_value.enum_value =
979 parameter->data.enum_param.valid_values,
981 value_node, "interpolation method enum parameter value",
982 yaml_filename);
983 break;
984 case (INT_PARAM):
985 parameter_value.int_value =
987 value_node, "interpolation method integer parameter value",
988 yaml_filename);
990 (parameter_value.int_value >= parameter->data.int_param.valid_min) &&
991 (parameter_value.int_value <= parameter->data.int_param.valid_max),
992 "\"%d\" is not a valid integer parameter value for parameter \"%s\" "
993 "of interpolation method \"%s\" "
994 "(valid range: %d <= value <= %d)",
995 parameter_value.int_value, parameter->name, interpolation_name,
996 parameter->data.int_param.valid_min,
997 parameter->data.int_param.valid_max);
998 break;
999 case (DBLE_PARAM):
1000 parameter_value.dble_value =
1002 value_node, "interpolation method double parameter value",
1003 yaml_filename);
1005 (parameter_value.dble_value >= parameter->data.dble_param.valid_min) &&
1006 (parameter_value.dble_value <= parameter->data.dble_param.valid_max),
1007 "\"%lf\" is not a valid double parameter value for parameter \"%s\" "
1008 "of interpolation method \"%s\" "
1009 "(valid range: %e <= value <= %e)",
1010 parameter_value.dble_value, parameter->name, interpolation_name,
1011 parameter->data.dble_param.valid_min,
1012 parameter->data.dble_param.valid_max);
1013 break;
1014 case (DEG_PARAM):
1015 parameter_value.dble_value =
1017 value_node, "interpolation method degree parameter value",
1018 yaml_filename);
1020 (parameter_value.dble_value >= parameter->data.dble_param.valid_min) &&
1021 (parameter_value.dble_value <= parameter->data.dble_param.valid_max),
1022 "\"%lf\" is not a valid degree parameter value for parameter \"%s\" "
1023 "of interpolation method \"%s\" "
1024 "(valid range: %e <= value <= %e)",
1025 parameter_value.dble_value, parameter->name, interpolation_name,
1026 parameter->data.dble_param.valid_min,
1027 parameter->data.dble_param.valid_max);
1028 parameter_value.dble_value *= YAC_RAD;
1029 break;
1030 case (BOOL_PARAM):
1031 parameter_value.bool_value =
1033 bool_names, num_bool_names, value_node,
1034 "interpolation method bool parameter value", yaml_filename);
1035 break;
1036 case (STR_PARAM):
1037 parameter_value.str_value =
1039 value_node, "interpolation method string parameter value",
1040 yaml_filename);
1042 strlen(parameter_value.str_value) <
1043 parameter->data.str_param.max_str_len,
1044 "\"%s\" is not a valid string parameter value for parameter \"%s\" "
1045 "of interpolation method \"%s\" "
1046 "(maximum string length: %d)",
1047 parameter_value.str_value, parameter->name, interpolation_name,
1048 (int)(parameter->data.str_param.max_str_len - 1));
1049 break;
1050 };
1051
1052 return parameter_value;
1053}
1054
1056 interp_method_parameter_value * parameter_values,
1057 struct interp_method_parameter const * parameters, size_t num_parameters,
1058 fy_node_pair_t parameter_pair, char const * interpolation_name,
1059 char const * parameter_name_prefix, char const * yaml_filename) {
1060 char const * routine_name = "yaml_parse_interp_method_parameter";
1061
1062 char const * parameter_name_ =
1064 fy_node_pair_key(parameter_pair),
1065 "interpolation method parameter name", yaml_filename);
1066
1067 char const * parameter_name;
1068 if (parameter_name_prefix) {
1069 parameter_name =
1070 xmalloc(strlen(parameter_name_prefix) + strlen(parameter_name_) + 2);
1071 sprintf(
1072 (char*)parameter_name, "%s:%s", parameter_name_prefix, parameter_name_);
1073 } else {
1074 parameter_name = parameter_name_;
1075 }
1076
1077 fy_node_t parameter_value_node =
1078 fy_node_pair_value(parameter_pair);
1079
1081 parameter_value_node &&
1082 (fy_node_is_scalar(parameter_value_node) ||
1083 fy_node_is_mapping(parameter_value_node)),
1084 "unsupported parameter node type for interpolation \"%s\" "
1085 "(the node is expected to be either scalar or a map)", interpolation_name);
1086
1087 if (fy_node_is_scalar(parameter_value_node)) {
1088
1089 int found_flag = 0;
1090 for (size_t i = 0; (i < num_parameters) && !found_flag; ++i)
1091 if ((found_flag = !strcmp(parameter_name, parameters[i].name)))
1092 parameter_values[i] =
1094 &parameters[i], fy_node_pair_value(parameter_pair),
1095 interpolation_name, yaml_filename);
1096
1098 found_flag,
1099 "\"%s\" is not a valid parameter for interpolation method \"%s\"",
1100 parameter_name, interpolation_name);
1101
1102 } else {
1103
1104 // parse parameter
1105 void * iter = NULL;
1106 fy_node_pair_t pair;
1107 while ((pair = fy_node_mapping_iterate(parameter_value_node, &iter)))
1109 parameter_values, parameters, num_parameters, pair, interpolation_name,
1110 parameter_name, yaml_filename);
1111 }
1112
1113 if (parameter_name_prefix) free((void*)parameter_name);
1114}
1115
1117 interp_method_parameter_value * parameter_values,
1118 struct yac_interpolation_method const * interp_method,
1119 fy_node_t parameter_node, char const * yaml_filename) {
1120 char const * routine_name = "yaml_parse_interp_method_parameters";
1121
1122 // set default parameter values
1123 for (size_t i = 0; i < interp_method->num_parameters; ++i)
1124 parameter_values[i] = interp_method->parameters[i].default_value;
1125
1126 // if there are no parameters
1127 if (!parameter_node) return;
1128
1130 fy_node_is_mapping(parameter_node),
1131 "unsupported interpolation method parameter node type "
1132 "for interpolation method \"%s\" "
1133 "(interpolation method parameters are expected to be defined as maps)",
1134 interp_method->name);
1135
1136 // parse parameter
1137 void * iter = NULL;
1138 fy_node_pair_t pair;
1139 while ((pair = fy_node_mapping_iterate(parameter_node, &iter)))
1141 parameter_values, interp_method->parameters,
1142 interp_method->num_parameters, pair, interp_method->name, NULL,
1143 yaml_filename);
1144}
1145
1147 struct yac_interp_stack_config * interp_stack,
1148 fy_node_t interp_method_node, char const * yaml_filename) {
1149 char const * routine_name = "yaml_parse_interp_method";
1150
1151 char const * interpolation_type_str;
1152 fy_node_t parameter_node;
1153
1155 &interpolation_type_str, &parameter_node,
1156 interp_method_node, yaml_filename);
1157
1158 struct yac_interpolation_method const * interp_method = NULL;
1159
1160 for (int i = 0; (i < NUM_INTERPOLATION_METHODS) && (!interp_method); ++i)
1161 if (!strcmp(interpolation_type_str, interpolation_methods[i].name))
1163
1166 "\"%s\" is not a valid interpolation method",
1167 interpolation_type_str);
1168
1170 interp_method_paramter_values[interp_method->num_parameters];
1172 interp_method_paramter_values, interp_method,
1173 parameter_node, yaml_filename);
1174 interp_method->add_interpolation(
1175 interp_stack, interp_method_paramter_values, yaml_filename);
1176}
1177
1179 struct yac_interp_stack_config * interp_stack,
1180 fy_node_t interp_stack_node, char const * yaml_filename) {
1181 char const * routine_name = "yaml_parse_interp_stack_value";
1182
1184 fy_node_is_sequence(interp_stack_node),
1185 "unsupported interpolation stack node type"
1186 "(interpolation stacks are expected to be defined as a sequence)");
1187
1188 // parse couplings
1189 void * iter = NULL;
1190 fy_node_t interp_stack_item;
1191 while ((interp_stack_item =
1192 fy_node_sequence_iterate(interp_stack_node, &iter)))
1194 interp_stack, interp_stack_item, yaml_filename);
1195}
1196
1197static struct field_couple_field_names yaml_parse_field_name(
1198 fy_node_t field_node, const char * yaml_filename) {
1199 char const * routine_name = "yaml_parse_field_name";
1200
1202 fy_node_is_scalar(field_node) ||
1203 fy_node_is_mapping(field_node),
1204 "unsupported field name node type "
1205 "(field name is either scalars or a map)");
1206
1207 struct field_couple_field_names field_name;
1208
1209 // if the node contains one name for both source and target field
1210 if (fy_node_is_scalar(field_node)) {
1211
1212 field_name.src =
1213 ((field_name.tgt =
1214 yaml_parse_string_value(field_node, "field name", yaml_filename)));
1215
1216 // if the node contains different names for the source and target field
1217 } else {
1218 field_name.src =
1219 fy_node_mapping_lookup_scalar0_by_simple_key(
1220 field_node, "src", (size_t)-1);
1221 field_name.tgt =
1222 fy_node_mapping_lookup_scalar0_by_simple_key(
1223 field_node, "tgt", (size_t)-1);
1224
1226 field_name.src && field_name.tgt &&
1227 (fy_node_mapping_item_count(field_node) == 2),
1228 "invalid field name mapping node "
1229 "(field name mapping node has to contain two maps "
1230 "with the keys \"src\" and \"tgt\")")
1231 }
1232
1233 return field_name;
1234}
1235
1237 char const *** values, size_t * num_values,
1238 fy_node_t values_node, char const * sequence_name,
1239 const char * yaml_filename) {
1240 char const * routine_name = "yaml_parse_string_sequence";
1241
1243 (*values == NULL) && (*num_values == 0),
1244 "values have already been set for sequence \"%s\"",
1245 sequence_name);
1246
1247 // if the field node contains multiple fields
1248 if (fy_node_is_sequence(values_node)) {
1249
1250 *num_values = (size_t)fy_node_sequence_item_count(values_node);
1251 *values = xmalloc(*num_values * sizeof(**values));
1252 for (size_t value_idx = 0; value_idx < *num_values; ++value_idx)
1253 (*values)[value_idx] =
1255 fy_node_sequence_get_by_index(values_node, value_idx),
1256 sequence_name, yaml_filename);
1257 } else {
1258 *num_values = 1;
1259 *values = xmalloc(sizeof(**values));
1260 **values =
1262 values_node, sequence_name, yaml_filename);
1263 }
1264}
1265
1267 struct field_couple_field_names ** field_names,
1268 size_t * num_field_names, fy_node_t fields_node,
1269 const char * yaml_filename) {
1270
1271 // if the field node contains multiple fields
1272 if (fy_node_is_sequence(fields_node)) {
1273
1274 size_t start_idx = *num_field_names;
1275 *num_field_names += (size_t)fy_node_sequence_item_count(fields_node);
1276 *field_names =
1277 xrealloc(*field_names, *num_field_names * sizeof(**field_names));
1278 for (size_t i = start_idx; i < *num_field_names; ++i)
1279 (*field_names)[i] =
1281 fy_node_sequence_get_by_index(fields_node, i), yaml_filename);
1282 } else {
1283 ++*num_field_names;
1284 *field_names =
1285 xrealloc(*field_names, *num_field_names * sizeof(**field_names));
1286 (*field_names)[*num_field_names-1] =
1287 yaml_parse_field_name(fields_node, yaml_filename);
1288 }
1289}
1290
1292 char const ** comp_name, char const *** grid_names, size_t * num_grid_names,
1293 fy_node_t values_node, char const * type_name, const char * yaml_filename) {
1294 char const * routine_name = "yaml_parse_comp_grids_names";
1295
1297 *comp_name == NULL, "%s component name already set", type_name);
1299 (*grid_names == NULL) && (*num_grid_names == 0),
1300 "%s grid names already set", type_name);
1301
1303 fy_node_is_mapping(values_node),
1304 "unsupported component/grid names node type (has to be a map)");
1305
1306 // parse component/grid names
1307 void * iter = NULL;
1308 fy_node_pair_t pair;
1309 while((pair = fy_node_mapping_iterate(values_node, &iter))) {
1310
1311 enum yaml_comp_grid_names_key_types comp_grid_names_key_type =
1314 yaml_comp_grid_names_keys, num_yaml_comp_grid_names_keys,
1315 fy_node_pair_key(pair),
1316 "component/grid names parameter name", yaml_filename);
1317 char const * comp_grid_names_key_name =
1319 yaml_comp_grid_names_keys, num_yaml_comp_grid_names_keys,
1320 comp_grid_names_key_type);
1321
1322 fy_node_t name_node = fy_node_pair_value(pair);
1323
1324 switch(comp_grid_names_key_type) {
1325 default:
1326 case(COMP_NAME):
1327 *comp_name =
1329 name_node, comp_grid_names_key_name, yaml_filename);
1330 break;
1331 case(GRID_NAMES):
1333 grid_names, num_grid_names,
1334 name_node, comp_grid_names_key_name, yaml_filename);
1335 break;
1336 }
1337 }
1338}
1339
1341 struct field_couple_buffer * field_buffer,
1342 fy_node_pair_t couple_pair, const char * yaml_filename,
1343 enum yac_time_unit_type time_unit) {
1344
1345 enum yaml_couple_key_types couple_key_type =
1348 yaml_couple_keys, num_yaml_couple_keys,
1349 fy_node_pair_key(couple_pair),
1350 "couple configuration parameter name", yaml_filename);
1351 char const * couple_key_name =
1353 yaml_couple_keys, num_yaml_couple_keys, couple_key_type);
1354
1355 fy_node_t value_node = fy_node_pair_value(couple_pair);
1356
1357 switch (couple_key_type) {
1358 default:
1359 case (SOURCE_NAMES):
1361 &(field_buffer->src.comp_name),
1362 &(field_buffer->src.grid.name),
1363 &(field_buffer->src.grid.count),
1364 value_node, couple_key_name, yaml_filename);
1365 break;
1366 case (SOURCE_COMPONENT):
1367 field_buffer->src.comp_name =
1368 yaml_parse_string_value(value_node, couple_key_name, yaml_filename);
1369 break;
1370 case (SOURCE_GRID):
1372 &field_buffer->src.grid.name, &field_buffer->src.grid.count,
1373 value_node, couple_key_name, yaml_filename);
1374 break;
1375 case (TARGET_NAMES):
1377 &(field_buffer->tgt.comp_name),
1378 &(field_buffer->tgt.grid.name),
1379 &(field_buffer->tgt.grid.count),
1380 value_node, couple_key_name, yaml_filename);
1381 break;
1382 case (TARGET_COMPONENT):
1383 field_buffer->tgt.comp_name =
1384 yaml_parse_string_value(value_node, couple_key_name, yaml_filename);
1385 break;
1386 case (TARGET_GRID):
1388 &field_buffer->tgt.grid.name, &field_buffer->tgt.grid.count,
1389 value_node, couple_key_name, yaml_filename);
1390 break;
1391 case (FIELD):
1393 &(field_buffer->field_names),
1394 &(field_buffer->num_field_names),
1395 value_node, yaml_filename);
1396 break;
1397 case (COUPLING_PERIOD):
1398 field_buffer->coupling_period =
1400 value_node, couple_key_name, yaml_filename, time_unit);
1401 break;
1402 case (TIME_REDUCTION):
1403 field_buffer->time_reduction =
1405 value_node, couple_key_name, yaml_filename);
1406 break;
1407 case (SOURCE_LAG):
1408 field_buffer->src.lag =
1410 value_node, couple_key_name, yaml_filename);
1411 break;
1412 case (TARGET_LAG):
1413 field_buffer->tgt.lag =
1415 value_node, couple_key_name, yaml_filename);
1416 break;
1417 case (WEIGHT_FILE_NAME):
1418 field_buffer->weight_file_name =
1420 value_node, couple_key_name, yaml_filename);
1421 break;
1422 case (MAPPING_SIDE):
1423 field_buffer->mapping_on_source =
1425 mapping_sides, num_mapping_sides,
1426 value_node, couple_key_name, yaml_filename);
1427 break;
1428 case (SCALE_FACTOR):
1429 field_buffer->scale_factor =
1431 value_node, couple_key_name, yaml_filename);
1432 break;
1433 case (SCALE_SUMMAND):
1434 field_buffer->scale_summand =
1436 value_node, couple_key_name, yaml_filename);
1437 break;
1438 case (INTERPOLATION):
1440 field_buffer->interp_stack, value_node, yaml_filename);
1441 break;
1442 case (SOURCE_MASK_NAME):
1443 case (SOURCE_MASK_NAMES):
1445 &(field_buffer->src_mask_names),
1446 &(field_buffer->num_src_mask_names),
1447 value_node, couple_key_name, yaml_filename);
1448 break;
1449 case (TARGET_MASK_NAME):
1450 field_buffer->tgt_mask_name =
1452 value_node, couple_key_name, yaml_filename);
1453 break;
1454 case (YAXT_EXCHANGER_NAME):
1455 field_buffer->yaxt_exchanger_name =
1457 value_node, couple_key_name, yaml_filename);
1458 break;
1459 }
1460}
1461
1463 struct yac_couple_config * couple_config, fy_node_t couple_node,
1464 char const * yaml_filename, enum yac_time_unit_type time_unit) {
1465 char const * routine_name = "yaml_parse_couple";
1466
1468 fy_node_is_mapping(couple_node),
1469 "unsupported couple node type "
1470 "(couples are expected to be defined as a mapping)");
1471
1472 // initialise field configuration buffer with default values
1473 struct field_couple_buffer field_buffer = {
1474 .src.comp_name = NULL,
1475 .src.grid.name = NULL,
1476 .src.grid.count = 0,
1477 .tgt.comp_name = NULL,
1478 .tgt.grid.name = NULL,
1479 .tgt.grid.count = 0,
1480 .field_names = NULL,
1481 .num_field_names = 0,
1482 .coupling_period = NULL,
1483 .time_reduction = TIME_NONE,
1484 .interp_stack = yac_interp_stack_config_new(),
1485 .src.lag = 0,
1486 .tgt.lag = 0,
1487 .weight_file_name = NULL,
1488 .mapping_on_source = 1,
1489 .scale_factor = 1.0,
1490 .scale_summand = 0.0,
1491 .src_mask_names = NULL,
1492 .num_src_mask_names = 0,
1493 .tgt_mask_name = NULL,
1494 .yaxt_exchanger_name = NULL};
1495
1496 // parse couple
1497 void * iter = NULL;
1498 fy_node_pair_t pair;
1499 while ((pair = fy_node_mapping_iterate(couple_node, &iter)))
1501 &field_buffer, pair, yaml_filename, time_unit);
1502
1504 field_buffer.src.comp_name, "missing source component name");
1506 field_buffer.src.grid.count > 0,
1507 "missing source grid name (component \"%s\")",
1508 field_buffer.src.comp_name);
1509 for (size_t i = 0; i < field_buffer.src.grid.count; ++i)
1511 (field_buffer.src.grid.name[i] != NULL) &&
1512 (field_buffer.src.grid.name[i][0] != '\0'),
1513 "invalid source grid name (component \"%s\" grid idx %zu)",
1514 field_buffer.src.comp_name, i);
1516 field_buffer.tgt.comp_name,
1517 "missing target component name");
1519 field_buffer.tgt.grid.count > 0,
1520 "missing target grid name (component \"%s\")",
1521 field_buffer.tgt.comp_name);
1522 for (size_t i = 0; i < field_buffer.tgt.grid.count; ++i)
1524 (field_buffer.tgt.grid.name[i] != NULL) &&
1525 (field_buffer.tgt.grid.name[i][0] != '\0'),
1526 "invalid target grid name (component \"%s\" grid idx %zu)",
1527 field_buffer.tgt.comp_name, i);
1529 field_buffer.num_field_names > 0,
1530 "missing field names "
1531 "(source component \"%s\" source grid \"%s\" "
1532 "target component \"%s\" target grid \"%s\")",
1533 field_buffer.src.comp_name, field_buffer.src.grid.name[0],
1534 field_buffer.tgt.comp_name, field_buffer.tgt.grid.name[0]);
1536 field_buffer.coupling_period,
1537 "missing coupling period "
1538 "(source component \"%s\" source grid \"%s\" "
1539 "target component \"%s\" target grid \"%s\")",
1540 field_buffer.src.comp_name, field_buffer.src.grid.name[0],
1541 field_buffer.tgt.comp_name, field_buffer.tgt.grid.name[0]);
1542
1543 for (size_t i = 0; i < field_buffer.num_field_names; ++i)
1544 for (size_t j = 0; j < field_buffer.src.grid.count; ++j)
1545 for (size_t k = 0; k < field_buffer.tgt.grid.count; ++k)
1547 couple_config,
1548 field_buffer.src.comp_name,
1549 field_buffer.src.grid.name[j],
1550 field_buffer.field_names[i].src,
1551 field_buffer.tgt.comp_name,
1552 field_buffer.tgt.grid.name[k],
1553 field_buffer.field_names[i].tgt,
1554 field_buffer.coupling_period,
1555 field_buffer.time_reduction,
1556 field_buffer.interp_stack,
1557 field_buffer.src.lag,
1558 field_buffer.tgt.lag,
1559 field_buffer.weight_file_name,
1560 field_buffer.mapping_on_source,
1561 field_buffer.scale_factor,
1562 field_buffer.scale_summand,
1563 field_buffer.num_src_mask_names,
1564 field_buffer.src_mask_names,
1565 field_buffer.tgt_mask_name,
1566 field_buffer.yaxt_exchanger_name);
1567
1568 // cleanup
1569 free((void*)field_buffer.src.grid.name);
1570 free((void*)field_buffer.tgt.grid.name);
1571 free((void*)field_buffer.field_names);
1572 free((void*)field_buffer.coupling_period);
1574 free((void*)field_buffer.src_mask_names);
1575}
1576
1578 struct yac_couple_config * couple_config,
1579 fy_node_t coupling_node, char const * yaml_filename,
1580 enum yac_time_unit_type time_unit) {
1581 char const * routine_name = "yaml_parse_coupling";
1582
1583 // check if the coupling node is empty -> nothing to be read
1584 if (!coupling_node) return;
1585
1587 fy_node_is_sequence(coupling_node),
1588 "unsupported coupling node type "
1589 "(couplings are expected to be defined as a sequence)");
1590
1591 // parse couplings
1592 void * iter = NULL;
1593 fy_node_t couple_node;
1594 while ((couple_node = fy_node_sequence_iterate(coupling_node, &iter)))
1595 yaml_parse_couple(couple_config, couple_node, yaml_filename, time_unit);
1596}
1597
1598static struct debug_config_file yaml_parse_config_file_value(
1599 fy_node_t config_file_node, char const * file_type_name,
1600 const char * yaml_filename) {
1601 char const * routine_name = "yaml_parse_config_file_value";
1602
1604 fy_node_is_scalar(config_file_node) ||
1605 fy_node_is_mapping(config_file_node),
1606 "unsupported config file node type "
1607 "(%s is either scalar or a map)", file_type_name);
1608
1609 struct debug_config_file config_file =
1610 {.name = NULL, .type = YAC_TEXT_FILETYPE_YAML, .include_definitions = 0};
1611
1612 char * str_buffer = xmalloc(strlen(file_type_name) + 32);
1613
1614 // if the node contains only the filename
1615 if (fy_node_is_scalar(config_file_node)) {
1616
1617 config_file.name =
1619 config_file_node,
1620 strcat(strcpy(str_buffer, file_type_name), " name"),
1621 yaml_filename);
1622
1623 // if the node contains the name and the type
1624 } else {
1625
1626 fy_node_t filename_node =
1627 fy_node_mapping_lookup_by_string(
1628 config_file_node, "filename", (size_t)-1);
1629 fy_node_t filetype_node =
1630 fy_node_mapping_lookup_by_string(
1631 config_file_node, "filetype", (size_t)-1);
1632 fy_node_t include_definitions_node =
1633 fy_node_mapping_lookup_by_string(
1634 config_file_node, "include_definitions", (size_t)-1);
1635
1637 filename_node,
1638 "invalid %s mapping node "
1639 "(global config file mapping node has to include a map "
1640 "with the keys \"filename\")", file_type_name)
1641
1642 config_file.name =
1644 filename_node, strcat(strcpy(str_buffer, file_type_name), " name"),
1645 yaml_filename);
1646 config_file.type =
1647 (filetype_node)?
1648 (enum yac_text_filetype)
1650 config_filetypes, num_config_filetypes,
1651 filetype_node, strcat(strcpy(str_buffer, file_type_name), " type"),
1652 yaml_filename):YAC_TEXT_FILETYPE_YAML;
1653 config_file.include_definitions =
1654 (include_definitions_node)?
1656 bool_names, num_bool_names,
1657 include_definitions_node,
1658 strcat(strcpy(str_buffer, file_type_name), " include definitions"),
1659 yaml_filename):0;
1660 }
1661
1663 config_file.name, "missing filename for %s", file_type_name);
1664
1665 free(str_buffer);
1666
1667 return config_file;
1668}
1669
1671 struct debug_config_file_buffer * config_file_buffer,
1672 fy_node_pair_t config_file_pair, char const * config_file_type_name,
1673 const char * yaml_filename) {
1674
1676 debug_sync_loc_key_type =
1679 yaml_debug_sync_loc_keys,
1680 num_yaml_debug_sync_loc_keys,
1681 fy_node_pair_key(config_file_pair),
1682 "config synchronisation location parameter name",
1683 yaml_filename);
1684 char const * debug_sync_loc_key_name =
1686 yaml_debug_sync_loc_keys, num_yaml_debug_sync_loc_keys,
1687 debug_sync_loc_key_type);
1688
1689 fy_node_t value_node = fy_node_pair_value(config_file_pair);
1690
1691 char config_file_type_name_sync[
1692 strlen(config_file_type_name) + strlen(debug_sync_loc_key_name) + 8];
1693 sprintf(
1694 config_file_type_name_sync, "%s (%s)",
1695 config_file_type_name, debug_sync_loc_key_name);
1696
1697 config_file_buffer->config_file[debug_sync_loc_key_type] =
1699 value_node, config_file_type_name_sync, yaml_filename);
1700}
1701
1703 fy_node_t config_file_node, char const * config_file_type_name,
1704 char const * yaml_filename) {
1705 char const * routine_name = "yaml_parse_debug_config_file_buffer";
1706
1708 fy_node_is_mapping(config_file_node),
1709 "unsupported %s node type "
1710 "(%s is expected to be defined as a mapping)",
1711 config_file_type_name, config_file_type_name);
1712
1713 struct debug_config_file_buffer config_file_buffer;
1714 config_file_buffer.sync_loc_ref[SYNC_LOC_DEF_COMP] =
1716 config_file_buffer.sync_loc_ref[SYNC_LOC_SYNC_DEF] =
1718 config_file_buffer.sync_loc_ref[SYNC_LOC_ENDDEF] =
1720 for (int i = 0; i < SYNC_LOC_COUNT; ++i) {
1721 config_file_buffer.config_file[i].name = NULL;
1722 config_file_buffer.config_file[i].type = YAC_TEXT_FILETYPE_YAML;
1723 config_file_buffer.config_file[i].include_definitions = 0;
1725 config_file_buffer.sync_loc_ref[i] != NULL,
1726 "invalid unsupported synchronisation location (%d) for %s",
1727 i, config_file_type_name);
1728 }
1729
1730 // parse couplings
1731 void * iter = NULL;
1732 fy_node_pair_t pair;
1733 while ((pair = fy_node_mapping_iterate(config_file_node, &iter)))
1735 &config_file_buffer, pair, config_file_type_name, yaml_filename);
1736
1737 return config_file_buffer;
1738}
1739
1741 struct yac_couple_config * couple_config, fy_node_t global_config_node,
1742 char const * yaml_filename) {
1743 char const * routine_name = "yaml_parse_debug_global_config";
1744
1745 char const * config_file_type_name = "debug global config file";
1746
1748 fy_node_is_mapping(global_config_node),
1749 "unsupported %s node type "
1750 "(%s is expected to be defined as a mapping)",
1751 config_file_type_name, config_file_type_name);
1752
1753 struct debug_config_file_buffer global_config_buffer =
1755 global_config_node, config_file_type_name, yaml_filename);
1756
1757
1758 for (int i = 0; i < SYNC_LOC_COUNT; ++i)
1759 if (global_config_buffer.config_file[i].name != NULL)
1761 couple_config, global_config_buffer.config_file[i].name,
1762 global_config_buffer.config_file[i].type,
1763 global_config_buffer.sync_loc_ref[i],
1764 global_config_buffer.config_file[i].include_definitions);
1765}
1766
1768 char const ** grid_name, char const ** file_name,
1769 fy_node_pair_t output_grid_pair, char const * yaml_filename) {
1770
1771 enum yaml_debug_output_grid_key_types output_grid_key_type =
1774 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
1775 fy_node_pair_key(output_grid_pair),
1776 "output grid parameter name", yaml_filename);
1777 char const * debug_output_key_name =
1779 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
1780 output_grid_key_type);
1781
1782 fy_node_t value_node = fy_node_pair_value(output_grid_pair);
1783
1784 switch(output_grid_key_type) {
1785 default:
1786 case(OUTPUT_GRID_GRID_NAME): {
1787 *grid_name =
1788 yaml_parse_string_value(value_node, debug_output_key_name, yaml_filename);
1789 break;
1790 }
1791 case(OUTPUT_GRID_FILE_NAME): {
1792 *file_name =
1793 yaml_parse_string_value(value_node, debug_output_key_name, yaml_filename);
1794 break;
1795 }
1796 };
1797}
1798
1800 struct yac_couple_config * couple_config, fy_node_t output_grid_node,
1801 char const * yaml_filename) {
1802 char const * routine_name = "yaml_parse_output_grid";
1803
1805 fy_node_is_mapping(output_grid_node),
1806 "unsupported output grid node type "
1807 "(output grids are expected to be defined as a mapping)");
1808
1809 char const * grid_name = NULL;
1810 char const * file_name = NULL;
1811
1812 // parse output grid
1813 void * iter = NULL;
1814 fy_node_pair_t pair;
1815 while ((pair = fy_node_mapping_iterate(output_grid_node, &iter)))
1816 yaml_parse_output_grid_pair(&grid_name, &file_name, pair, yaml_filename);
1817
1818 YAML_ASSERT(grid_name, "missing grid name");
1819 YAML_ASSERT_F(file_name, "missing file name for grid \"%s\"", grid_name);
1820
1821 yac_couple_config_add_grid(couple_config, grid_name);
1823 couple_config, grid_name, file_name);
1824}
1825
1827 struct yac_couple_config * couple_config, fy_node_t output_grids_node,
1828 char const * yaml_filename) {
1829 char const * routine_name = "yaml_parse_debug_output_grids";
1830
1832 fy_node_is_sequence(output_grids_node),
1833 "unsupported debug output grids node type "
1834 "(debug output grids is expected to be defined as a sequence)");
1835
1836 // parse output grids
1837 void * iter = NULL;
1838 fy_node_t output_grid_node;
1839 while ((output_grid_node =
1840 fy_node_sequence_iterate(output_grids_node, &iter)))
1842 couple_config, output_grid_node, yaml_filename);
1843}
1844
1846 struct yac_couple_config * couple_config, fy_node_pair_t debug_pair,
1847 const char * yaml_filename) {
1848
1849 enum yaml_debug_key_types debug_key_type =
1852 yaml_debug_keys, num_yaml_debug_keys,
1853 fy_node_pair_key(debug_pair),
1854 "debug configuration parameter name", yaml_filename);
1855
1856 fy_node_t value_node = fy_node_pair_value(debug_pair);
1857
1858 switch (debug_key_type) {
1859 default:
1860 case(GLOBAL_CONFIG):
1862 couple_config, value_node, yaml_filename);
1863 break;
1864 case(OUTPUT_GRIDS):
1866 couple_config, value_node, yaml_filename);
1867 break;
1868 case(MISSING_DEF):
1870 couple_config,
1872 bool_names, num_bool_names, value_node,
1873 "\"missing definition is fatal\" bool value", yaml_filename));
1874 break;
1875 };
1876}
1877
1879 struct yac_couple_config * couple_config,
1880 fy_node_t debug_node, char const * yaml_filename) {
1881 char const * routine_name = "yaml_parse_debug";
1882
1883 // check if the debug node is empty -> nothing to be read
1884 if (!debug_node) return;
1885
1887 fy_node_is_mapping(debug_node),
1888 "unsupported debug node type "
1889 "(debug is expected to be defined as a mapping)");
1890
1891 // parse couplings
1892 void * iter = NULL;
1893 fy_node_pair_t pair;
1894 while ((pair = fy_node_mapping_iterate(debug_node, &iter)))
1895 yaml_parse_debug_map_pair(couple_config, pair, yaml_filename);
1896}
1897
1899 struct yac_couple_config * couple_config, fy_node_pair_t base_pair,
1900 const char * yaml_filename, enum yac_time_unit_type * time_unit,
1901 char const ** start_datetime, char const ** end_datetime) {
1902 char const * routine_name = "yaml_parse_base_map_pair";
1903
1904 fy_node_t key_node = fy_node_pair_key(base_pair);
1905
1907 fy_node_is_scalar(key_node),
1908 "unsupported key node type "
1909 "(key nodes are expected to be scalar nodes)");
1910
1911 char const * base_key_name = fy_node_get_scalar0(key_node);
1912 int base_key_type =
1914 yaml_base_keys, num_yaml_base_keys, base_key_name);
1915
1917 (base_key_type == INT_MAX) || // for unknown keys, which are skipped
1918 (base_key_type == START_DATE) ||
1919 (base_key_type == END_DATE) ||
1920 (base_key_type == CALENDAR) ||
1921 (base_key_type == TIMESTEP_UNIT) ||
1922 (base_key_type == COUPLING) ||
1923 (base_key_type == DEBUG),
1924 "unsupported base key name \"%s\"",
1925 base_key_name);
1926
1927 fy_node_t value_node = fy_node_pair_value(base_pair);
1928
1929 switch (base_key_type) {
1930 case (START_DATE):
1931 *start_datetime =
1933 value_node, base_key_name, yaml_filename);
1934 break;
1935 case (END_DATE):
1936 *end_datetime =
1938 value_node, base_key_name, yaml_filename);
1939 break;
1940 case (CALENDAR):
1943 value_node, base_key_name, yaml_filename));
1944 break;
1945 case (TIMESTEP_UNIT): {
1946 enum yac_time_unit_type time_unit_ =
1948 value_node, base_key_name, yaml_filename);
1950 (*time_unit == TIME_UNIT_UNDEFINED) || (*time_unit == time_unit_),
1951 "inconsistent redefinition of time unit")
1952 *time_unit = time_unit_;
1953 break;
1954 }
1955 case (COUPLING):
1957 (*time_unit != TIME_UNIT_UNDEFINED),
1958 "time unit has to be defined before the couplings")
1960 couple_config, value_node, yaml_filename, *time_unit);
1961 break;
1962 case (DEBUG):
1964 couple_config, value_node, yaml_filename);
1965 default:
1966 // nothing to be done
1967 break;
1968 }
1969}
1970
1972 struct yac_couple_config * couple_config, fy_document_t document,
1973 const char * yaml_filename) {
1974 char const * routine_name = "yaml_parse_document";
1975
1976 // get root node of document
1977 fy_node_t root_node = fy_document_root(document);
1978
1979 // if the configuration file is empty
1980 if (!root_node) return;
1981
1983 fy_node_is_mapping(root_node),
1984 "unsupported root node type (root node is expected to be a mapping node)");
1985
1986 char const * start_datetime = NULL;
1987 char const * end_datetime = NULL;
1988
1989 // parse base root mappings
1990 enum yac_time_unit_type time_unit = TIME_UNIT_UNDEFINED;
1991 void * iter = NULL;
1992 fy_node_pair_t pair;
1993 while ((pair = fy_node_mapping_iterate(root_node, &iter)))
1995 couple_config, pair, yaml_filename, &time_unit,
1996 &start_datetime, &end_datetime);
1997
1998 if ((start_datetime != NULL) || (end_datetime != NULL)) {
1999
2000 YAC_ASSERT(
2002 "ERROR(yaml_parse_document): "
2003 "cannot set start/end datetime because calendar has not yet been set");
2004
2006 couple_config, start_datetime, end_datetime);
2007 }
2008}
2009
2011 struct yac_couple_config * couple_config, const char * yaml_filename,
2012 int parse_flags) {
2013 char const * routine_name = "yac_yaml_read_coupling";
2014
2015 // check whether the yaml configuration file exists
2017 yac_file_exists(yaml_filename),
2018 "ERROR(%s): YAML configuration file could not be found \"%s\"",
2019 routine_name, yaml_filename);
2020
2021 // open yaml configuration file
2022 FILE * config_file = xfopen(yaml_filename, "r");
2025 "ERROR(%s): could not open YAML configuration file \"%s\"",
2026 routine_name, yaml_filename);
2027
2028 // parse yaml configuration file into document
2029 struct fy_parse_cfg parse_config =
2030 {.search_path = ".",
2031 .userdata = NULL,
2032 .diag = NULL};
2033 parse_config.flags =
2034 (enum fy_parse_cfg_flags)parse_flags;
2035
2036 fy_document_t document =
2037 fy_document_build_from_fp(&parse_config, config_file);
2039 document,
2040 "ERROR(%s): could not parse YAML configuration file \"%s\"",
2041 routine_name, yaml_filename);
2042
2043 // resolve anchors and merge keys
2045 !fy_document_resolve(document),
2046 "could not resolve anchors and merge keys");
2047
2048 // parse document into couple configuration
2049 yaml_parse_document(couple_config, document, yaml_filename);
2050
2051 // cleanup
2052 fy_document_destroy(document);
2053 xfclose(config_file);
2054
2055 return;
2056}
2057
2060 char const * str_interp_stack_config, int parse_flags) {
2061 char const * routine_name =
2062 "yac_yaml_parse_interp_stack_config_string";
2063 char const * yaml_filename =
2064 "user provided interp stack config string";
2065
2067 str_interp_stack_config != NULL, "interpolation stack string is NULL");
2068
2069 // parse string into document
2070 struct fy_parse_cfg parse_config =
2071 {.search_path = ".",
2072 .userdata = NULL,
2073 .diag = NULL};
2074 parse_config.flags =
2075 (enum fy_parse_cfg_flags)parse_flags;
2076
2077 fy_document_t document =
2078 fy_document_build_from_string(
2079 &parse_config, str_interp_stack_config, (size_t)-1);
2080 YAML_ASSERT(document, "failed parsing");
2081
2082 // resolve anchors and merge keys
2084 !fy_document_resolve(document),
2085 "could not resolve anchors and merge keys");
2086
2087 fy_node_t interp_stack_config_node = fy_document_root(document);
2088 YAML_ASSERT(interp_stack_config_node, "invalid root node");
2089
2090 struct yac_interp_stack_config * interp_stack_config =
2092
2094 interp_stack_config, interp_stack_config_node,
2095 yaml_filename);
2096
2097 // cleanup
2098 fy_document_destroy(document);
2099
2100 return interp_stack_config;
2101}
2102
2104 fy_document_t document, char const * value) {
2105
2106 // return NULL if value is empty
2107 if (!value) return (fy_node_t)NULL;
2108
2109 fy_node_t scalar_node =
2110 fy_node_create_scalar_copy(document, value, strlen(value));
2111 YAC_ASSERT(
2112 scalar_node,
2113 "ERROR(yac_yaml_create_scalar): failed to create scalar node");
2114
2115 return scalar_node;
2116}
2117
2119 fy_document_t document, int value) {
2120
2121 char str_value[16];
2122 int value_size = snprintf(str_value, sizeof(str_value), "%d", value);
2124 (value_size >= 0) && ((size_t)value_size < sizeof(str_value)),
2125 "ERROR(yac_yaml_create_scalar_int): "
2126 "could not write \"%d\" to string buffer of size %zu",
2127 value, sizeof(str_value));
2128
2129 return yac_yaml_create_scalar(document, str_value);
2130}
2131
2133 fy_document_t document, double value) {
2134
2135 char str_value[32];
2136 int value_size = snprintf(str_value, sizeof(str_value), "%g", value);
2138 (value_size >= 0) && ((size_t)value_size < sizeof(str_value)),
2139 "ERROR(yac_yaml_create_scalar_dble): "
2140 "could not write \"%g\" to string buffer of size %zu",
2141 value, sizeof(str_value));
2142
2143 return yac_yaml_create_scalar(document, str_value);
2144}
2145
2147 fy_document_t document, char const * const * values, size_t num_values) {
2148
2149 // return NULL if sequence is empty
2150 if (num_values == 0) return (fy_node_t)NULL;
2151
2152 YAC_ASSERT(
2153 values, "ERROR(yac_yaml_create_sequence_scalar): no values provided");
2154
2155 // create sequence node
2156 fy_node_t sequence_node = fy_node_create_sequence(document);
2157 YAC_ASSERT(
2158 sequence_node, "ERROR(yac_yaml_create_sequence_scalar): "
2159 "failed to create sequence node");
2160
2161 for (size_t value_idx = 0; value_idx < num_values; ++value_idx) {
2162 char const * value = values[value_idx];
2164 value, "ERROR(yac_yaml_create_sequence_scalar): "
2165 "invalid value at idx %zu", value_idx);
2166 int appending_failed =
2167 fy_node_sequence_append(
2168 sequence_node, yac_yaml_create_scalar(document, value));
2169 YAC_ASSERT(
2170 !appending_failed, "ERROR(yac_yaml_create_sequence_scalar): "
2171 "failed to append interpolation node");
2172 }
2173
2174 return sequence_node;
2175}
2176
2178 fy_node_t map, char const * key, fy_node_t value) {
2179
2180 // if the value node is empty, return
2181 if (!value) return;
2182
2183 YAC_ASSERT(
2184 key, "ERROR(yac_yaml_map_append): NULL key is not supported");
2185
2186 fy_document_t document = fy_node_document(map);
2187 YAC_ASSERT(
2188 document,
2189 "ERROR(yac_yaml_map_append): failed to get document from node");
2190
2191 // set key and value for root node
2192 int appending_failed =
2193 fy_node_mapping_append(
2194 map, yac_yaml_create_scalar(document, key), value);
2195 YAC_ASSERT(
2196 !appending_failed,
2197 "ERROR(yac_yaml_map_append): failed to append mapping node pair");
2198}
2199
2201 fy_node_t map, char const * key, char const * value) {
2202
2203 fy_document_t document = fy_node_document(map);
2204 YAC_ASSERT(
2205 document, "ERROR(yac_yaml_map_append_scalar): "
2206 "failed to get document from node");
2207
2209}
2210
2212 fy_node_t map, char const * key, int value) {
2213
2214 fy_document_t document = fy_node_document(map);
2215 YAC_ASSERT(
2216 document, "ERROR(yac_yaml_map_append_scalar_int): "
2217 "failed to get document from node");
2218
2220 map, key, yac_yaml_create_scalar_int(document, value));
2221}
2222
2224 fy_node_t map, char const * key, double value) {
2225
2226 fy_document_t document = fy_node_document(map);
2227 YAC_ASSERT(
2228 document, "ERROR(yac_yaml_map_append_scalar_dble): "
2229 "failed to get document from node");
2230
2232 map, key, yac_yaml_create_scalar_dble(document, value));
2233}
2234
2236 fy_document_t document, struct yac_couple_config * couple_config,
2237 size_t couple_idx, size_t field_couple_idx) {
2238
2239 const char * src_field_name;
2240 const char * tgt_field_name;
2242 couple_config, couple_idx, field_couple_idx,
2243 &src_field_name, &tgt_field_name);
2244
2245 // if both names are identical
2246 if (!strcmp(src_field_name, tgt_field_name))
2247 return yac_yaml_create_scalar(document, src_field_name);
2248
2249 // create field name node
2250 fy_node_t field_name_node = fy_node_create_mapping(document);
2251 YAC_ASSERT(
2252 field_name_node, "ERROR(yac_yaml_create_field_name_node): "
2253 "failed to create mapping node");
2254
2255 // add source field name
2256 yac_yaml_map_append_scalar(field_name_node, "src", src_field_name);
2257
2258 // add target field name
2259 yac_yaml_map_append_scalar(field_name_node, "tgt", tgt_field_name);
2260
2261 return field_name_node;
2262}
2263
2265 fy_node_t map,
2266 struct interp_method_parameter const * parameter,
2268
2269 YAC_ASSERT(
2270 (parameter->type == ENUM_PARAM) ||
2271 (parameter->type == INT_PARAM) ||
2272 (parameter->type == DBLE_PARAM) ||
2273 (parameter->type == BOOL_PARAM) ||
2274 (parameter->type == STR_PARAM) ||
2275 (parameter->type == DEG_PARAM),
2276 "ERROR(yac_yaml_map_append_parameter): unsupported parameter type");
2277
2278 char const * key = parameter->name;
2279
2280 switch (parameter->type) {
2281 default:
2282 case (ENUM_PARAM): {
2284 map, key,
2286 parameter->data.enum_param.valid_values,
2287 parameter->data.enum_param.num_valid_values,
2288 value.enum_value));
2289 break;
2290 }
2291 case (INT_PARAM): {
2292 yac_yaml_map_append_scalar_int(map, key, value.int_value);
2293 break;
2294 }
2295 case (DEG_PARAM):
2296 case (DBLE_PARAM): {
2297 yac_yaml_map_append_scalar_dble(map, key, value.dble_value);
2298 break;
2299 }
2300 case (BOOL_PARAM): {
2302 map, key,
2304 bool_names, num_bool_names, value.bool_value));
2305 break;
2306 }
2307 case (STR_PARAM): {
2308 yac_yaml_map_append_scalar(map, key, value.str_value);
2309 break;
2310 }
2311 };
2312}
2313
2318
2319 YAC_ASSERT(
2320 (type == ENUM_PARAM) ||
2321 (type == INT_PARAM) ||
2322 (type == DBLE_PARAM) ||
2323 (type == BOOL_PARAM) ||
2324 (type == STR_PARAM) ||
2325 (type == DEG_PARAM),
2326 "ERROR(compare_parameter_values): "
2327 "invalid interpolation method parameter value type");
2328
2329 switch (type) {
2330 default:
2331 case (ENUM_PARAM):
2332 return
2333 (a->enum_value > b->enum_value) - (a->enum_value < b->enum_value);
2334 case (INT_PARAM):
2335 return
2336 (a->int_value > b->int_value) - (a->int_value < b->int_value);
2337 case (DEG_PARAM):
2338 case (DBLE_PARAM):
2339 return
2340 (a->dble_value > b->dble_value) - (a->dble_value < b->dble_value);
2341 case (BOOL_PARAM):
2342 return
2343 (a->bool_value > b->bool_value) - (a->bool_value < b->bool_value);
2344 case (STR_PARAM):
2345 if ((a->str_value != NULL) && (b->str_value != NULL))
2346 return strcmp(a->str_value, b->str_value);
2347 else
2348 return (a->str_value != NULL) - (b->str_value != NULL);
2349 }
2350}
2351
2353 fy_document_t document,
2354 union yac_interp_stack_config_entry const * interp_stack_entry) {
2355
2356 enum yac_interpolation_list interp_type =
2357 yac_interp_stack_config_entry_get_type(interp_stack_entry);
2358
2359 struct yac_interpolation_method const * interp_method = NULL;
2360 for (size_t i = 0;
2362 if (interpolation_methods[i].type == interp_type)
2364
2365 struct interp_method_parameter const * parameters =
2366 interp_method->parameters;
2367 size_t num_parameters = interp_method->num_parameters;
2368
2370 parameter_values[MAX(num_parameters,1)];
2371 for (size_t param_idx = 0; param_idx < num_parameters; ++param_idx)
2372 parameter_values[param_idx] = parameters[param_idx].default_value;
2373
2374 interp_method->get_interpolation(interp_stack_entry, parameter_values);
2375
2376 // create parameter node
2377 fy_node_t parameter_node = fy_node_create_mapping(document);
2378 YAC_ASSERT(
2379 parameter_node, "ERROR(yac_yaml_create_interpolation_node): "
2380 "failed to create mapping node");
2381
2382 size_t num_non_default_parameters = 0;
2383 for (size_t param_idx = 0; param_idx < num_parameters; ++param_idx) {
2385 &parameters[param_idx].default_value,
2386 parameter_values + param_idx, parameters[param_idx].type)) {
2387 ++num_non_default_parameters;
2389 parameter_node, parameters + param_idx,
2390 parameter_values[param_idx]);
2391 }
2392 }
2393
2394 fy_node_t interpolation_node;
2395 if (num_non_default_parameters) {
2396
2397 // create interpolation node
2398 interpolation_node = fy_node_create_mapping(document);
2399 YAC_ASSERT(
2400 interpolation_node, "ERROR(yac_yaml_create_interpolation_node): "
2401 "failed to create mapping node");
2402
2404 interpolation_node, interp_method->name, parameter_node);
2405 } else {
2406
2407 // free parameter node
2408 fy_node_free(parameter_node);
2409
2410 interpolation_node =
2411 yac_yaml_create_scalar(document, interp_method->name);
2412 }
2413
2414 return interpolation_node;
2415}
2416
2418 fy_document_t document, struct yac_couple_config * couple_config,
2419 size_t couple_idx, size_t field_couple_idx) {
2420
2421 struct yac_interp_stack_config * interp_stack =
2423 couple_config, couple_idx, field_couple_idx);
2424
2425 YAC_ASSERT(
2426 interp_stack, "ERROR(yac_yaml_create_interpolation_stack_node): "
2427 "invalid interpolation stack");
2428
2429 // create interpolation stack node
2430 fy_node_t interp_stack_node = fy_node_create_sequence(document);
2431 YAC_ASSERT(
2432 interp_stack_node, "ERROR(yac_yaml_create_interpolation_stack_node): "
2433 "failed to create sequence node");
2434
2435 size_t interp_stack_size =
2437 YAC_ASSERT(
2438 interp_stack_size, "ERROR(yac_yaml_create_interpolation_stack_node): "
2439 "invalid interpolation stack size");
2440
2441 for (size_t interp_stack_idx = 0; interp_stack_idx < interp_stack_size;
2442 ++interp_stack_idx) {
2443 int appending_failed =
2444 fy_node_sequence_append(
2445 interp_stack_node,
2447 document,
2449 interp_stack, interp_stack_idx)));
2450 YAC_ASSERT(
2451 !appending_failed,
2452 "ERROR(yac_yaml_create_interpolation_stack_node): "
2453 "failed to append interpolation node");
2454 }
2455
2456 return interp_stack_node;
2457}
2458
2460 fy_node_t coupling_node, struct yac_couple_config * couple_config,
2461 size_t couple_idx, size_t field_couple_idx) {
2462
2463 fy_document_t document = fy_node_document(coupling_node);
2464 YAC_ASSERT(
2465 document, "ERROR(yac_yaml_append_couple_field_nodes): "
2466 "failed to get document from node");
2467
2468 // create couple node
2469 fy_node_t field_couple_node = fy_node_create_mapping(document);
2470 YAC_ASSERT(
2471 coupling_node, "ERROR(yac_yaml_append_couple_field_nodes): "
2472 "failed to create mapping node");
2473
2474 // get component names
2475 char const * src_component_name;
2476 char const * tgt_component_name;
2478 couple_config, couple_idx, field_couple_idx,
2479 &src_component_name, &tgt_component_name);
2480
2481 // add source component name
2483 field_couple_node,
2485 yaml_couple_keys, num_yaml_couple_keys, SOURCE_COMPONENT),
2486 src_component_name);
2487
2488 // add target component name
2490 field_couple_node,
2492 yaml_couple_keys, num_yaml_couple_keys, TARGET_COMPONENT),
2493 tgt_component_name);
2494
2495 // get grid names
2496 char const * src_grid_name;
2497 char const * tgt_grid_name;
2499 couple_config, couple_idx, field_couple_idx,
2500 &src_grid_name, &tgt_grid_name);
2501
2502 // add source grid name
2504 field_couple_node,
2506 yaml_couple_keys, num_yaml_couple_keys, SOURCE_GRID),
2507 src_grid_name);
2508
2509 // add target grid name
2511 field_couple_node,
2513 yaml_couple_keys, num_yaml_couple_keys, TARGET_GRID),
2514 tgt_grid_name);
2515
2516 // add field names
2518 field_couple_node,
2520 yaml_couple_keys, num_yaml_couple_keys, FIELD),
2522 document, couple_config, couple_idx, field_couple_idx));
2523
2524 // add coupling period
2526 field_couple_node,
2528 yaml_couple_keys, num_yaml_couple_keys, COUPLING_PERIOD),
2530 couple_config, couple_idx, field_couple_idx));
2531
2532 // add time reduction
2534 field_couple_node,
2536 yaml_couple_keys, num_yaml_couple_keys, TIME_REDUCTION),
2538 time_operations, num_time_operations,
2540 couple_config, couple_idx, field_couple_idx)));
2541
2542 // add source lag
2544 field_couple_node,
2546 yaml_couple_keys, num_yaml_couple_keys, SOURCE_LAG),
2548 couple_config, couple_idx, field_couple_idx));
2549
2550 // add target lag
2552 field_couple_node,
2554 yaml_couple_keys, num_yaml_couple_keys, TARGET_LAG),
2556 couple_config, couple_idx, field_couple_idx));
2557
2558 // add weight file name
2560 couple_config, couple_idx, field_couple_idx))
2562 field_couple_node,
2564 yaml_couple_keys, num_yaml_couple_keys, WEIGHT_FILE_NAME),
2566 couple_config, couple_idx, field_couple_idx));
2567
2568 // add mapping side
2570 field_couple_node,
2572 yaml_couple_keys, num_yaml_couple_keys, MAPPING_SIDE),
2574 mapping_sides, num_mapping_sides,
2576 couple_config, couple_idx, field_couple_idx)));
2577
2578 // add scale factor
2580 field_couple_node,
2582 yaml_couple_keys, num_yaml_couple_keys, SCALE_FACTOR),
2584 couple_config, couple_idx, field_couple_idx));
2585
2586 // add scale summand
2588 field_couple_node,
2590 yaml_couple_keys, num_yaml_couple_keys, SCALE_SUMMAND),
2592 couple_config, couple_idx, field_couple_idx));
2593
2594 // add interpolation
2596 field_couple_node,
2598 yaml_couple_keys, num_yaml_couple_keys, INTERPOLATION),
2600 document, couple_config, couple_idx, field_couple_idx));
2601
2602 // add source mask names
2603 char const * const * src_mask_names;
2604 size_t num_src_mask_names;
2606 couple_config, couple_idx, field_couple_idx,
2607 &src_mask_names, &num_src_mask_names);
2608 if (num_src_mask_names == 1)
2610 field_couple_node,
2612 yaml_couple_keys, num_yaml_couple_keys, SOURCE_MASK_NAME),
2613 src_mask_names[0]);
2614 else if (num_src_mask_names > 1)
2616 field_couple_node,
2618 yaml_couple_keys, num_yaml_couple_keys, SOURCE_MASK_NAMES),
2620 document, src_mask_names, num_src_mask_names));
2621
2622 // add target mask name
2623 char const * tgt_mask_name =
2625 couple_config, couple_idx, field_couple_idx);
2626 if (tgt_mask_name)
2628 field_couple_node,
2630 yaml_couple_keys, num_yaml_couple_keys, TARGET_MASK_NAME),
2631 tgt_mask_name);
2632
2633 // add yaxt exchanger name
2634 char const * yaxt_exchanger_name =
2636 couple_config, couple_idx, field_couple_idx);
2637 if (yaxt_exchanger_name)
2639 field_couple_node,
2641 yaml_couple_keys, num_yaml_couple_keys, YAXT_EXCHANGER_NAME),
2642 yaxt_exchanger_name);
2643
2644 int appending_failed =
2645 fy_node_sequence_append(coupling_node, field_couple_node);
2646 YAC_ASSERT(
2647 !appending_failed,
2648 "ERROR(yac_yaml_append_couple_field_nodes): "
2649 "failed to append field couple node");
2650}
2651
2653 fy_node_t coupling_node, struct yac_couple_config * couple_config,
2654 size_t couple_idx) {
2655
2656 size_t num_couple_fields =
2657 yac_couple_config_get_num_couple_fields(couple_config, couple_idx);
2658
2659 for (size_t field_couple_idx = 0;
2660 field_couple_idx < num_couple_fields; ++field_couple_idx)
2662 coupling_node, couple_config, couple_idx, field_couple_idx);
2663}
2664
2666 fy_document_t document, char const * grid_name, char const * file_name) {
2667
2668 fy_node_t output_grid_node = fy_node_create_mapping(document);
2669 YAC_ASSERT(
2670 output_grid_node, "ERROR(yac_yaml_create_output_grid_node): "
2671 "failed to create mapping node");
2672
2674 output_grid_node,
2676 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
2678 grid_name);
2680 output_grid_node,
2682 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
2684 file_name);
2685
2686 return output_grid_node;
2687}
2688
2690 fy_document_t document, struct yac_couple_config * couple_config) {
2691
2692 // count the number of output grids
2693 size_t num_output_grids = 0;
2694 size_t num_grids =
2695 yac_couple_config_get_num_grids(couple_config);
2696 for (size_t grid_idx = 0; grid_idx < num_grids; ++grid_idx)
2698 couple_config,
2699 yac_couple_config_get_grid_name(couple_config, grid_idx)) != NULL)
2700 ++num_output_grids;
2701
2702 fy_node_t output_grids_node = NULL;
2703
2704 if (num_output_grids > 0) {
2705
2706 // create output grids node
2707 output_grids_node = fy_node_create_sequence(document);
2708 YAC_ASSERT(
2709 output_grids_node, "ERROR(yac_yaml_create_output_grids_node): "
2710 "failed to create sequence node");
2711
2712 // for all output grids
2713 for (size_t grid_idx = 0; grid_idx < num_grids; ++grid_idx) {
2714
2715 char const * grid_name =
2716 yac_couple_config_get_grid_name(couple_config, grid_idx);
2717 char const * file_name =
2718 yac_couple_config_grid_get_output_filename(couple_config, grid_name);
2719
2720 if (file_name != NULL) {
2721 int appending_failed =
2722 fy_node_sequence_append(
2723 output_grids_node,
2724 yac_yaml_create_output_grid_node(document, grid_name, file_name));
2725 YAC_ASSERT(
2726 !appending_failed, "ERROR(yac_yaml_create_output_grids_node): "
2727 "failed to append output grid node");
2728 }
2729 }
2730 }
2731
2732 return output_grids_node;
2733}
2734
2736 fy_document_t document, struct yac_couple_config * couple_config) {
2737
2738 // create debug node
2739 fy_node_t debug_node = fy_node_create_mapping(document);
2740 YAC_ASSERT(
2741 debug_node, "ERROR(yac_yaml_create_debug_node): "
2742 "failed to create mapping node");
2743
2744 // add output grids node
2746 debug_node,
2748 yaml_debug_keys, num_yaml_debug_keys, OUTPUT_GRIDS),
2749 yac_yaml_create_output_grids_node(document, couple_config));
2750
2751 // add "missing_definition_is_fatal" node
2753 debug_node,
2755 yaml_debug_keys, num_yaml_debug_keys, MISSING_DEF),
2757 bool_names, num_bool_names,
2759
2760 return debug_node;
2761}
2762
2764 fy_document_t document, struct yac_couple_config * couple_config) {
2765
2766 size_t num_couples =
2767 yac_couple_config_get_num_couples(couple_config);
2768
2769 if (!num_couples) return NULL;
2770
2771 // create coupling node
2772 fy_node_t coupling_node = fy_node_create_sequence(document);
2773 YAC_ASSERT(
2774 coupling_node, "ERROR(yac_yaml_create_coupling_node): "
2775 "failed to create sequence node");
2776
2777 // for all couples
2778 for (size_t couple_idx = 0; couple_idx < num_couples; ++couple_idx)
2780 coupling_node, couple_config, couple_idx);
2781
2782 return coupling_node;
2783}
2784
2786 fy_document_t document, struct yac_couple_config * couple_config,
2787 size_t component_idx, size_t field_idx) {
2788
2789 fy_node_t field_node = fy_node_create_mapping(document);
2790 YAC_ASSERT(
2791 field_node, "ERROR(yac_yaml_create_field_node): "
2792 "failed to create mapping node");
2793
2794 // get field parameters
2795 char const * component_name =
2797 couple_config, component_idx);
2798 char const * field_name =
2800 couple_config, component_idx, field_idx);
2801 char const * grid_name =
2803 couple_config, component_idx, field_idx);
2804 char const * metadata =
2806 couple_config, component_name, grid_name, field_name);
2807 size_t collection_size =
2809 couple_config, component_name, grid_name, field_name);
2810 char const * timestep =
2812 couple_config, component_name, grid_name, field_name);
2813 int role =
2815 couple_config, component_name, grid_name, field_name);
2816 double frac_mask_fallback_value =
2818 couple_config, component_name, grid_name, field_name);
2819
2820 // add field name
2821 yac_yaml_map_append_scalar(field_node, "name", field_name);
2822
2823 // add grid name
2824 yac_yaml_map_append_scalar(field_node, "grid_name", grid_name);
2825
2826 // add metadata
2827 if (metadata)
2828 yac_yaml_map_append_scalar(field_node, "metadata", metadata);
2829
2830 // add collection_size
2831 if (collection_size != SIZE_MAX)
2833 field_node, "collection_size", (int)collection_size);
2834
2835 // add timestep
2836 if (timestep)
2837 yac_yaml_map_append_scalar(field_node, "timestep", timestep);
2838
2839 // add role
2841 field_node, "role",
2843 role_types, num_role_types, (enum yac_field_exchange_type)role));
2844
2845 // add fractional fallback value
2846 if (YAC_FRAC_MASK_VALUE_IS_VALID(frac_mask_fallback_value))
2848 field_node, "frac_mask_fallback_value", frac_mask_fallback_value);
2849
2850 return field_node;
2851}
2852
2854 fy_document_t document, struct yac_couple_config * couple_config,
2855 size_t component_idx) {
2856
2857 size_t num_fields =
2858 yac_couple_config_get_num_fields(couple_config, component_idx);
2859
2860 if (num_fields == 0) return (fy_node_t)NULL;
2861
2862 fy_node_t fields_node = fy_node_create_sequence(document);
2863 YAC_ASSERT(
2864 fields_node, "ERROR(yac_yaml_create_fields_node): "
2865 "failed to create sequence node");
2866
2867 for (size_t field_idx = 0; field_idx < num_fields; ++field_idx) {
2868
2869 int appending_failed =
2870 fy_node_sequence_append(
2871 fields_node,
2873 document, couple_config, component_idx, field_idx));
2874 YAC_ASSERT(
2875 !appending_failed, "ERROR(yac_yaml_create_fields_node): "
2876 "failed to append field node");
2877 }
2878
2879 return fields_node;
2880}
2881
2883 fy_document_t document, struct yac_couple_config * couple_config,
2884 size_t component_idx) {
2885
2886 fy_node_t component_node = fy_node_create_mapping(document);
2887 YAC_ASSERT(
2888 component_node, "ERROR(yac_yaml_create_component_node): "
2889 "failed to create mapping node");
2890
2891 // get component name, component metadata, and fields
2892 char const * component_name =
2893 yac_couple_config_get_component_name(couple_config, component_idx);
2894 char const * metadata =
2895 yac_couple_config_component_get_metadata(couple_config, component_name);
2896 fy_node_t fields_node =
2898 document, couple_config, component_idx);
2899
2900 // add component name
2901 yac_yaml_map_append_scalar(component_node, "name", component_name);
2902
2903 // add metadata
2904 if (metadata)
2905 yac_yaml_map_append_scalar(component_node, "metadata", metadata);
2906
2907 // add fields
2908 yac_yaml_map_append(component_node, "fields", fields_node);
2909
2910 return component_node;
2911}
2912
2914 fy_document_t document, struct yac_couple_config * couple_config) {
2915
2916 // get number of components in coupling configuration
2918
2919 if (num_components == 0) return (fy_node_t)NULL;
2920
2921 // create sequence node
2922 fy_node_t components_node = fy_node_create_sequence(document);
2923 YAC_ASSERT(
2924 components_node, "ERROR(yac_yaml_create_components_node): "
2925 "failed to create sequence node");
2926
2927 for (size_t component_idx = 0; component_idx < num_components;
2928 ++component_idx) {
2929
2930 int appending_failed =
2931 fy_node_sequence_append(
2932 components_node,
2933 yac_yaml_create_component_node(document, couple_config, component_idx));
2934 YAC_ASSERT(
2935 !appending_failed, "ERROR(yac_yaml_create_components_node): "
2936 "failed to append component node");
2937 }
2938
2939 return components_node;
2940}
2941
2943 fy_document_t document, struct yac_couple_config * couple_config,
2944 size_t grid_idx) {
2945
2946 fy_node_t grid_node = fy_node_create_mapping(document);
2947 YAC_ASSERT(
2948 grid_node, "ERROR(yac_yaml_create_grid_node): "
2949 "failed to create mapping node");
2950
2951 // get grid name and metadata
2952 char const * grid_name =
2953 yac_couple_config_get_grid_name(couple_config, grid_idx);
2954 char const * metadata =
2955 yac_couple_config_grid_get_metadata(couple_config, grid_name);
2956
2957 // add grid name
2958 yac_yaml_map_append_scalar(grid_node, "name", grid_name);
2959
2960 // add metadata
2961 if (metadata)
2962 yac_yaml_map_append_scalar(grid_node, "metadata", metadata);
2963
2964 return grid_node;
2965}
2966
2968 fy_document_t document, struct yac_couple_config * couple_config) {
2969
2970 // get number of grids in coupling configuration
2971 size_t num_grids = yac_couple_config_get_num_grids(couple_config);
2972
2973 if (num_grids == 0) return (fy_node_t)NULL;
2974
2975 // create sequence node
2976 fy_node_t grids_node = fy_node_create_sequence(document);
2977 YAC_ASSERT(
2978 grids_node, "ERROR(yac_yaml_create_grids_node): "
2979 "failed to create sequence node");
2980
2981 for (size_t grids_idx = 0; grids_idx < num_grids; ++grids_idx) {
2982
2983 int appending_failed =
2984 fy_node_sequence_append(
2985 grids_node,
2986 yac_yaml_create_grid_node(document, couple_config, grids_idx));
2987 YAC_ASSERT(
2988 !appending_failed, "ERROR(yac_yaml_create_grids_node): "
2989 "failed to append grid node");
2990 }
2991
2992 return grids_node;
2993}
2994
2996 fy_document_t document, struct yac_couple_config * couple_config) {
2997
2998 // create definition
2999 fy_node_t definition_node = fy_node_create_mapping(document);
3000 YAC_ASSERT(
3001 definition_node,
3002 "ERROR(yac_yaml_create_definitions_node): "
3003 "failed to create mapping node");
3004
3005 // add components
3007 definition_node,
3008 "components", yac_yaml_create_components_node(document, couple_config));
3009
3010 // add grids
3012 definition_node, "grids", yac_yaml_create_grids_node(document, couple_config));
3013
3014 return definition_node;
3015}
3016
3018 fy_document_t document, struct yac_couple_config * couple_config,
3019 int include_definitions) {
3020
3021 // create root node
3022 fy_node_t root_node = fy_node_create_mapping(document);
3023 YAC_ASSERT(
3024 root_node,
3025 "ERROR(yac_yaml_create_couple_config_nodes): "
3026 "failed to create mapping node");
3027
3028 // add debug
3030 root_node,
3032 yaml_base_keys, num_yaml_base_keys, DEBUG),
3033 yac_yaml_create_debug_node(document, couple_config));
3034
3035 // add user definitions (components, grids, and fields)
3036 if (include_definitions)
3038 root_node, "definitions",
3039 yac_yaml_create_definitions_node(document, couple_config));
3040
3041 // add start datetime
3042 char * start_datetime = yac_couple_config_get_start_datetime(couple_config);
3044 root_node,
3046 yaml_base_keys, num_yaml_base_keys, START_DATE), start_datetime);
3047 free(start_datetime);
3048
3049 // add end datetime
3050 char * end_datetime = yac_couple_config_get_end_datetime(couple_config);
3052 root_node,
3054 yaml_base_keys, num_yaml_base_keys, END_DATE), end_datetime);
3055 free(end_datetime);
3056
3057 // add calendar
3059 root_node,
3061 yaml_base_keys, num_yaml_base_keys, CALENDAR),
3063 calendar_types, num_calendar_types, getCalendarType()));
3064
3065 // add timestep unit
3067 root_node,
3069 yaml_base_keys, num_yaml_base_keys, TIMESTEP_UNIT),
3071 timestep_units, num_timestep_units, C_ISO_FORMAT));
3072
3073 // add couplings
3075 root_node,
3077 yaml_base_keys, num_yaml_base_keys, COUPLING),
3078 yac_yaml_create_coupling_node(document, couple_config));
3079
3080 return root_node;
3081}
3082
3084 struct yac_couple_config * couple_config, int emit_flags,
3085 int include_definitions) {
3086
3087 // create an empty document
3088 fy_document_t document = fy_document_create(NULL);
3089 YAC_ASSERT(
3090 document, "ERROR(yac_yaml_emit): failed to create document");
3091
3092 // create nodes from coupling configuration
3093 fy_node_t root_node =
3095 document, couple_config, include_definitions);
3096
3097 // set root node of the document
3098 int setting_root_failed =
3099 fy_document_set_root(document, root_node);
3100 YAC_ASSERT(
3101 !setting_root_failed,
3102 "ERROR(yac_yaml_emit): failed to add root node to document");
3103
3104 // emit document to string
3105 char * str_document =
3106 fy_emit_document_to_string(
3107 document, (enum fy_emitter_cfg_flags)emit_flags);
3108
3109 YAC_ASSERT(
3110 str_document, "ERROR(yac_yaml_emit): failed to emit document to string");
3111
3112 // destroy document
3113 fy_document_destroy(document);
3114
3115 return str_document;
3116}
static double yaml_parse_double_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
yaml_debug_sync_loc_key_types
@ SYNC_LOC_COUNT
@ SYNC_LOC_ENDDEF
@ SYNC_LOC_DEF_COMP
@ SYNC_LOC_SYNC_DEF
#define DEF_DEG_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX)
#define DEF_ENUM_PARAM(NAME, DEFAULT,...)
static void yaml_parse_couple(struct yac_couple_config *couple_config, fy_node_t couple_node, char const *yaml_filename, enum yac_time_unit_type time_unit)
#define DEF_INTERP_STACK_GET_NO_PARAM(NAME)
static void yaml_parse_interp_method_parameter(interp_method_parameter_value *parameter_values, struct interp_method_parameter const *parameters, size_t num_parameters, fy_node_pair_t parameter_pair, char const *interpolation_name, char const *parameter_name_prefix, char const *yaml_filename)
#define DEF_STR_PARAM(NAME, DEFAULT, MAX_STR_LEN)
#define DEF_INTERP_STACK_ADD_NO_PARAM(NAME)
struct yac_interp_stack_config * yac_yaml_parse_interp_stack_config_string(char const *str_interp_stack_config, int parse_flags)
static void yaml_parse_field_names(struct field_couple_field_names **field_names, size_t *num_field_names, fy_node_t fields_node, const char *yaml_filename)
static void yac_yaml_append_couple_nodes(fy_node_t coupling_node, struct yac_couple_config *couple_config, size_t couple_idx)
interp_method_parameter_value
static fy_node_t yac_yaml_create_scalar_dble(fy_document_t document, double value)
static interp_method_parameter_value yaml_parse_interp_method_parameter_value(struct interp_method_parameter const *parameter, fy_node_t value_node, char const *interpolation_name, char const *yaml_filename)
#define DEF_INTERP_STACK_ADD(NAME,...)
static fy_node_t yac_yaml_create_interpolation_node(fy_document_t document, union yac_interp_stack_config_entry const *interp_stack_entry)
struct fy_node_pair * fy_node_pair_t
Definition config_yaml.c:53
static fy_node_t yac_yaml_create_field_node(fy_document_t document, struct yac_couple_config *couple_config, size_t component_idx, size_t field_idx)
interp_method_parameter_value_type
@ ENUM_PARAM
@ DBLE_PARAM
@ DEG_PARAM
@ INT_PARAM
@ BOOL_PARAM
@ STR_PARAM
static calendarType yaml_parse_calendar_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
static fy_node_t yac_yaml_create_grids_node(fy_document_t document, struct yac_couple_config *couple_config)
static void yaml_parse_base_map_pair(struct yac_couple_config *couple_config, fy_node_pair_t base_pair, const char *yaml_filename, enum yac_time_unit_type *time_unit, char const **start_datetime, char const **end_datetime)
static void yaml_parse_string_sequence(char const ***values, size_t *num_values, fy_node_t values_node, char const *sequence_name, const char *yaml_filename)
static fy_node_t yac_yaml_create_output_grids_node(fy_document_t document, struct yac_couple_config *couple_config)
static int compare_parameter_values(interp_method_parameter_value const *a, interp_method_parameter_value const *b, enum interp_method_parameter_value_type type)
int const YAC_YAML_PARSER_JSON_AUTO
Definition config_yaml.c:66
yaml_debug_key_types
@ GLOBAL_CONFIG
@ GLOBAL_DEFS
@ OUTPUT_GRIDS
@ MISSING_DEF
char * yac_yaml_emit_coupling(struct yac_couple_config *couple_config, int emit_flags, int include_definitions)
static fy_node_t yac_yaml_create_components_node(fy_document_t document, struct yac_couple_config *couple_config)
static fy_node_t yac_yaml_create_couple_config_nodes(fy_document_t document, struct yac_couple_config *couple_config, int include_definitions)
static fy_node_t yac_yaml_create_grid_node(fy_document_t document, struct yac_couple_config *couple_config, size_t grid_idx)
static void yac_yaml_map_append_scalar_dble(fy_node_t map, char const *key, double value)
static void yaml_parse_document(struct yac_couple_config *couple_config, fy_document_t document, const char *yaml_filename)
static int yaml_parse_enum_value(struct yac_name_type_pair const *valid_values, size_t num_valid_values, fy_node_t value_node, char const *key_name, char const *yaml_filename)
int const YAC_YAML_EMITTER_DEFAULT
emit to YAML format
Definition config_yaml.c:63
void yac_yaml_read_coupling(struct yac_couple_config *couple_config, const char *yaml_filename, int parse_flags)
yaml_couple_key_types
@ WEIGHT_FILE_NAME
@ SCALE_SUMMAND
@ TARGET_COMPONENT
@ SOURCE_GRID
@ SOURCE_MASK_NAME
@ INTERPOLATION
@ SOURCE_MASK_NAMES
@ YAXT_EXCHANGER_NAME
@ MAPPING_SIDE
@ TIME_REDUCTION
@ SOURCE_LAG
@ FIELD
@ TARGET_GRID
@ COUPLING_PERIOD
@ TARGET_NAMES
@ SOURCE_COMPONENT
@ SCALE_FACTOR
@ TARGET_LAG
@ TARGET_MASK_NAME
@ SOURCE_NAMES
static int yaml_parse_integer_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
static void yaml_parse_debug_output_grids(struct yac_couple_config *couple_config, fy_node_t output_grids_node, char const *yaml_filename)
int const YAC_YAML_EMITTER_JSON
emit to JSON format
Definition config_yaml.c:64
static enum yac_time_unit_type yaml_parse_timestep_unit_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
static void yac_yaml_map_append_scalar(fy_node_t map, char const *key, char const *value)
struct fy_document * fy_document_t
Definition config_yaml.c:51
int const YAC_YAML_PARSER_DEFAULT
default parse flags (YAML format)
Definition config_yaml.c:65
static fy_node_t yac_yaml_create_output_grid_node(fy_document_t document, char const *grid_name, char const *file_name)
#define DEF_INTERP_STACK_GET(NAME,...)
static struct field_couple_field_names yaml_parse_field_name(fy_node_t field_node, const char *yaml_filename)
static void yaml_parse_base_interp_method_node(char const **interpolation_type_str, fy_node_t *parameter_node, fy_node_t interp_method_node, char const *yaml_filename)
char *parameters[0] str_value
static fy_node_t yac_yaml_create_field_name_node(fy_document_t document, struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
static char const * yaml_parse_timestep_value(fy_node_t value_node, char const *key_name, char const *yaml_filename, enum yac_time_unit_type time_unit)
#define ADD_INTERPOLATION(NAME, TYPE)
#define DEF_DBLE_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX)
static struct debug_config_file_buffer yaml_parse_debug_config_file_buffer(fy_node_t config_file_node, char const *config_file_type_name, char const *yaml_filename)
#define DEF_NAME_TYPE_PAIR(NAME, TYPE)
#define YAML_ASSERT_F(CHECK, MSG,...)
static fy_node_t yac_yaml_create_component_node(fy_document_t document, struct yac_couple_config *couple_config, size_t component_idx)
static void yac_yaml_map_append_parameter(fy_node_t map, struct interp_method_parameter const *parameter, interp_method_parameter_value value)
yaml_debug_output_grid_key_types
@ OUTPUT_GRID_FILE_NAME
@ OUTPUT_GRID_GRID_NAME
static void yaml_parse_coupling(struct yac_couple_config *couple_config, fy_node_t coupling_node, char const *yaml_filename, enum yac_time_unit_type time_unit)
static fy_node_t yac_yaml_create_coupling_node(fy_document_t document, struct yac_couple_config *couple_config)
static void yaml_parse_interp_method_parameters(interp_method_parameter_value *parameter_values, struct yac_interpolation_method const *interp_method, fy_node_t parameter_node, char const *yaml_filename)
#define DEF_INT_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX)
static void yaml_parse_output_grid_pair(char const **grid_name, char const **file_name, fy_node_pair_t output_grid_pair, char const *yaml_filename)
static fy_node_t yac_yaml_create_interpolation_stack_node(fy_document_t document, struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
static enum yac_reduction_type yaml_parse_time_reduction_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
static void yaml_parse_debug_global_config(struct yac_couple_config *couple_config, fy_node_t global_config_node, char const *yaml_filename)
#define DEF_INTERP_METHOD(NAME, FUNC_ADD, FUNC_GET,...)
char const * yac_time_to_ISO(char const *time, enum yac_time_unit_type time_unit)
Definition event.c:329
int const YAC_YAML_PARSER_JSON_FORCE
assume JSON format
Definition config_yaml.c:67
static void yac_yaml_append_couple_field_nodes(fy_node_t coupling_node, struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
static void yaml_parse_interp_stack_value(struct yac_interp_stack_config *interp_stack, fy_node_t interp_stack_node, char const *yaml_filename)
static fy_node_t yac_yaml_create_debug_node(fy_document_t document, struct yac_couple_config *couple_config)
struct fy_node * fy_node_t
Definition config_yaml.c:52
static void yaml_parse_debug(struct yac_couple_config *couple_config, fy_node_t debug_node, char const *yaml_filename)
static void yac_yaml_map_append(fy_node_t map, char const *key, fy_node_t value)
static fy_node_t yac_yaml_create_sequence_scalar(fy_document_t document, char const *const *values, size_t num_values)
const interpolation_methods[]
static char const * yaml_parse_string_value(fy_node_t value_node, char const *name, char const *yaml_filename)
static void yaml_parse_debug_map_pair(struct yac_couple_config *couple_config, fy_node_pair_t debug_pair, const char *yaml_filename)
static void yac_yaml_map_append_scalar_int(fy_node_t map, char const *key, int value)
#define ADD_INTERPOLATION_NO_PARAM(NAME, TYPE)
static void yaml_parse_comp_grid_names(char const **comp_name, char const ***grid_names, size_t *num_grid_names, fy_node_t values_node, char const *type_name, const char *yaml_filename)
#define YAML_ASSERT(CHECK, MSG)
static fy_node_t yac_yaml_create_fields_node(fy_document_t document, struct yac_couple_config *couple_config, size_t component_idx)
static void yaml_parse_debug_config_file_map_pair(struct debug_config_file_buffer *config_file_buffer, fy_node_pair_t config_file_pair, char const *config_file_type_name, const char *yaml_filename)
yaml_base_key_types
@ DEBUG
@ TIMESTEP_UNIT
@ START_DATE
@ COUPLING
@ CALENDAR
@ END_DATE
enum yac_interp_ncc_weight_type weight_type
static void yaml_parse_interp_method(struct yac_interp_stack_config *interp_stack, fy_node_t interp_method_node, char const *yaml_filename)
#define DEF_NAME_TYPE_PAIRS(NAME,...)
yaml_comp_grid_names_key_types
@ COMP_NAME
@ GRID_NAMES
static fy_node_t yac_yaml_create_scalar(fy_document_t document, char const *value)
static void yaml_parse_output_grid(struct yac_couple_config *couple_config, fy_node_t output_grid_node, char const *yaml_filename)
static fy_node_t yac_yaml_create_scalar_int(fy_document_t document, int value)
static struct debug_config_file yaml_parse_config_file_value(fy_node_t config_file_node, char const *file_type_name, const char *yaml_filename)
#define DEF_BOOL_PARAM(NAME, DEFAULT)
static void yaml_parse_couple_map_pair(struct field_couple_buffer *field_buffer, fy_node_pair_t couple_pair, const char *yaml_filename, enum yac_time_unit_type time_unit)
@ EMITTER_DEFAULT
Definition config_yaml.c:56
@ PARSER_JSON_AUTO
Definition config_yaml.c:59
@ EMITTER_JSON
Definition config_yaml.c:57
@ PARSER_JSON_FORCE
Definition config_yaml.c:60
@ PARSER_DEFAULT
Definition config_yaml.c:58
@ NUM_INTERPOLATION_METHODS
static fy_node_t yac_yaml_create_definitions_node(fy_document_t document, struct yac_couple_config *couple_config)
char const * yac_couple_config_get_yaxt_exchanger_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
size_t yac_couple_config_get_num_fields(struct yac_couple_config *couple_config, size_t component_idx)
void yac_couple_config_get_field_grid_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_grid_name, char const **tgt_grid_name)
const char * yac_couple_config_grid_get_output_filename(struct yac_couple_config *couple_config, const char *grid_name)
char * yac_couple_config_get_start_datetime(struct yac_couple_config *couple_config)
void yac_couple_config_set_datetime(struct yac_couple_config *couple_config, char const *start, char const *end)
char const * yac_couple_config_get_field_timestep(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
int yac_couple_config_mapping_on_source(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_get_field_role(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
char const * yac_couple_config_get_coupling_period(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
struct yac_interp_stack_config * yac_couple_config_get_interp_stack(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_field_name(struct yac_couple_config *couple_config, size_t component_idx, size_t field_idx)
size_t yac_couple_config_get_field_collection_size(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
size_t yac_couple_config_get_num_couple_fields(struct yac_couple_config *couple_config, size_t couple_idx)
void yac_couple_config_get_src_mask_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const *const **mask_names, size_t *num_mask_names)
size_t yac_couple_config_get_num_couples(struct yac_couple_config *couple_config)
int yac_couple_config_get_target_lag(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_def_couple(struct yac_couple_config *couple_config, char const *src_comp_name, char const *src_grid_name, char const *src_field_name, char const *tgt_comp_name, char const *tgt_grid_name, char const *tgt_field_name, char const *coupling_period, int time_reduction, struct yac_interp_stack_config *interp_stack, int src_lag, int tgt_lag, const char *weight_file_name, int mapping_on_source, double scale_factor, double scale_summand, size_t num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name, char const *yaxt_exchanger_name)
double yac_couple_config_get_frac_mask_fallback_value(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
int yac_couple_config_get_source_lag(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
const char * yac_couple_config_field_get_metadata(struct yac_couple_config *couple_config, const char *comp_name, const char *grid_name, const char *field_name)
const char * yac_couple_config_grid_get_metadata(struct yac_couple_config *couple_config, const char *grid_name)
const char * yac_couple_config_component_get_metadata(struct yac_couple_config *couple_config, const char *comp_name)
double yac_couple_config_get_scale_factor(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_tgt_mask_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_add_grid(struct yac_couple_config *couple_config, char const *name)
char const * yac_couple_config_get_grid_name(struct yac_couple_config *couple_config, size_t grid_idx)
double yac_couple_config_get_scale_summand(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
enum yac_reduction_type yac_couple_config_get_coupling_period_operation(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_enforce_write_weight_file(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_grid_set_output_filename(struct yac_couple_config *couple_config, char const *grid_name, const char *output_filename)
void yac_couple_config_get_field_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_field_name, const char **tgt_field_name)
char const * yac_couple_config_get_weight_file_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_get_missing_definition_is_fatal(struct yac_couple_config *couple_config)
void yac_couple_config_get_field_couple_component_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_component_name, char const **tgt_component_name)
char const * yac_couple_config_get_component_name(struct yac_couple_config *couple_config, size_t component_idx)
void yac_couple_config_set_missing_definition_is_fatal(struct yac_couple_config *couple_config, int missing_definition_is_fatal)
size_t yac_couple_config_get_num_grids(struct yac_couple_config *couple_config)
char const * yac_couple_config_get_field_grid_name(struct yac_couple_config *couple_config, size_t component_idx, size_t field_idx)
void yac_couple_config_set_config_output_filename(struct yac_couple_config *couple_config, char const *filename, enum yac_text_filetype filetype, char const *ref, int include_definitions)
char * yac_couple_config_get_end_datetime(struct yac_couple_config *couple_config)
size_t yac_couple_config_get_num_components(struct yac_couple_config *couple_config)
yac_text_filetype
@ YAC_TEXT_FILETYPE_YAML
YAML format.
@ YAC_TEXT_FILETYPE_JSON
JSON format.
yac_reduction_type
@ TIME_NONE
@ TIME_ACCUMULATE
@ TIME_MAXIMUM
@ TIME_MINIMUM
@ TIME_AVERAGE
yac_time_unit_type
@ C_SECOND
@ TIME_UNIT_UNDEFINED
@ C_HOUR
@ C_DAY
@ C_MILLISECOND
@ C_MINUTE
@ C_MONTH
@ C_ISO_FORMAT
@ C_YEAR
yac_field_exchange_type
Definition fields.h:12
@ SOURCE
Definition fields.h:14
@ TARGET
Definition fields.h:15
@ NOTHING
Definition fields.h:13
#define YAC_RAD
Definition geometry.h:30
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_ENDDEF
Definition instance.h:35
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_COMP
Definition instance.h:33
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_SYNC
Definition instance.h:34
int(* func_compute_weights)(double[3], size_t, yac_const_coordinate_pointer, int *, double *, enum yac_cell_type cell_type)
#define YAC_INTERP_AVG_PARTIAL_COVERAGE_DEFAULT
yac_interp_avg_weight_type
@ YAC_INTERP_AVG_DIST
@ YAC_INTERP_AVG_ARITHMETIC
@ YAC_INTERP_AVG_BARY
#define YAC_INTERP_AVG_WEIGHT_TYPE_DEFAULT
char * key
#define YAC_INTERP_CALLBACK_COMPUTE_WEIGHTS_KEY_DEFAULT
struct @7::@8 value
enum callback_type type
#define YAC_INTERP_CHECK_CONSTRUCTOR_KEY_DEFAULT
#define YAC_INTERP_CHECK_DO_SEARCH_KEY_DEFAULT
#define YAC_INTERP_CONSERV_NORMALISATION_DEFAULT
#define YAC_INTERP_CONSERV_ENFORCED_CONSERV_DEFAULT
#define YAC_INTERP_CONSERV_PARTIAL_COVERAGE_DEFAULT
#define YAC_INTERP_CONSERV_ORDER_DEFAULT
yac_interp_method_conserv_normalisation
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
#define YAC_INTERP_CREEP_DISTANCE_DEFAULT
#define YAC_INTERP_FILE_WEIGHT_FILE_NAME_DEFAULT
#define YAC_INTERP_FIXED_VALUE_DEFAULT
#define YAC_INTERP_NCC_PARTIAL_COVERAGE_DEFAULT
#define YAC_INTERP_NCC_WEIGHT_TYPE_DEFAULT
yac_interp_ncc_weight_type
@ YAC_INTERP_NCC_DIST
distance weighted average of n source points
@ YAC_INTERP_NCC_AVG
average of n source points
#define YAC_INTERP_NNN_WEIGHTED_DEFAULT
yac_interp_nnn_weight_type
@ YAC_INTERP_NNN_GAUSS
distance with Gauss weights of n source points
@ YAC_INTERP_NNN_RBF
radial basis functions
@ YAC_INTERP_NNN_AVG
average of n source points
@ YAC_INTERP_NNN_DIST
distance weighted average of n source points
@ YAC_INTERP_NNN_ZERO
all weights are set to zero
#define YAC_INTERP_RBF_MAX_SEARCH_DISTANCE_DEFAULT
#define YAC_INTERP_RBF_N_DEFAULT
#define YAC_INTERP_NNN_MAX_SEARCH_DISTANCE_DEFAULT
#define YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT
#define YAC_INTERP_RBF_SCALE_DEFAULT
#define YAC_INTERP_NNN_N_DEFAULT
#define YAC_INTERP_RBF_KERNEL_DEFAULT
#define YAC_INTERP_SPMAP_MAX_SEARCH_DISTANCE_DEFAULT
yac_interp_spmap_scale_type
@ YAC_INTERP_SPMAP_NONE
weights are not scaled
@ YAC_INTERP_SPMAP_INVTGTAREA
@ YAC_INTERP_SPMAP_SRCAREA
@ YAC_INTERP_SPMAP_FRACAREA
#define YAC_INTERP_SPMAP_WEIGHTED_DEFAULT
#define YAC_INTERP_SPMAP_SPREAD_DISTANCE_DEFAULT
#define YAC_INTERP_SPMAP_SPHERE_RADIUS_DEFAULT
#define YAC_INTERP_SPMAP_SCALE_TYPE_DEFAULT
yac_interp_spmap_weight_type
@ YAC_INTERP_SPMAP_AVG
@ YAC_INTERP_SPMAP_DIST
#define YAC_INTERP_SPMAP_MIN_GLOBAL_ID_DEFAULT
size_t yac_interp_stack_config_get_size(struct yac_interp_stack_config *interp_stack)
union yac_interp_stack_config_entry const * yac_interp_stack_config_get_entry(struct yac_interp_stack_config *interp_stack, size_t interp_stack_idx)
enum yac_interpolation_list yac_interp_stack_config_entry_get_type(union yac_interp_stack_config_entry const *interp_stack_entry)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
struct yac_interp_stack_config * yac_interp_stack_config_new()
yac_interpolation_list
@ YAC_N_NEAREST_NEIGHBOR
@ YAC_CREEP
@ YAC_USER_FILE
@ YAC_USER_CALLBACK
@ YAC_SOURCE_TO_TARGET_MAP
@ YAC_CONSERVATIVE
@ YAC_FIXED_VALUE
@ YAC_CHECK
@ YAC_BERNSTEIN_BEZIER
@ YAC_NEAREST_CORNER_CELLS
@ YAC_RADIAL_BASIS_FUNCTION
@ YAC_AVERAGE
#define YAC_MAX_ROUTINE_NAME_LENGTH
#define YAC_MAX_FILE_NAME_LENGTH
#define YAC_FRAC_MASK_VALUE_IS_VALID(value)
int yac_file_exists(const char *filename)
Definition utils_core.c:12
#define xrealloc(ptr, size)
Definition ppm_xfuncs.h:67
#define xmalloc(size)
Definition ppm_xfuncs.h:66
#define xfclose(fp)
Definition ppm_xfuncs.h:79
#define xfopen(path, mode)
Definition ppm_xfuncs.h:74
struct debug_config_file_buffer::debug_config_file config_file[SYNC_LOC_COUNT]
char const * sync_loc_ref[SYNC_LOC_COUNT]
char const ** src_mask_names
Definition config_yaml.c:93
char const * yaxt_exchanger_name
Definition config_yaml.c:97
char const * coupling_period
Definition config_yaml.c:81
struct field_couple_buffer::@52::@53 grid
struct field_couple_buffer::@52 tgt
char const * weight_file_name
Definition config_yaml.c:84
char const * tgt_mask_name
Definition config_yaml.c:95
char const * comp_name
Definition config_yaml.c:74
struct yac_interp_stack_config * interp_stack
Definition config_yaml.c:83
struct field_couple_buffer::@52 src
struct field_couple_buffer::field_couple_field_names * field_names
char const ** name
Definition config_yaml.c:76
enum yac_reduction_type time_reduction
Definition config_yaml.c:82
struct yac_name_type_pair const * valid_values
struct interp_method_parameter::@54::@59 bool_param
struct interp_method_parameter::@54::@56 int_param
enum interp_method_parameter_value_type type
union interp_method_parameter::@54 data
struct interp_method_parameter::@54::@58 str_param
struct interp_method_parameter::@54::@55 enum_param
interp_method_parameter_value const default_value
struct interp_method_parameter::@54::@57 dble_param
int yac_name_type_pair_get_type(struct yac_name_type_pair const *pairs, size_t count, char const *name)
Definition utils_core.c:26
char const * yac_name_type_pair_get_name(struct yac_name_type_pair const *pairs, size_t count, int type)
Definition utils_core.c:17
#define MAX(a, b)
size_t num_grids
Definition yac.c:131
static size_t num_components
Definition yac.c:134
void yac_cdef_calendar(int calendar)
Definition yac.c:648
int yac_cget_calendar()
Definition yac.c:665
int const YAC_CALENDAR_NOT_SET
Definition yac.c:60
#define YAC_ASSERT_F(exp, format,...)
Definition yac_assert.h:19
#define YAC_ASSERT(exp, msg)
Definition yac_assert.h:16