YAC 3.20.0
Yet Another Coupler
Loading...
Searching...
No Matches
couple_config.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <limits.h>
10#include <stdlib.h>
11#include <stdio.h>
12#include <errno.h>
13#include <string.h>
14#include <math.h>
15
16#include <mpi.h>
17
18#include "couple_config.h"
22#include "couple_config_grid.h"
24
25#include "yac_mpi_common.h"
26#include "yac.h"
27#include "mtime_calendar.h"
28#include "utils_common.h"
29#include "config_yaml.h"
30#include "mtime_datetime.h"
33#include "yac_mpi_internal.h"
35#include "instance.h"
36
38 struct yac_couple_config const * couple_config, char const * component_name);
40 struct yac_couple_config const * couple_config, char const * grid_name);
42 struct yac_couple_config const * couple_config, size_t component_idx,
43 size_t grid_idx, char const * field_name);
44
46
47 struct yac_couple_config * couple_config =
48 xmalloc(1 * sizeof(*couple_config));
49
50 couple_config->start_datetime = NULL;
51 couple_config->end_datetime = NULL;
52
53 couple_config->config_outputs = NULL;
54 couple_config->num_config_outputs = 0;
55
56 couple_config->grids = NULL;
57 couple_config->num_grids = 0;
58
59 couple_config->components = NULL;
60 couple_config->num_components = 0;
61
62 couple_config->couples = NULL;
63 couple_config->num_couples = 0;
64
68
69 return couple_config;
70}
71
76 struct yac_couple_config const * couple_config, char const * component_name) {
77
78 size_t component_idx =
79 yac_couple_config_get_component_idx(couple_config, component_name);
80
81 YAC_ASSERT(couple_config->components != NULL,
82 "couple_config->components is NULL");
83
85 "invalid component index %zu (number of components: %zu)",
86 component_idx, couple_config->num_components);
87
88 return couple_config->components + component_idx;
89}
90
91static void couple_config_sync_calendar(MPI_Comm comm) {
92
93 int calendar = (int)getCalendarType();
94 if (calendar == CALENDAR_NOT_SET) calendar = INT_MAX;
95
96 // broadcast calendar
98 MPI_Allreduce(
99 MPI_IN_PLACE, &calendar, 1, MPI_INT, MPI_MIN, comm), comm);
100
101 // if no process has defined a calendar
102 if (calendar == INT_MAX) return;
103
104 // set calendar (if local process has already defined a calendar,
105 // the definition is checked for consistency)
106 yac_instance_def_calendar(calendar, "coupling configuration synchronization");
107}
108
109void yac_couple_config_delete(struct yac_couple_config * couple_config) {
110
111 deallocateDateTime((void*)couple_config->start_datetime);
112 deallocateDateTime((void*)couple_config->end_datetime);
113
115 &couple_config->config_outputs, &couple_config->num_config_outputs);
117 &couple_config->grids, &couple_config->num_grids);
119 &couple_config->components, &couple_config->num_components);
121 &couple_config->couples, &couple_config->num_couples);
122 free(couple_config);
123}
124
126 struct yac_couple_config * couple_config, char const * name) {
127
128 return
130 &(couple_config->grids), &(couple_config->num_grids), name);
131}
132
134 struct yac_couple_config * couple_config, char const * name) {
135
136 yac_couple_config_add_grid_(couple_config, name);
137}
138
140 struct yac_couple_config * couple_config, char const * name) {
141
142 return
144 &(couple_config->components), &(couple_config->num_components), name);
145}
146
148 struct yac_couple_config * couple_config, char const * name) {
149
151}
152
154 struct yac_couple_config * couple_config,
155 char const * comp_name, const char* metadata) {
156 struct yac_couple_config_component * component =
157 yac_couple_config_get_component(couple_config, comp_name);
159}
160
162 struct yac_couple_config * couple_config,
163 char const * grid_name, const char* output_filename) {
165 grid_name != NULL,
166 "invalid grid_name (NULL is not allowed)");
167 if(!yac_couple_config_contains_grid_name(couple_config, grid_name)) {
168 yac_couple_config_add_grid(couple_config, grid_name);
169 }
170 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
172 couple_config->grids + grid_idx, output_filename);
173}
174
176 struct yac_couple_config * couple_config,
177 char const * grid_name, const char* metadata) {
179 grid_name != NULL,
180 "invalid grid_name (NULL is not allowed)");
181 if(!yac_couple_config_contains_grid_name(couple_config, grid_name)) {
182 yac_couple_config_add_grid(couple_config, grid_name);
183 }
184 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
186 couple_config->grids + grid_idx, metadata);
187}
188
190 struct yac_couple_config * couple_config,
191 const char* comp_name, const char * grid_name, const char* field_name,
192 const char* metadata) {
193 size_t comp_idx = yac_couple_config_get_component_idx(couple_config, comp_name);
194 struct yac_couple_config_component * component =
195 couple_config->components + comp_idx;
196 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
198 component, grid_idx, field_name, metadata);
199}
200
202 struct yac_couple_config const * couple_config, const char * comp_name) {
203 size_t comp_idx = yac_couple_config_get_component_idx(couple_config, comp_name);
204 return couple_config->components[comp_idx].metadata;
205}
206
208 struct yac_couple_config const * couple_config,
209 const char * grid_name) {
210 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
211 return couple_config->grids[grid_idx].output_filename;
212}
213
215 struct yac_couple_config const * couple_config,
216 const char * grid_name) {
217 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
218 return couple_config->grids[grid_idx].metadata;
219}
220
222 struct yac_couple_config const * couple_config,
223 const char* comp_name, const char * grid_name, const char* field_name) {
224 struct yac_couple_config_component * component =
225 yac_couple_config_get_component(couple_config, comp_name);
226
227 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
228
230 component, grid_idx, field_name
231 );
232}
233
234#define CHECK_COMPONENT_IDX() \
235 YAC_ASSERT_F( \
236 component_idx < couple_config->num_components, "invalid component_idx")
237
238#define CHECK_GRID_IDX() \
239 YAC_ASSERT_F( \
240 grid_idx < couple_config->num_grids, "invalid grid_idx")
241
243 struct yac_couple_config * couple_config,
244 size_t component_idx, size_t grid_idx, char const * field_name,
245 char const * timestep, size_t collection_size) {
246
249
250 // check whether the field already exists
251 struct yac_couple_config_component * component =
252 couple_config->components + component_idx;
253
255 component, field_name, grid_idx, timestep, collection_size);
256}
257
259 struct yac_couple_config * couple_config, const char* component_name,
260 const char* grid_name, const char* name, char const * timestep,
261 size_t collection_size) {
262
264 couple_config,
265 yac_couple_config_get_component_idx(couple_config, component_name),
266 yac_couple_config_get_grid_idx(couple_config, grid_name),
267 name, timestep, collection_size);
268}
269
271 struct yac_couple_config const * couple_config) {
272
273 return couple_config->num_couples;
274}
275
277 struct yac_couple_config const * couple_config) {
278
280
281 switch(couple_config->missing_definition_is_fatal) {
283 "invalid value of missing_definition_is_fatal-flag");
285 ret = 0;
286 break;
288 ret = 1;
289 break;
292 break;
293 }
294 return ret;
295}
296
298 struct yac_couple_config * couple_config,
299 int missing_definition_is_fatal) {
300
301 enum yac_couple_config_flag_value user_value =
302 (missing_definition_is_fatal != 0)
305
307 (couple_config->missing_definition_is_fatal ==
309 (couple_config->missing_definition_is_fatal == user_value),
310 "inconsistent setting of \"missing_definition_is_fatal\"-flag "
311 "(old: %s new: %s)",
313 ? "TRUE" : "FALSE",
314 (user_value == YAC_COUPLE_CONFIG_FLAG_TRUE) ? "TRUE" : "FALSE");
315
316 couple_config->missing_definition_is_fatal = user_value;
317}
318
320 struct yac_couple_config const * couple_config) {
321
322 int apply_coordinate_check = APPLY_COORDINATE_CHECK_DEFAULT_VALUE;
323
324 switch(couple_config->apply_coordinate_check) {
325 YAC_UNREACHABLE_DEFAULT("invalid value of apply_coordinate_check-flag");
327 apply_coordinate_check = 0;
328 break;
329 }
331 apply_coordinate_check = 1;
332 break;
333 }
335 apply_coordinate_check = APPLY_COORDINATE_CHECK_DEFAULT_VALUE;
336 break;
337 }
338 }
339
340 return apply_coordinate_check;
341}
342
344 struct yac_couple_config * couple_config,
345 int apply_coordinate_check) {
346
347 enum yac_couple_config_flag_value user_value =
348 (apply_coordinate_check != 0)
351
353 (couple_config->apply_coordinate_check ==
355 (couple_config->apply_coordinate_check == user_value),
356 "inconsistent setting of \"apply_coordinate_check\"-flag "
357 "(old: %s new: %s)",
358 (couple_config->apply_coordinate_check ==
359 YAC_COUPLE_CONFIG_FLAG_TRUE) ? "TRUE" : "FALSE",
360 (user_value == YAC_COUPLE_CONFIG_FLAG_TRUE) ? "TRUE" : "FALSE");
361
362 couple_config->apply_coordinate_check = user_value;
363}
364
366 struct yac_couple_config const * couple_config) {
367
368 int coordinates_mismatch_is_fatal =
370
371 switch(couple_config->coordinates_mismatch_is_fatal) {
373 "invalid value of coordinates_mismatch_is_fatal-flag");
375 coordinates_mismatch_is_fatal = 0;
376 break;
377 }
379 coordinates_mismatch_is_fatal = 1;
380 break;
381 }
383 coordinates_mismatch_is_fatal =
385 break;
386 }
387 }
388
389 return coordinates_mismatch_is_fatal;
390}
391
393 struct yac_couple_config * couple_config,
394 int coordinates_mismatch_is_fatal) {
395
396 enum yac_couple_config_flag_value user_value =
397 (coordinates_mismatch_is_fatal != 0)
400
402 (couple_config->coordinates_mismatch_is_fatal ==
404 (couple_config->coordinates_mismatch_is_fatal == user_value),
405 "inconsistent setting of "
406 "\"coordinates_mismatch_is_fatal\"-flag "
407 "(old: %s new: %s)",
408 (couple_config->coordinates_mismatch_is_fatal ==
409 YAC_COUPLE_CONFIG_FLAG_TRUE) ? "TRUE" : "FALSE",
410 (user_value == YAC_COUPLE_CONFIG_FLAG_TRUE) ? "TRUE" : "FALSE");
411
412 couple_config->coordinates_mismatch_is_fatal = user_value;
413}
414
415#define CHECK_COUPLE_IDX() \
416 YAC_ASSERT_F(couple_idx < couple_config->num_couples, "invalid couple_idx")
417
419 struct yac_couple_config const * couple_config, size_t couple_idx) {
420
422
423 return couple_config->couples[couple_idx].num_field_couples;
424}
425
427 struct yac_couple_config const * couple_config, size_t couple_idx,
428 char const * couple_component_names[2]) {
429
431
432 for (int i = 0; i < 2; ++i)
433 couple_component_names[i] =
434 couple_config->components[
435 couple_config->couples[couple_idx].component_indices[i]].name;
436}
437
439 struct yac_couple_config const * couple_config, char const * component_name) {
440
441 YAC_ASSERT(component_name, "component name is NULL")
443 strlen(component_name) <= YAC_MAX_CHARLEN,
444 "component name is too long (maximum is YAC_MAX_CHARLEN)")
445
446 int found_flag = 0;
447
448 for (size_t component_idx = 0;
449 (component_idx < couple_config->num_components) && !found_flag;
450 ++component_idx) {
451 found_flag =
452 !strcmp(component_name, couple_config->components[component_idx].name);
453 }
454 return found_flag;
455}
456
458 struct yac_couple_config const * couple_config) {
459
460 return couple_config->num_components;
461}
462
464 struct yac_couple_config const * couple_config) {
465
466 return couple_config->num_grids;
467}
468
470 struct yac_couple_config const * couple_config, size_t component_idx) {
472 return couple_config->components[component_idx].num_fields;
473}
474
476 struct yac_couple_config const * couple_config, char const * component_name) {
477
478 size_t const component_idx =
479 yac_couple_config_get_component_idx_unsafe(couple_config, component_name);
480
482 component_idx != SIZE_MAX,
483 "Component \"%s\" not found in coupling configuration",
484 component_name);
485
486 return component_idx;
487}
488
490 struct yac_couple_config const * couple_config, char const * component_name) {
491
492 size_t component_idx = SIZE_MAX;
493 for (size_t i = 0; (i < couple_config->num_components) &&
494 (component_idx == SIZE_MAX); ++i) {
495 if (!strcmp(couple_config->components[i].name, component_name)) {
496 component_idx = i;
497 }
498 }
499
500 return component_idx;
501}
502
504 struct yac_couple_config const * couple_config, char const * grid_name) {
505
506 size_t const grid_idx =
507 yac_couple_config_get_grid_idx_unsafe(couple_config, grid_name);
508
510 grid_idx != SIZE_MAX, "grid name \"%s\" not in list of grids", grid_name)
511
512 return grid_idx;
513}
514
516 struct yac_couple_config const * couple_config, char const * grid_name) {
517
518 size_t grid_idx = SIZE_MAX;
519 for (size_t i = 0;
520 (i < couple_config->num_grids) && (grid_idx == SIZE_MAX); ++i) {
521 if (!strcmp(couple_config->grids[i].name, grid_name)) {
522 grid_idx = i;
523 }
524 }
525
526 return grid_idx;
527}
528
530 struct yac_couple_config const * couple_config, size_t component_idx,
531 size_t grid_idx, char const * field_name) {
533
534 size_t const field_idx = yac_couple_config_get_field_idx_unsafe(
535 couple_config, component_idx, grid_idx, field_name);
536
538 field_idx != SIZE_MAX,
539 "field \"%s\" for grid_idx %zu not found in component_idx %zu",
540 field_name, grid_idx, component_idx);
541
542 return field_idx;
543}
544
546 struct yac_couple_config const * couple_config, size_t component_idx,
547 size_t grid_idx, char const * field_name) {
548
549 struct yac_couple_config_component * component =
550 couple_config->components + component_idx;
551
552 struct yac_couple_config_field * field =
553 yac_couple_config_component_find_field(component, grid_idx, field_name);
554
555 return (field == NULL) ? SIZE_MAX : (size_t)(field - component->fields);
556}
557
559 struct yac_couple_config const * couple_config, size_t component_idx) {
560
562
563 return couple_config->components[component_idx].name;
564}
565
567 struct yac_couple_config const * couple_config, size_t component_idx,
568 size_t field_idx) {
569
571
572 struct yac_couple_config_component const * component =
573 couple_config->components + component_idx;
574
575 size_t const grid_idx =
577
579
580 struct yac_couple_config_grid const * grid =
581 couple_config->grids + grid_idx;
582
583 return grid->name;
584}
585
587 struct yac_couple_config const * couple_config, size_t component_idx,
588 size_t field_idx) {
589
591
592 struct yac_couple_config_component const * component =
593 couple_config->components + component_idx;
594
595 return yac_couple_config_component_get_field_name(component, field_idx);
596}
597
599 struct yac_couple_config const * couple_config,
600 char const * component_name, char const * grid_name,
601 char const * field_name) {
602
603 struct yac_couple_config_component const * component =
604 yac_couple_config_get_component(couple_config, component_name);
606 couple_config, grid_name);
607
609 component, grid_idx, field_name);
610}
611
613 struct yac_couple_config const * couple_config,
614 char const * component_name, char const * grid_name,
615 char const * field_name) {
616
617 int field_role = YAC_EXCHANGE_TYPE_NONE;
618
619 // Try to fine a matching component.
620 size_t component_idx =
621 yac_couple_config_get_component_idx_unsafe(couple_config, component_name);
622
623 // If a matching component name was found, try to find a matching grid.
624 size_t grid_idx = SIZE_MAX;
625 if (component_idx != SIZE_MAX) {
626 grid_idx = yac_couple_config_get_grid_idx_unsafe(couple_config, grid_name);
627 }
628
629 // If a matching grid name was found, try to find a matching field.
630 size_t field_idx = SIZE_MAX;
631 if (grid_idx != SIZE_MAX) {
633 couple_config, component_idx, grid_idx, field_name);
634 }
635
636 // If a matching field was found,
637 // check all couples for a matching component/field index pair
638 if (field_idx != SIZE_MAX) {
639
640 size_t const nbr_couples = couple_config->num_couples;
641 for(size_t couple_idx = 0;
642 (couple_idx<nbr_couples) && (field_role == YAC_EXCHANGE_TYPE_NONE);
643 ++couple_idx)
644 {
645 struct yac_couple_config_couple * couple =
646 couple_config->couples + couple_idx;
647
648 int const couple_has_component =
650
651 if (couple_has_component) {
652
653 field_role =
655 couple, component_idx, field_idx);
656
657 // the couple config interface should prevent this case from happening
659 field_role != YAC_EXCHANGE_TYPE_INVALID,
660 "field cannot be source and target at the same time "
661 "(component: \"%s\" grid: \"%s\" field: \"%s\" "
662 "couple_idx: %zu)",
663 component_name, grid_name, field_name, couple_idx);
664 }
665 }
666 }
667
668 return field_role;
669}
670
672 struct yac_couple_config const * couple_config,
673 size_t component_idx, size_t field_idx) {
674
676
677 struct yac_couple_config_component const * component =
678 couple_config->components + component_idx;
679
680 return yac_couple_config_component_field_is_valid(component, field_idx);
681}
682
684 struct yac_couple_config const * couple_config,
685 size_t couple_idx, size_t field_couple_idx) {
686
688
689 struct yac_couple_config_couple const * couple =
690 couple_config->couples + couple_idx;
691
693 couple, field_couple_idx);
694}
695
697 struct yac_couple_config const * couple_config,
698 size_t couple_idx, size_t field_couple_idx) {
699
701
702 struct yac_couple_config_couple const * couple =
703 couple_config->couples + couple_idx;
704
706 couple, field_couple_idx);
707}
708
710 struct yac_couple_config const * couple_config,
711 size_t couple_idx, size_t field_couple_idx) {
712
714
715 struct yac_couple_config_couple const * couple =
716 couple_config->couples + couple_idx;
717
719 couple, field_couple_idx);
720}
721
723 struct yac_couple_config const * couple_config,
724 size_t couple_idx, size_t field_couple_idx) {
725
727
728 struct yac_couple_config_couple * couple =
729 couple_config->couples + couple_idx;
730
732 couple, field_couple_idx);
733}
734
736 struct yac_couple_config const * couple_config,
737 size_t couple_idx, size_t field_couple_idx) {
738
740
741 struct yac_couple_config_couple * couple =
742 couple_config->couples + couple_idx;
743
745 couple, field_couple_idx);
746}
747
749 struct yac_couple_config const * couple_config,
750 size_t couple_idx, size_t field_couple_idx) {
751
753
754 struct yac_couple_config_couple * couple =
755 couple_config->couples + couple_idx;
756
758 couple, field_couple_idx);
759}
760
762 struct yac_couple_config const * couple_config,
763 size_t couple_idx, size_t field_couple_idx) {
764
766
767 struct yac_couple_config_couple const * couple =
768 couple_config->couples + couple_idx;
769
771 couple, field_couple_idx);
772}
773
775 struct yac_couple_config const * couple_config,
776 size_t couple_idx, size_t field_couple_idx) {
777
779
780 struct yac_couple_config_couple const * couple =
781 couple_config->couples + couple_idx;
782
784 couple, field_couple_idx);
785}
786
788 struct yac_couple_config const * couple_config,
789 size_t couple_idx, size_t field_couple_idx) {
790
792
793 struct yac_couple_config_couple const * couple =
794 couple_config->couples + couple_idx;
795
797 couple, field_couple_idx);
798}
799
801 struct yac_couple_config const * couple_config,
802 size_t couple_idx, size_t field_couple_idx) {
803
805
806 struct yac_couple_config_couple const * couple =
807 couple_config->couples + couple_idx;
808
810 couple, field_couple_idx);
811}
812
814 struct yac_couple_config const * couple_config,
815 size_t couple_idx, size_t field_couple_idx) {
816
818
819 struct yac_couple_config_couple const * couple =
820 couple_config->couples + couple_idx;
821
823 couple, field_couple_idx);
824}
825
827 struct yac_couple_config const * couple_config,
828 size_t couple_idx, size_t field_couple_idx,
829 char const * const ** mask_names, size_t * num_mask_names) {
830
832
833 struct yac_couple_config_couple const * couple =
834 couple_config->couples + couple_idx;
835
837 couple, field_couple_idx, mask_names, num_mask_names);
838}
839
841 struct yac_couple_config const * couple_config,
842 size_t couple_idx, size_t field_couple_idx) {
843
845
846 struct yac_couple_config_couple const * couple =
847 couple_config->couples + couple_idx;
848
850 couple, field_couple_idx);
851}
852
854 struct yac_couple_config const * couple_config,
855 size_t couple_idx, size_t field_couple_idx) {
856
858
859 struct yac_couple_config_couple const * couple =
860 couple_config->couples + couple_idx;
861
863 couple, field_couple_idx);
864}
865
866struct yac_collection_selection const *
868 struct yac_couple_config const * couple_config,
869 size_t couple_idx, size_t field_couple_idx) {
870
872
873 struct yac_couple_config_couple * couple =
874 couple_config->couples + couple_idx;
875
877 couple, field_couple_idx);
878}
879
881 struct yac_couple_config const * couple_config,
882 size_t couple_idx, size_t field_couple_idx) {
883
885
886 struct yac_couple_config_couple * couple =
887 couple_config->couples + couple_idx;
888
890 couple, field_couple_idx);
891}
892
894 struct yac_couple_config const * couple_config,
895 size_t couple_idx, size_t field_couple_idx,
896 char const ** src_grid_name, char const ** tgt_grid_name) {
897
899
900 struct yac_couple_config_couple const * couple =
901 couple_config->couples + couple_idx;
902
903 size_t src_component_idx =
905 size_t src_field_idx =
906 yac_couple_config_couple_get_source_field_idx(couple, field_couple_idx);
907
908 size_t tgt_component_idx =
910 size_t tgt_field_idx =
911 yac_couple_config_couple_get_target_field_idx(couple, field_couple_idx);
912
913 struct yac_couple_config_component const * src_component =
914 couple_config->components + src_component_idx;
915 struct yac_couple_config_component const * tgt_component =
916 couple_config->components + tgt_component_idx;
917
919 src_component, src_field_idx);
921 tgt_component, tgt_field_idx);
922
923 *src_grid_name = couple_config->grids[src_grid_idx].name;
924 *tgt_grid_name = couple_config->grids[tgt_grid_idx].name;
925}
926
928 struct yac_couple_config * couple_config,
929 char const * comp_name, char const * grid_name, char const * field_name,
930 double frac_mask_fallback_value) {
931
933 YAC_FRAC_MASK_VALUE_IS_VALID(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);
937
938 struct yac_couple_config_component * component =
939 yac_couple_config_get_component(couple_config, comp_name);
940 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
941
943 component, grid_idx, field_name, frac_mask_fallback_value);
944}
945
947 struct yac_couple_config const * couple_config,
948 char const * component_name, char const * grid_name,
949 char const * field_name) {
950
951 struct yac_couple_config_component const * component =
952 yac_couple_config_get_component(couple_config, component_name);
953 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
954
955 double frac_mask_fallback_value =
957 component, grid_idx, field_name);
958
959 return frac_mask_fallback_value;
960}
961
963 struct yac_couple_config const * couple_config,
964 char const * component_name, char const * grid_name,
965 char const * field_name) {
966
967 struct yac_couple_config_component const * component =
968 yac_couple_config_get_component(couple_config, component_name);
969 size_t grid_idx = yac_couple_config_get_grid_idx(couple_config, grid_name);
970
972 component, grid_idx, field_name);
973}
974
976 struct yac_couple_config const * couple_config,
977 size_t couple_idx, size_t field_couple_idx,
978 char const ** src_component_name, char const ** tgt_component_name) {
979
981
982 struct yac_couple_config_couple * couple =
983 couple_config->couples + couple_idx;
984
985 size_t src_component_idx =
987 size_t tgt_component_idx =
989
990 *src_component_name = couple_config->components[src_component_idx].name;
991 *tgt_component_name = couple_config->components[tgt_component_idx].name;
992}
993
995 struct yac_couple_config const * couple_config,
996 size_t couple_idx, size_t field_couple_idx,
997 char const ** src_field_name, const char ** tgt_field_name) {
998
1000
1001 struct yac_couple_config_couple * couple =
1002 couple_config->couples + couple_idx;
1003
1004 size_t src_component_idx =
1005 yac_couple_config_couple_get_source_component_idx(couple, field_couple_idx);
1006 size_t src_field_idx =
1007 yac_couple_config_couple_get_source_field_idx(couple, field_couple_idx);
1008
1009 size_t tgt_component_idx =
1010 yac_couple_config_couple_get_target_component_idx(couple, field_couple_idx);
1011 size_t tgt_field_idx =
1012 yac_couple_config_couple_get_target_field_idx(couple, field_couple_idx);
1013
1014 struct yac_couple_config_component const * src_component =
1015 couple_config->components + src_component_idx;
1016 struct yac_couple_config_component const * tgt_component =
1017 couple_config->components + tgt_component_idx;
1018
1019 *src_field_name =
1020 yac_couple_config_component_get_field_name(src_component, src_field_idx);
1021 *tgt_field_name =
1022 yac_couple_config_component_get_field_name(tgt_component, tgt_field_idx);
1023}
1024
1026 struct yac_couple_config const * couple_config,
1027 size_t couple_idx, size_t field_couple_idx) {
1028
1030
1031 struct yac_couple_config_couple const * couple =
1032 couple_config->couples + couple_idx;
1033
1034 size_t source_component_idx =
1035 yac_couple_config_couple_get_source_component_idx(couple, field_couple_idx);
1036 size_t source_field_idx =
1037 yac_couple_config_couple_get_source_field_idx(couple, field_couple_idx);
1038
1039 struct yac_couple_config_component const * source_component =
1040 couple_config->components + source_component_idx;
1041
1043 source_component, source_field_idx);
1044
1046 timestep,
1047 "no valid timestep defined (component: \"%s\" field \"%s\")",
1048 source_component->name,
1050 source_component, source_field_idx));
1051
1052 return timestep;
1053}
1054
1056 struct yac_couple_config const * couple_config,
1057 size_t couple_idx, size_t field_couple_idx) {
1058
1060
1061 struct yac_couple_config_couple const * couple =
1062 couple_config->couples + couple_idx;
1063
1064 size_t target_component_idx =
1065 yac_couple_config_couple_get_target_component_idx(couple, field_couple_idx);
1066 size_t target_field_idx =
1067 yac_couple_config_couple_get_target_field_idx(couple, field_couple_idx);
1068
1069 struct yac_couple_config_component const * target_component =
1070 couple_config->components + target_component_idx;
1071
1073 target_component, target_field_idx);
1074
1076 timestep,
1077 "no valid timestep defined (component: \"%s\" field \"%s\")",
1078 target_component->name,
1079 yac_couple_config_component_get_field_name(target_component, target_field_idx));
1080
1081 return timestep;
1082}
1083
1084static char * normalise_utc_suffix(const char *src)
1085{
1086 YAC_ASSERT(src != NULL, "src is NULL");
1087
1088 // allocate and copy string
1089 size_t const src_len = strlen(src);
1090 char * dst = strdup(src);
1091
1092 char const suffix[] = "+00:00";
1093 enum {SUFFIX_LEN = sizeof(suffix) - 1 }; // excludes '\0'
1094
1095 // if string has "+00:00" suffix
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';
1099 }
1100 return dst;
1101}
1102
1103static struct _datetime * newDateTime_utc_patch(const char *str_new)
1104{
1105 // mtime does not support defining UTC with "+00:00" suffix, therefore, need
1106 // to replace it with "Z" here before calling newDateTime.
1107 // See https://gitlab.dkrz.de/icon-libraries/libmtime/-/work_items/46.
1108 char * const str_normalised = normalise_utc_suffix(str_new);
1109 struct _datetime * new = newDateTime(str_normalised);
1110 free(str_normalised);
1111 return new;
1112}
1113
1114static void set_datetime(
1115 char const * type_datetime, struct _datetime ** old, char const * str_new) {
1116
1117 if ((str_new == NULL) || (strlen(str_new) == 0)) return;
1118
1119 YAC_ASSERT(
1121 "calendar has not yet been set");
1122
1123 struct _datetime * new = newDateTime_utc_patch(str_new);
1124
1126 new != NULL, "failed to parse datetime \"%s\"", str_new);
1127
1128 char old_datetime_buffer[MAX_DATETIME_STR_LEN],
1129 new_datetime_buffer[MAX_DATETIME_STR_LEN];
1130
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));
1136
1137 deallocateDateTime(*old);
1138
1139 *old = new;
1140}
1141
1143 struct yac_couple_config * couple_config,
1144 char const * start, char const * end) {
1145
1146 set_datetime("start", &(couple_config->start_datetime), start);
1147 set_datetime("end", &(couple_config->end_datetime), end);
1148}
1149
1151 struct yac_couple_config const * couple_config) {
1152
1153 YAC_ASSERT(
1154 couple_config->start_datetime, "start_datetime not yet defined");
1155
1156 char datetime_buffer[MAX_DATETIME_STR_LEN];
1157
1158 return
1159 xstrdup(datetimeToString(couple_config->start_datetime, datetime_buffer));
1160}
1161
1163 struct yac_couple_config const * couple_config) {
1164
1165 YAC_ASSERT(couple_config->end_datetime, "end_datetime not yet defined");
1166
1167 char datetime_buffer[MAX_DATETIME_STR_LEN];
1168
1169 return
1170 xstrdup(datetimeToString(couple_config->end_datetime, datetime_buffer));
1171}
1172
1174 struct yac_couple_config const * couple_config, size_t grid_idx) {
1175
1177 grid_idx < couple_config->num_grids, "Invalid grid idx %zu", grid_idx);
1178
1179 return couple_config->grids[grid_idx].name;
1180}
1181
1183 struct yac_couple_config const * couple_config, char const * grid_name) {
1184
1185 int found_flag = 0;
1186
1187 for (size_t grid_idx = 0;
1188 (grid_idx < couple_config->num_grids) && !found_flag; ++grid_idx) {
1189 found_flag = !strcmp(couple_config->grids[grid_idx].name, grid_name);
1190 }
1191 return found_flag;
1192}
1193
1195 struct yac_couple_config * couple_config,
1196 size_t src_comp_idx, size_t tgt_comp_idx) {
1197
1198 struct yac_couple_config_couple search_couple;
1199 yac_couple_config_couple_init(&search_couple, src_comp_idx, tgt_comp_idx);
1200
1201 struct yac_couple_config_couple * couple =
1203 couple_config->num_couples, couple_config->couples, &search_couple);
1204
1205 size_t couple_idx = SIZE_MAX;
1206 if (couple != NULL) {
1207 couple_idx = (size_t)(couple - couple_config->couples);
1208 } else {
1209 couple_idx =
1211 couple_config, src_comp_idx, tgt_comp_idx);
1212 }
1213
1215 couple_idx != SIZE_MAX,
1216 "failed to add couple (component indices: %zu, %zu)",
1217 src_comp_idx, tgt_comp_idx);
1218
1219 return couple_idx;
1220}
1221
1223 struct yac_couple_config * couple_config,
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,
1227 struct yac_interp_stack_config * interp_stack, int src_lag, int tgt_lag,
1228 const char* weight_file_name, int weight_file_on_existing,
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,
1232 struct yac_collection_selection const * collection_selection,
1233 int use_raw_exchange) {
1234
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");
1249 YAC_ASSERT(
1250 (time_reduction == TIME_NONE) ||
1251 (time_reduction == TIME_ACCUMULATE) ||
1252 (time_reduction == TIME_AVERAGE) ||
1253 (time_reduction == TIME_MINIMUM) ||
1254 (time_reduction == TIME_MAXIMUM), "invalid parameter: time_reduction");
1255 YAC_ASSERT_F(isnormal(scale_factor), "\"%lf\" is not a valid scale factor",
1256 scale_factor);
1257 YAC_ASSERT_F(isnormal(scale_summand) || (scale_summand == 0.0),
1258 "\"%lf\" is not a valid scale summand", scale_summand);
1259 YAC_ASSERT(
1260 (collection_selection == NULL) ||
1261 (yac_collection_selection_get_collection_size(collection_selection) > 0),
1262 "invalid collection selection (size has to be > 0, if provided)");
1263 YAC_ASSERT(
1264 (weight_file_on_existing == YAC_WEIGHT_FILE_ERROR) ||
1265 (weight_file_on_existing == YAC_WEIGHT_FILE_KEEP) ||
1266 (weight_file_on_existing == YAC_WEIGHT_FILE_OVERWRITE),
1267 "invalid parameter: weight_file_on_existing");
1269 strcmp(src_comp_name, tgt_comp_name) ||
1270 strcmp(src_grid_name, tgt_grid_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\")",
1274 src_comp_name, src_grid_name, src_field_name);
1275
1276 // get component indices
1277 size_t const src_comp_idx =
1278 yac_couple_config_add_component_(couple_config, src_comp_name);
1279 size_t const tgt_comp_idx =
1280 yac_couple_config_add_component_(couple_config, tgt_comp_name);
1281 size_t const src_grid_idx =
1283 size_t const tgt_grid_idx =
1285
1286 // get current role of the field that we want to define as source here
1287 int const orig_src_field_role =
1288 yac_couple_config_get_field_role(couple_config, src_comp_name,
1289 src_grid_name, src_field_name);
1290
1291 size_t const src_field_idx =
1293 couple_config, src_comp_idx, src_grid_idx,
1294 src_field_name, NULL, SIZE_MAX);
1295
1296 // check if definition of couple with given field as source is consistent
1297 // with previous definitions including this field
1299 orig_src_field_role == YAC_EXCHANGE_TYPE_SOURCE ||
1300 orig_src_field_role == YAC_EXCHANGE_TYPE_NONE,
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\")",
1305 src_comp_name, src_grid_name, src_field_name);
1306
1307 // get current role of the field that we want to define as target here
1308 int const orig_tgt_field_role =
1309 yac_couple_config_get_field_role(couple_config, tgt_comp_name,
1310 tgt_grid_name, tgt_field_name);
1311
1312 size_t const tgt_field_idx =
1314 couple_config, tgt_comp_idx, tgt_grid_idx,
1315 tgt_field_name, NULL, SIZE_MAX);
1316
1317 // check if definition of couple with given field as target is consistent
1318 // with previous definitions including this field
1319 if (orig_tgt_field_role == YAC_EXCHANGE_TYPE_TARGET) {
1320
1321 // field may only be defined once as target. However, redefinition of an
1322 // already defined couple is allowed. So we need to check if the couple we
1323 // are trying to define is a redefinition.
1325 yac_couple_config_couple_init(&mask, src_comp_idx, tgt_comp_idx);
1326 struct yac_couple_config_couple * couple =
1328 couple_config->num_couples, couple_config->couples, &mask);
1329
1331 couple != NULL,
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\")",
1335 src_comp_name, src_grid_name, src_field_name,
1336 tgt_comp_name, tgt_grid_name, tgt_field_name);
1337
1338 int const is_redefinition =
1340 couple, src_comp_idx, src_field_idx, tgt_comp_idx, tgt_field_idx);
1341
1342 char const * _src_comp_name;
1343 char const * _src_grid_name;
1344 char const * _src_field_name;
1346 tgt_comp_name, tgt_grid_name, tgt_field_name,
1347 &_src_comp_name, &_src_grid_name, &_src_field_name
1348 );
1350 is_redefinition,
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\")",
1356 tgt_comp_name, tgt_grid_name, tgt_field_name,
1357 src_comp_name, src_grid_name, src_field_name,
1358 _src_comp_name, _src_grid_name, _src_field_name
1359 );
1360 } else {
1361 // If field is not already defined as target it must be undefined in order
1362 // to legally define it as target.
1364 orig_tgt_field_role == YAC_EXCHANGE_TYPE_NONE, // any target field must not be defined before
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\")",
1369 tgt_comp_name, tgt_grid_name, tgt_field_name
1370 );
1371 }
1372
1373 // get or create raw couple
1374 size_t const couple_idx =
1376 couple_config, src_comp_idx, tgt_comp_idx);
1377
1378 // append/merge field couple into (possibly new) couple
1379 struct yac_couple_config_couple * const couple =
1380 couple_config->couples + couple_idx;
1382 couple,
1383 src_comp_idx, src_field_idx, src_lag,
1384 tgt_comp_idx, tgt_field_idx, tgt_lag,
1385 coupling_period, time_reduction,
1386 interp_stack,
1387 mapping_on_source, weight_file_name,
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);
1393}
1394
1396 char const * type_datetime, struct _datetime ** datetime, MPI_Comm comm) {
1397
1398 // convert datetime to string
1399 char datetime_buffer[MAX_DATETIME_STR_LEN];
1400 char * str_datetime = datetimeToString(*datetime, datetime_buffer);
1401
1402 // copy from static to dynamic memory
1403 if (str_datetime != NULL) str_datetime = xstrdup(str_datetime);
1404
1405 // delete old datetime
1406 deallocateDateTime(*datetime);
1407
1408 // synchronize datetime string across processes
1409 yac_couple_config_sync_string(type_datetime, &str_datetime, comm);
1410
1411 // convert datetime string to _datetime struct
1412 *datetime = newDateTime(str_datetime);
1413
1414 free(str_datetime);
1415}
1416
1418 struct yac_couple_config * couple_config, MPI_Comm comm) {
1419
1422 "start_datetime", &(couple_config->start_datetime), comm);
1424 "end_datetime", &(couple_config->end_datetime), comm);
1425}
1426
1428 struct yac_couple_config * couple_config, MPI_Comm comm,
1429 char const * output_ref){
1430
1431 // sync time stuff
1432 couple_config_sync_time(couple_config, comm);
1433
1435 &couple_config->config_outputs, &couple_config->num_config_outputs, comm);
1437 &couple_config->grids, &couple_config->num_grids,
1438 couple_config->components, couple_config->num_components, comm);
1440 &couple_config->components, &couple_config->num_components,
1441 couple_config->couples, couple_config->num_couples, comm);
1442 yac_couple_config_couples_merge(couple_config, comm);
1443
1445 "missing_definition_is_fatal",
1446 &(couple_config->missing_definition_is_fatal), comm);
1448 "apply_coordinate_check",
1449 &(couple_config->apply_coordinate_check), comm);
1451 "coordinates_mismatch_is_fatal",
1452 &(couple_config->coordinates_mismatch_is_fatal), comm);
1453
1454 struct yac_couple_config_config_output * config_output = NULL;
1455 if (output_ref != NULL)
1456 for (size_t i = 0; (i < couple_config->num_config_outputs) &&
1457 (config_output == NULL); ++i)
1458 if (!strcmp(output_ref, couple_config->config_outputs[i].ref))
1459 config_output = couple_config->config_outputs + i;
1460
1461 if (config_output != NULL) {
1462
1463 int rank;
1464 MPI_Comm_rank(comm, &rank);
1465
1466 // rank 0 writes the coupling configuration to file
1467 if (rank == 0) {
1468
1469 FILE * config_file = fopen(config_output->name, "w");
1470
1472 config_file != NULL,
1473 "failed to create coupling configuration file \"%s\" (%s)",
1474 config_output->name, strerror(errno));
1475
1477 (config_output->type == YAC_TEXT_FILETYPE_YAML) ||
1478 (config_output->type == YAC_TEXT_FILETYPE_JSON),
1479 "invalid coupling configuration filetype (type = %d)",
1480 config_output->type);
1481
1482 int emit_flags;
1483 switch(config_output->type) {
1484 default:
1486 emit_flags = YAC_YAML_EMITTER_DEFAULT;
1487 break;
1489 emit_flags = YAC_YAML_EMITTER_JSON;
1490 break;
1491 }
1492
1495 char * str_couple_config =
1497 couple_config, emit_flags, (int)include_definitions);
1498
1499 fputs(str_couple_config, config_file);
1500 free(str_couple_config);
1501 fclose(config_file);
1502 }
1503 yac_mpi_call(MPI_Barrier(comm), comm);
1504 }
1505}
1506
1508 struct yac_couple_config * couple_config,
1509 char const * filename, enum yac_text_filetype filetype, char const * ref,
1510 int include_definitions) {
1511
1513 &couple_config->config_outputs,
1514 &couple_config->num_config_outputs,
1515 filename, filetype, ref, include_definitions);
1516}
1517
1525 struct yac_couple_config const * couple_config,
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) {
1529
1530 size_t const tgt_comp_idx =
1531 yac_couple_config_get_component_idx(couple_config, tgt_component_name);
1532
1533 *result_couple_idx = SIZE_MAX;
1534 *result_field_couple_idx = SIZE_MAX;
1535
1536 for (size_t couple_idx = 0;
1537 couple_idx < couple_config->num_couples; ++couple_idx) {
1538 struct yac_couple_config_couple const * couple =
1539 couple_config->couples + couple_idx;
1541 couple, tgt_comp_idx))
1542 continue;
1543 size_t fc_idx =
1545 couple, couple_config,
1546 tgt_field_name, tgt_grid_name, tgt_component_name);
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\")",
1552 tgt_component_name, tgt_grid_name,
1553 tgt_field_name);
1554 *result_couple_idx = couple_idx;
1555 *result_field_couple_idx = fc_idx;
1556 }
1557 }
1558}
1559
1561 struct yac_couple_config const * couple_config,
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) {
1565
1566 size_t couple_idx, field_couple_idx;
1568 couple_config, tgt_component_name, tgt_grid_name,
1569 tgt_field_name, &couple_idx, &field_couple_idx);
1570
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\")",
1575 tgt_component_name, tgt_grid_name, tgt_field_name);
1576
1577 struct yac_couple_config_couple const * couple =
1578 couple_config->couples + couple_idx;
1579
1580 size_t src_component_idx =
1581 yac_couple_config_couple_get_source_component_idx(couple, field_couple_idx);
1582 size_t src_field_idx =
1583 yac_couple_config_couple_get_source_field_idx(couple, field_couple_idx);
1584
1585 struct yac_couple_config_component const * src_component =
1586 couple_config->components + src_component_idx;
1587
1588 size_t src_grid_idx =
1590 src_component, src_field_idx);
1591
1592 *src_component_name = src_component->name;
1593 *src_grid_name = couple_config->grids[src_grid_idx].name;
1594 *src_field_name =
1595 yac_couple_config_component_get_field_name(src_component, src_field_idx);
1596}
1597
1600 struct yac_couple_config * couple_config,
1601 size_t couple_idx, size_t field_couple_idx) {
1602
1604
1605 struct yac_couple_config_couple * couple =
1606 couple_config->couples + couple_idx;
1607
1608 size_t src_comp_idx =
1609 yac_couple_config_couple_get_source_component_idx(couple, field_couple_idx);
1610 size_t src_field_idx =
1611 yac_couple_config_couple_get_source_field_idx(couple, field_couple_idx);
1612 size_t tgt_comp_idx =
1613 yac_couple_config_couple_get_target_component_idx(couple, field_couple_idx);
1614 size_t tgt_field_idx =
1615 yac_couple_config_couple_get_target_field_idx(couple, field_couple_idx);
1616
1617 struct yac_couple_config_component const * src_comp =
1618 couple_config->components + src_comp_idx;
1619 struct yac_couple_config_component const * tgt_comp =
1620 couple_config->components + tgt_comp_idx;
1621
1622 size_t src_grid_idx =
1624 src_comp, src_field_idx);
1625 size_t tgt_grid_idx =
1627 tgt_comp, tgt_field_idx);
1628
1629 char const * src_comp_name = src_comp->name;
1630 char const * src_grid_name =
1631 couple_config->grids[src_grid_idx].name;
1632 char const * src_field_name =
1633 yac_couple_config_component_get_field_name(src_comp, src_field_idx);
1634
1635 char const * tgt_comp_name = tgt_comp->name;
1636 char const * tgt_grid_name =
1637 couple_config->grids[tgt_grid_idx].name;
1638 char const * tgt_field_name =
1639 yac_couple_config_component_get_field_name(tgt_comp, tgt_field_idx);
1640
1641 // generate new interpolation generation configuration object
1642 struct yac_interpolation_gen_config * interp_gen_config =
1644
1645 // set reorder type
1646 int const is_mapping_on_source =
1648 couple, field_couple_idx);
1650 interp_gen_config,
1651 is_mapping_on_source ? YAC_MAPPING_ON_SRC : YAC_MAPPING_ON_TGT);
1652
1653 // set fractional masking fallback value
1656 src_comp, src_field_idx);
1657 // if it is not NO_VALUE
1660 interp_gen_config, frac_mask_fallback_value);
1661 }
1662
1663 // set scaling factor, scaling summand, and yaxt exchanger name
1664 double scale_factor =
1666 couple, field_couple_idx);
1667 double scale_summand =
1669 couple, field_couple_idx);
1670 char const * yaxt_exchanger_name =
1672 couple, field_couple_idx);
1674 interp_gen_config, scale_factor);
1676 interp_gen_config, scale_summand);
1678 interp_gen_config, yaxt_exchanger_name);
1679
1680 // get source and target field collection size
1681 size_t src_collection_size =
1683 src_comp, src_field_idx);
1684 size_t tgt_collection_size =
1686 tgt_comp, tgt_field_idx);
1687
1688 // if the user provided a collection selection for the couple
1689 struct yac_collection_selection const * collection_selection =
1691 couple, field_couple_idx);
1692 if (collection_selection != NULL) {
1693
1696 collection_selection) == tgt_collection_size,
1697 "target field collection size does not match size of provided "
1698 "collection selection: \n"
1699 " source:\n"
1700 " component name: \"%s\"\n"
1701 " grid name: \"%s\"\n"
1702 " field name: \"%s\"\n"
1703 " collection_size: %zu\n"
1704 " target:\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"
1710 " size: %zu\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,
1715 yac_collection_selection_get_max_index(collection_selection));
1718 collection_selection) < src_collection_size,
1719 "maximum index of provided collection selection exceeds source "
1720 "field collection size: \n"
1721 " source:\n"
1722 " component name: \"%s\"\n"
1723 " grid name: \"%s\"\n"
1724 " field name: \"%s\"\n"
1725 " collection_size: %zu\n"
1726 " target:\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"
1732 " size: %zu\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,
1737 yac_collection_selection_get_max_index(collection_selection));
1738
1740 interp_gen_config, collection_selection);
1741
1742 } else { // no collection selection was provided by the user
1744 src_collection_size == tgt_collection_size,
1745 "collection sizes do not match for coupled fields (%zu != %zu): \n"
1746 " source:\n"
1747 " component name: \"%s\"\n"
1748 " grid name: \"%s\"\n"
1749 " field name: \"%s\"\n"
1750 " target:\n"
1751 " component name: \"%s\"\n"
1752 " grid name: \"%s\"\n"
1753 " field name: \"%s\"\n",
1754 src_collection_size, tgt_collection_size,
1755 src_comp_name, src_grid_name, src_field_name,
1756 tgt_comp_name, tgt_grid_name, tgt_field_name);
1757
1759 interp_gen_config, src_collection_size);
1760 }
1761
1762 return interp_gen_config;
1763}
unsigned component_idx[3]
unsigned num_components
unsigned grid_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
Definition config_yaml.c:59
int const YAC_YAML_EMITTER_JSON
emit to JSON format
Definition config_yaml.c:60
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)
#define CHECK_GRID_IDX()
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
@ YAC_TEXT_FILETYPE_YAML
YAML format.
@ YAC_TEXT_FILETYPE_JSON
JSON format.
yac_reduction_type
@ TIME_NONE
@ TIME_ACCUMULATE
@ TIME_MAXIMUM
@ TIME_MINIMUM
@ TIME_AVERAGE
#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)
Definition instance.c:1544
@ 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.
Definition __init__.py:1
#define xstrdup(s)
Definition ppm_xfuncs.h:84
#define xmalloc(size)
Definition ppm_xfuncs.h:66
struct yac_couple_config_field * fields
enum yac_couple_config_flag_value include_definitions
enum yac_text_filetype type
type of the file
struct yac_couple_config_couple * couples
enum yac_couple_config_flag_value coordinates_mismatch_is_fatal
struct yac_couple_config_config_output * 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.
int collection_size
char const * weight_file_name
char const src_grid_name[]
char const tgt_grid_name[]
static int mask[16]
char const * name
Definition toy_scrip.c:114
int const YAC_EXCHANGE_TYPE_SOURCE
Definition yac.c:43
int const YAC_EXCHANGE_TYPE_NONE
Definition yac.c:42
int const YAC_EXCHANGE_TYPE_TARGET
Definition yac.c:44
int yac_cget_calendar()
Definition yac.c:1005
int const YAC_CALENDAR_NOT_SET
Definition yac.c:71
int const YAC_EXCHANGE_TYPE_INVALID
Definition yac.c:41
#define YAC_MAX_CHARLEN
Definition yac.h:106
#define YAC_ASSERT_F(exp, format,...)
Definition yac_assert.h:39
#define YAC_UNREACHABLE_DEFAULT(msg)
Definition yac_assert.h:56
#define yac_mpi_call(call, comm)