32 "definition phase (after component definition)",
33 "definition phase (after synchronisation)",
37#define CHECK_PHASE(FUNC_NAME, REF_PHASE, NEW_PHASE) \
39 enum yac_instance_phase ref_phase_ = (REF_PHASE); \
41 instance->phase == (ref_phase_), \
42 "ERROR(%s): Invalid phase " \
43 "(current phase: \"%s\" expected phase: \"%s\")", \
44 #FUNC_NAME, yac_instance_phase_str[instance->phase], \
45 yac_instance_phase_str[(ref_phase_)]); \
46 instance->phase = (NEW_PHASE); \
48#define CHECK_MIN_PHASE(FUNC_NAME, MIN_REF_PHASE) \
50 enum yac_instance_phase ref_min_phase_ = (MIN_REF_PHASE); \
52 instance->phase >= (ref_min_phase_), \
53 "ERROR(%s): Invalid phase " \
54 "(current phase: \"%s\" minimum expected phase: \"%s\")", \
55 #FUNC_NAME, yac_instance_phase_str[instance->phase], \
56 yac_instance_phase_str[(ref_min_phase_)]); \
58#define CHECK_MAX_PHASE(FUNC_NAME, MAX_REF_PHASE) \
60 enum yac_instance_phase ref_max_phase_ = (MAX_REF_PHASE); \
62 instance->phase <= (ref_max_phase_), \
63 "ERROR(%s): Invalid phase " \
64 "(current phase: \"%s\" maximum expected phase: \"%s\")", \
66 yac_instance_phase_str[ \
67 MIN(instance->phase,INSTANCE_UNKNOWN)], \
68 yac_instance_phase_str[(ref_max_phase_)]); \
108 .coupling_period = NULL,
111 .start_datetime = NULL,
112 .end_datetime = NULL};
168 for (
size_t i = 0; (i <
num_grids) && (grid == NULL); ++i)
172 *delete_flag = grid == NULL;
183 if ((ret = strcmp(a_->
comp_name, b_->comp_name)))
return ret;
184 else return strcmp(a_->
grid_name, b_->grid_name);
189 const char * grid_name,
size_t num_fields,
192 for (
size_t i = 0; i < num_fields; ++i) {
207 size_t couple_idx,
size_t field_couple_idx) {
209 char const *
const * src_mask_names;
210 size_t num_src_mask_names;
212 couple_config, couple_idx, field_couple_idx,
213 &src_mask_names, &num_src_mask_names);
220 .mask_names = src_mask_names,
221 .num_mask_names = num_src_mask_names,
224 couple_config, couple_idx, field_couple_idx),
227 couple_config, couple_idx, field_couple_idx))?
229 couple_config, couple_idx, field_couple_idx):NULL,
236 size_t couple_idx,
size_t field_couple_idx) {
245 couple_config, couple_idx, field_couple_idx),
252 size_t num_mask_names_a,
char const *
const * mask_names_a,
254 size_t num_mask_names_b,
char const *
const * mask_names_b) {
256 if ((a == NULL) || (b == NULL))
return (a == NULL) - (b == NULL);
258 size_t num_interp_fields[2] =
263 (num_mask_names_a == 0) ||
264 (num_mask_names_a == num_interp_fields[0]),
265 "ERROR(compare_field_config_fields): inconsistent mask names defined")
267 (num_mask_names_b == 0) ||
268 (num_mask_names_b == num_interp_fields[1]),
269 "ERROR(compare_field_config_fields): inconsistent mask names defined")
272 if (num_interp_fields[0] != num_interp_fields[1])
273 return (
int)num_interp_fields[0] - (int)num_interp_fields[1];
283 for (
size_t i = 0; i < num_interp_fields[0]; ++i) {
290 if ((ret = (location_a > location_b) -
291 (location_a < location_b)))
return ret;
298 if ((ret = (coordinates_a > coordinates_b) -
299 (coordinates_a < coordinates_b)))
return ret;
301 char const *
const * mask_names[2] =
302 {num_mask_names_a?mask_names_a:NULL,
303 num_mask_names_b?mask_names_b:NULL};
304 int const *
masks[2];
306 for (
int j = 0; j < 2; ++j) {
308 if (mask_names[j] != NULL)
311 grid[j], temp_interp_field.
location, mask_names[j][i]);
340 (
int)(b_->src_interp_config.weight_file_name == NULL)))
return ret;
343 b_->src_interp_config.weight_file_name)))
return ret;
348 b_->src_interp_config.interp_stack);
359 b_->comp_grid_pair.config[0].comp_name)))
return ret;
361 b_->comp_grid_pair.config[1].comp_name)))
return ret;
363 b_->comp_grid_pair.config[0].grid_name)))
return ret;
365 b_->comp_grid_pair.config[1].grid_name)))
return ret;
368 if ((ret = (
int)(a_->
reorder_type) - (
int)(b_->reorder_type)))
return ret;
374 (b_->yaxt_exchanger_name == NULL)))
return ret;
383 &(b_->frac_mask_fallback_value),
sizeof(
double));
387 struct
yac_instance * instance,
int couple_idx,
int field_couple_idx,
394 couple_config, couple_idx, field_couple_idx);
396 char const * coupling_period =
398 couple_config, couple_idx, field_couple_idx);
399 char const * timestep;
404 couple_config, couple_idx, field_couple_idx);
407 couple_config, couple_idx, field_couple_idx);
412 couple_config, couple_idx, field_couple_idx);
415 couple_config, couple_idx, field_couple_idx);
420 {.timestep = timestep,
421 .coupling_period = coupling_period,
423 .reduction_operation = reduction_operation,
441 struct field_config ** field_configs_,
size_t * count) {
444 MPI_Comm comm = instance->
comm;
449 size_t total_num_fields = 0;
450 for (
size_t couple_idx = 0; couple_idx < num_couples; ++couple_idx)
456 int (*fields_available)[2] =
457 xmalloc(total_num_fields *
sizeof(*fields_available));
458 for (
size_t couple_idx = 0, i = 0; couple_idx < num_couples;
460 size_t curr_num_fields =
462 for (
size_t field_couple_idx = 0; field_couple_idx < curr_num_fields;
463 ++field_couple_idx, ++i) {
464 char const * src_component_name;
465 char const * tgt_component_name;
466 char const * src_grid_name;
467 char const * tgt_grid_name;
468 const char * src_field_name;
469 const char * tgt_field_name;
471 couple_config, couple_idx, field_couple_idx,
472 &src_component_name, &tgt_component_name);
474 couple_config, couple_idx, field_couple_idx,
475 &src_grid_name, &tgt_grid_name);
477 couple_config, couple_idx, field_couple_idx,
478 &src_field_name, &tgt_field_name);
479 fields_available[i][0] =
481 src_component_name, src_field_name, src_grid_name,
482 num_fields, coupling_fields) != NULL;
483 fields_available[i][1] =
485 tgt_component_name, tgt_field_name, tgt_grid_name,
486 num_fields, coupling_fields) != NULL;
490 MPI_Allreduce(MPI_IN_PLACE, fields_available,
491 2 * total_num_fields,
492 MPI_INT, MPI_MAX, comm), comm);
495 size_t new_total_num_fields = 0;
496 for (
size_t couple_idx = 0, i = 0; couple_idx < num_couples;
498 size_t curr_num_fields =
500 for (
size_t field_couple_idx = 0; field_couple_idx < curr_num_fields;
501 ++field_couple_idx, ++i) {
502 if (fields_available[i][0] && fields_available[i][1]) {
503 ++new_total_num_fields;
504 }
else if (comm_rank == 0) {
505 int missing_definition_is_fatal =
507 char const * src_component_name;
508 char const * tgt_component_name;
509 char const * src_grid_name;
510 char const * tgt_grid_name;
511 const char * src_field_name;
512 const char * tgt_field_name;
514 couple_config, couple_idx, field_couple_idx,
515 &src_component_name, &tgt_component_name);
517 couple_config, couple_idx, field_couple_idx,
518 &src_grid_name, &tgt_grid_name);
520 couple_config, couple_idx, field_couple_idx,
521 &src_field_name, &tgt_field_name);
522 fprintf(stderr,
"%s: couple defined for field: \n"
524 " component name: \"%s\"\n"
525 " grid name: \"%s\"\n"
526 " field name: \"%s\"\n"
528 " component name: \"%s\"\n"
529 " grid name: \"%s\"\n"
530 " field name: \"%s\"\n",
531 missing_definition_is_fatal?
"ERROR":
"WARNING",
532 (fields_available[i][0])?
"defined":
"not defined",
533 src_component_name, src_grid_name, src_field_name,
534 (fields_available[i][1])?
"defined":
"not defined",
535 tgt_component_name, tgt_grid_name, tgt_field_name);
537 !missing_definition_is_fatal,
538 "ERROR(get_field_configuration): missing definition")
542 total_num_fields = new_total_num_fields;
545 xmalloc(total_num_fields *
sizeof(*field_configs));
547 size_t field_config_idx = 0;
551 for (
size_t couple_idx = 0, i = 0; couple_idx < num_couples; ++couple_idx) {
553 size_t curr_num_fields =
556 for (
size_t field_couple_idx = 0; field_couple_idx < curr_num_fields;
557 ++field_couple_idx, ++i) {
559 if (!fields_available[i][0] || !fields_available[i][1])
continue;
564 couple_config, couple_idx, field_couple_idx,
568 couple_config, couple_idx, field_couple_idx,
574 const char * src_field_name;
575 const char * tgt_field_name;
577 couple_config, couple_idx, field_couple_idx,
578 &src_field_name, &tgt_field_name);
582 num_fields, coupling_fields);
586 num_fields, coupling_fields);
588 double frac_mask_fallback_value =
592 double scale_factor =
594 couple_config, couple_idx, field_couple_idx);
595 double scale_summand =
597 couple_config, couple_idx, field_couple_idx);
598 char const * yaxt_exchanger_name =
600 couple_config, couple_idx, field_couple_idx);
611 "ERROR: collection sizes do not match for coupled fields (%zu != %zu): \n"
613 " component name: \"%s\"\n"
614 " grid name: \"%s\"\n"
615 " field name: \"%s\"\n"
617 " component name: \"%s\"\n"
618 " grid name: \"%s\"\n"
619 " field name: \"%s\"\n",
631 field_configs[field_config_idx].
src_comp_idx = src_comp_idx;
640 couple_config, couple_idx, field_couple_idx))?
647 frac_mask_fallback_value;
648 field_configs[field_config_idx].
scale_factor = scale_factor;
649 field_configs[field_config_idx].
scale_summand = scale_summand;
658 free(fields_available);
661 int * field_src_field_config_compare_matrix =
662 xmalloc((
size_t)(total_num_fields * (total_num_fields - 1)) *
663 sizeof(*field_src_field_config_compare_matrix));
664 int * field_tgt_field_config_compare_matrix =
665 field_src_field_config_compare_matrix +
666 (size_t)(total_num_fields * (total_num_fields - 1)) / 2;
668 for (
unsigned i = 0, k = 0; i < total_num_fields; ++i) {
669 for (
unsigned j = i + 1; j < total_num_fields; ++j, ++k) {
670 field_src_field_config_compare_matrix[k] =
672 field_configs[i].src_interp_config.field,
678 field_tgt_field_config_compare_matrix[k] =
680 field_configs[i].tgt_interp_config.field,
690 MPI_Allreduce(MPI_IN_PLACE, field_src_field_config_compare_matrix,
691 total_num_fields * (total_num_fields - 1),
692 MPI_INT, MPI_LOR, comm), comm);
694 int * field_src_field_config_ids =
695 xcalloc(2 * (
size_t)total_num_fields,
696 sizeof(*field_src_field_config_ids));
697 int * field_tgt_field_config_ids =
698 field_src_field_config_ids + (size_t)total_num_fields;
700 for (
unsigned i = 0, k = 0,
id = 1; i < total_num_fields; ++i) {
701 if (field_src_field_config_ids[i] != 0) {
702 k += total_num_fields - i - 1;
705 field_src_field_config_ids[i] = (int)
id;
706 for (
unsigned j = i + 1; j < total_num_fields; ++j, ++k)
707 if (!field_src_field_config_compare_matrix[k])
708 field_src_field_config_ids[j] = (int)
id;
712 for (
unsigned i = 0, k = 0,
id = 1; i < total_num_fields; ++i) {
713 if (field_tgt_field_config_ids[i] != 0) {
714 k += total_num_fields - i - 1;
717 field_tgt_field_config_ids[i] = (int)
id;
718 for (
unsigned j = i + 1; j < total_num_fields; ++j, ++k)
719 if (!field_tgt_field_config_compare_matrix[k])
720 field_tgt_field_config_ids[j] = (int)
id;
724 free(field_src_field_config_compare_matrix);
726 for (
unsigned i = 0; i < total_num_fields; ++i) {
728 field_src_field_config_ids[i];
730 field_tgt_field_config_ids[i];
732 free(field_src_field_config_ids);
736 int * field_config_compare_matrix =
737 xmalloc((
size_t)(total_num_fields * (total_num_fields - 1)) / 2 *
738 sizeof(*field_config_compare_matrix));
739 for (
unsigned i = 0, k = 0; i < total_num_fields; ++i)
740 for (
unsigned j = i + 1; j < total_num_fields; ++j, ++k)
741 field_config_compare_matrix[k] =
743 &(field_configs[i]), &(field_configs[j])) != 0;
746 MPI_Allreduce(MPI_IN_PLACE, field_config_compare_matrix,
747 (total_num_fields * (total_num_fields - 1)) / 2,
748 MPI_INT, MPI_LOR, comm), comm);
750 int * field_config_ids =
751 xcalloc((
size_t)total_num_fields,
sizeof(*field_config_ids));
753 for (
unsigned i = 0, k = 0,
id = 1; i < total_num_fields; ++i) {
754 if (field_config_ids[i] != 0) {
755 k += total_num_fields - i - 1;
758 field_config_ids[i] = (int)
id;
759 for (
unsigned j = i + 1; j < total_num_fields; ++j, ++k)
760 if (!field_config_compare_matrix[k])
761 field_config_ids[j] = (int)
id;
765 free(field_config_compare_matrix);
767 for (
unsigned i = 0; i < total_num_fields; ++i)
768 field_configs[i].
id = field_config_ids[i];
769 free(field_config_ids);
772 *field_configs_ = field_configs;
773 *count = total_num_fields;
782 return a_->
id - b_->id;
803 size_t * num_fields, MPI_Comm
comm) {
813 (num_mask_names == 0) || (num_fields_ == num_mask_names),
814 "ERROR(get_interp_fields_from_coupling_field): "
815 "missmatch in number of interpolation fields of coupling field \"%s\" "
816 "and number of provided mask names (%zu != %zu)",
819 uint64_t local_counts[2] =
820 {(uint64_t)num_fields_, (uint64_t)num_mask_names};
821 uint64_t global_counts[2];
825 local_counts, global_counts, 2, MPI_UINT64_T, MPI_MAX, comm), comm);
828 local_counts[0] == global_counts[0],
829 "ERROR(get_interp_fields_from_coupling_field): missmatch in number of"
830 "local interpolation fields for coupling field \"%s\" and global "
835 (num_mask_names != 0) || (global_counts[1] == 0),
836 "ERROR(get_interp_fields_from_coupling_field): local process did "
837 "not provide mask names for coupling field \"%s\" while others did",
841 interp_fields_ =
xmalloc(num_fields_ *
sizeof(*interp_fields_));
844 num_fields_ *
sizeof(*interp_fields_));
848 for (
size_t i = 0; i < num_mask_names; ++i) {
849 char const * mask_name = mask_names[i];
852 "ERROR(get_interp_fields_from_coupling_field): "
853 "make_names[%zu] is NULL", i);
856 grid, interp_fields_[i].location, mask_name);
859 uint64_t
data[num_fields_][3];
861 for (
size_t i = 0; i < num_fields_; ++i) {
862 data[i][0] = (uint64_t)interp_fields_[i].location;
863 data[i][1] = (uint64_t)interp_fields_[i].coordinates_idx;
864 data[i][2] = (uint64_t)interp_fields_[i].masks_idx;
869 MPI_IN_PLACE,
data, 3 * (
int)num_fields_,
870 MPI_UINT64_T, MPI_MIN, comm), comm);
872 for (
size_t i = 0; i < num_fields_; ++i) {
874 data[i][0] == (uint64_t)(interp_fields_[i].location),
875 "ERROR(get_interp_fields_from_coupling_field): location mismatch")
877 data[i][1] == (uint64_t)(interp_fields_[i].coordinates_idx),
878 "ERROR(get_interp_fields_from_coupling_field): "
879 "coordinates index mismatch")
881 data[i][2] == (uint64_t)(interp_fields_[i].masks_idx),
882 "ERROR(get_interp_fields_from_coupling_field): "
883 "masks index mismatch")
888 uint64_t zero_counts[2] = {0,0};
893 zero_counts, counts, 2,
894 MPI_UINT64_T, MPI_MAX, comm), comm);
896 num_fields_ = (size_t)(counts[0]);
897 interp_fields_ =
xmalloc(num_fields_ *
sizeof(*interp_fields_));
899 uint64_t
data[num_fields_][3];
901 for (
size_t i = 0; i < num_fields_; ++i) {
903 data[i][1] = (uint64_t)UINT64_MAX;
904 data[i][2] = (uint64_t)UINT64_MAX;
909 MPI_IN_PLACE,
data, 3 * (
int)num_fields_,
910 MPI_UINT64_T, MPI_MIN, comm), comm);
912 for (
size_t i = 0; i < num_fields_; ++i) {
919 *interp_fields = interp_fields_;
920 *num_fields = num_fields_;
925 size_t num_local_grids,
struct output_grid ** output_grids,
926 size_t * output_grid_count) {
932 *output_grid_count = 0;
933 for (
size_t grid_idx = 0; grid_idx <
num_grids; ++grid_idx)
937 ++*output_grid_count;
939 *output_grids =
xmalloc(*output_grid_count *
sizeof(**output_grids));
943 for (
size_t grid_idx = 0, output_grid_idx = 0; grid_idx <
num_grids; ++grid_idx) {
944 char const * grid_name =
946 char const * filename =
948 if (filename != NULL) {
950 for (
size_t i = 0; (i < num_local_grids) && (local_grid == NULL); ++i)
952 local_grid = local_grids[i];
953 (*output_grids)[output_grid_idx].grid_name = grid_name;
954 (*output_grids)[output_grid_idx].filename = filename;
955 (*output_grids)[output_grid_idx].grid = local_grid;
972 MPI_Comm comm = instance->
comm;
976 size_t output_grid_count;
982 output_grids, output_grid_count,
sizeof(*output_grids),
986 for (
size_t i = 0; i < output_grid_count; ++i) {
989 int split_key = (grid != NULL)?1:MPI_UNDEFINED;
993 MPI_Comm output_comm;
994 yac_mpi_call(MPI_Comm_split(comm, split_key, 0, &output_comm), comm);
1001 grid, output_grids[i].filename, output_comm);
1016 MPI_Comm comm = instance->
comm;
1022 instance, &field_configs, &field_count);
1025 qsort(field_configs, field_count,
sizeof(*field_configs),
1033 MPI_Comm comp_pair_comm = MPI_COMM_NULL;
1037 for (
size_t i = 0; i < field_count; ++i) {
1039 struct field_config * curr_field_config = field_configs + i;
1046 if ((prev_comp_grid_pair == NULL) ||
1054 if (comp_pair_comm != MPI_COMM_NULL)
1057 int comp_is_available[2] =
1065 is_active = comp_is_available[0] || comp_is_available[1];
1068 &comp_pair_comm), comm);
1071 yac_mpi_call(MPI_Allreduce(MPI_IN_PLACE, comp_is_available, 2,
1072 MPI_INT, MPI_LOR, comp_pair_comm), comm);
1073 is_active = comp_is_available[0] && comp_is_available[1];
1089 char const * grid_names[2] =
1093 int delete_flags[2];
1101 for (
int i = 0; i < 2; ++i)
1110 curr_field_config - 1, curr_field_config))) {
1115 size_t num_src_fields;
1120 &src_fields, &num_src_fields, comp_pair_comm);
1122 size_t num_tgt_fields;
1127 &tgt_fields, &num_tgt_fields, comp_pair_comm);
1130 num_tgt_fields == 1,
1131 "ERROR(generate_interpolations): "
1132 "only one point set per target field supported")
1141 num_src_fields, src_fields, *tgt_fields);
1152 curr_field_config - 1, curr_field_config))) {
1180 (curr_field_config[-1].reorder_type !=
1191 strcmp(curr_field_config[-1].yaxt_exchanger_name,
1194 &(curr_field_config[-1].frac_mask_fallback_value),
1240 prev_comp_grid_pair = curr_comp_grid_pair;
1247 if (comp_pair_comm != MPI_COMM_NULL)
1249 for (
size_t i = 0; i < field_count; ++i) {
1250 free((
void*)(field_configs[i].src_interp_config.event_data.start_datetime));
1251 free((
void*)(field_configs[i].src_interp_config.event_data.end_datetime));
1252 free((
void*)(field_configs[i].tgt_interp_config.event_data.start_datetime));
1253 free((
void*)(field_configs[i].tgt_interp_config.event_data.end_datetime));
1255 free(field_configs);
1262 "ERROR(yac_instance_sync_def): no components have been defined");
1272 if (requires_def_sync)
1278 "ERROR(yac_instance_setup): no components have been defined");
1298 int include_definitions = 0;
1306 char const ** comp_names,
size_t num_comp_names) {
1310 instance->
comp_config, comp_names, num_comp_names);
1315 const char* comp_name){
1324 const char* comp_name){
1352 MPI_Comm dummy_comm;
1358 if (instance == NULL)
return;
1408 char const ** comp_names,
size_t num_comps) {
1414 "ERROR(yac_instance_def_components): components have already been defined")
1417 for (
size_t i = 0; i < num_comps; ++i)
1436 struct yac_instance * instance,
char const * field_name,
1449 field_name,
"ERROR(yac_instance_add_field): "
1450 "\"NULL\" is not a valid field name")
1453 "ERROR(yac_instance_add_field): field name is too long "
1454 "(maximum is YAC_MAX_CHARLEN)")
1456 (collection_size > 0) && (collection_size < INT_MAX),
1457 "ERROR(yac_instance_add_field): \"%d\" is not a valid collection size "
1458 "(component \"%s\" grid \"%s\" field \"%s\")",
1459 collection_size, comp_name, grid_name, field_name)
1463 couple_config, comp_name, grid_name, field_name,
1464 timestep, collection_size);
1474 "ERROR(yac_instance_add_field): "
1475 "field with the name \"%s\" has already been defined",
1496 char const * src_comp_name,
char const * src_grid_name,
char const * src_field_name,
1497 char const * tgt_comp_name,
char const * tgt_grid_name,
char const * tgt_field_name,
1498 char const * coupling_period,
int time_reduction,
1500 const char* weight_file_name,
int mapping_on_source,
1501 double scale_factor,
double scale_summand,
size_t num_src_mask_names,
1502 char const *
const * src_mask_names,
char const * tgt_mask_name,
1503 char const * yaxt_exchanger_name) {
1509 instance->
couple_config, src_comp_name, src_grid_name, src_field_name,
1510 tgt_comp_name, tgt_grid_name, tgt_field_name, coupling_period,
1511 time_reduction, interp_stack_config, src_lag, tgt_lag, weight_file_name,
1512 mapping_on_source, scale_factor, scale_summand, num_src_mask_names,
1513 src_mask_names, tgt_mask_name, yaxt_exchanger_name);
1517 const char * comp_name,
const char* grid_name,
const char * field_name){
size_t yac_basic_grid_get_named_mask_idx(struct yac_basic_grid *grid, enum yac_location location, char const *mask_name)
int const * yac_basic_grid_get_field_mask(struct yac_basic_grid *grid, struct yac_interp_field field)
void yac_basic_grid_to_file_parallel(struct yac_basic_grid *grid, char const *filename, MPI_Comm comm)
yac_const_coordinate_pointer yac_basic_grid_get_field_coordinates(struct yac_basic_grid *grid, struct yac_interp_field field)
char const * yac_basic_grid_get_name(struct yac_basic_grid *grid)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
int yac_component_config_comp_size(struct yac_component_config *comp_config, char const *comp_name)
int yac_component_config_comp_rank(struct yac_component_config *comp_config, char const *comp_name)
void yac_component_config_delete(struct yac_component_config *comp_config)
MPI_Comm yac_component_config_get_comps_comm(struct yac_component_config *comp_config, const char **names, size_t num_names)
int yac_component_config_contains_component(struct yac_component_config *comp_config, char const *comp_name)
struct yac_component_config * yac_component_config_new(struct yac_couple_config *couple_config, char const **names, size_t num_names, MPI_Comm comm_)
char * yac_yaml_emit_coupling(struct yac_couple_config *couple_config, int emit_flags, int include_definitions)
char const * yac_couple_config_get_yaxt_exchanger_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_sync(struct yac_couple_config *couple_config, MPI_Comm comm, char const *output_ref)
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)
int yac_couple_config_contains_grid_name(struct yac_couple_config *couple_config, char const *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)
void yac_couple_config_component_add_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)
int yac_couple_config_mapping_on_source(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
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)
size_t yac_couple_config_get_field_collection_size(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
size_t yac_couple_config_get_num_couple_fields(struct yac_couple_config *couple_config, size_t couple_idx)
void yac_couple_config_get_src_mask_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const *const **mask_names, size_t *num_mask_names)
size_t yac_couple_config_get_num_couples(struct yac_couple_config *couple_config)
int yac_couple_config_get_target_lag(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_def_couple(struct yac_couple_config *couple_config, char const *src_comp_name, char const *src_grid_name, char const *src_field_name, char const *tgt_comp_name, char const *tgt_grid_name, char const *tgt_field_name, char const *coupling_period, int time_reduction, struct yac_interp_stack_config *interp_stack, int src_lag, int tgt_lag, const char *weight_file_name, int mapping_on_source, double scale_factor, double scale_summand, size_t num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name, char const *yaxt_exchanger_name)
double yac_couple_config_get_frac_mask_fallback_value(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
int yac_couple_config_get_source_lag(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
double yac_couple_config_get_scale_factor(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_tgt_mask_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_add_grid(struct yac_couple_config *couple_config, char const *name)
char const * yac_couple_config_get_grid_name(struct yac_couple_config *couple_config, size_t grid_idx)
double yac_couple_config_get_scale_summand(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
enum yac_reduction_type yac_couple_config_get_coupling_period_operation(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_enforce_write_weight_file(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_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)
struct yac_couple_config * yac_couple_config_new()
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_source_timestep(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_add_component(struct yac_couple_config *couple_config, char const *name)
size_t yac_couple_config_get_num_grids(struct yac_couple_config *couple_config)
char * yac_couple_config_get_end_datetime(struct yac_couple_config *couple_config)
char const * yac_couple_config_get_target_timestep(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_delete(struct yac_couple_config *couple_config)
void yac_dist_grid_pair_delete(struct yac_dist_grid_pair *grid_pair)
struct yac_dist_grid_pair * yac_dist_grid_pair_new(struct yac_basic_grid *grid_a, struct yac_basic_grid *grid_b, MPI_Comm comm)
struct event * yac_event_new()
void yac_event_add(struct event *event, char const *delta_model_time, char const *delta_coupling_time, int lag, enum yac_reduction_type time_operation, const char *startdate, const char *stopdate)
void yac_set_coupling_field_put_op(struct coupling_field *field, struct event *event, struct yac_interpolation *interpolation)
void yac_set_coupling_field_get_op(struct coupling_field *field, struct event *event, struct yac_interpolation *interpolation)
char const * yac_get_coupling_field_comp_name(struct coupling_field *field)
struct yac_basic_grid * yac_coupling_field_get_basic_grid(struct coupling_field *field)
size_t yac_coupling_field_get_num_interp_fields(struct coupling_field *field)
struct yac_interp_field const * yac_coupling_field_get_interp_fields(struct coupling_field *cpl_field)
struct coupling_field * yac_coupling_field_new(char const *field_name, char const *component_name, struct yac_basic_grid *grid, struct yac_interp_field *interp_fields, unsigned num_interp_fields, size_t collection_size, const char *timestep)
const char * yac_get_coupling_field_name(struct coupling_field *field)
void yac_coupling_field_delete(struct coupling_field *cpl_field)
void yac_instance_delete(struct yac_instance *instance)
char * yac_instance_setup_and_emit_config(struct yac_instance *instance, struct yac_basic_grid **grids, size_t num_grids, int emit_flags)
int yac_instance_get_comp_rank(struct yac_instance *instance, const char *comp_name)
char * yac_instance_get_start_datetime(struct yac_instance *instance)
char * yac_instance_get_end_datetime(struct yac_instance *instance)
void yac_instance_def_datetime(struct yac_instance *instance, const char *start_datetime, const char *end_datetime)
void yac_instance_setup(struct yac_instance *instance, struct yac_basic_grid **grids, size_t num_grids)
void yac_instance_sync_def(struct yac_instance *instance)
static void get_output_grids(struct yac_instance *instance, struct yac_basic_grid **local_grids, size_t num_local_grids, struct output_grid **output_grids, size_t *output_grid_count)
struct yac_instance * yac_instance_new(MPI_Comm comm)
int yac_instance_components_are_defined(struct yac_instance *instance)
void yac_instance_def_couple(struct yac_instance *instance, 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_config, int src_lag, int tgt_lag, const char *weight_file_name, int mapping_on_source, double scale_factor, double scale_summand, size_t num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name, char const *yaxt_exchanger_name)
static int compare_output_grids(const void *a, const void *b)
static void generate_interpolations(struct yac_instance *instance, struct yac_basic_grid **grids, size_t num_grids)
struct coupling_field * yac_instance_add_field(struct yac_instance *instance, char const *field_name, char const *comp_name, struct yac_basic_grid *grid, struct yac_interp_field *interp_fields, size_t num_interp_fields, int collection_size, char const *timestep)
void yac_instance_set_couple_config(struct yac_instance *instance, struct yac_couple_config *couple_config)
static struct coupling_field * get_coupling_field(char const *component_name, const char *field_name, const char *grid_name, size_t num_fields, struct coupling_field **coupling_fields)
void yac_instance_dummy_new(MPI_Comm comm)
static struct yac_basic_grid * get_basic_grid(const char *grid_name, struct yac_basic_grid **grids, size_t num_grids, int *delete_flag)
void yac_instance_def_components(struct yac_instance *instance, char const **comp_names, size_t num_comps)
#define CHECK_MIN_PHASE(FUNC_NAME, MIN_REF_PHASE)
static void get_field_configuration(struct yac_instance *instance, struct field_config **field_configs_, size_t *count)
static int compare_field_config_ids(const void *a, const void *b)
static int compare_field_config_fields(struct coupling_field *a, size_t num_mask_names_a, char const *const *mask_names_a, struct coupling_field *b, size_t num_mask_names_b, char const *const *mask_names_b)
struct yac_couple_config * yac_instance_get_couple_config(struct yac_instance *instance)
struct field_config_event_data get_event_data(struct yac_instance *instance, int couple_idx, int field_couple_idx, enum field_type field_type)
static int compare_comp_grid_config(const void *a, const void *b)
static struct tgt_field_config get_tgt_interp_config(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
static struct field_config_event_data empty_event_data
static struct src_field_config get_src_interp_config(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
static const char * yac_instance_phase_str[]
static struct event * generate_event(struct field_config_event_data event_data)
static int compare_field_config_field_ids(const void *a, const void *b)
#define CHECK_PHASE(FUNC_NAME, REF_PHASE, NEW_PHASE)
static void write_grids_to_file(struct yac_instance *instance, struct yac_basic_grid **grids, size_t num_grids)
#define CHECK_MAX_PHASE(FUNC_NAME, MAX_REF_PHASE)
static void get_interp_fields_from_coupling_field(struct coupling_field *field, char const *const *mask_names, size_t num_mask_names, struct yac_interp_field **interp_fields, size_t *num_fields, MPI_Comm comm)
@ INSTANCE_DEFINITION_COMP
@ INSTANCE_DEFINITION_SYNC
static int compare_field_config(const void *a, const void *b)
int yac_instance_get_comp_size(struct yac_instance *instance, const char *comp_name)
MPI_Comm yac_instance_get_comps_comm(struct yac_instance *instance, char const **comp_names, size_t num_comp_names)
static int compare_field_config_interp_method(const void *a, const void *b)
static struct yac_interp_weights * generate_interp_weights(struct src_field_config src_interp_config, struct yac_interp_grid *interp_grid)
struct coupling_field * yac_instance_get_field(struct yac_instance *instance, const char *comp_name, const char *grid_name, const char *field_name)
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_ENDDEF
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_COMP
#define YAC_INSTANCE_CONFIG_OUTPUT_REF_SYNC
void yac_interp_grid_delete(struct yac_interp_grid *interp_grid)
struct yac_interp_grid * yac_interp_grid_new(struct yac_dist_grid_pair *grid_pair, char const *src_grid_name, char const *tgt_grid_name, size_t num_src_fields, struct yac_interp_field const *src_fields, struct yac_interp_field const tgt_field)
void yac_interp_method_delete(struct interp_method **method)
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
int yac_interp_stack_config_compare(void const *a_, void const *b_)
struct interp_method ** yac_interp_stack_config_generate(struct yac_interp_stack_config *interp_stack)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
void yac_interp_weights_write_to_file(struct yac_interp_weights *weights, char const *filename, char const *src_grid_name, char const *tgt_grid_name, size_t src_grid_size, size_t tgt_grid_size)
struct yac_interpolation * yac_interp_weights_get_interpolation(struct yac_interp_weights *weights, enum yac_interp_weights_reorder_type reorder, size_t collection_size, double frac_mask_fallback_value, double scaling_factor, double scaling_summand, char const *yaxt_exchanger_name)
yac_interp_weights_reorder_type
@ YAC_MAPPING_ON_TGT
weights will be applied at target processes
@ YAC_MAPPING_ON_SRC
weights will be appied at source processes
struct yac_interpolation * yac_interpolation_copy(struct yac_interpolation *interp)
void yac_interpolation_inc_ref_count(struct yac_interpolation *interpolation)
void yac_interpolation_delete(struct yac_interpolation *interp)
#define xrealloc(ptr, size)
#define xcalloc(nmemb, size)
struct comp_grid_config config[2]
struct yac_basic_grid * grid
struct yac_interp_field * interp_fields
size_t collection_size
number of vertical levels or bundles
char const * end_datetime
char const * start_datetime
enum yac_reduction_type reduction_operation
char const * coupling_period
char const * yaxt_exchanger_name
struct comp_grid_pair_config comp_grid_pair
enum yac_interp_weights_reorder_type reorder_type
struct tgt_field_config tgt_interp_config
struct src_field_config src_interp_config
double frac_mask_fallback_value
struct yac_basic_grid * grid
const char * weight_file_name
char const *const * mask_names
struct field_config_event_data event_data
struct yac_interp_stack_config * interp_stack
struct coupling_field * field
struct field_config_event_data event_data
struct coupling_field * field
struct yac_basic_grid_data data
struct _datetime * end_datetime
struct _datetime * start_datetime
struct coupling_field ** cpl_fields
enum yac_instance_phase phase
struct yac_component_config * comp_config
struct yac_couple_config * couple_config
enum yac_location location
static struct user_input_data_masks ** masks
struct yac_basic_grid ** grids
#define YAC_ASSERT_F(exp, format,...)
#define YAC_ASSERT(exp, msg)
#define yac_mpi_call(call, comm)
double const (* yac_const_coordinate_pointer)[3]