27#include "mtime_calendar.h"
30#include "mtime_datetime.h"
43 size_t grid_idx,
char const * field_name);
48 xmalloc(1 *
sizeof(*couple_config));
56 couple_config->
grids = NULL;
82 "couple_config->components is NULL");
85 "invalid component index %zu (number of components: %zu)",
93 int calendar = (int)getCalendarType();
94 if (calendar == CALENDAR_NOT_SET) calendar = INT_MAX;
99 MPI_IN_PLACE, &calendar, 1, MPI_INT, MPI_MIN, comm), comm);
102 if (calendar == INT_MAX)
return;
155 char const * comp_name,
const char*
metadata) {
163 char const * grid_name,
const char* output_filename) {
166 "invalid grid_name (NULL is not allowed)");
177 char const * grid_name,
const char*
metadata) {
180 "invalid grid_name (NULL is not allowed)");
191 const char* comp_name,
const char * grid_name,
const char* field_name,
209 const char * grid_name) {
216 const char * grid_name) {
223 const char* comp_name,
const char * grid_name,
const char* field_name) {
234#define CHECK_COMPONENT_IDX() \
236 component_idx < couple_config->num_components, "invalid component_idx")
238#define CHECK_GRID_IDX() \
240 grid_idx < couple_config->num_grids, "invalid grid_idx")
260 const char* grid_name,
const char*
name,
char const * timestep,
283 "invalid value of missing_definition_is_fatal-flag");
299 int missing_definition_is_fatal) {
302 (missing_definition_is_fatal != 0)
310 "inconsistent setting of \"missing_definition_is_fatal\"-flag "
327 apply_coordinate_check = 0;
331 apply_coordinate_check = 1;
340 return apply_coordinate_check;
345 int apply_coordinate_check) {
348 (apply_coordinate_check != 0)
356 "inconsistent setting of \"apply_coordinate_check\"-flag "
368 int coordinates_mismatch_is_fatal =
373 "invalid value of coordinates_mismatch_is_fatal-flag");
375 coordinates_mismatch_is_fatal = 0;
379 coordinates_mismatch_is_fatal = 1;
383 coordinates_mismatch_is_fatal =
389 return coordinates_mismatch_is_fatal;
394 int coordinates_mismatch_is_fatal) {
397 (coordinates_mismatch_is_fatal != 0)
405 "inconsistent setting of "
406 "\"coordinates_mismatch_is_fatal\"-flag "
415#define CHECK_COUPLE_IDX() \
416 YAC_ASSERT_F(couple_idx < couple_config->num_couples, "invalid couple_idx")
428 char const * couple_component_names[2]) {
432 for (
int i = 0; i < 2; ++i)
433 couple_component_names[i] =
441 YAC_ASSERT(component_name,
"component name is NULL")
444 "component name is too long (maximum is YAC_MAX_CHARLEN)")
483 "Component \"%s\" not found in coupling configuration",
510 grid_idx != SIZE_MAX,
"grid name \"%s\" not in list of grids", grid_name)
521 if (!strcmp(couple_config->
grids[i].
name, grid_name)) {
531 size_t grid_idx,
char const * field_name) {
538 field_idx != SIZE_MAX,
539 "field \"%s\" for grid_idx %zu not found in component_idx %zu",
547 size_t grid_idx,
char const * field_name) {
555 return (field == NULL) ? SIZE_MAX : (size_t)(field - component->
fields);
600 char const * component_name,
char const * grid_name,
601 char const * field_name) {
606 couple_config, grid_name);
614 char const * component_name,
char const * grid_name,
615 char const * field_name) {
630 size_t field_idx = SIZE_MAX;
638 if (field_idx != SIZE_MAX) {
640 size_t const nbr_couples = couple_config->
num_couples;
641 for(
size_t couple_idx = 0;
646 couple_config->
couples + couple_idx;
648 int const couple_has_component =
651 if (couple_has_component) {
660 "field cannot be source and target at the same time "
661 "(component: \"%s\" grid: \"%s\" field: \"%s\" "
663 component_name, grid_name, field_name, couple_idx);
685 size_t couple_idx,
size_t field_couple_idx) {
690 couple_config->
couples + couple_idx;
693 couple, field_couple_idx);
698 size_t couple_idx,
size_t field_couple_idx) {
703 couple_config->
couples + couple_idx;
706 couple, field_couple_idx);
711 size_t couple_idx,
size_t field_couple_idx) {
716 couple_config->
couples + couple_idx;
719 couple, field_couple_idx);
724 size_t couple_idx,
size_t field_couple_idx) {
729 couple_config->
couples + couple_idx;
732 couple, field_couple_idx);
737 size_t couple_idx,
size_t field_couple_idx) {
742 couple_config->
couples + couple_idx;
745 couple, field_couple_idx);
750 size_t couple_idx,
size_t field_couple_idx) {
755 couple_config->
couples + couple_idx;
758 couple, field_couple_idx);
763 size_t couple_idx,
size_t field_couple_idx) {
768 couple_config->
couples + couple_idx;
771 couple, field_couple_idx);
776 size_t couple_idx,
size_t field_couple_idx) {
781 couple_config->
couples + couple_idx;
784 couple, field_couple_idx);
789 size_t couple_idx,
size_t field_couple_idx) {
794 couple_config->
couples + couple_idx;
797 couple, field_couple_idx);
802 size_t couple_idx,
size_t field_couple_idx) {
807 couple_config->
couples + couple_idx;
810 couple, field_couple_idx);
815 size_t couple_idx,
size_t field_couple_idx) {
820 couple_config->
couples + couple_idx;
823 couple, field_couple_idx);
828 size_t couple_idx,
size_t field_couple_idx,
829 char const *
const ** mask_names,
size_t * num_mask_names) {
834 couple_config->
couples + couple_idx;
837 couple, field_couple_idx, mask_names, num_mask_names);
842 size_t couple_idx,
size_t field_couple_idx) {
847 couple_config->
couples + couple_idx;
850 couple, field_couple_idx);
855 size_t couple_idx,
size_t field_couple_idx) {
860 couple_config->
couples + couple_idx;
863 couple, field_couple_idx);
869 size_t couple_idx,
size_t field_couple_idx) {
874 couple_config->
couples + couple_idx;
877 couple, field_couple_idx);
882 size_t couple_idx,
size_t field_couple_idx) {
887 couple_config->
couples + couple_idx;
890 couple, field_couple_idx);
895 size_t couple_idx,
size_t field_couple_idx,
901 couple_config->
couples + couple_idx;
903 size_t src_component_idx =
905 size_t src_field_idx =
908 size_t tgt_component_idx =
910 size_t tgt_field_idx =
914 couple_config->
components + src_component_idx;
916 couple_config->
components + tgt_component_idx;
919 src_component, src_field_idx);
921 tgt_component, tgt_field_idx);
929 char const * comp_name,
char const * grid_name,
char const * field_name,
930 double frac_mask_fallback_value) {
934 "\"%lf\" is not a valid fractional mask fallback value "
935 "(component: \"%s\" grid: \"%s\" field \"%s\")",
936 frac_mask_fallback_value, comp_name, grid_name, field_name);
943 component,
grid_idx, field_name, frac_mask_fallback_value);
948 char const * component_name,
char const * grid_name,
949 char const * field_name) {
955 double frac_mask_fallback_value =
959 return frac_mask_fallback_value;
964 char const * component_name,
char const * grid_name,
965 char const * field_name) {
977 size_t couple_idx,
size_t field_couple_idx,
978 char const ** src_component_name,
char const ** tgt_component_name) {
983 couple_config->
couples + couple_idx;
985 size_t src_component_idx =
987 size_t tgt_component_idx =
990 *src_component_name = couple_config->
components[src_component_idx].
name;
991 *tgt_component_name = couple_config->
components[tgt_component_idx].
name;
996 size_t couple_idx,
size_t field_couple_idx,
997 char const ** src_field_name,
const char ** tgt_field_name) {
1002 couple_config->
couples + couple_idx;
1004 size_t src_component_idx =
1006 size_t src_field_idx =
1009 size_t tgt_component_idx =
1011 size_t tgt_field_idx =
1015 couple_config->
components + src_component_idx;
1017 couple_config->
components + tgt_component_idx;
1027 size_t couple_idx,
size_t field_couple_idx) {
1032 couple_config->
couples + couple_idx;
1034 size_t source_component_idx =
1036 size_t source_field_idx =
1040 couple_config->
components + source_component_idx;
1043 source_component, source_field_idx);
1047 "no valid timestep defined (component: \"%s\" field \"%s\")",
1048 source_component->
name,
1050 source_component, source_field_idx));
1057 size_t couple_idx,
size_t field_couple_idx) {
1062 couple_config->
couples + couple_idx;
1064 size_t target_component_idx =
1066 size_t target_field_idx =
1070 couple_config->
components + target_component_idx;
1073 target_component, target_field_idx);
1077 "no valid timestep defined (component: \"%s\" field \"%s\")",
1078 target_component->
name,
1089 size_t const src_len = strlen(
src);
1090 char * dst = strdup(
src);
1092 char const suffix[] =
"+00:00";
1093 enum {SUFFIX_LEN =
sizeof(suffix) - 1 };
1096 if (src_len >= SUFFIX_LEN && strcmp(
src + src_len - SUFFIX_LEN, suffix) == 0) {
1097 dst[src_len - SUFFIX_LEN] =
'Z';
1098 dst[src_len - SUFFIX_LEN + 1] =
'\0';
1109 struct _datetime *
new = newDateTime(str_normalised);
1110 free(str_normalised);
1115 char const * type_datetime,
struct _datetime ** old,
char const * str_new) {
1117 if ((str_new == NULL) || (strlen(str_new) == 0))
return;
1121 "calendar has not yet been set");
1126 new != NULL,
"failed to parse datetime \"%s\"", str_new);
1128 char old_datetime_buffer[MAX_DATETIME_STR_LEN],
1129 new_datetime_buffer[MAX_DATETIME_STR_LEN];
1132 (*old == NULL) || (equal_to == compareDatetime(*old,
new)),
1133 "inconsistent %s datetime (old: \"%s\" new: \"%s\")", type_datetime,
1134 datetimeToString(*old, old_datetime_buffer),
1135 datetimeToString(
new, new_datetime_buffer));
1137 deallocateDateTime(*old);
1144 char const * start,
char const * end) {
1154 couple_config->
start_datetime,
"start_datetime not yet defined");
1156 char datetime_buffer[MAX_DATETIME_STR_LEN];
1167 char datetime_buffer[MAX_DATETIME_STR_LEN];
1196 size_t src_comp_idx,
size_t tgt_comp_idx) {
1205 size_t couple_idx = SIZE_MAX;
1206 if (couple != NULL) {
1207 couple_idx = (size_t)(couple - couple_config->
couples);
1211 couple_config, src_comp_idx, tgt_comp_idx);
1215 couple_idx != SIZE_MAX,
1216 "failed to add couple (component indices: %zu, %zu)",
1217 src_comp_idx, tgt_comp_idx);
1224 char const * src_comp_name,
char const *
src_grid_name,
char const * src_field_name,
1225 char const * tgt_comp_name,
char const *
tgt_grid_name,
char const * tgt_field_name,
1226 char const * coupling_period,
int time_reduction,
1229 int mapping_on_source,
double scale_factor,
double scale_summand,
1230 size_t num_src_mask_names,
char const *
const * src_mask_names,
1231 char const * tgt_mask_name,
char const * yaxt_exchanger_name,
1233 int use_raw_exchange) {
1235 YAC_ASSERT(src_comp_name && src_comp_name[0] !=
'\0',
1236 "invalid parameter: src_comp_name");
1238 "invalid parameter: src_grid_name");
1239 YAC_ASSERT(src_field_name && src_field_name[0] !=
'\0',
1240 "invalid parameter: src_field_name");
1241 YAC_ASSERT(tgt_comp_name && tgt_comp_name[0] !=
'\0',
1242 "invalid parameter: tgt_comp_name");
1244 "invalid parameter: tgt_grid_name");
1245 YAC_ASSERT(tgt_field_name && tgt_field_name[0] !=
'\0',
1246 "invalid parameter: tgt_field_name");
1247 YAC_ASSERT(coupling_period && coupling_period[0] !=
'\0',
1248 "invalid parameter: coupling_period");
1254 (time_reduction ==
TIME_MAXIMUM),
"invalid parameter: time_reduction");
1255 YAC_ASSERT_F(isnormal(scale_factor),
"\"%lf\" is not a valid scale factor",
1257 YAC_ASSERT_F(isnormal(scale_summand) || (scale_summand == 0.0),
1258 "\"%lf\" is not a valid scale summand", scale_summand);
1260 (collection_selection == NULL) ||
1262 "invalid collection selection (size has to be > 0, if provided)");
1267 "invalid parameter: weight_file_on_existing");
1269 strcmp(src_comp_name, tgt_comp_name) ||
1271 strcmp(src_field_name, tgt_field_name),
1272 "a field cannot have the role of source and target at the same time "
1273 "(comp_name: \"%s\" grid_name: \"%s\" field_name: \"%s\")",
1277 size_t const src_comp_idx =
1279 size_t const tgt_comp_idx =
1281 size_t const src_grid_idx =
1283 size_t const tgt_grid_idx =
1287 int const orig_src_field_role =
1291 size_t const src_field_idx =
1293 couple_config, src_comp_idx, src_grid_idx,
1294 src_field_name, NULL, SIZE_MAX);
1301 "Trying to define field as source which has already been defined as "
1302 "target in another couple previously. This is not allowed since fields "
1303 "must be either source or target. "
1304 "(component_name: \"%s\" grid_name: \"%s\" field_name: \"%s\")",
1308 int const orig_tgt_field_role =
1312 size_t const tgt_field_idx =
1314 couple_config, tgt_comp_idx, tgt_grid_idx,
1315 tgt_field_name, NULL, SIZE_MAX);
1332 "Internal error. Trying to find couple for redefinition but it cannot be found. "
1333 "(src_component_name: \"%s\" src_grid_name: \"%s\" src_field_name: \"%s\") "
1334 "(tgt_component_name: \"%s\" tgt_grid_name: \"%s\" tgt_field_name: \"%s\")",
1338 int const is_redefinition =
1340 couple, src_comp_idx, src_field_idx, tgt_comp_idx, tgt_field_idx);
1342 char const * _src_comp_name;
1343 char const * _src_grid_name;
1344 char const * _src_field_name;
1347 &_src_comp_name, &_src_grid_name, &_src_field_name
1351 "Trying to define field as target which has already been defined as "
1352 "target in another couple previously. This is not allowed. "
1353 "(tgt_component_name: \"%s\" tgt_grid_name: \"%s\" tgt_field_name: \"%s\") "
1354 "(new_src_component_name: \"%s\" new_src_grid_name: \"%s\" new_src_field_name: \"%s\")"
1355 "(existing_src_component_name: \"%s\" extisting_src_grid_name: \"%s\" existing_src_field_name: \"%s\")",
1358 _src_comp_name, _src_grid_name, _src_field_name
1365 "Trying to define field as target which has already been defined as "
1366 "source in another couple previously. This is not allowed since fields "
1367 "must be either source or target. "
1368 "(component_name: \"%s\" grid_name: \"%s\" field_name: \"%s\")",
1374 size_t const couple_idx =
1376 couple_config, src_comp_idx, tgt_comp_idx);
1380 couple_config->
couples + couple_idx;
1383 src_comp_idx, src_field_idx, src_lag,
1384 tgt_comp_idx, tgt_field_idx, tgt_lag,
1385 coupling_period, time_reduction,
1388 scale_factor, scale_summand,
1389 weight_file_on_existing,
1390 num_src_mask_names, src_mask_names,
1391 tgt_mask_name, yaxt_exchanger_name,
1392 collection_selection, use_raw_exchange);
1396 char const * type_datetime,
struct _datetime ** datetime, MPI_Comm comm) {
1399 char datetime_buffer[MAX_DATETIME_STR_LEN];
1400 char * str_datetime = datetimeToString(*datetime, datetime_buffer);
1403 if (str_datetime != NULL) str_datetime =
xstrdup(str_datetime);
1406 deallocateDateTime(*datetime);
1412 *datetime = newDateTime(str_datetime);
1429 char const * output_ref){
1445 "missing_definition_is_fatal",
1448 "apply_coordinate_check",
1451 "coordinates_mismatch_is_fatal",
1455 if (output_ref != NULL)
1457 (config_output == NULL); ++i)
1461 if (config_output != NULL) {
1464 MPI_Comm_rank(comm, &rank);
1469 FILE * config_file = fopen(config_output->
name,
"w");
1472 config_file != NULL,
1473 "failed to create coupling configuration file \"%s\" (%s)",
1474 config_output->
name, strerror(errno));
1479 "invalid coupling configuration filetype (type = %d)",
1480 config_output->
type);
1483 switch(config_output->
type) {
1495 char * str_couple_config =
1499 fputs(str_couple_config, config_file);
1500 free(str_couple_config);
1501 fclose(config_file);
1526 char const * tgt_component_name,
char const *
tgt_grid_name,
1527 char const * tgt_field_name,
1528 size_t * result_couple_idx,
size_t * result_field_couple_idx) {
1530 size_t const tgt_comp_idx =
1533 *result_couple_idx = SIZE_MAX;
1534 *result_field_couple_idx = SIZE_MAX;
1536 for (
size_t couple_idx = 0;
1537 couple_idx < couple_config->
num_couples; ++couple_idx) {
1539 couple_config->
couples + couple_idx;
1541 couple, tgt_comp_idx))
1545 couple, couple_config,
1547 if (fc_idx != SIZE_MAX) {
1549 *result_couple_idx == SIZE_MAX,
1550 "multiple couples with the same target "
1551 "(component: \"%s\" grid: \"%s\" field: \"%s\")",
1554 *result_couple_idx = couple_idx;
1555 *result_field_couple_idx = fc_idx;
1562 char const * tgt_component_name,
char const *
tgt_grid_name,
1563 char const * tgt_field_name,
char const ** src_component_name,
1564 char const **
src_grid_name,
char const ** src_field_name) {
1566 size_t couple_idx, field_couple_idx;
1569 tgt_field_name, &couple_idx, &field_couple_idx);
1572 couple_idx != SIZE_MAX,
1573 "provided field is not defined as a target in any coupling "
1574 "(target component: \"%s\" target grid: \"%s\" target field: \"%s\")",
1578 couple_config->
couples + couple_idx;
1580 size_t src_component_idx =
1582 size_t src_field_idx =
1586 couple_config->
components + src_component_idx;
1588 size_t src_grid_idx =
1590 src_component, src_field_idx);
1592 *src_component_name = src_component->
name;
1601 size_t couple_idx,
size_t field_couple_idx) {
1606 couple_config->
couples + couple_idx;
1608 size_t src_comp_idx =
1610 size_t src_field_idx =
1612 size_t tgt_comp_idx =
1614 size_t tgt_field_idx =
1622 size_t src_grid_idx =
1624 src_comp, src_field_idx);
1625 size_t tgt_grid_idx =
1627 tgt_comp, tgt_field_idx);
1629 char const * src_comp_name = src_comp->
name;
1631 couple_config->
grids[src_grid_idx].
name;
1632 char const * src_field_name =
1635 char const * tgt_comp_name = tgt_comp->
name;
1637 couple_config->
grids[tgt_grid_idx].
name;
1638 char const * tgt_field_name =
1646 int const is_mapping_on_source =
1648 couple, field_couple_idx);
1656 src_comp, src_field_idx);
1664 double scale_factor =
1666 couple, field_couple_idx);
1667 double scale_summand =
1669 couple, field_couple_idx);
1672 couple, field_couple_idx);
1674 interp_gen_config, scale_factor);
1676 interp_gen_config, scale_summand);
1681 size_t src_collection_size =
1683 src_comp, src_field_idx);
1684 size_t tgt_collection_size =
1686 tgt_comp, tgt_field_idx);
1691 couple, field_couple_idx);
1692 if (collection_selection != NULL) {
1696 collection_selection) == tgt_collection_size,
1697 "target field collection size does not match size of provided "
1698 "collection selection: \n"
1700 " component name: \"%s\"\n"
1701 " grid name: \"%s\"\n"
1702 " field name: \"%s\"\n"
1703 " collection_size: %zu\n"
1705 " component name: \"%s\"\n"
1706 " grid name: \"%s\"\n"
1707 " field name: \"%s\"\n"
1708 " collection_size: %zu\n"
1709 " collection selection:\n"
1711 " max_index: %zu\n",
1712 src_comp_name,
src_grid_name, src_field_name, src_collection_size,
1713 tgt_comp_name,
tgt_grid_name, tgt_field_name, tgt_collection_size,
1718 collection_selection) < src_collection_size,
1719 "maximum index of provided collection selection exceeds source "
1720 "field collection size: \n"
1722 " component name: \"%s\"\n"
1723 " grid name: \"%s\"\n"
1724 " field name: \"%s\"\n"
1725 " collection_size: %zu\n"
1727 " component name: \"%s\"\n"
1728 " grid name: \"%s\"\n"
1729 " field name: \"%s\"\n"
1730 " collection_size: %zu\n"
1731 " collection selection:\n"
1733 " max_index: %zu\n",
1734 src_comp_name,
src_grid_name, src_field_name, src_collection_size,
1735 tgt_comp_name,
tgt_grid_name, tgt_field_name, tgt_collection_size,
1740 interp_gen_config, collection_selection);
1744 src_collection_size == tgt_collection_size,
1745 "collection sizes do not match for coupled fields (%zu != %zu): \n"
1747 " component name: \"%s\"\n"
1748 " grid name: \"%s\"\n"
1749 " field name: \"%s\"\n"
1751 " component name: \"%s\"\n"
1752 " grid name: \"%s\"\n"
1753 " field name: \"%s\"\n",
1754 src_collection_size, tgt_collection_size,
1759 interp_gen_config, src_collection_size);
1762 return interp_gen_config;
unsigned component_idx[3]
#define YAC_ASSERT(exp, msg)
char * yac_yaml_emit_coupling(struct yac_couple_config *couple_config, int emit_flags, int include_definitions)
int const YAC_YAML_EMITTER_DEFAULT
emit to YAML format
int const YAC_YAML_EMITTER_JSON
emit to JSON format
int yac_couple_config_get_enforce_write_weight_file(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
double yac_couple_config_get_scale_summand(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_get_couple_component_names(struct yac_couple_config const *couple_config, size_t couple_idx, char const *couple_component_names[2])
void yac_couple_config_get_field_couple_component_names(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_component_name, char const **tgt_component_name)
struct yac_interp_stack_config * yac_couple_config_get_interp_stack(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
static size_t yac_couple_config_get_field_idx_unsafe(struct yac_couple_config const *couple_config, size_t component_idx, size_t grid_idx, char const *field_name)
int yac_couple_config_get_missing_definition_is_fatal(struct yac_couple_config const *couple_config)
static void yac_couple_config_find_field_couple_with_target(struct yac_couple_config const *couple_config, char const *tgt_component_name, char const *tgt_grid_name, char const *tgt_field_name, size_t *result_couple_idx, size_t *result_field_couple_idx)
static void set_datetime(char const *type_datetime, struct _datetime **old, char const *str_new)
int yac_couple_config_get_use_raw_exchange(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_get_field_names(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_field_name, const char **tgt_field_name)
char * yac_couple_config_get_end_datetime(struct yac_couple_config const *couple_config)
static void couple_config_sync_time(struct yac_couple_config *couple_config, MPI_Comm comm)
void yac_couple_config_set_grid_output_filename(struct yac_couple_config *couple_config, char const *grid_name, const char *output_filename)
void yac_couple_config_set_component_metadata(struct yac_couple_config *couple_config, char const *comp_name, const char *metadata)
void yac_couple_config_sync(struct yac_couple_config *couple_config, MPI_Comm comm, char const *output_ref)
void yac_couple_config_field_enable_frac_mask(struct yac_couple_config *couple_config, char const *comp_name, char const *grid_name, char const *field_name, double frac_mask_fallback_value)
#define CHECK_COUPLE_IDX()
const char * yac_couple_config_get_grid_output_filename(struct yac_couple_config const *couple_config, const char *grid_name)
const char * yac_couple_config_get_component_metadata(struct yac_couple_config const *couple_config, const char *comp_name)
static void couple_config_sync_datetime(char const *type_datetime, struct _datetime **datetime, MPI_Comm comm)
char const * yac_couple_config_get_yaxt_exchanger_name(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_field_grid_name(struct yac_couple_config const *couple_config, size_t component_idx, size_t field_idx)
char const * yac_couple_config_get_field_timestep(struct yac_couple_config const *couple_config, char const *component_name, char const *grid_name, char const *field_name)
double yac_couple_config_get_scale_factor(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_source_timestep(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_set_datetime(struct yac_couple_config *couple_config, char const *start, char const *end)
size_t yac_couple_config_get_num_grids(struct yac_couple_config const *couple_config)
size_t yac_couple_config_get_component_idx(struct yac_couple_config const *couple_config, char const *component_name)
char const * yac_couple_config_get_target_timestep(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_set_apply_coordinate_check(struct yac_couple_config *couple_config, int apply_coordinate_check)
char const * yac_couple_config_get_weight_file_name(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
struct yac_interpolation_gen_config * yac_couple_config_get_interpolation_gen_config(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_is_valid_component_name(struct yac_couple_config const *couple_config, char const *component_name)
void yac_couple_config_get_src_mask_names(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx, char const *const **mask_names, size_t *num_mask_names)
char const * yac_couple_config_get_grid_name(struct yac_couple_config const *couple_config, size_t grid_idx)
double yac_couple_config_get_frac_mask_fallback_value(struct yac_couple_config const *couple_config, char const *component_name, char const *grid_name, char const *field_name)
static char * normalise_utc_suffix(const char *src)
size_t yac_couple_config_get_grid_idx(struct yac_couple_config const *couple_config, char const *grid_name)
static void couple_config_sync_calendar(MPI_Comm comm)
static size_t yac_couple_config_add_component_(struct yac_couple_config *couple_config, char const *name)
size_t yac_couple_config_get_num_couples(struct yac_couple_config const *couple_config)
static size_t yac_couple_config_add_grid_(struct yac_couple_config *couple_config, char const *name)
struct yac_collection_selection const * yac_couple_config_get_collection_selection(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_tgt_mask_name(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_get_source_lag(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_set_field_metadata(struct yac_couple_config *couple_config, const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
size_t yac_couple_config_get_field_collection_size(struct yac_couple_config const *couple_config, char const *component_name, char const *grid_name, char const *field_name)
#define CHECK_COMPONENT_IDX()
char * yac_couple_config_get_start_datetime(struct yac_couple_config const *couple_config)
int yac_couple_config_get_field_role(struct yac_couple_config const *couple_config, char const *component_name, char const *grid_name, char const *field_name)
static struct yac_couple_config_component * yac_couple_config_get_component(struct yac_couple_config const *couple_config, char const *component_name)
size_t yac_couple_config_get_num_components(struct yac_couple_config const *couple_config)
void yac_couple_config_set_coordinates_mismatch_is_fatal(struct yac_couple_config *couple_config, int coordinates_mismatch_is_fatal)
char const * yac_couple_config_get_field_name(struct yac_couple_config const *couple_config, size_t component_idx, size_t field_idx)
size_t yac_couple_config_get_num_couple_fields(struct yac_couple_config const *couple_config, size_t couple_idx)
static struct _datetime * newDateTime_utc_patch(const char *str_new)
size_t yac_couple_config_get_num_fields(struct yac_couple_config const *couple_config, size_t component_idx)
void yac_couple_config_add_grid(struct yac_couple_config *couple_config, char const *name)
void yac_couple_config_set_grid_metadata(struct yac_couple_config *couple_config, char const *grid_name, const char *metadata)
int yac_couple_config_contains_grid_name(struct yac_couple_config const *couple_config, char const *grid_name)
size_t yac_couple_config_get_field_idx(struct yac_couple_config const *couple_config, size_t component_idx, size_t grid_idx, char const *field_name)
int yac_couple_config_get_target_lag(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
const char * yac_couple_config_get_grid_metadata(struct yac_couple_config const *couple_config, const char *grid_name)
static size_t yac_couple_config_add_couple_(struct yac_couple_config *couple_config, size_t src_comp_idx, size_t tgt_comp_idx)
enum yac_weight_file_on_existing yac_couple_config_get_weight_file_on_existing(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
struct yac_couple_config * yac_couple_config_new()
int yac_couple_config_get_coordinates_mismatch_is_fatal(struct yac_couple_config const *couple_config)
int yac_couple_config_get_mapping_on_source(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
static size_t yac_couple_config_get_component_idx_unsafe(struct yac_couple_config const *couple_config, char const *component_name)
void yac_couple_config_add_component_field(struct yac_couple_config *couple_config, const char *component_name, const char *grid_name, const char *name, char const *timestep, size_t collection_size)
void yac_couple_config_get_field_grid_names(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_grid_name, char const **tgt_grid_name)
char const * yac_couple_config_get_component_name(struct yac_couple_config const *couple_config, size_t component_idx)
int yac_couple_config_get_apply_coordinate_check(struct yac_couple_config const *couple_config)
int yac_couple_config_is_valid_field(struct yac_couple_config const *couple_config, size_t component_idx, size_t field_idx)
void yac_couple_config_set_missing_definition_is_fatal(struct yac_couple_config *couple_config, int missing_definition_is_fatal)
void yac_couple_config_add_component(struct yac_couple_config *couple_config, char const *name)
void yac_couple_config_get_field_source(struct yac_couple_config const *couple_config, char const *tgt_component_name, char const *tgt_grid_name, char const *tgt_field_name, char const **src_component_name, char const **src_grid_name, char const **src_field_name)
char const * yac_couple_config_get_coupling_period(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_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)
static size_t yac_couple_config_add_component_field_(struct yac_couple_config *couple_config, size_t component_idx, size_t grid_idx, char const *field_name, char const *timestep, size_t collection_size)
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)
enum yac_reduction_type yac_couple_config_get_coupling_period_operation(struct yac_couple_config const *couple_config, size_t couple_idx, size_t field_couple_idx)
static size_t yac_couple_config_get_grid_idx_unsafe(struct yac_couple_config const *couple_config, char const *grid_name)
void yac_couple_config_delete(struct yac_couple_config *couple_config)
const char * yac_couple_config_get_field_metadata(struct yac_couple_config const *couple_config, const char *comp_name, const char *grid_name, const char *field_name)
#define MISSING_DEFINITION_IS_FATAL_DEFAULT_VALUE
@ YAC_TEXT_FILETYPE_YAML
YAML format.
@ YAC_TEXT_FILETYPE_JSON
JSON format.
#define APPLY_COORDINATE_CHECK_DEFAULT_VALUE
#define COORDINATES_MISMATCH_IS_FATAL_DEFAULT_VALUE
char const * yac_couple_config_component_get_field_metadata(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
int yac_couple_config_component_field_is_valid(struct yac_couple_config_component const *component, size_t field_idx)
size_t yac_couple_config_component_update_or_append_field(struct yac_couple_config_component *component, char const *field_name, size_t grid_idx, char const *timestep, size_t collection_size)
size_t yac_couple_config_component_append(struct yac_couple_config_component **components, size_t *num_components, char const *name)
char const * yac_couple_config_component_get_field_name(struct yac_couple_config_component const *component, size_t field_idx)
char const * yac_couple_config_component_get_field_timestep(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
double yac_couple_config_component_get_field_frac_mask_fallback_value(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
char const * yac_couple_config_component_get_field_timestep_by_idx(struct yac_couple_config_component const *component, size_t field_idx)
void yac_couple_config_components_merge(struct yac_couple_config_component **components, size_t *num_components, struct yac_couple_config_couple *couples, size_t num_couples, MPI_Comm comm)
struct yac_couple_config_field * yac_couple_config_component_find_field(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
void yac_couple_config_component_set_field_metadata(struct yac_couple_config_component *component, size_t grid_idx, char const *field_name, char const *metadata)
double yac_couple_config_component_get_field_frac_mask_fallback_value_by_idx(struct yac_couple_config_component const *component, size_t field_idx)
void yac_couple_config_set_component_metadata_value(struct yac_couple_config_component *component, char const *metadata)
size_t yac_couple_config_component_get_field_collection_size(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
void yac_couple_config_components_free(struct yac_couple_config_component **components, size_t *num_components)
size_t yac_couple_config_component_get_field_collection_size_by_idx(struct yac_couple_config_component const *component, size_t field_idx)
size_t yac_couple_config_component_get_field_grid_idx(struct yac_couple_config_component const *component, size_t field_idx)
void yac_couple_config_component_set_field_frac_mask_fallback_value(struct yac_couple_config_component *component, size_t grid_idx, char const *field_name, double value)
void yac_couple_config_config_outputs_free(struct yac_couple_config_config_output **config_outputs, size_t *num_config_outputs)
enum yac_couple_config_flag_value yac_couple_config_config_output_get_include_definitions(struct yac_couple_config_config_output const *config_output)
void yac_couple_config_config_output_append(struct yac_couple_config_config_output **config_outputs, size_t *num_config_outputs, char const *filename, enum yac_text_filetype filetype, char const *ref, int include_definitions_)
void yac_couple_config_config_outputs_merge(struct yac_couple_config_config_output **config_outputs, size_t *num_config_outputs, MPI_Comm comm)
size_t yac_couple_config_couple_get_source_component_idx(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
void yac_couple_config_couples_free(struct yac_couple_config_couple **couples, size_t *num_couples)
int yac_couple_config_couple_has_component(struct yac_couple_config_couple const *couple, size_t component_idx)
void yac_couple_config_couple_append_or_merge_field_couple_from_definition(struct yac_couple_config_couple *couple, size_t src_comp_idx, size_t src_field_idx, int src_lag, size_t tgt_comp_idx, size_t tgt_field_idx, int tgt_lag, char const *coupling_period, int time_reduction, struct yac_interp_stack_config *interp_stack, int mapping_on_source, const char *weight_file_name, double scale_factor, double scale_summand, int weight_file_on_existing, 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 const * yac_couple_config_couple_get_coupling_period(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
struct yac_couple_config_couple * yac_couple_config_couple_find(size_t num_couples, struct yac_couple_config_couple const *couples, struct yac_couple_config_couple const *pattern)
int yac_couple_config_couple_get_mapping_on_source(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
int yac_couple_config_couple_get_field_role_from_field_idx(struct yac_couple_config_couple const *couple, size_t component_idx, size_t field_idx)
size_t yac_couple_config_couple_get_source_field_idx(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
size_t yac_couple_config_couple_get_target_field_idx(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
size_t yac_couple_config_couple_find_field_couple_with_target(struct yac_couple_config_couple const *couple, struct yac_couple_config const *couple_config, char const *tgt_field_name, char const *tgt_grid_name, char const *tgt_comp_name)
int yac_couple_config_couple_get_enforce_write_weight_file(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
char const * yac_couple_config_couple_get_yaxt_exchanger_name(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
void yac_couple_config_couple_init(struct yac_couple_config_couple *couple, size_t component_idx_a, size_t component_idx_b)
void yac_couple_config_couples_merge(struct yac_couple_config *couple_config, MPI_Comm comm)
double yac_couple_config_couple_get_scale_factor(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
struct yac_collection_selection const * yac_couple_config_couple_get_collection_selection(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
int yac_couple_config_couple_get_source_lag(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
int yac_couple_config_couple_get_target_lag(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
void yac_couple_config_couple_get_src_mask_names(struct yac_couple_config_couple const *couple, size_t field_couple_idx, char const *const **mask_names, size_t *num_mask_names)
char const * yac_couple_config_couple_get_tgt_mask_name(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
struct yac_interp_stack_config * yac_couple_config_couple_get_interp_stack(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
int yac_couple_config_couple_has_field_couple(struct yac_couple_config_couple const *couple, size_t src_component_idx, size_t src_field_idx, size_t tgt_component_idx, size_t tgt_field_idx)
int yac_couple_config_couple_get_use_raw_exchange(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
enum yac_weight_file_on_existing yac_couple_config_couple_get_weight_file_on_existing(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
size_t yac_couple_config_couples_append(struct yac_couple_config *couple_config, size_t component_idx_a, size_t component_idx_b)
double yac_couple_config_couple_get_scale_summand(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
enum yac_reduction_type yac_couple_config_couple_get_coupling_period_operation(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
char const * yac_couple_config_couple_get_weight_file_name(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
size_t yac_couple_config_couple_get_target_component_idx(struct yac_couple_config_couple const *couple, size_t field_couple_idx)
void yac_couple_config_grids_free(struct yac_couple_config_grid **grids, size_t *num_grids)
void yac_couple_config_set_grid_metadata_value(struct yac_couple_config_grid *grid, char const *metadata)
size_t yac_couple_config_grid_append(struct yac_couple_config_grid **grids, size_t *num_grids, char const *name)
void yac_couple_config_set_grid_output_filename_value(struct yac_couple_config_grid *grid, char const *output_filename)
void yac_couple_config_grids_merge(struct yac_couple_config_grid **grids, size_t *num_grids, struct yac_couple_config_component *components, size_t num_components, MPI_Comm comm)
void yac_couple_config_sync_flag_value(char const *flag_value_name, enum yac_couple_config_flag_value *flag, MPI_Comm comm)
void yac_couple_config_sync_string(char const *string_name, char **string, MPI_Comm comm)
yac_couple_config_flag_value
@ YAC_COUPLE_CONFIG_FLAG_TRUE
@ YAC_COUPLE_CONFIG_FLAG_FALSE
@ YAC_COUPLE_CONFIG_FLAG_UNSET
size_t yac_collection_selection_get_collection_size(struct yac_collection_selection const *collection_selection)
Get the size of the collection selection.
size_t yac_collection_selection_get_max_index(struct yac_collection_selection const *selection)
Get the maximum index of a collection selection.
void yac_instance_def_calendar(int calendar_type, char const *source)
@ YAC_MAPPING_ON_TGT
weights will be applied at target processes
@ YAC_MAPPING_ON_SRC
weights will be applied at source processes
yac_weight_file_on_existing
@ YAC_WEIGHT_FILE_KEEP
keep existing weight file
@ YAC_WEIGHT_FILE_OVERWRITE
overwrite existing weight file
@ YAC_WEIGHT_FILE_ERROR
error when weight file existis already
void yac_interpolation_gen_config_set_reorder(struct yac_interpolation_gen_config *config, enum yac_interp_weights_reorder_type reorder)
Set the reordering strategy for interpolation weights.
void yac_interpolation_gen_config_set_collection_size(struct yac_interpolation_gen_config *config, size_t collection_size)
Set the number of contiguous fields (starting at "0") in the field collection.
void yac_interpolation_gen_config_set_collection_selection(struct yac_interpolation_gen_config *config, struct yac_collection_selection const *collection_selection)
Set the collection selection of source field in the source field collection.
void yac_interpolation_gen_config_set_scaling_factor(struct yac_interpolation_gen_config *config, double scaling_factor)
Set the multiplicative scaling factor.
void yac_interpolation_gen_config_set_yaxt_exchanger_name(struct yac_interpolation_gen_config *config, char const *name)
Set the name of the Yaxt exchanger.
void yac_interpolation_gen_config_set_frac_mask_fallback_value(struct yac_interpolation_gen_config *config, double frac_mask_fallback_value)
Set the fractional mask fallback value.
struct yac_interpolation_gen_config * yac_interpolation_gen_config_new(void)
Allocate and initialise an interpolation generation configuration structure.
void yac_interpolation_gen_config_set_scaling_summand(struct yac_interpolation_gen_config *config, double scaling_summand)
Set the additive scaling summand.
Configuration management for interpolation generation.
Defines internal basic interpolation definitions.
#define YAC_FRAC_MASK_VALUE_IS_VALID(value)
Test whether a fractional mask value is valid.
struct yac_couple_config_field * fields
char const * name
name of the file
enum yac_couple_config_flag_value include_definitions
enum yac_text_filetype type
type of the file
size_t component_indices[2]
char const * output_filename
struct yac_couple_config_couple * couples
enum yac_couple_config_flag_value coordinates_mismatch_is_fatal
struct yac_couple_config_config_output * config_outputs
size_t num_config_outputs
struct _datetime * end_datetime
enum yac_couple_config_flag_value missing_definition_is_fatal
struct yac_couple_config_grid * grids
struct _datetime * start_datetime
struct yac_couple_config_component * components
enum yac_couple_config_flag_value apply_coordinate_check
Configuration structure for interpolation generation.
char * yaxt_exchanger_name
double frac_mask_fallback_value
char const * weight_file_name
char const src_grid_name[]
char const tgt_grid_name[]
int const YAC_EXCHANGE_TYPE_SOURCE
int const YAC_EXCHANGE_TYPE_NONE
int const YAC_EXCHANGE_TYPE_TARGET
int const YAC_CALENDAR_NOT_SET
int const YAC_EXCHANGE_TYPE_INVALID
#define YAC_ASSERT_F(exp, format,...)
#define YAC_UNREACHABLE_DEFAULT(msg)
#define yac_mpi_call(call, comm)