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"
20#if defined(__NVCOMPILER)
21# pragma diag_default unsigned_compare_with_zero
22#elif defined(__GNUC__)
23# pragma GCC diagnostic pop
34#include "mtime_calendar.h"
184#define CAST_NAME_TYPE_PAIRS(...) (struct yac_name_type_pair[]) {__VA_ARGS__}
185#define COUNT_NAME_TYPE_PAIRS(...) \
186 sizeof(CAST_NAME_TYPE_PAIRS(__VA_ARGS__)) / sizeof(struct yac_name_type_pair)
187#define DEF_NAME_TYPE_PAIR(NAME, TYPE) {.name = #NAME, .type = (int)(TYPE)}
188#define DEF_NAME_TYPE_PAIRS(NAME, ...) \
189 static const struct yac_name_type_pair NAME [] = {__VA_ARGS__}; \
190 static const size_t num_ ## NAME = COUNT_NAME_TYPE_PAIRS(__VA_ARGS__);
232 yaml_debug_sync_loc_keys,
243 yaml_debug_output_grid_keys,
308 yaml_comp_grid_names_keys,
313 yaml_weight_file_data_keys,
318 weight_file_on_existing_types,
323enum interp_method_parameter_value_type{
337#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 23 || __NVCOMPILER_MAJOR__ == 24 && __NVCOMPILER_MINOR__ <= 3)
365 enum interp_method_parameter_value_type
type;
367#if defined __NVCOMPILER && (__NVCOMPILER_MAJOR__ <= 23 || __NVCOMPILER_MAJOR__ == 24 && __NVCOMPILER_MINOR__ <= 3)
407#define DEF_INTERP_METHOD_ADD_FUNC(NAME, FUNC) \
408 static void add_interp_method_ ## NAME ( \
409 struct yac_interp_stack_config * interp_stack, \
410 interp_method_parameter_value parameter_value, \
411 char const * yaml_filename) { \
412 char const * routine_name = "add_interp_method_" #NAME; \
413 (void)parameter_value; \
414 (void)yaml_filename; \
415 (void)routine_name; \
419#define DEF_INTERP_METHOD_GET_FUNC(NAME, FUNC) \
420 static void get_interp_method_ ## NAME ( \
421 union yac_interp_stack_config_entry const * interp_stack_entry, \
422 interp_method_parameter_value * parameter_value) { \
423 char const * routine_name = "get_interp_method_" #NAME; \
424 (void)interp_stack_entry; \
425 (void)parameter_value; \
426 (void)routine_name; \
430#define DEF_ENUM_PARAM(NAME, DEFAULT, ...) \
432 .type = ENUM_PARAM, \
434 {.valid_values = CAST_NAME_TYPE_PAIRS(__VA_ARGS__), \
435 .num_valid_values = COUNT_NAME_TYPE_PAIRS(__VA_ARGS__)}, \
436 .default_value.data.enum_value = (int)(DEFAULT)}
437#define DEF_INT_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX) \
441 {.valid_min = (int)(VALID_MIN), \
442 .valid_max = (int)(VALID_MAX)}, \
443 .default_value.data.int_value = (int)(DEFAULT)}
444#define DEF_DBLE_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX, ALLOW_NAN) \
446 .type = DBLE_PARAM, \
448 {.valid_min = (double)(VALID_MIN), \
449 .valid_max = (double)(VALID_MAX), \
450 .allow_nan = (int)(ALLOW_NAN) \
452 .default_value.data.dble_value = (double)(DEFAULT)}
453#define DEF_DEG_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX) \
457 {.valid_min = (double)(VALID_MIN), \
458 .valid_max = (double)(VALID_MAX), \
459 .allow_nan = (int)false}, \
460 .default_value.data.dble_value = (double)(DEFAULT)}
461#define DEF_BOOL_PARAM(NAME, DEFAULT) \
463 .type = BOOL_PARAM, \
464 .default_value.data.bool_value = (int)(DEFAULT)}
465#define DEF_STR_PARAM(NAME, DEFAULT, MAX_STR_LEN) \
468 .data.str_param.max_str_len = (MAX_STR_LEN), \
469 .default_value.data.str_value = (DEFAULT)}
470#define DEF_MAP_PARAM(NAME, SUBPARAMS) \
473 .data.map_param.sub_params = (SUBPARAMS ## _subparams), \
474 .data.map_param.num_sub_params = (SUBPARAMS ## _subparams_count), \
475 .default_value.data.map_values = NULL}
476#define DEF_MAP_SUBPARAMS(NAME, ...) \
477 static struct interp_method_parameter \
478 NAME ## _subparams [] = {__VA_ARGS__}; \
480 NAME ## _subparams_count = \
481 sizeof(NAME ## _subparams) / sizeof(NAME ## _subparams[0])};
482#define DEF_SEQ_PARAM(NAME, SUBPARAM) \
485 .data.seq_param.sub_param = (SUBPARAM), \
486 .default_value.data.seq.values = NULL, \
487 .default_value.data.seq.count = 0}
490#define YAML_ASSERT(CHECK, MSG) \
491 YAC_ASSERT_F((CHECK), \
492 "ERROR(%s): " MSG " in YAML configuration file \"%s\"", \
493 routine_name, yaml_filename)
494#define YAML_ASSERT_F(CHECK, MSG, ...) \
495 YAC_ASSERT_F((CHECK), \
496 "ERROR(%s): " MSG " in YAML configuration file \"%s\"", \
497 routine_name, __VA_ARGS__, yaml_filename)
498#define YAML_UNREACHABLE_DEFAULT(MSG) \
499 YAC_UNREACHABLE_DEFAULT_F( \
500 "ERROR(%s): " MSG " in YAML configuration file \"%s\"", \
501 routine_name, yaml_filename)
502#define YAML_UNREACHABLE_DEFAULT_F(MSG, ...) \
503 YAC_UNREACHABLE_DEFAULT_F( \
504 "ERROR(%s): " MSG " in YAML configuration file \"%s\"", \
505 routine_name, __VA_ARGS__, yaml_filename)
507#define DEF_INTERP_STACK_ADD(NAME, ...) \
508 yac_interp_stack_config_add_ ## NAME ( \
509 interp_stack, __VA_ARGS__);
511#define DEF_INTERP_STACK_ADD_NO_PARAM(NAME) \
512 yac_interp_stack_config_add_ ## NAME ( \
515#define DEF_INTERP_STACK_GET(NAME, ...) \
516 yac_interp_stack_config_entry_get_ ## NAME ( \
517 interp_stack_entry, __VA_ARGS__);
519#define DEF_INTERP_STACK_GET_NO_PARAM(NAME) \
522#define DEF_INTERP_METHOD(YAML_NAME, FUNC_ADD, FUNC_GET, ...) \
523 DEF_INTERP_METHOD_ADD_FUNC(YAML_NAME, FUNC_ADD) \
524 DEF_INTERP_METHOD_GET_FUNC(YAML_NAME, FUNC_GET) \
525 DEF_MAP_SUBPARAMS(YAML_NAME, __VA_ARGS__)
527#define DEF_INTERP_METHOD_NO_PARAM(YAML_NAME, UI_NAME) \
528 DEF_INTERP_METHOD_ADD_FUNC( \
529 YAML_NAME, DEF_INTERP_STACK_ADD_NO_PARAM(UI_NAME)) \
530 DEF_INTERP_METHOD_GET_FUNC( \
531 YAML_NAME, DEF_INTERP_STACK_GET_NO_PARAM(UI_NAME))
537 parameter_value.data.map_values[0].data.enum_value,
538 parameter_value.data.map_values[1].data.bool_value),
542 ¶meter_value->data.map_values[1].data.bool_value)
543 parameter_value->
data.map_values[0].
data.enum_value =
544 (
int)reduction_type;,
560 parameter_value.
data.map_values[0].
data.enum_value,
561 parameter_value.
data.map_values[1].
data.bool_value),
565 ¶meter_value->
data.map_values[1].
data.bool_value)
566 parameter_value->
data.map_values[0].
data.enum_value =
582 parameter_value.
data.map_values[0].
data.enum_value,
583 (
size_t)parameter_value.
data.map_values[1].
data.int_value,
584 parameter_value.
data.map_values[2].
data.dble_value,
585 parameter_value.
data.map_values[3].
data.dble_value),
589 &
type, &n, ¶meter_value->
data.map_values[2].
data.dble_value,
590 ¶meter_value->
data.map_values[3].
data.dble_value)
591 parameter_value->
data.map_values[0].
data.enum_value = (
int)
type;
592 parameter_value->
data.map_values[1].
data.int_value = (
int)n;
615 parameter_value.
data.map_values[0].
data.int_value,
616 parameter_value.
data.map_values[1].
data.bool_value,
617 parameter_value.
data.map_values[2].
data.bool_value,
619 parameter_value.
data.map_values[3].
data.enum_value),
622 ¶meter_value->
data.map_values[0].
data.int_value,
623 ¶meter_value->
data.map_values[1].
data.bool_value,
624 ¶meter_value->
data.map_values[2].
data.bool_value,
626 parameter_value->
data.map_values[3].
data.enum_value =
662 "configurations for the computation and reading of %s cell areas "
663 "were provided (only one is allowed)",
type);
678 return cell_area_config;
691 "ERROR(get_cell_area_config_parameters): "
692 "invalid cell area configuration type (%s)", desc);
714 double * lon,
double * lat) {
717 parameters[0].is_set,
718 "ERROR(parse_point_coordinates): longitude coordinate is not defined");
720 parameters[1].is_set,
721 "ERROR(parse_point_coordinates): longitude coordinate is not defined");
732 "ERROR(parse_point_selection_parameter_bnd_circle): "
733 "bounding circle center is not defined");
736 "ERROR(parse_point_selection_parameter_bnd_circle): "
737 "bounding circle radius is not defined");
749 bounding_circle_center,
757 source_to_target_map_overwrite_condition,
762 size_t point_selection_type_idx = SIZE_MAX;
764 i < source_to_target_map_overwrite_condition_subparams_count; ++i) {
765 if (parameter.data.map_values[i].is_set) {
767 point_selection_type_idx == SIZE_MAX,
768 "ERROR(parse_point_selection_parameter): "
769 "more than one point selection type was provided")
770 point_selection_type_idx = i;
775 point_selection_type_idx != SIZE_MAX,
776 "ERROR(parse_point_selection_parameter): point selection is defined")
779 switch (point_selection_type_idx) {
785 src_point_selection =
787 parameter.data.map_values[0]);
792 return src_point_selection;
810 parse_point_selection_parameter(
812 double spread_distance =
814 double max_search_distance =
830 return overwrite_config;
849 "ERROR(get_point_selection_parameters): %s point selection type",
854 double center_lon, center_lat, radius;
856 point_selection, ¢er_lon, ¢er_lat, &radius);
860 data.map_values[0].data.dble_value =
865 data.map_values[1].data.dble_value =
869 data.map_values[1].data.dble_value =
881 source_to_target_map_overwrite,
882 DEF_MAP_PARAM(condition, source_to_target_map_overwrite_condition),
893 source_to_target_map_overwrite_seq =
895static void get_overwrite_config_parameters(
913 source_to_target_map_overwrite_seq);
927 source_to_target_map_cell_area_provider_yac,
931 source_to_target_map_cell_area_provider_file,
937 source_to_target_map_cell_area_provider,
939 DEF_MAP_PARAM(file, source_to_target_map_cell_area_provider_file))
945 parameter_value.
data.map_values[0].
data.dble_value;
947 parameter_value.
data.map_values[1].
data.dble_value;
950 parameter_value.
data.map_values[2].
data.enum_value;
953 parameter_value.
data.map_values[3].
data.enum_value;
955 parse_cell_area_config_parameters(
956 parameter_value.
data.map_values[4],
959 parse_cell_area_config_parameters(
960 parameter_value.
data.map_values[5],
964 scale_type, source_cell_area_config, target_cell_area_config);
971 (parameter_value.
data.map_values[6].
data.seq.count > 0)?
973 (parameter_value.
data.map_values[6].
data.seq.count + 1),
974 sizeof(*overwrite_configs)):NULL;
975 for (
size_t i = 0; i < parameter_value.
data.map_values[6].
data.seq.count;
977 overwrite_configs[i] =
993 parameter_value->
data.map_values[0].
data.dble_value =
995 parameter_value->
data.map_values[1].
data.dble_value =
997 parameter_value->
data.map_values[2].
data.enum_value =
999 parameter_value->
data.map_values[3].
data.enum_value =
1003 ¶meter_value->
data.map_values[4].
data.map_values[0].
data.map_values[0].
data.dble_value,
1004 ¶meter_value->
data.map_values[4].
data.map_values[1].
data.map_values[0].
data.str_value,
1005 ¶meter_value->
data.map_values[4].
data.map_values[1].
data.map_values[1].
data.str_value,
1006 ¶meter_value->
data.map_values[4].
data.map_values[1].
data.map_values[2].
data.int_value,
1010 ¶meter_value->
data.map_values[5].
data.map_values[0].
data.map_values[0].
data.dble_value,
1011 ¶meter_value->
data.map_values[5].
data.map_values[1].
data.map_values[0].
data.str_value,
1012 ¶meter_value->
data.map_values[5].
data.map_values[1].
data.map_values[1].
data.str_value,
1013 ¶meter_value->
data.map_values[5].
data.map_values[1].
data.map_values[2].
data.int_value,
1015 size_t overwrite_config_count = 0;
1017 (overwrite_configs != NULL) &&
1018 (overwrite_configs[overwrite_config_count] != NULL);
1019 ++overwrite_config_count);
1020 parameter_value->
data.map_values[6].
data.seq.values =
1022 overwrite_config_count *
1024 *(parameter_value->
data.map_values[6].
data.seq.values)));
1025 parameter_value->
data.map_values[6].
data.seq.count =
1026 overwrite_config_count;
1027 for (
size_t i = 0; i < overwrite_config_count; ++i)
1028 get_overwrite_config_parameters(
1029 overwrite_configs[i],
1030 parameter_value->
data.map_values[6].
data.seq.values + i);,
1067 src_cell_area, source_to_target_map_cell_area_provider),
1069 tgt_cell_area, source_to_target_map_cell_area_provider),
1071 overwrite, &source_to_target_map_overwrite_seq))
1076 (isnan(parameter_value.
data.map_values[0].
data.dble_value) ||
1077 parameter_value.
data.map_values[0].
data.dble_value != DBL_MAX),
1078 "parameter 'user_value' of interpolation method 'fixed' is unset");
1080 fixed, parameter_value.
data.map_values[0].
data.dble_value),
1082 fixed, ¶meter_value->
data.map_values[0].
data.dble_value),
1091 parameter_value.
data.map_values[0].
data.str_value,
1092 "parameter \"filename\" of interpolation method \"user file\" is unset");
1094 (
char*)(parameter_value.
data.map_values[0].
data.str_value),
1096 parameter_value.
data.map_values[1].
data.enum_value,
1098 parameter_value.
data.map_values[2].
data.enum_value),
1102 ¶meter_value->
data.map_values[0].
data.str_value,
1103 &on_missing_file, &on_success)
1104 parameter_value->
data.map_values[1].
data.enum_value =
1105 (
int)on_missing_file;
1106 parameter_value->
data.map_values[2].
data.enum_value =
1129 (
char*)(parameter_value.
data.map_values[0].
data.str_value),
1130 (
char*)(parameter_value.
data.map_values[1].
data.str_value)),
1132 ¶meter_value->
data.map_values[0].
data.str_value,
1133 ¶meter_value->
data.map_values[1].
data.str_value),
1150 (
size_t)parameter_value.
data.map_values[0].
data.int_value,
1151 parameter_value.
data.map_values[1].
data.dble_value,
1152 parameter_value.
data.map_values[2].
data.dble_value),
1155 &n, ¶meter_value->
data.map_values[1].
data.dble_value,
1156 ¶meter_value->
data.map_values[2].
data.dble_value)
1157 parameter_value->
data.map_values[0].
data.int_value = (
int)n;
1159 parameter_value->
data.map_values[3].
data.enum_value = (
int)0;,
1178 creep, parameter_value.
data.map_values[0].
data.int_value),
1180 creep, ¶meter_value->
data.map_values[0].
data.int_value),
1189 parameter_value.
data.map_values[0].
data.str_value,
1191 "of interpolation method \"user
callback\" is unset")
1194 (
char*)(parameter_value.
data.map_values[0].
data.str_value)),
1197 ¶meter_value->
data.map_values[0].
data.str_value),
1204#define ADD_INTERPOLATION(NAME, TYPE) \
1207 .add_interpolation = add_interp_method_ ## NAME , \
1208 .get_interpolation = get_interp_method_ ## NAME , \
1209 .parameter = DEF_MAP_PARAM(NAME, NAME)}
1210#define ADD_INTERPOLATION_NO_PARAM(NAME, TYPE) \
1213 .add_interpolation = add_interp_method_ ## NAME , \
1214 .get_interpolation = get_interp_method_ ## NAME , \
1217 .type = MAP_PARAM, \
1218 .data.map_param.sub_params = NULL, \
1219 .data.map_param.num_sub_params = 0, \
1220 .default_value.data.map_values = NULL}}
1223struct yac_interpolation_method {
1226 void(*add_interpolation)(
1230 void(*get_interpolation)(
1254 char const * routine_name =
"yaml_parse_string_value";
1257 value_node && fy_node_is_scalar(value_node),
1258 "unsupported node type for \"%s\" (the node is expected to be scalar)",
1261 return fy_node_get_scalar0(value_node);
1266 char const * routine_name =
"yaml_parse_calendar_value";
1268 char const * calendar_name =
1273 calendar_types, num_calendar_types, calendar_name);
1276 calendar_type != INT_MAX,
1277 "\"%s\" is not a valid calendar name", calendar_name);
1279 return (calendarType)calendar_type;
1285 char const * routine_name =
"yaml_parse_timestep_value";
1290 value_node && fy_node_is_scalar(value_node),
1291 "unsupported node type for \"%s\" (the node is expected to be scalar)",
1293 char const * timestep =
1295 char const * timestep_iso =
1299 timestep_iso,
"valid to convert timestep \"%s\" to ISO 8601 format",
1302 return strdup(timestep_iso);
1307 char const * routine_name =
"yaml_parse_timestep_unit_value";
1309 char const * timestep_unit_str =
1314 timestep_units, num_timestep_units, timestep_unit_str);
1317 timestep_unit != INT_MAX,
1318 "\"%s\" is not a valid time step unit", timestep_unit_str);
1325 char const * routine_name =
"yaml_parse_time_reduction_value";
1327 char const * time_reduction_str =
1330 int time_reduction =
1332 time_operations, num_time_operations, time_reduction_str);
1335 time_reduction != INT_MAX,
1336 "\"%s\" is not a valid time reduction type in", time_reduction_str);
1343 char const * routine_name =
"yaml_parse_integer_value";
1345 char const * integer_str =
1349 long int long_value = strtol(integer_str, &endptr, 10);
1352 (endptr != integer_str) && (*endptr ==
'\0') &&
1353 (long_value >= INT_MIN) && (long_value <= INT_MAX),
1354 "\"%s\" is not a valid integer value", integer_str);
1356 return (
int)long_value;
1361 char const * routine_name =
"yaml_parse_size_t_value";
1363 char const * size_t_str =
1367 char *endptr = NULL;
1368 uintmax_t temp = strtoumax(size_t_str, &endptr, 10);
1371 (errno == 0) && (endptr != size_t_str) && (*endptr ==
'\0') &&
1373 "\"%s\" is not a valid size_t value", size_t_str);
1375 return (
size_t)temp;
1380 char const * routine_name =
"yaml_parse_double_value";
1382 char const * double_str =
1386 double dble_value = strtod(double_str, &endptr);
1389 (endptr != double_str) && (*endptr ==
'\0'),
1390 "\"%s\" is not a valid double value for \"%s\"", double_str, key_name);
1398 char const * routine_name =
"yaml_parse_enum_value";
1400 char const * value_str =
1409 "\"%s\" is not a valid enum value for \"%s\" ", value_str, key_name);
1424 char const ** interpolation_type_str,
fy_node_t * parameter_node,
1426 char const * routine_name =
"yaml_parse_base_interp_method_node";
1431 switch(fy_node_get_type(interp_method_node)) {
1433 "unsupported interpolation method node type "
1434 "(interpolation methods are expected to be defined as either scalar "
1439 interpolation_name_node = interp_method_node;
1440 *parameter_node = NULL;
1444 case (FYNT_MAPPING):
1447 fy_node_mapping_item_count(interp_method_node) == 1,
1448 "base interpolation method node is only allowed to have one pair ");
1451 fy_node_mapping_get_by_index(interp_method_node, 0);
1453 interpolation_name_node = fy_node_pair_key(base_interp_method_pair);
1455 fy_node_t base_interp_method_value_node =
1456 fy_node_pair_value(base_interp_method_pair);
1459 fy_node_is_mapping(base_interp_method_value_node),
1460 "unsupported base interpolation method value node type "
1461 "for interpolation method \"%s\" "
1462 "(interpolation method parameters are expected to be "
1465 interpolation_name_node,
"interpolation method name",
yaml_filename));
1467 *parameter_node = base_interp_method_value_node;
1471 *interpolation_type_str =
1473 interpolation_name_node,
"interpolation method name",
yaml_filename);
1486 switch(parameter.
type) {
1489 "ERROR(yaml_interp_method_parameter_get_default): "
1490 "unsupported parameter type");
1528 return parameter_value;
1538 switch(parameter.
type) {
1541 "ERROR(yaml_interp_method_parameter_free): "
1542 "unsupported parameter type");
1547 for (
size_t seq_idx = 0;
1561 for (
size_t param_idx = 0;
1585 fy_node_t value_node,
char const * interpolation_name,
1601 fy_node_t value_node,
char const * interpolation_name,
1603 char const * routine_name =
"yaml_parse_interp_method_map_parameter";
1607 !value_node || fy_node_is_mapping(value_node),
1608 "invalid node type for parameter \"%s\" of interpolation method "
1609 "\"%s\" (has to be a map)", map_parameter.
name, interpolation_name);
1618 while ((parameter_pair = fy_node_mapping_iterate(value_node, &iter))) {
1621 char const * sub_parameter_name =
1623 fy_node_pair_key(parameter_pair),
1625 size_t sub_param_idx = SIZE_MAX;
1627 (i < num_sub_parameters) && (sub_param_idx == SIZE_MAX); ++i)
1628 if (!strcmp(sub_parameter_name, sub_parameters[i].
name))
1631 sub_param_idx != SIZE_MAX,
1632 "\"%s\" is not a valid parameter for interpolation method \"%s\"",
1633 sub_parameter_name, interpolation_name);
1635 fy_node_t parameter_value_node = fy_node_pair_value(parameter_pair);
1638 sub_parameters[sub_param_idx], &map_parameter_values[sub_param_idx],
1657 size_t * seq_parameter_count,
1658 fy_node_t value_node,
char const * interpolation_name,
1660 char const * routine_name =
"yaml_parse_interp_method_seq_parameter";
1664 fy_node_is_sequence(value_node),
1665 "invalid node type for parameter \"%s\" of interpolation method "
1666 "\"%s\" (has to be a sequence)", seq_parameter.
name, interpolation_name);
1670 *seq_parameter_count =
1671 (size_t)fy_node_sequence_item_count(value_node);
1672 *seq_parameter_values =
1673 xmalloc(*seq_parameter_count *
sizeof(**seq_parameter_values));
1676 for (
size_t seq_idx = 0; seq_idx < *seq_parameter_count; ++seq_idx) {
1677 (*seq_parameter_values)[seq_idx] =
1682 (*seq_parameter_values) + seq_idx,
1683 fy_node_sequence_get_by_index(
1684 value_node, (
int)seq_idx),
1704 fy_node_t value_node,
char const * interpolation_name,
1706 char const * routine_name =
"yaml_parse_interp_method_parameter_value";
1710 !parameter_value->
is_set,
1711 "\"%s\" parameter of interpolation method \"%s\" has already been set",
1712 parameter.
name, interpolation_name);
1715 switch(parameter.
type) {
1717 "unsupported type parameter \"%s\" of interpolation method \"%s\"",
1718 parameter.
name, interpolation_name);
1724 value_node,
"interpolation method enum parameter value",
1730 value_node,
"interpolation method integer parameter value",
1735 "\"%d\" is not a valid integer parameter value for parameter \"%s\" "
1736 "of interpolation method \"%s\" "
1737 "(valid range: %d <= value <= %d)",
1745 value_node,
"interpolation method double parameter value",
1755 "\"%lf\" is not a valid double parameter value for parameter \"%s\" "
1756 "of interpolation method \"%s\" "
1757 "(valid range: %e <= value <= %e; NaN allowed: %s)",
1766 value_node,
"interpolation method degree parameter value",
1773 "\"%lf\" is not a valid degree parameter value for parameter \"%s\" "
1774 "of interpolation method \"%s\" "
1775 "(valid range: %e <= value <= %e)",
1784 bool_names, num_bool_names, value_node,
1785 "interpolation method bool parameter value",
yaml_filename);
1790 value_node,
"interpolation method string parameter value",
1795 "\"%s\" is not a valid string parameter value for parameter \"%s\" "
1796 "of interpolation method \"%s\" "
1797 "(maximum string length: %d)",
1815 parameter_value->
is_set = 1;
1821 char const * routine_name =
"yaml_parse_interp_method";
1823 char const * interpolation_type_str;
1828 &interpolation_type_str, ¶meter_node,
1832 struct yac_interpolation_method const *
interp_method = NULL;
1839 "\"%s\" is not a valid interpolation method",
1840 interpolation_type_str);
1861 char const * routine_name =
"yaml_parse_interp_stack_value";
1864 fy_node_is_sequence(interp_stack_node),
1865 "unsupported interpolation stack node type"
1866 "(interpolation stacks are expected to be defined as a sequence)");
1871 while ((interp_stack_item =
1872 fy_node_sequence_iterate(interp_stack_node, &iter)))
1879 char const * routine_name =
"yaml_parse_field_name";
1881 struct field_couple_field_names field_name;
1883 switch(fy_node_get_type(field_node)) {
1886 "unsupported field name node type "
1887 "(field name is either scalars or a map)");
1890 case (FYNT_SCALAR): {
1900 case (FYNT_MAPPING): {
1903 fy_node_mapping_lookup_scalar0_by_simple_key(
1904 field_node,
"src", (
size_t)-1);
1906 fy_node_mapping_lookup_scalar0_by_simple_key(
1907 field_node,
"tgt", (
size_t)-1);
1910 field_name.src && field_name.tgt &&
1911 (fy_node_mapping_item_count(field_node) == 2),
1912 "invalid field name mapping node "
1913 "(field name mapping node has to contain two maps "
1914 "with the keys \"src\" and \"tgt\")")
1924 size_t ** values,
size_t * num_values,
1925 fy_node_t values_node,
char const * sequence_name,
1928 char const * routine_name =
"yaml_parse_size_t_sequence";
1931 (*values == NULL) && (*num_values == 0),
1932 "values have already been set for sequence \"%s\"",
1936 if (fy_node_is_sequence(values_node)) {
1938 *num_values = (size_t)fy_node_sequence_item_count(values_node);
1939 *values =
xmalloc(*num_values *
sizeof(**values));
1941 for (
size_t value_idx = 0; value_idx < *num_values; ++value_idx)
1942 (*values)[value_idx] =
1944 fy_node_sequence_get_by_index(values_node, value_idx),
1949 *values =
xmalloc(
sizeof(**values));
1957 fy_node_t values_node,
char const * sequence_name,
1960 char const * routine_name =
"yaml_parse_collection_selection_sequence";
1963 *collection_selection == NULL,
1964 "values have already been set for sequence \"%s\"",
1968 size_t * indices = NULL;
1973 *collection_selection =
1980 char const *** values,
size_t * num_values,
1981 fy_node_t values_node,
char const * sequence_name,
1983 char const * routine_name =
"yaml_parse_string_sequence";
1986 (*values == NULL) && (*num_values == 0),
1987 "values have already been set for sequence \"%s\"",
1991 if (fy_node_is_sequence(values_node)) {
1993 *num_values = (size_t)fy_node_sequence_item_count(values_node);
1994 *values =
xmalloc(*num_values *
sizeof(**values));
1995 for (
size_t value_idx = 0; value_idx < *num_values; ++value_idx)
1996 (*values)[value_idx] =
1998 fy_node_sequence_get_by_index(values_node, value_idx),
2002 *values =
xmalloc(
sizeof(**values));
2011 size_t * num_field_names,
fy_node_t fields_node,
2015 if (fy_node_is_sequence(fields_node)) {
2017 size_t start_idx = *num_field_names;
2018 *num_field_names += (size_t)fy_node_sequence_item_count(fields_node);
2021 for (
size_t i = start_idx; i < *num_field_names; ++i)
2024 fy_node_sequence_get_by_index(fields_node, i),
yaml_filename);
2029 (*field_names)[*num_field_names-1] =
2035 char const ** comp_name,
char const ***
grid_names,
size_t * num_grid_names,
2037 char const * routine_name =
"yaml_parse_comp_grids_names";
2040 *comp_name == NULL,
"%s component name already set", type_name);
2042 (*
grid_names == NULL) && (*num_grid_names == 0),
2043 "%s grid names already set", type_name);
2046 fy_node_is_mapping(values_node),
2047 "unsupported component/grid names node type (has to be a map)");
2052 while((pair = fy_node_mapping_iterate(values_node, &iter))) {
2057 yaml_comp_grid_names_keys, num_yaml_comp_grid_names_keys,
2058 fy_node_pair_key(pair),
2060 char const * comp_grid_names_key_name =
2062 yaml_comp_grid_names_keys, num_yaml_comp_grid_names_keys,
2063 comp_grid_names_key_type);
2065 fy_node_t name_node = fy_node_pair_value(pair);
2067 switch(comp_grid_names_key_type) {
2087 char const * routine_name =
"yaml_parse_weight_file";
2093 "%s \"on existing\" already set ", type_name);
2096 fy_node_is_mapping(values_node),
2097 "unsupported weight file data node type (has to be a map)");
2102 while((pair = fy_node_mapping_iterate(values_node, &iter))) {
2107 yaml_weight_file_data_keys, num_yaml_weight_file_data_keys,
2108 fy_node_pair_key(pair),
2110 char const * weight_file_data_key_name =
2112 yaml_weight_file_data_keys, num_yaml_weight_file_data_keys,
2113 weight_file_data_key_type);
2115 fy_node_t weight_file_data_node = fy_node_pair_value(pair);
2117 switch(weight_file_data_key_type) {
2122 weight_file_data_node, weight_file_data_key_name,
yaml_filename);
2128 weight_file_on_existing_types,
2129 num_weight_file_on_existing_types,
2130 weight_file_data_node, weight_file_data_key_name,
2141 char const * routine_name =
"yaml_parse_couple_map_pair";
2146 yaml_couple_keys, num_yaml_couple_keys,
2147 fy_node_pair_key(couple_pair),
2149 char const * couple_key_name =
2151 yaml_couple_keys, num_yaml_couple_keys, couple_key_type);
2153 fy_node_t value_node = fy_node_pair_value(couple_pair);
2155 switch (couple_key_type) {
2224 weight_file_on_existing_types,
2225 num_weight_file_on_existing_types,
2237 mapping_sides, num_mapping_sides,
2279 bool_names, num_bool_names,
2288 char const * routine_name =
"yaml_parse_couple";
2291 fy_node_is_mapping(couple_node),
2292 "unsupported couple node type "
2293 "(couples are expected to be defined as a mapping)");
2298 .src.grid.name = NULL,
2299 .src.grid.count = 0,
2300 .tgt.comp_name = NULL,
2301 .tgt.grid.name = NULL,
2302 .tgt.grid.count = 0,
2303 .field_names = NULL,
2304 .num_field_names = 0,
2305 .coupling_period = NULL,
2310 .weight_file.name = NULL,
2312 .mapping_on_source = 1,
2313 .scale_factor = 1.0,
2314 .scale_summand = 0.0,
2315 .src_mask_names = NULL,
2316 .num_src_mask_names = 0,
2317 .tgt_mask_name = NULL,
2318 .yaxt_exchanger_name = NULL,
2319 .collection_selection = NULL,
2320 .use_raw_exchange = 0};
2325 while ((pair = fy_node_mapping_iterate(couple_node, &iter)))
2330 field_buffer.
src.
comp_name,
"missing source component name");
2333 "missing source grid name (component \"%s\")",
2335 for (
size_t i = 0; i < field_buffer.
src.
grid.
count; ++i)
2339 "invalid source grid name (component \"%s\" grid idx %zu)",
2343 "missing target component name");
2346 "missing target grid name (component \"%s\")",
2348 for (
size_t i = 0; i < field_buffer.
tgt.
grid.
count; ++i)
2352 "invalid target grid name (component \"%s\" grid idx %zu)",
2356 "missing field names "
2357 "(source component \"%s\" source grid \"%s\" "
2358 "target component \"%s\" target grid \"%s\")",
2363 "missing coupling period "
2364 "(source component \"%s\" source grid \"%s\" "
2365 "target component \"%s\" target grid \"%s\")",
2370 for (
size_t j = 0; j < field_buffer.
src.
grid.
count; ++j)
2371 for (
size_t k = 0; k < field_buffer.
tgt.
grid.
count; ++k)
2413 char const * routine_name =
"yaml_parse_coupling";
2416 if (!coupling_node)
return;
2419 fy_node_is_sequence(coupling_node),
2420 "unsupported coupling node type "
2421 "(couplings are expected to be defined as a sequence)");
2426 while ((couple_node = fy_node_sequence_iterate(coupling_node, &iter)))
2431 fy_node_t config_file_node, char const * file_type_name,
2433 char const * routine_name =
"yaml_parse_config_file_value";
2435 struct debug_config_file config_file =
2438 char * str_buffer =
xmalloc(strlen(file_type_name) + 32);
2440 switch(fy_node_get_type(config_file_node)) {
2443 "unsupported config file node type "
2444 "(%s is either scalar or a map)", file_type_name);
2447 case (FYNT_SCALAR): {
2452 strcat(strcpy(str_buffer, file_type_name),
" name"),
2459 case (FYNT_MAPPING): {
2462 fy_node_mapping_lookup_by_string(
2463 config_file_node,
"filename", (
size_t)-1);
2465 fy_node_mapping_lookup_by_string(
2466 config_file_node,
"filetype", (
size_t)-1);
2468 fy_node_mapping_lookup_by_string(
2469 config_file_node,
"include_definitions", (
size_t)-1);
2473 "invalid %s mapping node "
2474 "(global config file mapping node has to include a map "
2475 "with the keys \"filename\")", file_type_name)
2479 filename_node, strcat(strcpy(str_buffer, file_type_name),
" name"),
2485 config_filetypes, num_config_filetypes,
2486 filetype_node, strcat(strcpy(str_buffer, file_type_name),
" type"),
2488 config_file.include_definitions =
2489 (include_definitions_node)?
2491 bool_names, num_bool_names,
2492 include_definitions_node,
2493 strcat(strcpy(str_buffer, file_type_name),
" include definitions"),
2500 config_file.name,
"missing filename for %s", file_type_name);
2509 fy_node_pair_t config_file_pair,
char const * config_file_type_name,
2513 debug_sync_loc_key_type =
2516 yaml_debug_sync_loc_keys,
2517 num_yaml_debug_sync_loc_keys,
2518 fy_node_pair_key(config_file_pair),
2519 "config synchronisation location parameter name",
2521 char const * debug_sync_loc_key_name =
2523 yaml_debug_sync_loc_keys, num_yaml_debug_sync_loc_keys,
2524 debug_sync_loc_key_type);
2526 fy_node_t value_node = fy_node_pair_value(config_file_pair);
2528 char config_file_type_name_sync[
2529 strlen(config_file_type_name) + strlen(debug_sync_loc_key_name) + 8];
2531 config_file_type_name_sync,
"%s (%s)",
2532 config_file_type_name, debug_sync_loc_key_name);
2534 config_file_buffer->
config_file[debug_sync_loc_key_type] =
2540 fy_node_t config_file_node, char const * config_file_type_name,
2542 char const * routine_name =
"yaml_parse_debug_config_file_buffer";
2545 fy_node_is_mapping(config_file_node),
2546 "unsupported %s node type "
2547 "(%s is expected to be defined as a mapping)",
2548 config_file_type_name, config_file_type_name);
2563 "invalid unsupported synchronisation location (%d) for %s",
2564 i, config_file_type_name);
2570 while ((pair = fy_node_mapping_iterate(config_file_node, &iter)))
2572 &config_file_buffer, pair, config_file_type_name,
yaml_filename);
2574 return config_file_buffer;
2580 char const * routine_name =
"yaml_parse_debug_global_config";
2582 char const * config_file_type_name =
"debug global config file";
2585 fy_node_is_mapping(global_config_node),
2586 "unsupported %s node type "
2587 "(%s is expected to be defined as a mapping)",
2588 config_file_type_name, config_file_type_name);
2604 char const ** grid_name,
char const **
file_name,
2606 char const * routine_name =
"yaml_parse_output_grid_pair";
2611 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
2612 fy_node_pair_key(output_grid_pair),
2614 char const * debug_output_key_name =
2616 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
2617 output_grid_key_type);
2619 fy_node_t value_node = fy_node_pair_value(output_grid_pair);
2621 switch(output_grid_key_type) {
2639 char const * routine_name =
"yaml_parse_output_grid";
2642 fy_node_is_mapping(output_grid_node),
2643 "unsupported output grid node type "
2644 "(output grids are expected to be defined as a mapping)");
2646 char const * grid_name = NULL;
2652 while ((pair = fy_node_mapping_iterate(output_grid_node, &iter)))
2666 char const * routine_name =
"yaml_parse_debug_output_grids";
2669 fy_node_is_sequence(output_grids_node),
2670 "unsupported debug output grids node type "
2671 "(debug output grids is expected to be defined as a sequence)");
2676 while ((output_grid_node =
2677 fy_node_sequence_iterate(output_grids_node, &iter)))
2685 char const * routine_name =
"yaml_parse_debug_map_pair";
2690 yaml_debug_keys, num_yaml_debug_keys,
2691 fy_node_pair_key(debug_pair),
2694 fy_node_t value_node = fy_node_pair_value(debug_pair);
2696 switch (debug_key_type) {
2710 bool_names, num_bool_names, value_node,
2711 "\"missing definition is fatal\" bool value",
yaml_filename));
2719 char const * routine_name =
"yaml_parse_debug";
2722 if (!debug_node)
return;
2725 fy_node_is_mapping(debug_node),
2726 "unsupported debug node type "
2727 "(debug is expected to be defined as a mapping)");
2732 while ((pair = fy_node_mapping_iterate(debug_node, &iter)))
2739 char const ** start_datetime,
char const ** end_datetime) {
2740 char const * routine_name =
"yaml_parse_base_map_pair";
2742 fy_node_t key_node = fy_node_pair_key(base_pair);
2745 fy_node_is_scalar(key_node),
2746 "unsupported key node type "
2747 "(key nodes are expected to be scalar nodes)");
2749 char const * base_key_name = fy_node_get_scalar0(key_node);
2752 yaml_base_keys, num_yaml_base_keys, base_key_name);
2754 fy_node_t value_node = fy_node_pair_value(base_pair);
2756 switch (base_key_type) {
2778 "inconsistent redefinition of time unit")
2779 *time_unit = time_unit_;
2785 "time unit has to be defined before the couplings")
2801 char const * routine_name =
"yaml_parse_document";
2804 fy_node_t root_node = fy_document_root(document);
2807 if (!root_node)
return;
2810 fy_node_is_mapping(root_node),
2811 "unsupported root node type (root node is expected to be a mapping node)");
2813 char const * start_datetime = NULL;
2814 char const * end_datetime = NULL;
2820 while ((pair = fy_node_mapping_iterate(root_node, &iter)))
2823 &start_datetime, &end_datetime);
2825 if ((start_datetime != NULL) || (end_datetime != NULL)) {
2829 "ERROR(yaml_parse_document): "
2830 "cannot set start/end datetime because calendar has not yet been set");
2833 couple_config, start_datetime, end_datetime);
2840 char const * routine_name =
"yac_yaml_read_coupling";
2845 "ERROR(%s): YAML configuration file could not be found \"%s\"",
2852 "ERROR(%s): could not open YAML configuration file \"%s\"",
2856 struct fy_parse_cfg parse_config =
2857 {.search_path =
".",
2860 parse_config.flags =
2861 (
enum fy_parse_cfg_flags)parse_flags;
2864 fy_document_build_from_fp(&parse_config, config_file);
2867 "ERROR(%s): could not parse YAML configuration file \"%s\"",
2872 !fy_document_resolve(document),
2873 "could not resolve anchors and merge keys");
2879 fy_document_destroy(document);
2887 char const * str_interp_stack_config,
int parse_flags) {
2888 char const * routine_name =
2889 "yac_yaml_parse_interp_stack_config_string";
2891 "user-provided interp stack config string";
2894 str_interp_stack_config != NULL,
"interpolation stack string is NULL");
2897 struct fy_parse_cfg parse_config =
2898 {.search_path =
".",
2901 parse_config.flags =
2902 (
enum fy_parse_cfg_flags)parse_flags;
2905 fy_document_build_from_string(
2906 &parse_config, str_interp_stack_config, (
size_t)-1);
2911 !fy_document_resolve(document),
2912 "could not resolve anchors and merge keys");
2914 fy_node_t interp_stack_config_node = fy_document_root(document);
2915 YAML_ASSERT(interp_stack_config_node,
"invalid root node");
2921 interp_stack_config, interp_stack_config_node,
2925 fy_document_destroy(document);
2927 return interp_stack_config;
2937 fy_node_create_scalar_copy(document,
value, strlen(
value));
2940 "ERROR(yac_yaml_create_scalar): failed to create scalar node");
2949 int value_size = snprintf(str_value,
sizeof(str_value),
"%d",
value);
2951 (value_size >= 0) && ((
size_t)value_size <
sizeof(str_value)),
2952 "ERROR(yac_yaml_create_scalar_int): "
2953 "could not write \"%d\" to string buffer of size %zu",
2954 value,
sizeof(str_value));
2963 int value_size = snprintf(str_value,
sizeof(str_value),
"%zu",
value);
2965 (value_size >= 0) && ((
size_t)value_size <
sizeof(str_value)),
2966 "ERROR(yac_yaml_create_scalar_size_t): "
2967 "could not write \"%zu\" to string buffer of size %zu",
2968 value,
sizeof(str_value));
2977 int value_size = snprintf(str_value,
sizeof(str_value),
"%g",
value);
2979 (value_size >= 0) && ((
size_t)value_size <
sizeof(str_value)),
2980 "ERROR(yac_yaml_create_scalar_dble): "
2981 "could not write \"%g\" to string buffer of size %zu",
2982 value,
sizeof(str_value));
2988 fy_document_t document,
char const *
const * values,
size_t num_values) {
2991 if (num_values == 0)
return (
fy_node_t)NULL;
2994 values,
"ERROR(yac_yaml_create_sequence_scalar): no values provided");
2997 fy_node_t sequence_node = fy_node_create_sequence(document);
2999 sequence_node,
"ERROR(yac_yaml_create_sequence_scalar): "
3000 "failed to create sequence node");
3002 for (
size_t value_idx = 0; value_idx < num_values; ++value_idx) {
3003 char const *
value = values[value_idx];
3005 value,
"ERROR(yac_yaml_create_sequence_scalar): "
3006 "invalid value at idx %zu", value_idx);
3007 int appending_failed =
3008 fy_node_sequence_append(
3011 !appending_failed,
"ERROR(yac_yaml_create_sequence_scalar): "
3012 "failed to append interpolation node");
3015 return sequence_node;
3019 fy_document_t document,
size_t const * values,
size_t num_values) {
3022 if (num_values == 0)
return (
fy_node_t)NULL;
3025 values,
"ERROR(yac_yaml_create_sequence_scalar_size_t): "
3026 "no values provided");
3029 fy_node_t sequence_node = fy_node_create_sequence(document);
3031 sequence_node,
"ERROR(yac_yaml_create_sequence_scalar_size_t): "
3032 "failed to create sequence node");
3035 for (
size_t value_idx = 0; value_idx < num_values; ++value_idx) {
3037 snprintf(str_value,
sizeof(str_value),
"%zu", values[value_idx]);
3039 (value_size >= 0) && ((
size_t)value_size <
sizeof(str_value)),
3040 "ERROR(yac_yaml_create_sequence_scalar_size_t): "
3041 "could not write \"%zu\" to string buffer of size %zu",
3042 values[value_idx],
sizeof(str_value));
3046 "ERROR(yac_yaml_create_sequence_scalar_size_t): "
3047 "failed to create scalar at idx %zu", value_idx);
3048 int appending_failed = fy_node_sequence_append(sequence_node, scalar_node);
3051 "ERROR(yac_yaml_create_sequence_scalar_size_t): "
3052 "failed to append sequence element");
3055 return sequence_node;
3066 key,
"ERROR(yac_yaml_map_append): NULL key is not supported");
3071 "ERROR(yac_yaml_map_append): failed to get document from node");
3074 int appending_failed =
3075 fy_node_mapping_append(
3079 "ERROR(yac_yaml_map_append): failed to append mapping node pair");
3087 document,
"ERROR(yac_yaml_map_append_scalar): "
3088 "failed to get document from node");
3098 document,
"ERROR(yac_yaml_map_append_scalar_int): "
3099 "failed to get document from node");
3110 document,
"ERROR(yac_yaml_map_append_scalar_size_t): "
3111 "failed to get document from node");
3122 document,
"ERROR(yac_yaml_map_append_scalar_dble): "
3123 "failed to get document from node");
3131 size_t couple_idx,
size_t field_couple_idx) {
3133 const char * src_field_name;
3134 const char * tgt_field_name;
3136 couple_config, couple_idx, field_couple_idx,
3137 &src_field_name, &tgt_field_name);
3140 if (!strcmp(src_field_name, tgt_field_name))
3144 fy_node_t field_name_node = fy_node_create_mapping(document);
3146 field_name_node,
"ERROR(yac_yaml_create_field_name_node): "
3147 "failed to create mapping node");
3155 return field_name_node;
3164 switch (parameter.
type) {
3166 "ERROR(yac_yaml_create_scalar_parameter_node): "
3167 "unsupported parameter type");
3168 case (ENUM_PARAM): {
3184 case (DBLE_PARAM): {
3189 case (BOOL_PARAM): {
3204 return parameter_node;
3213 map, parameter.
name,
3215 document, parameter, parameter_value));
3224 switch (parameter.
type) {
3226 "ERROR(compare_parameter_values): "
3227 "invalid interpolation method parameter value type");
3267 size_t seq_parameter_values_count,
3271 parameter.
type == SEQ_PARAM,
3272 "ERROR(yac_yaml_create_seq_parameter_node): "
3273 "parameter \"%s\" is not a map", parameter.
name);
3277 (seq_parameter_values_count > 0)?fy_node_create_sequence(document):NULL;
3279 sequence_node || (seq_parameter_values_count == 0),
3280 "ERROR(yac_yaml_create_seq_parameter_node): "
3281 "failed to create sequence node");
3286 for (
size_t seq_idx = 0; seq_idx < seq_parameter_values_count; ++seq_idx) {
3290 seq_parameter_values[seq_idx];
3292 switch (sub_parameter.
type) {
3295 "ERROR(yac_yaml_create_seq_parameter_node): "
3296 "parameter \"%s\" has unsupported parameter type",
3297 sub_parameter.
name);
3302 sub_parameter_node =
3333 int appending_failed =
3334 fy_node_sequence_append(sequence_node, sub_parameter_node);
3337 "ERROR(yac_yaml_create_seq_parameter_node): "
3338 "failed to append parameter \"%s\" to sequence", parameter.
name);
3341 return sequence_node;
3350 parameter.
type == MAP_PARAM,
3351 "ERROR(yac_yaml_create_non_default_map_parameter_node): "
3352 "parameter \"%s\" is not a map", parameter.
name);
3355 fy_node_t parameter_node = fy_node_create_mapping(document);
3357 parameter_node,
"ERROR(yac_yaml_create_non_default_map_parameter_node): "
3358 "failed to create mapping node");
3360 int contains_non_default_values = 0;
3361 for (
size_t sub_param_idx = 0;
3368 map_parameter_values[sub_param_idx];
3370 switch(sub_parameter.
type) {
3373 "ERROR(yac_yaml_create_non_default_map_parameter_node): "
3374 "parameter \"%s\" has unsupported parameter type",
3385 if (sub_parameter_node) {
3387 parameter_node, sub_parameter.
name, sub_parameter_node);
3388 contains_non_default_values = 1;
3402 if (sub_parameter_node) {
3404 parameter_node, sub_parameter.
name, sub_parameter_node);
3405 contains_non_default_values = 1;
3420 &sub_parameter_value, sub_parameter)) {
3422 document, parameter_node, sub_parameter, sub_parameter_value);
3423 contains_non_default_values = 1;
3431 if (!contains_non_default_values) {
3432 fy_node_free(parameter_node);
3433 parameter_node = NULL;
3435 return parameter_node;
3445 struct yac_interpolation_method const *
interp_method = NULL;
3461 interp_method->get_interpolation(interp_stack_entry, ¶meter_value);
3473 if (parameter_node) {
3476 interpolation_node = fy_node_create_mapping(document);
3478 interpolation_node,
"ERROR(yac_yaml_create_interpolation_node): "
3479 "failed to create mapping node");
3485 interpolation_node =
3489 return interpolation_node;
3494 size_t couple_idx,
size_t field_couple_idx) {
3498 couple_config, couple_idx, field_couple_idx);
3501 interp_stack,
"ERROR(yac_yaml_create_interpolation_stack_node): "
3502 "invalid interpolation stack");
3505 fy_node_t interp_stack_node = fy_node_create_sequence(document);
3507 interp_stack_node,
"ERROR(yac_yaml_create_interpolation_stack_node): "
3508 "failed to create sequence node");
3510 size_t interp_stack_size =
3513 interp_stack_size,
"ERROR(yac_yaml_create_interpolation_stack_node): "
3514 "invalid interpolation stack size");
3516 for (
size_t interp_stack_idx = 0; interp_stack_idx < interp_stack_size;
3517 ++interp_stack_idx) {
3518 int appending_failed =
3519 fy_node_sequence_append(
3524 interp_stack, interp_stack_idx)));
3527 "ERROR(yac_yaml_create_interpolation_stack_node): "
3528 "failed to append interpolation node");
3531 return interp_stack_node;
3536 size_t couple_idx,
size_t field_couple_idx) {
3540 document,
"ERROR(yac_yaml_append_couple_field_nodes): "
3541 "failed to get document from node");
3544 fy_node_t field_couple_node = fy_node_create_mapping(document);
3546 coupling_node,
"ERROR(yac_yaml_append_couple_field_nodes): "
3547 "failed to create mapping node");
3550 char const * src_component_name;
3551 char const * tgt_component_name;
3553 couple_config, couple_idx, field_couple_idx,
3554 &src_component_name, &tgt_component_name);
3561 src_component_name);
3568 tgt_component_name);
3574 couple_config, couple_idx, field_couple_idx,
3581 yaml_couple_keys, num_yaml_couple_keys,
SOURCE_GRID),
3588 yaml_couple_keys, num_yaml_couple_keys,
TARGET_GRID),
3595 yaml_couple_keys, num_yaml_couple_keys,
FIELD),
3597 document, couple_config, couple_idx, field_couple_idx));
3605 couple_config, couple_idx, field_couple_idx));
3613 time_operations, num_time_operations,
3615 couple_config, couple_idx, field_couple_idx)));
3621 yaml_couple_keys, num_yaml_couple_keys,
SOURCE_LAG),
3623 couple_config, couple_idx, field_couple_idx));
3629 yaml_couple_keys, num_yaml_couple_keys,
TARGET_LAG),
3631 couple_config, couple_idx, field_couple_idx));
3635 couple_config, couple_idx, field_couple_idx)) {
3641 couple_config, couple_idx, field_couple_idx));
3647 weight_file_on_existing_types, num_weight_file_on_existing_types,
3649 couple_config, couple_idx, field_couple_idx)));
3658 mapping_sides, num_mapping_sides,
3660 couple_config, couple_idx, field_couple_idx)));
3668 couple_config, couple_idx, field_couple_idx));
3676 couple_config, couple_idx, field_couple_idx));
3684 document, couple_config, couple_idx, field_couple_idx));
3687 char const *
const * src_mask_names;
3688 size_t num_src_mask_names;
3690 couple_config, couple_idx, field_couple_idx,
3691 &src_mask_names, &num_src_mask_names);
3692 if (num_src_mask_names == 1)
3698 else if (num_src_mask_names > 1)
3704 document, src_mask_names, num_src_mask_names));
3707 char const * tgt_mask_name =
3709 couple_config, couple_idx, field_couple_idx);
3718 char const * yaxt_exchanger_name =
3720 couple_config, couple_idx, field_couple_idx);
3721 if (yaxt_exchanger_name)
3726 yaxt_exchanger_name);
3731 couple_config, couple_idx, field_couple_idx);
3732 if (collection_selection) {
3735 size_t const * indices =
3737 size_t * continous_indices = NULL;
3738 if (indices == NULL) {
3741 for (
size_t i = 0; i <
collection_size; ++i) continous_indices[i] = i;
3742 indices = continous_indices;
3758 free(continous_indices);
3767 bool_names, num_bool_names,
3769 couple_config, couple_idx, field_couple_idx)));
3771 int appending_failed =
3772 fy_node_sequence_append(coupling_node, field_couple_node);
3775 "ERROR(yac_yaml_append_couple_field_nodes): "
3776 "failed to append field couple node");
3781 size_t couple_idx) {
3783 size_t num_couple_fields =
3786 for (
size_t field_couple_idx = 0;
3787 field_couple_idx < num_couple_fields; ++field_couple_idx)
3789 coupling_node, couple_config, couple_idx, field_couple_idx);
3795 fy_node_t output_grid_node = fy_node_create_mapping(document);
3797 output_grid_node,
"ERROR(yac_yaml_create_output_grid_node): "
3798 "failed to create mapping node");
3803 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
3809 yaml_debug_output_grid_keys, num_yaml_debug_output_grid_keys,
3813 return output_grid_node;
3820 size_t num_output_grids = 0;
3831 if (num_output_grids > 0) {
3834 output_grids_node = fy_node_create_sequence(document);
3836 output_grids_node,
"ERROR(yac_yaml_create_output_grids_node): "
3837 "failed to create sequence node");
3842 char const * grid_name =
3848 int appending_failed =
3849 fy_node_sequence_append(
3853 !appending_failed,
"ERROR(yac_yaml_create_output_grids_node): "
3854 "failed to append output grid node");
3859 return output_grids_node;
3866 fy_node_t debug_node = fy_node_create_mapping(document);
3868 debug_node,
"ERROR(yac_yaml_create_debug_node): "
3869 "failed to create mapping node");
3882 yaml_debug_keys, num_yaml_debug_keys,
MISSING_DEF),
3884 bool_names, num_bool_names,
3893 size_t num_couples =
3896 if (!num_couples)
return NULL;
3899 fy_node_t coupling_node = fy_node_create_sequence(document);
3901 coupling_node,
"ERROR(yac_yaml_create_coupling_node): "
3902 "failed to create sequence node");
3905 for (
size_t couple_idx = 0; couple_idx < num_couples; ++couple_idx)
3907 coupling_node, couple_config, couple_idx);
3909 return coupling_node;
3916 fy_node_t field_node = fy_node_create_mapping(document);
3918 field_node,
"ERROR(yac_yaml_create_field_node): "
3919 "failed to create mapping node");
3922 char const * component_name =
3925 char const * field_name =
3928 char const * grid_name =
3931 char const * metadata =
3933 couple_config, component_name, grid_name, field_name);
3936 couple_config, component_name, grid_name, field_name);
3937 char const * timestep =
3939 couple_config, component_name, grid_name, field_name);
3942 couple_config, component_name, grid_name, field_name);
3943 double frac_mask_fallback_value =
3945 couple_config, component_name, grid_name, field_name);
3975 field_node,
"frac_mask_fallback_value", frac_mask_fallback_value);
3989 fy_node_t fields_node = fy_node_create_sequence(document);
3991 fields_node,
"ERROR(yac_yaml_create_fields_node): "
3992 "failed to create sequence node");
3994 for (
size_t field_idx = 0; field_idx <
num_fields; ++field_idx) {
3996 int appending_failed =
3997 fy_node_sequence_append(
4002 !appending_failed,
"ERROR(yac_yaml_create_fields_node): "
4003 "failed to append field node");
4013 fy_node_t component_node = fy_node_create_mapping(document);
4015 component_node,
"ERROR(yac_yaml_create_component_node): "
4016 "failed to create mapping node");
4019 char const * component_name =
4021 char const * metadata =
4037 return component_node;
4049 fy_node_t components_node = fy_node_create_sequence(document);
4051 components_node,
"ERROR(yac_yaml_create_components_node): "
4052 "failed to create sequence node");
4057 int appending_failed =
4058 fy_node_sequence_append(
4062 !appending_failed,
"ERROR(yac_yaml_create_components_node): "
4063 "failed to append component node");
4066 return components_node;
4073 fy_node_t grid_node = fy_node_create_mapping(document);
4075 grid_node,
"ERROR(yac_yaml_create_grid_node): "
4076 "failed to create mapping node");
4079 char const * grid_name =
4081 char const * metadata =
4103 fy_node_t grids_node = fy_node_create_sequence(document);
4105 grids_node,
"ERROR(yac_yaml_create_grids_node): "
4106 "failed to create sequence node");
4108 for (
size_t grids_idx = 0; grids_idx <
num_grids; ++grids_idx) {
4110 int appending_failed =
4111 fy_node_sequence_append(
4115 !appending_failed,
"ERROR(yac_yaml_create_grids_node): "
4116 "failed to append grid node");
4126 fy_node_t definition_node = fy_node_create_mapping(document);
4129 "ERROR(yac_yaml_create_definitions_node): "
4130 "failed to create mapping node");
4141 return definition_node;
4146 int include_definitions) {
4149 fy_node_t root_node = fy_node_create_mapping(document);
4152 "ERROR(yac_yaml_create_couple_config_nodes): "
4153 "failed to create mapping node");
4159 yaml_base_keys, num_yaml_base_keys,
DEBUG),
4163 if (include_definitions)
4165 root_node,
"definitions",
4173 yaml_base_keys, num_yaml_base_keys,
START_DATE), start_datetime);
4174 free(start_datetime);
4181 yaml_base_keys, num_yaml_base_keys,
END_DATE), end_datetime);
4188 yaml_base_keys, num_yaml_base_keys,
CALENDAR),
4190 calendar_types, num_calendar_types, getCalendarType()));
4204 yaml_base_keys, num_yaml_base_keys,
COUPLING),
4212 int include_definitions) {
4217 document,
"ERROR(yac_yaml_emit): failed to create document");
4222 document, couple_config, include_definitions);
4225 int setting_root_failed =
4226 fy_document_set_root(document, root_node);
4228 !setting_root_failed,
4229 "ERROR(yac_yaml_emit): failed to add root node to document");
4232 char * str_document =
4233 fy_emit_document_to_string(
4234 document, (
enum fy_emitter_cfg_flags)emit_flags);
4237 str_document,
"ERROR(yac_yaml_emit): failed to emit document to string");
4240 fy_document_destroy(document);
4242 return str_document;
char const * grid_names[]
unsigned component_idx[3]
char const * field_names[8]
#define YAC_ASSERT(exp, msg)
static struct yac_point_selection * parse_point_selection_parameter_bnd_circle(interp_method_parameter_value const parameter)
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
#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_STR_PARAM(NAME, DEFAULT, MAX_STR_LEN)
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)
static struct yac_spmap_overwrite_config * parse_overwrite_config_parameter(interp_method_parameter_value const *parameter_value, struct yac_spmap_scale_config *scale_config)
static fy_node_t yac_yaml_create_scalar_dble(fy_document_t document, double value)
#define YAML_UNREACHABLE_DEFAULT_F(MSG,...)
#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
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)
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 fy_node_t yac_yaml_create_sequence_scalar_size_t(fy_document_t document, size_t const *values, size_t num_values)
int const YAC_YAML_PARSER_JSON_AUTO
static void yaml_parse_size_t_sequence(size_t **values, size_t *num_values, fy_node_t values_node, char const *sequence_name, const char *yaml_filename)
#define YAML_UNREACHABLE_DEFAULT(MSG)
char * yac_yaml_emit_coupling(struct yac_couple_config *couple_config, int emit_flags, int include_definitions)
static size_t yaml_parse_size_t_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
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)
#define DEF_INTERP_METHOD_NO_PARAM(YAML_NAME, UI_NAME)
static void yaml_parse_interp_method_seq_parameter(struct interp_method_parameter seq_parameter, interp_method_parameter_value **seq_parameter_values, size_t *seq_parameter_count, fy_node_t value_node, char const *interpolation_name, char const *yaml_filename)
int const YAC_YAML_EMITTER_DEFAULT
emit to YAML format
void yac_yaml_read_coupling(struct yac_couple_config *couple_config, const char *yaml_filename, int parse_flags)
#define DEF_SEQ_PARAM(NAME, SUBPARAM)
static fy_node_t yac_yaml_create_non_default_map_parameter_node(fy_document_t document, interp_method_parameter_value const *map_parameter_values, struct interp_method_parameter parameter)
@ WEIGHT_FILE_ON_EXISTING
static int yaml_parse_integer_value(fy_node_t value_node, char const *key_name, char const *yaml_filename)
static fy_node_t yac_yaml_create_scalar_parameter_node(fy_document_t document, struct interp_method_parameter parameter, interp_method_parameter_value parameter_value)
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
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)
static int compare_parameter_values(interp_method_parameter_value const *a, interp_method_parameter_value const *b, struct interp_method_parameter parameter)
struct fy_document * fy_document_t
int const YAC_YAML_PARSER_DEFAULT
default parse flags (YAML format)
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)
reads interpolation name and user-provided parameters from YAML node
static void yaml_parse_weight_file_data(char const **weight_file_name, enum yac_weight_file_on_existing *on_existing, fy_node_t values_node, char const *type_name, const char *yaml_filename)
static void parse_point_coordinates(interp_method_parameter_value const *parameters, double *lon, double *lat)
yaml_weight_file_data_key_types
@ WEIGHT_FILE_DATA_ON_EXISTING
#define DEF_INTERP_METHOD(YAML_NAME, FUNC_ADD, FUNC_GET,...)
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)
static void get_cell_area_config_parameters(struct yac_spmap_cell_area_config const *cell_area_config, double *sphere_radius, char const **filename, char const **varname, int *min_global_id, char const *desc)
#define DEF_MAP_PARAM(NAME, SUBPARAMS)
#define ADD_INTERPOLATION(NAME, TYPE)
static void get_point_selection_parameters(struct yac_point_selection const *point_selection, interp_method_parameter_value *parameter_value)
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)
@ NUM_INTERPOLATION_METHODS
static void yaml_parse_interp_method_map_parameter(struct interp_method_parameter map_parameter, interp_method_parameter_value *map_parameter_values, fy_node_t value_node, char const *interpolation_name, char const *yaml_filename)
yaml_debug_output_grid_key_types
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)
#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)
static void yac_yaml_map_append_scalar_size_t(fy_node_t map, char const *key, size_t value)
static fy_node_t yac_yaml_create_scalar_size_t(fy_document_t document, size_t value)
static interp_method_parameter_value yaml_interp_method_parameter_get_default(struct interp_method_parameter parameter)
allocates parameter values and assigns default values based on provided interpolation parameter defin...
char const * yac_time_to_ISO(char const *time, enum yac_time_unit_type time_unit)
int const YAC_YAML_PARSER_JSON_FORCE
assume JSON format
static void yac_yaml_map_append_parameter(fy_document_t document, fy_node_t map, struct interp_method_parameter parameter, interp_method_parameter_value parameter_value)
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
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 fy_node_t yac_yaml_create_seq_parameter_node(fy_document_t document, interp_method_parameter_value const *seq_parameter_values, size_t seq_parameter_values_count, struct interp_method_parameter parameter)
static char const * yaml_parse_string_value(fy_node_t value_node, char const *name, char const *yaml_filename)
static void yaml_parse_interp_method_parameter_value(struct interp_method_parameter parameter, interp_method_parameter_value *parameter_value, fy_node_t value_node, char const *interpolation_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)
static void yaml_interp_method_parameter_free(interp_method_parameter_value parameter_value, struct interp_method_parameter parameter)
free memory associated with
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
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)
#define DEF_DBLE_PARAM(NAME, DEFAULT, VALID_MIN, VALID_MAX, ALLOW_NAN)
static void yaml_parse_collection_selection_sequence(struct yac_collection_selection **collection_selection, fy_node_t values_node, char const *sequence_name, const char *yaml_filename)
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)
struct interp_method_parameter_value interp_method_parameter_value
#define DEF_MAP_SUBPARAMS(NAME,...)
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)
enum yac_weight_file_on_existing yac_couple_config_get_weight_file_on_existing(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)
int yac_couple_config_get_use_raw_exchange(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
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)
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)
struct yac_collection_selection const * yac_couple_config_get_collection_selection(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)
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 weight_file_on_existing, 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, struct yac_collection_selection const *collection_selection, int use_raw_exchange)
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_YAML
YAML format.
@ YAC_TEXT_FILETYPE_JSON
JSON format.
size_t yac_collection_selection_get_collection_size(struct yac_collection_selection const *collection_selection)
Get the size of the collection selection.
size_t const * yac_collection_selection_get_indices(struct yac_collection_selection const *collection_selection)
Get explicit selection indices if non-contiguous.
void yac_collection_selection_delete(struct yac_collection_selection *collection_selection)
Delete a collection selection object.
struct yac_collection_selection * yac_collection_selection_new(size_t collection_size, size_t const *selection_indices)
Create a new collection selection.
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_ENDDEF
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_COMP
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_SYNC
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_ARITHMETIC
#define YAC_INTERP_AVG_WEIGHT_TYPE_DEFAULT
yac_func_compute_weights callback
#define YAC_INTERP_CALLBACK_COMPUTE_WEIGHTS_KEY_DEFAULT
#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_ON_SUCCESS_DEFAULT
#define YAC_INTERP_FILE_WEIGHT_FILE_NAME_DEFAULT
yac_interp_file_on_missing_file
@ YAC_INTERP_FILE_MISSING_CONT
continue on missing file
@ YAC_INTERP_FILE_MISSING_ERROR
abort on missing file
yac_interp_file_on_success
@ YAC_INTERP_FILE_SUCCESS_CONT
@ YAC_INTERP_FILE_SUCCESS_STOP
#define YAC_INTERP_FILE_ON_MISSING_FILE_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_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
char const * yac_spmap_cell_area_config_get_filename(struct yac_spmap_cell_area_config const *cell_area_config)
struct yac_spmap_cell_area_config const * yac_spmap_scale_config_get_tgt_cell_area_config(struct yac_spmap_scale_config const *scale_config)
struct yac_interp_spmap_config const * yac_spmap_overwrite_config_get_spmap_config(struct yac_spmap_overwrite_config const *overwrite_config)
double yac_spmap_cell_area_config_get_sphere_radius(struct yac_spmap_cell_area_config const *cell_area_config)
struct yac_spmap_cell_area_config * yac_spmap_cell_area_config_file_new(char const *filename, char const *varname, yac_int min_global_id)
struct yac_spmap_overwrite_config * yac_spmap_overwrite_config_new(struct yac_point_selection const *src_point_selection, struct yac_interp_spmap_config const *config)
void yac_spmap_overwrite_configs_delete(struct yac_spmap_overwrite_config **overwrite_configs)
struct yac_point_selection const * yac_spmap_overwrite_config_get_src_point_selection(struct yac_spmap_overwrite_config const *overwrite_config)
yac_int yac_spmap_cell_area_config_get_min_global_id(struct yac_spmap_cell_area_config const *cell_area_config)
enum yac_interp_spmap_cell_area_provider yac_spmap_cell_area_config_get_type(struct yac_spmap_cell_area_config const *cell_area_config)
double yac_interp_spmap_config_get_max_search_distance(struct yac_interp_spmap_config const *spmap_config)
struct yac_spmap_cell_area_config const * yac_spmap_scale_config_get_src_cell_area_config(struct yac_spmap_scale_config const *scale_config)
char const * yac_spmap_cell_area_config_get_varname(struct yac_spmap_cell_area_config const *cell_area_config)
struct yac_interp_spmap_config * yac_interp_spmap_config_new(double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, struct yac_spmap_scale_config const *scale_config)
void yac_spmap_scale_config_delete(struct yac_spmap_scale_config *scale_config)
void yac_interp_spmap_config_delete(struct yac_interp_spmap_config *config)
struct yac_spmap_scale_config const * yac_interp_spmap_config_get_scale_config(struct yac_interp_spmap_config const *spmap_config)
double yac_interp_spmap_config_get_spread_distance(struct yac_interp_spmap_config const *spmap_config)
void yac_spmap_cell_area_config_delete(struct yac_spmap_cell_area_config *cell_area_config)
enum yac_interp_spmap_scale_type yac_spmap_scale_config_get_type(struct yac_spmap_scale_config const *scale_config)
struct yac_spmap_cell_area_config * yac_spmap_cell_area_config_yac_new(double sphere_radius)
enum yac_interp_spmap_weight_type yac_interp_spmap_config_get_weight_type(struct yac_interp_spmap_config const *spmap_config)
struct yac_spmap_scale_config * yac_spmap_scale_config_new(enum yac_interp_spmap_scale_type scale_type, struct yac_spmap_cell_area_config const *source_cell_area_config, struct yac_spmap_cell_area_config const *target_cell_area_config)
#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_CELL_AREA_CONFIG_DEFAULT
#define YAC_INTERP_SPMAP_VARNAME_DEFAULT
#define YAC_INTERP_SPMAP_FILENAME_DEFAULT
#define YAC_INTERP_SPMAP_WEIGHTED_DEFAULT
#define YAC_INTERP_SPMAP_SPREAD_DISTANCE_DEFAULT
yac_interp_spmap_cell_area_provider
@ YAC_INTERP_SPMAP_CELL_AREA_FILE
@ YAC_INTERP_SPMAP_CELL_AREA_YAC
#define YAC_INTERP_SPMAP_SPHERE_RADIUS_DEFAULT
#define YAC_INTERP_SPMAP_SCALE_TYPE_DEFAULT
yac_interp_spmap_weight_type
#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_SOURCE_TO_TARGET_MAP
@ YAC_NEAREST_CORNER_CELLS
@ YAC_RADIAL_BASIS_FUNCTION
#define YAC_MAX_ROUTINE_NAME_LENGTH
#define YAC_MAX_FILE_NAME_LENGTH
#define YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE
yac_weight_file_on_existing
@ YAC_WEIGHT_FILE_KEEP
keep existing weight file
@ YAC_WEIGHT_FILE_UNDEFINED
@ YAC_WEIGHT_FILE_OVERWRITE
overwrite existing weight file
@ YAC_WEIGHT_FILE_ERROR
error when weight file existis already
Defines internal basic interpolation definitions.
#define YAC_FRAC_MASK_VALUE_IS_VALID(value)
Test whether a fractional mask value is valid.
int yac_file_exists(const char *filename)
struct yac_point_selection * yac_point_selection_bnd_circle_new(double center_lon, double center_lat, double inc_angle)
void yac_point_selection_delete(struct yac_point_selection *point_select)
void yac_point_selection_bnd_circle_get_config(struct yac_point_selection const *point_selection, double *center_lon, double *center_lat, double *inc_angle)
enum yac_point_selection_type yac_point_selection_get_type(struct yac_point_selection const *point_select)
@ YAC_POINT_SELECTION_TYPE_BND_CIRCLE
@ YAC_POINT_SELECTION_TYPE_EMPTY
#define xrealloc(ptr, size)
#define xcalloc(nmemb, size)
#define xfopen(path, mode)
enum yac_text_filetype type
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
char const * yaxt_exchanger_name
char const * coupling_period
enum yac_weight_file_on_existing on_existing
char const * tgt_mask_name
struct yac_interp_stack_config * interp_stack
struct field_couple_buffer::@65 src
struct field_couple_buffer::@66 weight_file
struct field_couple_buffer::@65::@67 grid
struct yac_collection_selection * collection_selection
struct field_couple_buffer::field_couple_field_names * field_names
size_t num_src_mask_names
struct field_couple_buffer::@65 tgt
enum yac_reduction_type time_reduction
struct interp_method_parameter_value * values
struct interp_method_parameter_value::@68::@69 seq
struct interp_method_parameter_value * map_values
union interp_method_parameter_value::@68 data
struct interp_method_parameter::@70::@72 int_param
struct interp_method_parameter * sub_params
struct yac_name_type_pair const * valid_values
struct interp_method_parameter::@70::@71 enum_param
struct interp_method_parameter::@70::@75 bool_param
enum interp_method_parameter_value_type type
struct interp_method_parameter * sub_param
struct interp_method_parameter::@70::@77 seq_param
struct interp_method_parameter::@70::@76 map_param
struct interp_method_parameter::@70::@73 dble_param
struct interp_method_parameter::@70::@74 str_param
union interp_method_parameter::@70 data
interp_method_parameter_value const default_value
struct yac_spmap_scale_config * scale_config
double max_search_distance
struct yac_point_selection * src_point_selection
char const * weight_file_name
char const src_grid_name[]
char const tgt_grid_name[]
int yac_name_type_pair_get_type(struct yac_name_type_pair const *pairs, size_t count, char const *name)
char const * yac_name_type_pair_get_name(struct yac_name_type_pair const *pairs, size_t count, int type)
void yac_cdef_calendar(int calendar)
int const YAC_CALENDAR_NOT_SET
#define YAC_UNREACHABLE_DEFAULT_F(format,...)
#define YAC_ASSERT_F(exp, format,...)
#define YAC_UNREACHABLE_DEFAULT(msg)