YetAnotherCoupler 3.1.1
Loading...
Searching...
No Matches
yac_interface.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 <stdlib.h>
10#include <stdio.h>
11#include <string.h>
12#include "yac_mpi_common.h"
13#include "ensure_array_size.h"
14#include "event.h"
15#include "yac_interface.h"
16#include "mpi_handshake.h"
17#include "utils_mci.h"
18#include "version.h"
19#include "instance.h"
20#include "fields.h"
21#include "couple_config.h"
22#include "config_yaml.h"
23#include "geometry.h"
24
28
32
42
48
57
58int const YAC_CALENDAR_NOT_SET = CALENDAR_NOT_SET;
59int const YAC_PROLEPTIC_GREGORIAN = PROLEPTIC_GREGORIAN;
60int const YAC_YEAR_OF_365_DAYS = YEAR_OF_365_DAYS;
61int const YAC_YEAR_OF_360_DAYS = YEAR_OF_360_DAYS;
62
66
69
75
78
81
86
93
99
100static int default_instance_id = INT_MAX;
101
102static int yac_instance_count = 0;
103
104void ** pointer_lookup_table = NULL;
106
107struct yac_basic_grid ** grids = NULL;
108size_t num_grids = 0;
109
110static struct user_input_data_component ** components = NULL;
111static size_t num_components = 0;
112
114static size_t num_points = 0;
115
116static struct user_input_data_masks ** masks = NULL;
117static size_t num_masks = 0;
118
120static size_t num_interp_stack_configs = 0;
121
131
150
157static void * yac_unique_id_to_pointer(int id, char const * id_name) {
158
161 id >= 0,
162 "ERROR(yac_unique_id_to_pointer): invalid %s", id_name)
163 return pointer_lookup_table[id];
164}
165
174static int yac_lookup_pointer(void const * pointer) {
175
176 int ret = INT_MAX;
177 for (int i = 0; (ret == INT_MAX) && (i < pointer_lookup_table_size); ++i)
178 if (pointer_lookup_table[i] == pointer) ret = i;
179 return ret;
180}
181
195
196/* ---------------------------------------------------------------------- */
197
198static int yac_add_grid(
199 const char * grid_name, struct yac_basic_grid_data grid_data) {
200
201 for (size_t i = 0; i < num_grids; ++i)
203 strcmp(yac_basic_grid_get_name(grids[i]), grid_name),
204 "ERROR(yac_add_grid): multiple definitions of grid with identical name")
205
207 strlen(grid_name) <= YAC_MAX_CHARLEN,
208 "ERROR(yac_add_grid): grid name is too long (maximum is YAC_MAX_CHARLEN)")
209
210 struct yac_basic_grid * grid = yac_basic_grid_new(grid_name, grid_data);
211
212 grids = xrealloc(grids, (num_grids + 1) * sizeof(*grids));
213 grids[num_grids] = grid;
214 num_grids++;
215 return yac_pointer_to_unique_id(grid);
216}
217
218static void yac_free_grids() {
219
220 for (size_t i = 0; i < num_grids; ++i)
222 free(grids);
223 grids = NULL;
224 num_grids = 0;
225}
226
227/* ---------------------------------------------------------------------- */
228
229static void yac_free_points() {
230
231 for (size_t i = 0; i < num_points; ++i) free(points[i]);
232 free(points);
233 points = NULL;
234 num_points = 0;
235}
236
237/* ---------------------------------------------------------------------- */
238
239static void yac_free_masks() {
240
241 for (size_t i = 0; i < num_masks; ++i) free(masks[i]);
242 free(masks);
243 masks = NULL;
244 num_masks = 0;
245}
246
247/* ---------------------------------------------------------------------- */
248
249static void yac_free_components() {
250
251 for (size_t i = 0; i < num_components; ++i){
252 free(components[i]->name);
253 free(components[i]);
254 }
255 free(components);
256 components = NULL;
257 num_components = 0;
258}
259
260/* ---------------------------------------------------------------------- */
261
271
272/* ---------------------------------------------------------------------- */
273
274static void check_default_instance_id(char const * routine_name) {
275
277 default_instance_id != INT_MAX,
278 "ERROR(%s): no default yac instance is defined yet", routine_name)
279}
280
281/* ---------------------------------------------------------------------- */
282
283static void yac_check_version(MPI_Comm comm) {
284
285 int comm_rank;
286 yac_mpi_call(MPI_Comm_rank(comm, &comm_rank), comm);
287
288 char recv_version[64];
289
290 size_t yac_version_len = strlen(yac_version) + 1;
291
293 yac_version_len <= sizeof(recv_version),
294 "ERROR(yac_check_version): "
295 "version string \"%s\" is too long (has to be shorter than %zu)",
296 yac_version, sizeof(recv_version))
297
298 if (comm_rank == 0) strcpy(recv_version, yac_version);
299
301 MPI_Bcast(recv_version, (int)yac_version_len, MPI_CHAR, 0, comm), comm);
302
304 !strcmp(recv_version, yac_version),
305 "ERROR(yac_check_version): inconsistent yac versions between processes "
306 "(on local process \"%s\"; on root \"%s\")", yac_version, recv_version)
307}
308
309void check_mpi_initialised(char const * routine_name) {
310
313 "ERROR(%s): "
314 "MPI has not yet been initialised, but this call got a "
315 "communicator which is not allowed by the MPI standard "
316 "(MPI_COMM_WORLD is not to be used before the call to "
317 "MPI_Init or MPI_Init_thread)", routine_name);
318}
319
320void yac_cmpi_handshake(MPI_Comm comm, size_t n, char const** group_names,
321 MPI_Comm * group_comms) {
322 check_mpi_initialised("yac_cmpi_handshake");
323 yac_mpi_handshake(comm, n, group_names, group_comms);
324}
325
326void yac_cmpi_handshake_f2c(MPI_Fint comm, int n, char const** group_names,
327 MPI_Fint * group_comms) {
328 MPI_Comm comm_c = MPI_Comm_f2c(comm);
329 MPI_Comm * group_comms_c = xmalloc(n*sizeof(*group_comms_c));
330 yac_mpi_handshake(comm_c, n, group_names, group_comms_c);
331 for(int i = 0; i<n; ++i)
332 group_comms[i] = MPI_Comm_c2f(group_comms_c[i]);
333 free(group_comms_c);
334}
335
336static int yac_init(MPI_Comm comm) {
337
338 check_mpi_initialised("yac_init");
339 yac_yaxt_init(comm);
340 yac_check_version(comm);
341
342 int comm_rank, comm_size;
343 yac_mpi_call(MPI_Comm_rank(comm, &comm_rank), comm);
344 yac_mpi_call(MPI_Comm_size(comm, &comm_size), comm);
345
347 return
349 yac_instance_new(comm));
350}
351
353 check_default_instance_id("yac_cget_default_instance_id");
354 return default_instance_id;
355}
356
358 MPI_Comm comm, int * yac_instance_id) {
359
360 *yac_instance_id = yac_init(comm);
361}
362
364 MPI_Fint comm, int * yac_instance_id) {
365
366 yac_cinit_comm_instance(MPI_Comm_f2c(comm), yac_instance_id);
367}
368
369void yac_cinit_comm ( MPI_Comm comm ) {
370
372 default_instance_id == INT_MAX,
373 "ERROR(yac_cinit_comm): default yac instance already defined")
374
376}
377
378void yac_cinit_comm_f2c ( MPI_Fint comm_f ) {
379
380 yac_cinit_comm(MPI_Comm_f2c(comm_f));
381}
382
384 int * yac_instance_id) {
385
386 // we have to initalise MPI here in order to be able to use MPI_COMM_WORLD
387 yac_mpi_init();
388 MPI_Comm yac_comm;
389 const char* group_name = "yac";
390 yac_cmpi_handshake(MPI_COMM_WORLD, 1, &group_name, &yac_comm);
391 yac_cinit_comm_instance(yac_comm, yac_instance_id);
392 yac_mpi_call(MPI_Comm_free(&yac_comm), MPI_COMM_WORLD);
393}
394
395void yac_cinit ( void ) {
397 default_instance_id == INT_MAX,
398 "ERROR(yac_cinit_comm): default yac instance already defined")
399
401}
402
403/* ---------------------------------------------------------------------- */
404
405void yac_cinit_comm_dummy ( MPI_Comm comm ) {
406
407 check_mpi_initialised("yac_cinit_comm_dummy");
408
409 yac_yaxt_init(comm);
410 yac_check_version(comm);
411
413}
414
415void yac_cinit_comm_dummy_f2c ( MPI_Fint comm_f ) {
416
417 check_mpi_initialised("yac_cinit_comm_dummy_f2c");
418 yac_cinit_comm_dummy(MPI_Comm_f2c(comm_f));
419}
420
421void yac_cinit_dummy( void ) {
422
423 // we have to initalise MPI here in order to be able to use MPI_COMM_WORLD
424 yac_mpi_init();
425 yac_cmpi_handshake(MPI_COMM_WORLD, 0, NULL, NULL);
426}
427
428/* ---------------------------------------------------------------------- */
429
433
437
438/* ---------------------------------------------------------------------- */
439
440
441void yac_cread_config_yaml_instance( int yac_instance_id,
442 const char * yaml_filename){
443 struct yac_instance * instance
444 = yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
446 yac_instance_get_couple_config(instance), yaml_filename,
448}
449
450void yac_cread_config_yaml( const char * yaml_filename){
451 check_default_instance_id("read_config_yaml");
453}
454
455void yac_cread_config_json_instance( int yac_instance_id,
456 const char * yaml_filename){
457 struct yac_instance * instance
458 = yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
460 yac_instance_get_couple_config(instance), yaml_filename,
462}
463
464void yac_cread_config_json( const char * yaml_filename){
465 check_default_instance_id("read_config_yaml");
467}
468
469/* ---------------------------------------------------------------------- */
470
471static void yac_ccleanup_instance_(int yac_instance_id) {
472
473 struct yac_instance * instance
474 = yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
475
476 /* free memory */
477 yac_instance_delete(instance);
479 if(yac_instance_id == default_instance_id)
480 default_instance_id = INT_MAX;
481
482 // remove dangeling pointers from components
483 for(int i = 0; i<num_components;++i){
484 if(components[i]->instance == instance){
485 components[i]->instance = NULL;
486 }
487 }
488}
489
490void yac_ccleanup_instance (int yac_instance_id) {
491
492 yac_ccleanup_instance_(yac_instance_id);
493
494 /* cleanup mpi */
496}
497
499
500 check_default_instance_id("yac_ccleanup");
501
503}
504
505/* ---------------------------------------------------------------------- */
506
516
517void yac_cfinalize_instance(int yac_instance_id) {
518
519 yac_ccleanup_instance_(yac_instance_id);
520
521 /* cleanup close MPI */
522
523 if (yac_instance_count == 0) cleanup();
524}
525
527
528 if (default_instance_id != INT_MAX)
530
531 /* cleanup close MPI */
532
533 if (yac_instance_count == 0) cleanup();
534}
535
536/* ---------------------------------------------------------------------- */
537
539 int yac_instance_id, const char * start_datetime,
540 const char * end_datetime) {
541
543 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"),
544 start_datetime, end_datetime);
545}
546
547void yac_cdef_datetime ( const char * start_datetime,
548 const char * end_datetime ) {
549
550 check_default_instance_id("yac_cdef_datetime");
552 default_instance_id, start_datetime, end_datetime);
553}
554
555void yac_cdef_calendar ( int calendar ) {
556
558 (calendar == YAC_PROLEPTIC_GREGORIAN) ||
559 (calendar == YAC_YEAR_OF_360_DAYS) ||
560 (calendar == YAC_YEAR_OF_365_DAYS),
561 "ERROR(yac_cdef_calendar): invalid calendar type")
562
563 calendarType curr_calendar = getCalendarType();
565 (curr_calendar == CALENDAR_NOT_SET) ||
566 (curr_calendar == (calendarType)calendar),
567 "ERROR(yac_cdef_calendar): inconsistent calendar definition")
568
569 initCalendar((calendarType)calendar);
570}
571
572/* ---------------------------------------------------------------------- */
573
574char * yac_cget_start_datetime_instance(int yac_instance_id) {
575
576 return
578 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"));
579}
580
581char * yac_cget_start_datetime ( void ) {
582
583 check_default_instance_id("yac_cget_start_datetime");
585}
586
587/* ---------------------------------------------------------------------- */
588
589char * yac_cget_end_datetime_instance(int yac_instance_id) {
590
591 return
593 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"));
594}
595
596char * yac_cget_end_datetime ( void ) {
597
598 check_default_instance_id("yac_cget_end_datetime");
600}
601
602/* ---------------------------------------------------------------------- */
603
604/* The YAC version number is provided in version.h
605 */
606
607char * yac_cget_version ( void ) {
608 return yac_version;
609}
610
611/* ---------------------------------------------------------------------- */
612
614 int comp_id, char const * routine) {
615
616 struct user_input_data_component * comp_info =
617 yac_unique_id_to_pointer(comp_id, "comp_id");
618
620 comp_info->instance != NULL,
621 "ERROR(%s): instance of component \"%s\" is already finalized",
622 routine, comp_info->name);
623
624 return comp_info;
625}
626
627/* ---------------------------------------------------------------------- */
628
629/* c interface routine */
630
631void yac_cget_comp_comm ( int comp_id, MPI_Comm *comp_comm ) {
632
633 struct user_input_data_component * comp_info =
634 get_user_input_data_component(comp_id, "yac_cget_comp_comm");
635
636 *comp_comm =
638 comp_info->instance, (char const **)&(comp_info->name), 1);
639}
640
641/* internal routine to serve the Fortran interface */
642
643void yac_get_comp_comm_f2c ( int comp_id, MPI_Fint *comp_comm_f ) {
644
645 MPI_Comm comp_comm;
646 yac_cget_comp_comm(comp_id, &comp_comm);
647
648 *comp_comm_f = MPI_Comm_c2f(comp_comm);
649}
650
651/* ---------------------------------------------------------------------- */
652
653/* c interface routine */
654
656 int yac_instance_id,
657 char const ** comp_names, int num_comps, MPI_Comm * comps_comm) {
658
659 *comps_comm =
661 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"),
662 comp_names, (size_t)num_comps);
663}
664
666 const char ** comp_names, int num_comps, MPI_Comm * comps_comm) {
667
668 check_default_instance_id("yac_cget_comps_comm");
670 default_instance_id, comp_names, num_comps, comps_comm);
671}
672
673/* internal routine to serve the Fortran interface */
674
676 int yac_instance_id,
677 char const ** comp_names, int num_comps, MPI_Fint * comps_comm_f) {
678
679 MPI_Comm comps_comm;
681 yac_instance_id, comp_names, num_comps, &comps_comm);
682 *comps_comm_f = MPI_Comm_c2f(comps_comm);
683}
684
686 char const ** comp_names, int num_comps, MPI_Fint *comps_comm_f) {
687
688 MPI_Comm comps_comm;
689 yac_cget_comps_comm(comp_names, num_comps, &comps_comm);
690 *comps_comm_f = MPI_Comm_c2f(comps_comm);
691}
692
693/* ---------------------------------------------------------------------- */
694
696 int yac_instance_id, char const * name, int * comp_id){
697
698 struct yac_instance * instance =
699 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
700
703 "ERROR(yac_cpredef_comp_instance): components have already been defined");
704
706 (name != NULL) && (*name != '\0'),
707 "ERROR(yac_cpredef_comp_instance): missing component name");
708
709 for (size_t i = 0; i < num_components; ++i) {
711 (components[i]->instance != instance) ||
712 strcmp(components[i]->name, name),
713 "ERROR(yac_cpredef_comp_instance): "
714 "component \"%s\" is already defined", name);
715 }
716
717 components =
718 xrealloc(
719 components, (num_components + 1) * sizeof(*components));
720
723 components[num_components]->name = strdup(name);
726}
727
728void yac_cpredef_comp(char const * name, int * comp_id){
729 check_default_instance_id("yac_cpredef_comp");
731}
732
734 int yac_instance_id, char const ** comp_names, int num_comps,
735 int * comp_ids) {
736
737 struct yac_instance * instance =
738 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
739
740 for(int i = 0; i<num_comps; ++i)
741 yac_cpredef_comp_instance(yac_instance_id, comp_names[i], comp_ids + i);
742
743 // count predefined components and set their index
744 size_t comp_counter = 0;
745 char const ** all_comp_names = xmalloc(num_components * sizeof(*all_comp_names));
746 for(int i = 0; i<num_components; ++i){
747 if(components[i]->instance == instance){
748 all_comp_names[comp_counter] = components[i]->name;
749 comp_counter++;
750 }
751 }
752
753 yac_instance_def_components(instance, all_comp_names, comp_counter);
754
755 free(all_comp_names);
756}
757
759 char const ** comp_names, int num_comps, int * comp_ids ) {
760
761 check_default_instance_id("yac_cdef_comps");
763 default_instance_id, comp_names, num_comps, comp_ids);
764}
765
767 int yac_instance_id, char const * comp_name, int * comp_id ) {
768
769 yac_cdef_comps_instance(yac_instance_id, &comp_name, 1, comp_id);
770}
771
772void yac_cdef_comp ( char const * comp_name, int * comp_id ) {
773
774 yac_cdef_comps(&comp_name, 1, comp_id);
775}
776
777/* ---------------------------------------------------------------------- */
778
780 struct yac_basic_grid * grid, enum yac_location location,
781 yac_coordinate_pointer coordinates) {
782
783 struct user_input_data_points * curr_points = xmalloc(1 * sizeof(*curr_points));
784 curr_points->default_mask_id = INT_MAX;
785 curr_points->grid = grid;
786 curr_points->location = location;
787 curr_points->coordinates_idx =
789
790 points = xrealloc(points, (num_points + 1) * sizeof(*points));
792 num_points++;
793
795}
796
797/* ---------------------------------------------------------------------- */
798
800 double const * x_vertices, size_t count, char const * routine_name) {
801
802 for (size_t i = 0; i < count; ++i)
804 (x_vertices[i] >= -720.0) && (x_vertices[i] <= 720.0),
805 "ERROR(%s): x_vertices[%zu] = %lf outside of valid range [-720;720]",
806 routine_name, i, x_vertices[i]);
807}
808
810 double const * y_vertices, size_t count, char const * routine_name) {
811
812 for (size_t i = 0; i < count; ++i)
814 (y_vertices[i] >= -90.00001) && (y_vertices[i] <= 90.00001),
815 "ERROR(%s): y_vertices[%zu] = %lf "
816 "outside of valid range [90.00001;90.00001]",
817 routine_name, i, y_vertices[i]);
818}
819
820/* ---------------------------------------------------------------------- */
821
822void yac_cdef_points_reg2d ( int const grid_id,
823 int const *nbr_points,
824 int const located,
825 double const *x_points,
826 double const *y_points,
827 int *point_id ) {
828
830 struct yac_basic_grid * grid = yac_unique_id_to_pointer(grid_id, "grid_id");
831
832 size_t num_points = yac_basic_grid_get_data_size(grid, location);
834 ((size_t)nbr_points[0] * (size_t)nbr_points[1]) == num_points,
835 "ERROR(yac_cdef_points_reg2d): nbr_points does not match with grid")
836
838 x_points, (size_t)(nbr_points[0]), "yac_cdef_points_reg2d");
840 y_points, (size_t)(nbr_points[1]), "yac_cdef_points_reg2d");
841
842 yac_coordinate_pointer coordinates =
843 xmalloc(num_points * sizeof(*coordinates));
844 for (int i = 0, k = 0; i < nbr_points[1]; ++i)
845 for (int j = 0; j < nbr_points[0]; ++j, ++k)
846 LLtoXYZ(x_points[j], y_points[i], coordinates[k]);
847
848 *point_id = user_input_data_add_points(grid, location, coordinates);
849}
850
851/* ---------------------------------------------------------------------- */
852
853void yac_cdef_points_curve2d ( int const grid_id,
854 int const *nbr_points,
855 int const located,
856 double const *x_points,
857 double const *y_points,
858 int *point_id ) {
859
860 enum yac_location location = yac_get_location(located);
861 struct yac_basic_grid * grid = yac_unique_id_to_pointer(grid_id, "grid_id");
862
863 size_t num_points = yac_basic_grid_get_data_size(grid, location);
865 ((size_t)nbr_points[0] * (size_t)nbr_points[1]) == num_points,
866 "ERROR(yac_cdef_points_curve2d): nbr_points does not match with grid"
867 " (%zu*%zu != %zu)",
868 (size_t)nbr_points[0], (size_t)nbr_points[1], num_points)
869
871 x_points, (size_t)(nbr_points[0]), "yac_cdef_points_curve2d");
873 y_points, (size_t)(nbr_points[1]), "yac_cdef_points_curve2d");
874
875 yac_coordinate_pointer coordinates =
876 xmalloc(num_points * sizeof(*coordinates));
877 for (int i = 0, k = 0; i < nbr_points[1]; ++i)
878 for (int j = 0; j < nbr_points[0]; ++j, ++k)
879 LLtoXYZ(x_points[k], y_points[k], coordinates[k]);
880
881 *point_id = user_input_data_add_points(grid, location, coordinates);
882}
883
884/* ---------------------------------------------------------------------- */
885
886void yac_cdef_points_unstruct ( int const grid_id,
887 int const nbr_points,
888 int const located,
889 double const *x_points,
890 double const *y_points,
891 int *point_id ) {
892
893 enum yac_location location = yac_get_location(located);
894 struct yac_basic_grid * grid = yac_unique_id_to_pointer(grid_id, "grid_id");
895
897 (size_t)nbr_points == yac_basic_grid_get_data_size(grid, location),
898 "ERROR(yac_cdef_points_unstruct): nbr_points does not match with grid")
899
900 check_x_vertices(x_points, (size_t)nbr_points, "yac_cdef_points_unstruct");
901 check_y_vertices(y_points, (size_t)nbr_points, "yac_cdef_points_unstruct");
902
903 yac_coordinate_pointer coordinates =
904 xmalloc((size_t)nbr_points * sizeof(*coordinates));
905 for (int i = 0; i < nbr_points; ++i)
906 LLtoXYZ(x_points[i], y_points[i], coordinates[i]);
907
908 *point_id = user_input_data_add_points(grid, location, coordinates);
909}
910
911/* ---------------------------------------------------------------------- */
912
914 struct yac_basic_grid * grid, enum yac_location location,
915 int const * is_valid, size_t nbr_points, char const * name) {
916
917 struct user_input_data_masks * curr_mask = xmalloc(1 * sizeof(*curr_mask));
918 curr_mask->grid = grid;
919 curr_mask->location = location;
920 curr_mask->masks_idx =
921 yac_basic_grid_add_mask(grid, location, is_valid, nbr_points, name);
922
923 masks = xrealloc(masks, (num_masks + 1) * sizeof(*masks));
924 masks[num_masks] = curr_mask;
925 num_masks++;
926
927 return yac_pointer_to_unique_id(curr_mask);
928}
929
930/* ---------------------------------------------------------------------- */
931
932void yac_cdef_mask_named ( int const grid_id,
933 int const nbr_points,
934 int const located,
935 int const * is_valid,
936 char const * name,
937 int *mask_id ) {
938
939 enum yac_location location = yac_get_location(located);
940 struct yac_basic_grid * grid = yac_unique_id_to_pointer(grid_id, "grid_id");
941
943 (size_t)nbr_points == yac_basic_grid_get_data_size(grid, location),
944 "ERROR(yac_cdef_mask_named): nbr_points does not match with grid")
945
946 *mask_id =
948 grid, location, is_valid, (size_t)nbr_points, name);
949}
950
951void yac_cdef_mask ( int const grid_id,
952 int const nbr_points,
953 int const located,
954 int const * is_valid,
955 int *mask_id ) {
956
957 yac_cdef_mask_named(grid_id, nbr_points, located, is_valid, NULL, mask_id);
958}
959
960void yac_cset_mask ( int const * is_valid, int points_id ) {
961
963 yac_unique_id_to_pointer(points_id, "points_id");
964
967 "ERROR(yac_cset_mask): default mask has already been set before")
968
969 struct yac_basic_grid * grid = points->grid;
970 enum yac_location location = points->location;
971 size_t nbr_points = yac_basic_grid_get_data_size(grid, location);
972
974 user_input_data_add_mask(grid, location, is_valid, nbr_points, NULL);
975}
976
977/* ---------------------------------------------------------------------- */
978
979void yac_cdef_field_mask ( char const * name,
980 int const comp_id,
981 int const * point_ids,
982 int const * mask_ids,
983 int const num_pointsets,
984 int collection_size,
985 const char* timestep,
986 int time_unit,
987 int * field_id ) {
988
990 num_pointsets >= 1,
991 "ERROR(yac_cdef_field_mask): invalid number of pointsets")
992
994 point_ids != NULL,"ERROR(yac_cdef_field_mask): no point_ids provided")
995
996 struct yac_basic_grid * grid =
997 ((struct user_input_data_points *)
998 yac_unique_id_to_pointer(point_ids[0], "point_ids[0]"))->grid;
999
1001 struct yac_interp_field * interp_fields =
1002 (num_pointsets == 1)?
1004 xmalloc((size_t)num_pointsets * sizeof(*interp_fields));
1005
1006 for (int i = 0; i < num_pointsets; ++i) {
1007
1009 yac_unique_id_to_pointer(point_ids[i], "point_ids[i]");
1010
1011 YAC_ASSERT(
1012 grid == points->grid,
1013 "ERROR(yac_cdef_field_mask): grid of point_ids do not match")
1014
1015 size_t masks_idx;
1016 if (mask_ids[i] != INT_MAX) {
1017
1018 struct user_input_data_masks * mask =
1019 yac_unique_id_to_pointer(mask_ids[i], "mask_ids[i]");
1020
1021 YAC_ASSERT(
1022 mask->grid == points->grid,
1023 "ERROR(yac_cdef_field_mask): "
1024 "grids of mask and points do not match")
1025 YAC_ASSERT(
1026 mask->location == points->location,
1027 "ERROR(yac_cdef_field_mask): "
1028 "location of mask and points do not match")
1029 masks_idx = mask->masks_idx;
1030 } else {
1031 masks_idx = SIZE_MAX;
1032 }
1033
1034 interp_fields[i].location = points->location;
1035 interp_fields[i].coordinates_idx = points->coordinates_idx;
1036 interp_fields[i].masks_idx = masks_idx;
1037 }
1038
1039 struct user_input_data_component * comp_info =
1040 get_user_input_data_component(comp_id, "yac_cdef_field_mask");
1041
1042 *field_id =
1045 comp_info->instance, name, comp_info->name,
1046 grid, interp_fields, num_pointsets, collection_size,
1047 yac_time_to_ISO(timestep, (enum yac_time_unit_type)time_unit)));
1048
1049 if (num_pointsets > 1) free(interp_fields);
1050}
1051
1052void yac_cdef_field ( char const * name,
1053 int const comp_id,
1054 int const * point_ids,
1055 int const num_pointsets,
1056 int collection_size,
1057 const char* timestep,
1058 int time_unit,
1059 int * field_id ) {
1060
1061 YAC_ASSERT(
1062 num_pointsets >= 1,
1063 "ERROR(yac_cdef_field): invalid number of pointsets")
1064
1065 YAC_ASSERT(
1066 point_ids != NULL, "ERROR(yac_cdef_field): no point_ids provided")
1067
1068 int * mask_ids = xmalloc((size_t)num_pointsets * sizeof(*mask_ids));
1069
1070 for (int i = 0; i < num_pointsets; ++i)
1071 mask_ids[i] =
1072 ((struct user_input_data_points *)
1073 yac_unique_id_to_pointer(point_ids[i], "point_ids[i]"))->
1074 default_mask_id;
1075
1077 name, comp_id, point_ids, mask_ids, num_pointsets,
1078 collection_size, timestep, time_unit, field_id);
1079
1080 free(mask_ids);
1081}
1082
1084 int yac_instance_id, const char* comp_name, const char* grid_name,
1085 const char* field_name, double frac_mask_fallback_value) {
1086 struct yac_instance * instance =
1087 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1088 struct yac_couple_config * couple_config =
1091 couple_config, comp_name, grid_name, field_name,
1092 frac_mask_fallback_value);
1093}
1094
1096 const char* comp_name, const char* grid_name, const char* field_name,
1097 double frac_mask_fallback_value) {
1098 check_default_instance_id("yac_cenable_field_frac_mask");
1100 default_instance_id, comp_name, grid_name, field_name,
1101 frac_mask_fallback_value);
1102}
1103
1105 const char* comp_name, const char* metadata) {
1106 struct yac_instance * instance =
1107 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1108 struct yac_couple_config * couple_config = yac_instance_get_couple_config(instance);
1109 yac_couple_config_component_set_metadata(couple_config, comp_name, metadata);
1110}
1111
1112void yac_cdef_component_metadata(const char* comp_name, const char* metadata) {
1113 check_default_instance_id("yac_cdef_component_metadata");
1115}
1116
1117void yac_cdef_grid_metadata_instance(int yac_instance_id, const char* grid_name,
1118 const char* metadata) {
1119 struct yac_instance * instance =
1120 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1121 struct yac_couple_config * couple_config
1123 yac_couple_config_grid_set_metadata(couple_config, grid_name, metadata);
1124}
1125
1126void yac_cdef_grid_metadata(const char* grid_name, const char* metadata) {
1127 check_default_instance_id("yac_cdef_grid_metadata");
1129}
1130
1131void yac_cdef_field_metadata_instance(int yac_instance_id, const char* comp_name,
1132 const char* grid_name, const char* field_name, const char* metadata) {
1133 struct yac_instance * instance =
1134 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1135 struct yac_couple_config * couple_config
1137 yac_couple_config_field_set_metadata(couple_config, comp_name, grid_name, field_name, metadata);
1138}
1139
1140void yac_cdef_field_metadata(const char* comp_name, const char* grid_name,
1141 const char* field_name, const char* metadata) {
1142 check_default_instance_id("yac_cdef_field_metadata");
1144 field_name, metadata);
1145}
1146
1147const char* yac_cget_component_metadata_instance(int yac_instance_id,
1148 const char* comp_name) {
1149 struct yac_instance * instance =
1150 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1151 struct yac_couple_config * couple_config = yac_instance_get_couple_config(instance);
1152 return yac_couple_config_component_get_metadata(couple_config, comp_name);
1153}
1154
1155const char* yac_cget_component_metadata(const char* comp_name) {
1156 check_default_instance_id("yac_cget_component_metadata");
1158}
1159
1160const char* yac_cget_grid_metadata_instance(int yac_instance_id,
1161 const char* grid_name) {
1162 struct yac_instance * instance =
1163 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1164 struct yac_couple_config * couple_config = yac_instance_get_couple_config(instance);
1165 return yac_couple_config_grid_get_metadata(couple_config, grid_name);
1166}
1167
1168const char* yac_cget_grid_metadata(const char* grid_name) {
1169 check_default_instance_id("yac_cget_grid_metadata");
1171}
1172
1173const char* yac_cget_field_metadata_instance(int yac_instance_id,
1174 const char* comp_name, const char* grid_name, const char* field_name) {
1175 struct yac_instance * instance =
1176 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1177 struct yac_couple_config * couple_config = yac_instance_get_couple_config(instance);
1178 return yac_couple_config_field_get_metadata(couple_config, comp_name, grid_name,
1179 field_name);
1180}
1181
1182const char* yac_cget_field_metadata(const char* comp_name, const char* grid_name,
1183 const char* field_name) {
1184 check_default_instance_id("yac_cget_field_metadata");
1186 grid_name, field_name);
1187}
1188
1190 struct yac_ext_couple_config * ext_couple_config) {
1191 ext_couple_config->weight_file = NULL;
1192 ext_couple_config->mapping_side = 1;
1193 ext_couple_config->scale_factor = 1.0;
1194 ext_couple_config->scale_summand = 0.0;
1195 ext_couple_config->num_src_mask_names = 0;
1196 ext_couple_config->src_mask_names = NULL;
1197 ext_couple_config->tgt_mask_name = NULL;
1198}
1199
1200void yac_cget_ext_couple_config(int * ext_couple_config_id) {
1201
1202 struct yac_ext_couple_config * ext_couple_config =
1203 xmalloc(1 * sizeof(*ext_couple_config));
1204 init_ext_couple_config(ext_couple_config);
1205 *ext_couple_config_id = yac_pointer_to_unique_id(ext_couple_config);
1206}
1207
1208void yac_cfree_ext_couple_config(int ext_couple_config_id) {
1209 struct yac_ext_couple_config * ext_couple_config =
1210 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1211 free(ext_couple_config->weight_file);
1212 for (size_t i = 0; i < ext_couple_config->num_src_mask_names; ++i)
1213 free(ext_couple_config->src_mask_names[i]);
1214 free(ext_couple_config->src_mask_names);
1215 free(ext_couple_config->tgt_mask_name);
1216 free(ext_couple_config);
1217}
1218
1220 struct yac_ext_couple_config * ext_couple_config,
1221 char const * weight_file) {
1222 free(ext_couple_config->weight_file);
1223 ext_couple_config->weight_file =
1224 (weight_file != NULL)?strdup(weight_file):NULL;
1225}
1226
1227void yac_cset_ext_couple_config_weight_file(int ext_couple_config_id,
1228 char const * weight_file) {
1230 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"),
1231 weight_file);
1232}
1233
1234void yac_cget_ext_couple_config_weight_file(int ext_couple_config_id,
1235 char const ** weight_file) {
1236 struct yac_ext_couple_config * ext_couple_config =
1237 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1238 *weight_file = ext_couple_config->weight_file;
1239}
1240
1242 struct yac_ext_couple_config * ext_couple_config,
1243 int mapping_side) {
1245 (mapping_side == 0) ||
1246 (mapping_side == 1),
1247 "ERROR(yac_cset_ext_couple_config_mapping_side_): "
1248 "\"%d\" is not a valid mapping side (has to be 0 or 1)",
1249 mapping_side);
1250 ext_couple_config->mapping_side = mapping_side;
1251}
1252
1253void yac_cset_ext_couple_config_mapping_side(int ext_couple_config_id,
1254 int mapping_side) {
1256 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"),
1257 mapping_side);
1258}
1259
1260void yac_cget_ext_couple_config_mapping_side(int ext_couple_config_id,
1261 int * mapping_side) {
1262 struct yac_ext_couple_config * ext_couple_config =
1263 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1264 *mapping_side = ext_couple_config->mapping_side;
1265}
1266
1268 struct yac_ext_couple_config * ext_couple_config,
1269 double scale_factor) {
1270 YAC_ASSERT_F(isnormal(scale_factor),
1271 "ERROR(yac_cset_ext_couple_config_scale_factor_): "
1272 "\"%lf\" is not a valid scale factor", scale_factor);
1273 ext_couple_config->scale_factor = scale_factor;
1274}
1275
1276void yac_cset_ext_couple_config_scale_factor(int ext_couple_config_id,
1277 double scale_factor) {
1279 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"),
1280 scale_factor);
1281}
1282
1283void yac_cget_ext_couple_config_scale_factor(int ext_couple_config_id,
1284 double * scale_factor) {
1285 struct yac_ext_couple_config * ext_couple_config =
1286 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1287 *scale_factor = ext_couple_config->scale_factor;
1288}
1289
1291 struct yac_ext_couple_config * ext_couple_config,
1292 double scale_summand) {
1293 YAC_ASSERT_F((scale_summand == 0.0) || isnormal(scale_summand),
1294 "ERROR(yac_cset_ext_couple_config_scale_summand_): "
1295 "\"%lf\" is not a valid scale summand", scale_summand);
1296 ext_couple_config->scale_summand = scale_summand;
1297}
1298
1299void yac_cset_ext_couple_config_scale_summand(int ext_couple_config_id,
1300 double scale_summand) {
1302 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"),
1304}
1305
1306void yac_cget_ext_couple_config_scale_summand(int ext_couple_config_id,
1307 double * scale_summand) {
1308 struct yac_ext_couple_config * ext_couple_config =
1309 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1310 *scale_summand = ext_couple_config->scale_summand;
1311}
1312
1314 struct yac_ext_couple_config * ext_couple_config,
1315 size_t num_src_mask_names, char const * const * src_mask_names) {
1317 "ERROR(yac_cset_ext_couple_config_src_mask_names_): "
1318 "\"%zu\" is not a valid number of source mask names",
1320 if (ext_couple_config->num_src_mask_names > 0)
1321 for (size_t i = 0; i < ext_couple_config->num_src_mask_names; ++i)
1322 free(ext_couple_config->src_mask_names[i]);
1323 free(ext_couple_config->src_mask_names);
1324 ext_couple_config->num_src_mask_names = num_src_mask_names;
1325 if (num_src_mask_names > 0) {
1326 ext_couple_config->src_mask_names =
1328 for (size_t i = 0; i < num_src_mask_names; ++i)
1329 ext_couple_config->src_mask_names[i] = strdup(src_mask_names[i]);
1330 } else ext_couple_config->src_mask_names = NULL;
1331}
1332
1334 int ext_couple_config_id, size_t num_src_mask_names,
1335 char const * const * src_mask_names) {
1337 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"),
1339}
1340
1342 int ext_couple_config_id, size_t * num_src_mask_names,
1343 char const * const ** src_mask_names) {
1344 struct yac_ext_couple_config * ext_couple_config =
1345 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1346 *num_src_mask_names = ext_couple_config->num_src_mask_names;
1347 *src_mask_names = (char const * const *)ext_couple_config->src_mask_names;
1348}
1349
1351 struct yac_ext_couple_config * ext_couple_config,
1352 char const * tgt_mask_name) {
1353 free(ext_couple_config->tgt_mask_name);
1354 ext_couple_config->tgt_mask_name =
1355 (tgt_mask_name != NULL)?strdup(tgt_mask_name):NULL;
1356}
1357
1359 int ext_couple_config_id, char const * tgt_mask_name) {
1361 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"),
1363}
1364
1366 int ext_couple_config_id, char const ** tgt_mask_name) {
1367 struct yac_ext_couple_config * ext_couple_config =
1368 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id");
1369 *tgt_mask_name = ext_couple_config->tgt_mask_name;
1370}
1371
1373 int yac_instance_id,
1374 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1375 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1376 char const * coupling_timestep, int time_unit, int time_reduction,
1377 int interp_stack_config_id, int src_lag, int tgt_lag,
1378 struct yac_ext_couple_config * ext_couple_config) {
1379 struct yac_instance * instance =
1380 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
1381 struct yac_interp_stack_config * interp_stack_config =
1383 interp_stack_config_id, "interp_stack_config_id");
1384 char const * coupling_timestep_iso8601 =
1385 yac_time_to_ISO(coupling_timestep, (enum yac_time_unit_type)time_unit);
1386 yac_instance_def_couple(instance,
1387 src_comp_name, src_grid_name, src_field_name,
1388 tgt_comp_name, tgt_grid_name, tgt_field_name,
1389 coupling_timestep_iso8601, time_reduction,
1390 interp_stack_config, src_lag, tgt_lag,
1391 ext_couple_config->weight_file,
1392 ext_couple_config->mapping_side,
1393 ext_couple_config->scale_factor,
1394 ext_couple_config->scale_summand,
1395 ext_couple_config->num_src_mask_names,
1396 (char const * const *)ext_couple_config->src_mask_names,
1397 ext_couple_config->tgt_mask_name);
1398}
1399
1401 int yac_instance_id,
1402 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1403 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1404 char const * coupling_timestep, int time_unit, int time_reduction,
1405 int interp_stack_config_id, int src_lag, int tgt_lag,
1406 int ext_couple_config_id) {
1407
1409 yac_instance_id, src_comp_name, src_grid_name, src_field_name,
1410 tgt_comp_name, tgt_grid_name, tgt_field_name, coupling_timestep,
1411 time_unit, time_reduction, interp_stack_config_id, src_lag, tgt_lag,
1412 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"));
1413}
1414
1416 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1417 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1418 char const * coupling_timestep, int time_unit, int time_reduction,
1419 int interp_stack_config_id, int src_lag, int tgt_lag,
1420 int ext_couple_config_id) {
1421
1422 check_default_instance_id("yac_cdef_couple_custom");
1424 src_comp_name, src_grid_name, src_field_name,
1425 tgt_comp_name, tgt_grid_name, tgt_field_name, coupling_timestep,
1426 time_unit, time_reduction, interp_stack_config_id, src_lag, tgt_lag,
1427 yac_unique_id_to_pointer(ext_couple_config_id, "ext_couple_config_id"));
1428}
1429
1431 int yac_instance_id,
1432 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1433 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1434 char const * coupling_timestep, int time_unit, int time_reduction,
1435 int interp_stack_config_id, int src_lag, int tgt_lag) {
1436
1437 struct yac_ext_couple_config ext_couple_config;
1438 init_ext_couple_config(&ext_couple_config);
1439
1441 yac_instance_id, src_comp_name, src_grid_name, src_field_name,
1442 tgt_comp_name, tgt_grid_name, tgt_field_name, coupling_timestep,
1443 time_unit, time_reduction, interp_stack_config_id, src_lag, tgt_lag,
1444 &ext_couple_config);
1445}
1446
1448 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1449 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1450 char const * coupling_timestep, int time_unit, int time_reduction,
1451 int interp_stack_config_id, int src_lag, int tgt_lag){
1452
1453 check_default_instance_id("yac_cdef_couple");
1455 src_comp_name, src_grid_name, src_field_name,
1456 tgt_comp_name, tgt_grid_name, tgt_field_name,
1457 coupling_timestep, time_unit, time_reduction, interp_stack_config_id,
1458 src_lag, tgt_lag);
1459}
1460
1462 int yac_instance_id,
1463 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1464 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1465 char const * coupling_timestep, int time_unit, int time_reduction,
1466 int interp_stack_config_id, int src_lag, int tgt_lag,
1467 char const * weight_file, int mapping_side,
1468 double scale_factor, double scale_summand,
1469 int num_src_mask_names, char const * const * src_mask_names,
1470 char const * tgt_mask_name) {
1471
1473 num_src_mask_names >= 0,
1474 "ERROR(yac_cdef_couple_instance_): "
1475 "\"%d\" is not a valid number of source mask names", num_src_mask_names)
1476
1477 struct yac_ext_couple_config ext_couple_config;
1478 init_ext_couple_config(&ext_couple_config);
1480 &ext_couple_config, weight_file);
1482 &ext_couple_config, mapping_side);
1484 &ext_couple_config, scale_factor);
1486 &ext_couple_config, scale_summand);
1488 &ext_couple_config, (size_t)num_src_mask_names, src_mask_names);
1490 &ext_couple_config, tgt_mask_name);
1491
1493 yac_instance_id, src_comp_name, src_grid_name, src_field_name,
1494 tgt_comp_name, tgt_grid_name, tgt_field_name, coupling_timestep,
1495 time_unit, time_reduction, interp_stack_config_id, src_lag, tgt_lag,
1496 &ext_couple_config);
1497}
1498
1500 char const * src_comp_name, char const * src_grid_name, char const * src_field_name,
1501 char const * tgt_comp_name, char const * tgt_grid_name, char const * tgt_field_name,
1502 char const * coupling_timestep, int time_unit, int time_reduction,
1503 int interp_stack_config_id, int src_lag, int tgt_lag,
1504 char const * weight_file, int mapping_side,
1505 double scale_factor, double scale_summand,
1506 int num_src_mask_names, char const * const * src_mask_names,
1507 char const * tgt_mask_name) {
1508
1509 check_default_instance_id("yac_cdef_couple_");
1511 src_comp_name, src_grid_name, src_field_name,
1512 tgt_comp_name, tgt_grid_name, tgt_field_name,
1513 coupling_timestep, time_unit, time_reduction, interp_stack_config_id,
1514 src_lag, tgt_lag, weight_file, mapping_side,
1517}
1518
1519/* ---------------------------------------------------------------------- */
1520
1522 int collection_size,
1523 int num_interp_fields,
1524 int const * interp_field_sizes ) {
1525
1526 struct coupling_field * cpl_field =
1527 yac_unique_id_to_pointer(field_id, "field_id");
1528
1532 "ERROR(yac_ccheck_field_dimensions): mismatching collection sizes "
1533 "for component %s grid %s field %s (%d != %d)",
1537 yac_get_coupling_field_name(cpl_field),
1539
1540 if (num_interp_fields != -1) {
1541
1543 (size_t)num_interp_fields ==
1545 "ERROR(yac_ccheck_field_dimensions): mismatching number of interp fields "
1546 "for component %s grid %s field %s (%d != %zu)",
1550 yac_get_coupling_field_name(cpl_field),
1552
1553 if (interp_field_sizes) {
1554 for (int interp_field_idx = 0; interp_field_idx < num_interp_fields;
1555 ++interp_field_idx) {
1556
1558 (size_t)interp_field_sizes[interp_field_idx] ==
1560 cpl_field,
1562 cpl_field, (size_t)interp_field_idx)),
1563 "ERROR(yac_ccheck_field_dimensions): mismatching interp field size "
1564 "for component %s grid %s field %s interp_field_idx %d (%d != %zu)",
1568 yac_get_coupling_field_name(cpl_field),
1569 interp_field_idx,
1570 interp_field_sizes[interp_field_idx],
1572 cpl_field,
1574 cpl_field, (size_t)interp_field_idx)));
1575 }
1576 }
1577 }
1578}
1579
1580/* ---------------------------------------------------------------------- */
1581
1582void yac_cget_action(int field_id, int * action) {
1583
1584 struct coupling_field * cpl_field =
1585 yac_unique_id_to_pointer(field_id, "field_id");
1588
1589 YAC_ASSERT(
1590 (exchange_type == NOTHING) ||
1591 (exchange_type == SOURCE) ||
1592 (exchange_type == TARGET),
1593 "ERROR(yac_cget_action): invalid field exchange type")
1594
1595 switch(exchange_type) {
1596 default:
1597 case(NOTHING): {
1598
1599 *action = YAC_ACTION_NONE;
1600 break;
1601 }
1602 case(TARGET): {
1603
1604 enum yac_action_type event_action =
1606 *action = (int)((event_action == RESTART)?GET_FOR_RESTART:event_action);
1607 break;
1608 }
1609 case(SOURCE): {
1610
1611 enum yac_action_type event_action = NONE;
1612 unsigned num_puts = yac_get_coupling_field_num_puts(cpl_field);
1613 for (unsigned put_idx = 0; put_idx < num_puts; ++put_idx)
1614 event_action =
1615 MAX(
1616 event_action,
1618 yac_get_coupling_field_put_op_event(cpl_field, put_idx)));
1619 *action = (int)((event_action == RESTART)?PUT_FOR_RESTART:event_action);
1620 break;
1621 }
1622 }
1623}
1624
1625const char* yac_cget_field_datetime(int field_id){
1626 struct coupling_field * cpl_field =
1627 yac_unique_id_to_pointer(field_id, "field_id");
1628 return yac_coupling_field_get_datetime(cpl_field);
1629}
1630
1631/* ---------------------------------------------------------------------- */
1632
1633static void inline yac_cupdate_(
1634 struct coupling_field * cpl_field, struct event * event, int is_source) {
1635
1638 "ERROR(yac_cupdate): current action of %s field \"%s\" of "
1639 "componente \"%s\" is not YAC_ACTION_NONE",
1640 ((is_source)?"source":"target"), yac_get_coupling_field_name(cpl_field),
1643}
1644
1645void yac_cupdate(int field_id) {
1646
1647 struct coupling_field * cpl_field =
1648 yac_unique_id_to_pointer(field_id, "field_id");
1651
1652 YAC_ASSERT(
1653 (exchange_type == NOTHING) ||
1654 (exchange_type == SOURCE) ||
1655 (exchange_type == TARGET),
1656 "ERROR(yac_cupdate): invalid field exchange type")
1657
1658 switch(exchange_type) {
1659 default:
1660 case(NOTHING): {
1661 break;
1662 }
1663 case(TARGET): {
1664
1666 cpl_field, yac_get_coupling_field_get_op_event(cpl_field), 0);
1667 break;
1668 }
1669 case(SOURCE): {
1670
1671 unsigned num_puts = yac_get_coupling_field_num_puts(cpl_field);
1672 for (unsigned put_idx = 0; put_idx < num_puts; ++put_idx)
1674 cpl_field,
1675 yac_get_coupling_field_put_op_event(cpl_field, put_idx), 1);
1676 break;
1677 }
1678 }
1679}
1680
1681/* ---------------------------------------------------------------------- */
1682
1684 int const field_id,
1685 int const collection_size,
1686 double *recv_field) { // recv_field[collection_size][Points]
1687
1688 struct coupling_field * cpl_field =
1689 yac_unique_id_to_pointer(field_id, "field_id");
1690
1691 YAC_ASSERT(
1693 "ERROR(get_recv_field_pointers): invalid number of interpolation fields "
1694 "(should be one)")
1695
1696 enum yac_location location =
1698 size_t num_points =
1699 yac_coupling_field_get_data_size(cpl_field, location);
1700
1701 double ** recv_field_ = xmalloc(collection_size * sizeof(*recv_field_));
1702
1703 for (int i = 0; i < collection_size; ++i) {
1704 recv_field_[i] = recv_field;
1705 recv_field += num_points;
1706 }
1707
1708 return recv_field_;
1709}
1710
1712 int const field_id, int collection_size, int *info, int *ierr) {
1713
1714 *info = (int)NONE;
1715 *ierr = 0;
1716
1717 struct coupling_field * cpl_field =
1718 yac_unique_id_to_pointer(field_id, "field_id");
1719
1721 return NULL;
1722
1723 /* --------------------------------------------------------------------
1724 Check for restart and coupling events
1725 -------------------------------------------------------------------- */
1726
1727 struct event * event = yac_get_coupling_field_get_op_event(cpl_field);
1729 *info = (int)((action == RESTART)?GET_FOR_RESTART:action);
1730
1731 /* --------------------------------------------------------------------
1732 add one model time step (as provided in coupling configuration) to
1733 the current event date
1734 -------------------------------------------------------------------- */
1735
1737
1738 /* ------------------------------------------------------------------
1739 return in case we are already beyond the end of the run
1740 ------------------------------------------------------------------ */
1741
1742 if ( action == OUT_OF_BOUND ) {
1743
1744 fputs("WARNING: yac get action is beyond end of run date!\n", stderr);
1745 fputs("WARNING: yac get action is beyond end of run date!\n", stdout);
1746
1747 return NULL;
1748 }
1749
1750 /* --------------------------------------------------------------------
1751 start actions
1752 -------------------------------------------------------------------- */
1753
1754 if ( action == NONE ) return NULL;
1755
1756 YAC_ASSERT(
1757 collection_size == yac_get_coupling_field_collection_size(cpl_field),
1758 "ERROR: collection size does not match with coupling configuration.")
1759
1761}
1762
1763static void yac_get ( int const field_id,
1764 int collection_size,
1765 double ** recv_field,
1766 int is_async,
1767 int *info,
1768 int *ierr ) {
1769
1770 yac_ccheck_field_dimensions(field_id, collection_size, 1, NULL);
1771
1772 struct yac_interpolation * interpolation =
1773 yac_cget_pre_processing(field_id, collection_size, info, ierr);
1774
1775 if ((*ierr == 0) && (interpolation != NULL)) {
1776 if (is_async)
1777 yac_interpolation_execute_get_async(interpolation, recv_field);
1778 else
1779 yac_interpolation_execute_get(interpolation, recv_field);
1780 }
1781}
1782
1783/* ---------------------------------------------------------------------- */
1784
1785void yac_get_ ( int const field_id,
1786 int const collection_size,
1787 double *recv_field,
1788 int is_async,
1789 int *info,
1790 int *ierr ) {
1791
1792 yac_ccheck_field_dimensions(field_id, collection_size, 1, NULL);
1793
1794 /* Needed to transfer from Fortran data structure to C */
1795 double ** recv_field_ =
1796 get_recv_field_pointers(field_id, collection_size, recv_field);
1797
1798 yac_get(field_id, collection_size, recv_field_, is_async, info, ierr);
1799
1800 free(recv_field_);
1801}
1802
1803void yac_cget_ ( int const field_id,
1804 int const collection_size,
1805 double *recv_field, // recv_field[collection_size][Points]
1806 int *info,
1807 int *ierr ) {
1808
1809 yac_get_(field_id, collection_size, recv_field, 0, info, ierr);
1810}
1811
1812void yac_cget_async_ ( int const field_id,
1813 int const collection_size,
1814 double *recv_field, // recv_field[collection_size][Points]
1815 int *info,
1816 int *ierr ) {
1817
1818 yac_get_(field_id, collection_size, recv_field, 1, info, ierr);
1819}
1820
1821void yac_cget ( int const field_id,
1822 int collection_size,
1823 double ** recv_field, // recv_field[collection_size][Points]
1824 int *info,
1825 int *ierr ) {
1826
1827 yac_get(field_id, collection_size, recv_field, 0, info, ierr);
1828}
1829
1830void yac_cget_async ( int const field_id,
1831 int collection_size,
1832 double ** recv_field, // recv_field[collection_size][Points]
1833 int *info,
1834 int *ierr ) {
1835
1836
1837 yac_get(field_id, collection_size, recv_field, 1, info, ierr);
1838}
1839
1840/* ---------------------------------------------------------------------- */
1841
1843 int const field_id,
1844 int const collection_size,
1845 double * send_field, // send_field[collection_size][nPointSets][Points]
1846 double * send_frac_mask,
1847 double **** send_field_,
1848 double **** send_frac_mask_) {
1849
1850 struct coupling_field * cpl_field =
1851 yac_unique_id_to_pointer(field_id, "field_id");
1852
1853 size_t num_interp_fields =
1855
1856 size_t * num_points = xmalloc(num_interp_fields * sizeof(*num_points));
1857
1858 for (size_t i = 0; i < num_interp_fields; i++) {
1859
1860 enum yac_location location =
1862 num_points[i] = yac_coupling_field_get_data_size(cpl_field, location);
1863 }
1864
1865 *send_field_ = xmalloc(collection_size * sizeof(**send_field_));
1866 for (int i = 0; i < collection_size; ++i) {
1867 (*send_field_)[i] = xmalloc(num_interp_fields * sizeof(***send_field_));
1868 for (size_t j = 0; j < num_interp_fields; ++j) {
1869 (*send_field_)[i][j] = send_field;
1870 send_field += num_points[j];
1871 }
1872 }
1873 if (send_frac_mask != NULL) {
1874 *send_frac_mask_ =
1875 xmalloc(collection_size * sizeof(**send_frac_mask_));
1876 for (int i = 0; i < collection_size; ++i) {
1877 (*send_frac_mask_)[i] =
1878 xmalloc(num_interp_fields * sizeof(***send_frac_mask_));
1879 for (size_t j = 0; j < num_interp_fields; ++j) {
1880 (*send_frac_mask_)[i][j] = send_frac_mask;
1881 send_frac_mask += num_points[j];
1882 }
1883 }
1884 }
1885 free(num_points);
1886}
1887
1888void yac_cput_ ( int const field_id,
1889 int const collection_size,
1890 double *send_field, // send_field[collection_size]
1891 // [nPointSets]
1892 // [Points]
1893 int *info,
1894 int *ierr ) {
1895
1896 yac_ccheck_field_dimensions(field_id, collection_size, -1, NULL);
1897
1898 /* Needed to transfer from Fortran data structure to C */
1899 double *** send_field_;
1901 field_id, collection_size, send_field, NULL, &send_field_, NULL);
1902
1903 yac_cput ( field_id, collection_size, send_field_, info, ierr );
1904
1905 for (int i = 0; i < collection_size; ++i) free(send_field_[i]);
1906 free(send_field_);
1907}
1908
1909void yac_cput_frac_ ( int const field_id,
1910 int const collection_size,
1911 double *send_field, // send_field[collection_size]
1912 // [nPointSets]
1913 // [Points]
1914 double *send_frac_mask, // send_frac_mask[collection_size]
1915 // [nPointSets]
1916 // [Points]
1917 int *info,
1918 int *ierr ) {
1919
1920 yac_ccheck_field_dimensions(field_id, collection_size, -1, NULL);
1921
1922 /* Needed to transfer from Fortran data structure to C */
1923 double *** send_field_;
1924 double *** send_frac_mask_;
1926 field_id, collection_size, send_field, send_frac_mask,
1927 &send_field_, &send_frac_mask_);
1928
1930 field_id, collection_size, send_field_, send_frac_mask_, info, ierr);
1931
1932 for (int i = 0; i < collection_size; ++i) {
1933 free(send_field_[i]);
1934 free(send_frac_mask_[i]);
1935 }
1936 free(send_field_);
1937 free(send_frac_mask_);
1938}
1939
1940/* ---------------------------------------------------------------------- */
1941
1943 int const field_id,
1944 int const collection_size,
1945 double **send_field, // send_field[collection_size*nPointSets][Points]
1946 double **send_frac_mask,
1947 double ****send_field_,
1948 double ****send_frac_mask_) {
1949
1950 struct coupling_field * cpl_field =
1951 yac_unique_id_to_pointer(field_id, "field_id");
1952
1953 size_t num_interp_fields =
1955
1956 size_t * num_points = xmalloc(num_interp_fields * sizeof(*num_points));
1957
1958 for (size_t i = 0; i < num_interp_fields; i++) {
1959
1960 enum yac_location location =
1962 num_points[i] = yac_coupling_field_get_data_size(cpl_field, location);
1963 }
1964
1965 *send_field_ = xmalloc(collection_size * sizeof(**send_field_));
1966 for (int i = 0, k = 0; i < collection_size; ++i) {
1967
1968 (*send_field_)[i] = xmalloc(num_interp_fields * sizeof(***send_field_));
1969 for (size_t j = 0; j < num_interp_fields; ++j, ++k)
1970 (*send_field_)[i][j] = send_field[k];
1971 }
1972 if (send_frac_mask != NULL) {
1973 *send_frac_mask_ = xmalloc(collection_size * sizeof(**send_frac_mask_));
1974 for (int i = 0, k = 0; i < collection_size; ++i) {
1975
1976 (*send_frac_mask_)[i] =
1977 xmalloc(num_interp_fields * sizeof(***send_frac_mask_));
1978 for (size_t j = 0; j < num_interp_fields; ++j, ++k)
1979 (*send_frac_mask_)[i][j] = send_frac_mask[k];
1980 }
1981 }
1982
1983 free(num_points);
1984}
1985
1986void yac_cput_ptr_ ( int const field_id,
1987 int const collection_size,
1988 double ** send_field, // send_field[collection_size *
1989 // nPointSets][Points]
1990 int *info,
1991 int *ierr ) {
1992
1993 yac_ccheck_field_dimensions(field_id, collection_size, -1, NULL);
1994
1995 /* Needed to transfer from Fortran data structure to C */
1996 double *** send_field_;
1998 field_id, collection_size, send_field, NULL, &send_field_, NULL);
1999
2000 yac_cput ( field_id, collection_size, send_field_, info, ierr );
2001
2002 for (int i = 0; i < collection_size; ++i) free(send_field_[i]);
2003 free(send_field_);
2004}
2005
2006void yac_cput_frac_ptr_ ( int const field_id,
2007 int const collection_size,
2008 double ** send_field, // send_field[collection_size *
2009 // nPointSets][Points]
2010 double ** send_frac_mask, // send_frac_mask[collection_size *
2011 // nPointSets][Points]
2012 int *info,
2013 int *ierr ) {
2014
2015 yac_ccheck_field_dimensions(field_id, collection_size, -1, NULL);
2016
2017 /* Needed to transfer from Fortran data structure to C */
2018 double *** send_field_;
2019 double *** send_frac_mask_;
2021 field_id, collection_size, send_field, send_frac_mask,
2022 &send_field_, &send_frac_mask_);
2023
2025 field_id, collection_size, send_field_, send_frac_mask_, info, ierr);
2026
2027 for (int i = 0; i < collection_size; ++i) {
2028 free(send_field_[i]);
2029 free(send_frac_mask_[i]);
2030 }
2031 free(send_field_);
2032 free(send_frac_mask_);
2033}
2034
2035/* ---------------------------------------------------------------------- */
2036
2037void yac_ctest(int field_id, int * flag) {
2038
2039 struct coupling_field * cpl_field =
2040 yac_unique_id_to_pointer(field_id, "field_id");
2041
2042 *flag = 1;
2043 if (yac_get_coupling_field_exchange_type(cpl_field) == SOURCE) {
2044 for (
2045 unsigned put_idx = 0;
2046 (put_idx < yac_get_coupling_field_num_puts(cpl_field)) && *flag;
2047 ++put_idx)
2048 *flag &=
2051 }
2052
2053 if (*flag && yac_get_coupling_field_exchange_type(cpl_field) == TARGET)
2054 *flag =
2057}
2058
2059/* ---------------------------------------------------------------------- */
2060
2061void yac_cwait(int field_id) {
2062
2063 struct coupling_field * cpl_field =
2064 yac_unique_id_to_pointer(field_id, "field_id");
2065
2066 if (yac_get_coupling_field_exchange_type(cpl_field) == SOURCE) {
2067 for (
2068 unsigned put_idx = 0;
2069 (put_idx < yac_get_coupling_field_num_puts(cpl_field)); ++put_idx)
2072 }
2073
2077}
2078
2079/* ---------------------------------------------------------------------- */
2080
2081void * yac_get_field_put_mask_c2f(int field_id) {
2082
2083 struct coupling_field * cpl_field =
2084 yac_unique_id_to_pointer(field_id, "field_id");
2085
2086 return (void*)yac_get_coupling_field_put_mask(cpl_field);
2087}
2088
2089void * yac_get_field_get_mask_c2f(int field_id) {
2090
2091 struct coupling_field * cpl_field =
2092 yac_unique_id_to_pointer(field_id, "field_id");
2093
2094 return (void*)yac_get_coupling_field_get_mask(cpl_field);
2095}
2096
2097/* ---------------------------------------------------------------------- */
2098
2100 struct coupling_field * cpl_field, unsigned put_idx,
2101 int const collection_size, double *** send_field,
2102 double **** send_field_acc_, double *** send_frac_mask,
2103 double **** send_frac_mask_acc_, int *info, int *ierr) {
2104
2105 *ierr = 0;
2106
2107 int with_frac_mask = send_frac_mask != NULL;
2108
2109 /* ------------------------------------------------------------------
2110 Check for restart and coupling events
2111 ------------------------------------------------------------------ */
2112
2113 struct event * event = yac_get_coupling_field_put_op_event(cpl_field, put_idx);
2115 *info = (int)((action == RESTART)?PUT_FOR_RESTART:action);
2116
2117 /* ------------------------------------------------------------------
2118 add one model time step (as provided in coupling configuration) to
2119 the current event date
2120 ------------------------------------------------------------------ */
2121
2123
2124 /* ------------------------------------------------------------------
2125 return in case we are already beyond the end of the run
2126 ------------------------------------------------------------------ */
2127
2128 if (action == OUT_OF_BOUND) {
2129
2130 fputs("WARNING: yac put action is beyond end of run date!\n", stderr);
2131 fputs("WARNING: yac put action is beyond end of run date!\n", stdout);
2132
2133 *send_field_acc_ = NULL;
2134 *send_frac_mask_acc_ = NULL;
2135 return NULL;
2136 }
2137
2138 /* ------------------------------------------------------------------
2139 start actions
2140 ------------------------------------------------------------------ */
2141
2142 if ( action == NONE ) return NULL;
2143
2144 /* ------------------------------------------------------------------
2145 If it is time for restart, set appropriate flags and continue
2146 ------------------------------------------------------------------ */
2147
2148 /* ------------------------------------------------------------------
2149 First deal with instant sends
2150 ------------------------------------------------------------------ */
2151
2152 int ** put_mask = yac_get_coupling_field_put_mask(cpl_field);
2153 size_t num_interp_fields =
2155
2157 if ( time_operation == TIME_NONE ) {
2158
2159 *info = MAX((int)COUPLING, *info);
2160
2161 if (with_frac_mask) {
2162
2163 // apply fractional mask to send field
2164 double *** send_field_acc =
2166 *send_field_acc_ = send_field_acc;
2167 *send_frac_mask_acc_ = send_frac_mask;
2168
2169 for (int h = 0; h < collection_size; h++) {
2170 for (size_t i = 0; i < num_interp_fields; i++) {
2171 size_t num_points =
2173 cpl_field,
2174 yac_coupling_field_get_interp_fields(cpl_field)[i].location);
2175 if (put_mask) {
2176 for (size_t j = 0; j < num_points; ++j) {
2177 if (put_mask[i][j]) {
2178 double frac_mask = send_frac_mask[h][i][j];
2179 if (frac_mask != 0.0)
2180 send_field_acc[h][i][j] = send_field[h][i][j] * frac_mask;
2181 }
2182 }
2183 } else {
2184 for (size_t j = 0; j < num_points; ++j) {
2185 double frac_mask = send_frac_mask[h][i][j];
2186 if (frac_mask != 0.0)
2187 send_field_acc[h][i][j] = send_field[h][i][j] * frac_mask;
2188 }
2189 }
2190 }
2191 }
2192 } else {
2193 *send_field_acc_ = NULL;
2194 *send_frac_mask_acc_ = NULL;
2195 }
2196 return yac_get_coupling_field_put_op_interpolation(cpl_field, put_idx);
2197 }
2198
2199 /* ------------------------------------------------------------------
2200 Accumulation & Averaging
2201 ------------------------------------------------------------------ */
2202
2203 YAC_ASSERT(
2208 "ERROR(yac_cput_pre_processing): invalid time operation type")
2209
2210 int time_accumulation_count =
2212
2213 time_accumulation_count++;
2214
2215 // if this is the first accumulation step
2216 if (time_accumulation_count == 1) {
2217
2218 double send_field_acc_init_value;
2219 switch (time_operation) {
2220 default:
2221 case(TIME_ACCUMULATE):
2222 case(TIME_AVERAGE):
2223 send_field_acc_init_value = 0.0;
2224 break;
2225 case(TIME_MINIMUM):
2226 send_field_acc_init_value = DBL_MAX;
2227 break;
2228 case(TIME_MAXIMUM):
2229 send_field_acc_init_value = -DBL_MAX;
2230 break;
2231 }
2232
2233 /* initalise memory */
2234
2236 cpl_field, put_idx, send_field_acc_init_value);
2237 if (with_frac_mask)
2239 cpl_field, put_idx, 0.0);
2240 }
2241
2242 /* accumulate data */
2243
2244 double *** send_field_acc =
2246 *send_field_acc_ = send_field_acc;
2247 double *** send_frac_mask_acc;
2248 if (with_frac_mask) {
2249 send_frac_mask_acc =
2251 *send_frac_mask_acc_ = send_frac_mask_acc;
2252 } else {
2253 send_frac_mask_acc = NULL;
2254 *send_frac_mask_acc_ = NULL;
2255 }
2256
2257#define NO_CHECK (1)
2258#define PUT_CHECK (put_mask[i][j])
2259#define SUM +=
2260#define ASSIGN =
2261#define AGGREGATE_FRAC(CHECK, EXTRA_CHECK, ACCU_OP) \
2262 { \
2263 for (size_t j = 0; j < num_points; ++j) { \
2264 double frac_mask = send_frac_mask[h][i][j]; \
2265 double send_field_value = send_field[h][i][j] * frac_mask; \
2266 if (CHECK && (EXTRA_CHECK)) { \
2267 if (frac_mask != 0.0) { \
2268 send_field_acc[h][i][j] ACCU_OP send_field_value; \
2269 send_frac_mask_acc[h][i][j] ACCU_OP frac_mask; \
2270 } \
2271 } \
2272 } \
2273 }
2274#define AGGREATE_NOFRAC(CHECK, EXTRA_CHECK, ACCU_OP) \
2275 { \
2276 for (size_t j = 0; j < num_points; ++j) {\
2277 double send_field_value = send_field[h][i][j]; \
2278 if (CHECK && (EXTRA_CHECK)) \
2279 send_field_acc[h][i][j] ACCU_OP send_field_value; \
2280 } \
2281 }
2282#define AGGREGATE(EXTRA_CHECK, ACCU_OP) \
2283 { \
2284 for (int h = 0; h < collection_size; h++) { \
2285 for (size_t i = 0; i < num_interp_fields; i++) { \
2286 size_t num_points = \
2287 yac_coupling_field_get_data_size( \
2288 cpl_field, \
2289 yac_coupling_field_get_interp_fields(cpl_field)[i].location); \
2290 if (with_frac_mask) { \
2291 if (put_mask) AGGREGATE_FRAC(PUT_CHECK, EXTRA_CHECK, ACCU_OP) \
2292 else AGGREGATE_FRAC(NO_CHECK, EXTRA_CHECK, ACCU_OP) \
2293 } else { \
2294 if (put_mask) AGGREATE_NOFRAC(PUT_CHECK, EXTRA_CHECK, ACCU_OP) \
2295 else AGGREATE_NOFRAC(NO_CHECK, EXTRA_CHECK, ACCU_OP) \
2296 } \
2297 } \
2298 } \
2299 break; \
2300 }
2301
2302 switch (time_operation) {
2303 default:
2304 case(TIME_ACCUMULATE):
2305 case(TIME_AVERAGE):
2307 case(TIME_MINIMUM):
2308 AGGREGATE(send_field_acc[h][i][j] > send_field_value, ASSIGN)
2309 case(TIME_MAXIMUM):
2310 AGGREGATE(send_field_acc[h][i][j] < send_field_value, ASSIGN)
2311 }
2312
2313#undef AGGREGATE
2314#undef AGGREATE_NOFRAC
2315#undef AGGREGATE_FRAC
2316#undef ASSIGN
2317#undef SUM
2318#undef PUT_CHECK
2319#undef NO_CHECK
2320
2321/* --------------------------------------------------------------------
2322 Check whether we have to perform the coupling in this call
2323 -------------------------------------------------------------------- */
2324
2325 if (action == REDUCTION) {
2327 cpl_field, put_idx, time_accumulation_count);
2328 return NULL;
2329 }
2330
2331/* --------------------------------------------------------------------
2332 Average data if required
2333 -------------------------------------------------------------------- */
2334
2335 if (( time_operation == TIME_AVERAGE ) ||
2337
2338 double weight = 1.0 / (double)time_accumulation_count;
2339
2340#define NO_CHECK (1)
2341#define PUT_CHECK (put_mask[i][j])
2342#define WEIGHT_ACC_(ACC, CHECK, EXTRA_CHECK) \
2343 { \
2344 for (size_t j = 0; j < num_points; j++) \
2345 if (CHECK && (EXTRA_CHECK)) ACC[h][i][j] *= weight; \
2346 }
2347#define WEIGHT_ACC(ACC, EXTRA_CHECK) \
2348 { \
2349 if (put_mask) WEIGHT_ACC_(ACC, PUT_CHECK, EXTRA_CHECK) \
2350 else WEIGHT_ACC_(ACC, NO_CHECK, EXTRA_CHECK) \
2351 }
2352
2353 for (int h = 0; h < collection_size; ++h) {
2354 for (size_t i = 0; i < num_interp_fields; i++) {
2355 size_t num_points =
2357 cpl_field,
2358 yac_coupling_field_get_interp_fields(cpl_field)[i].location);
2359 if (with_frac_mask)
2360 WEIGHT_ACC(send_frac_mask_acc, NO_CHECK)
2362 if (with_frac_mask)
2363 WEIGHT_ACC(send_field_acc, send_frac_mask_acc[h][i][j] != 0.0)
2364 else
2365 WEIGHT_ACC(send_field_acc, NO_CHECK)
2366 }
2367 }
2368 }
2369 }
2370
2371#undef NO_CHECK
2372#undef PUT_CHECK
2373#undef WEIGHT_ACC_
2374#undef WEIGHT_ACC
2375
2376 // reset time_accumulation_count
2378 cpl_field, put_idx, 0);
2379
2380/* --------------------------------------------------------------------
2381 return interpolation
2382 -------------------------------------------------------------------- */
2383
2384 *info = MAX((int)COUPLING, *info);
2385 return yac_get_coupling_field_put_op_interpolation(cpl_field, put_idx);
2386}
2387
2388void yac_cput_frac ( int const field_id,
2389 int const collection_size,
2390 double *** const send_field, // send_field[collection_size]
2391 // [nPointSets][Points]
2392 double *** const send_frac_mask, // send_frac_mask[collection_size]
2393 // [nPointSets][Points]
2394 int *info,
2395 int *ierr ) {
2396
2397 yac_ccheck_field_dimensions(field_id, collection_size, -1, NULL);
2398
2399 *info = NONE;
2400 *ierr = 0;
2401
2402 struct coupling_field * cpl_field =
2403 yac_unique_id_to_pointer(field_id, "field_id");
2404
2406 return;
2407
2408 YAC_ASSERT(
2410 "ERROR: collection size does not match with coupling configuration.")
2411
2412 for (unsigned put_idx = 0;
2413 put_idx < yac_get_coupling_field_num_puts(cpl_field); ++put_idx) {
2414
2415 int curr_action;
2416 int curr_ierr;
2417 double *** send_field_acc;
2418 double *** send_frac_mask_acc;
2419 struct yac_interpolation * interpolation =
2421 cpl_field, put_idx, collection_size,
2422 send_field, &send_field_acc,
2423 send_frac_mask, &send_frac_mask_acc,
2424 &curr_action, &curr_ierr);
2425
2426 *info = MAX(*info, curr_action);
2427 *ierr = MAX(*ierr, curr_ierr);
2428
2429 /* ------------------------------------------------------------------
2430 return in case we are already beyond the end of the run
2431 ------------------------------------------------------------------ */
2432 if (curr_action == OUT_OF_BOUND) {
2433 *info = OUT_OF_BOUND;
2434 return;
2435 }
2436
2437 /* ------------------------------------------------------------------
2438 in case there is nothing to be done for the current put
2439 ------------------------------------------------------------------ */
2440 if ((curr_action == NONE) || (curr_action == REDUCTION)) continue;
2441
2442 /* ------------------------------------------------------------------
2443 in case we are supposed to couple
2444 ------------------------------------------------------------------ */
2445 if ((*ierr == 0) && (interpolation != NULL)) {
2446
2447 int with_frac_mask =
2448 yac_interpolation_with_frac_mask(interpolation);
2449
2451 (with_frac_mask && (send_frac_mask != NULL)) ||
2452 !with_frac_mask,
2453 "ERROR: interpolation for field \"%s\" was built for dynamic "
2454 "fractional masking, but no mask was provided",
2455 yac_get_coupling_field_name(cpl_field));
2457 (!with_frac_mask && (send_frac_mask == NULL)) ||
2458 with_frac_mask,
2459 "ERROR: interpolation for field \"%s\" was not built for dynamic "
2460 "fractional masking, but a mask was provided",
2461 yac_get_coupling_field_name(cpl_field));
2462
2463 double *** send_field_ptr =
2464 (send_field_acc == NULL)?send_field:send_field_acc;
2465 double *** send_frac_mask_ptr =
2466 (send_frac_mask_acc == NULL)?send_frac_mask:send_frac_mask_acc;
2467
2468 if (with_frac_mask)
2470 interpolation, send_field_ptr, send_frac_mask_ptr);
2471 else
2472 yac_interpolation_execute_put(interpolation, send_field_ptr);
2473 }
2474 }
2475}
2476
2477void yac_cput ( int const field_id,
2478 int const collection_size,
2479 double *** const send_field, // send_field[collection_size]
2480 // [nPointSets][Points]
2481 int *info,
2482 int *ierr ) {
2483
2485 field_id, collection_size, send_field, NULL, info, ierr);
2486}
2487
2488/* ---------------------------------------------------------------------- */
2489
2490
2491void yac_cexchange_ ( int const send_field_id,
2492 int const recv_field_id,
2493 int const collection_size,
2494 double *send_field, // send_field[collection_size]
2495 // [nPointSets]
2496 // [Points]
2497 double *recv_field, // recv_field[collection_size][Points]
2498 int *send_info,
2499 int *recv_info,
2500 int *ierr ) {
2501
2502 yac_ccheck_field_dimensions(send_field_id, collection_size, 1, NULL);
2503 yac_ccheck_field_dimensions(recv_field_id, collection_size, -1, NULL);
2504
2505 /* Needed to transfer from Fortran data structure to C */
2506 double *** send_field_;
2508 send_field_id, collection_size, send_field, NULL, &send_field_, NULL);
2509 double ** recv_field_ =
2510 get_recv_field_pointers(recv_field_id, collection_size, recv_field);
2511
2513 send_field_id, recv_field_id, collection_size, send_field_, recv_field_,
2514 send_info, recv_info, ierr);
2515
2516 free(recv_field_);
2517 for (int i = 0; i < collection_size; ++i) free(send_field_[i]);
2518 free(send_field_);
2519}
2520
2521/* ---------------------------------------------------------------------- */
2522
2523
2524void yac_cexchange_frac_ ( int const send_field_id,
2525 int const recv_field_id,
2526 int const collection_size,
2527 double *send_field, // send_field[collection_size]
2528 // [nPointSets]
2529 // [Points]
2530 double *send_frac_mask, // send_frac_mask[collection_size]
2531 // [nPointSets]
2532 // [Points]
2533 double *recv_field, // recv_field[collection_size][Points]
2534 int *send_info,
2535 int *recv_info,
2536 int *ierr ) {
2537
2538 yac_ccheck_field_dimensions(send_field_id, collection_size, 1, NULL);
2539 yac_ccheck_field_dimensions(recv_field_id, collection_size, -1, NULL);
2540
2541 /* Needed to transfer from Fortran data structure to C */
2542 double *** send_field_;
2543 double *** send_frac_mask_;
2545 send_field_id, collection_size, send_field, send_frac_mask,
2546 &send_field_, &send_frac_mask_);
2547 double ** recv_field_ =
2548 get_recv_field_pointers(recv_field_id, collection_size, recv_field);
2549
2551 send_field_id, recv_field_id, collection_size, send_field_, send_frac_mask_,
2552 recv_field_, send_info, recv_info, ierr);
2553
2554 free(recv_field_);
2555 for (int i = 0; i < collection_size; ++i) {
2556 free(send_field_[i]);
2557 free(send_frac_mask_[i]);
2558 }
2559 free(send_field_);
2560 free(send_frac_mask_);
2561}
2562
2563/* ---------------------------------------------------------------------- */
2564
2565
2566void yac_cexchange_ptr_ ( int const send_field_id,
2567 int const recv_field_id,
2568 int const collection_size,
2569 double ** send_field, // send_field[collection_size *
2570 // nPointSets][Points]
2571 double ** recv_field, // recv_field[collection_size][Points]
2572 int *send_info,
2573 int *recv_info,
2574 int *ierr ) {
2575
2576 yac_ccheck_field_dimensions(send_field_id, collection_size, 1, NULL);
2577 yac_ccheck_field_dimensions(recv_field_id, collection_size, -1, NULL);
2578
2579
2580 /* Needed to transfer from Fortran data structure to C */
2581 double *** send_field_;
2583 send_field_id, collection_size, send_field, NULL, &send_field_, NULL);
2584
2586 send_field_id, recv_field_id, collection_size, send_field_, recv_field,
2587 send_info, recv_info, ierr);
2588
2589 for (int i = 0; i < collection_size; ++i) free(send_field_[i]);
2590 free(send_field_);
2591}
2592
2593/* ---------------------------------------------------------------------- */
2594
2595
2596void yac_cexchange_frac_ptr_ ( int const send_field_id,
2597 int const recv_field_id,
2598 int const collection_size,
2599 double ** send_field, // send_field[collection_size *
2600 // nPointSets][Points]
2601 double ** send_frac_mask, // send_frac_mask[collection_size *
2602 // nPointSets][Points]
2603 double ** recv_field, // recv_field[collection_size][Points]
2604 int *send_info,
2605 int *recv_info,
2606 int *ierr ) {
2607
2608 yac_ccheck_field_dimensions(send_field_id, collection_size, 1, NULL);
2609 yac_ccheck_field_dimensions(recv_field_id, collection_size, -1, NULL);
2610
2611 /* Needed to transfer from Fortran data structure to C */
2612 double *** send_field_;
2613 double *** send_frac_mask_;
2615 send_field_id, collection_size, send_field, send_frac_mask,
2616 &send_field_, &send_frac_mask_);
2617
2619 send_field_id, recv_field_id, collection_size, send_field_, send_frac_mask_,
2620 recv_field, send_info, recv_info, ierr);
2621
2622 for (int i = 0; i < collection_size; ++i) {
2623 free(send_field_[i]);
2624 free(send_frac_mask_[i]);
2625 }
2626 free(send_field_);
2627 free(send_frac_mask_);
2628}
2629
2630/* ---------------------------------------------------------------------- */
2631
2632void yac_cexchange_frac ( int const send_field_id,
2633 int const recv_field_id,
2634 int const collection_size,
2635 double *** const send_field, // send_field[collection_size]
2636 // [nPointSets][Points]
2637 double *** const send_frac_mask, // send_frac_mask[collection_size]
2638 // [nPointSets][Points]
2639 double ** recv_field, // recv_field[collection_size][Points]
2640 int *send_info,
2641 int *recv_info,
2642 int *ierr ) {
2643
2644 yac_ccheck_field_dimensions(send_field_id, collection_size, 1, NULL);
2645 yac_ccheck_field_dimensions(recv_field_id, collection_size, -1, NULL);
2646
2647 *send_info = NONE;
2648 *ierr = -1;
2649
2650 struct coupling_field * send_cpl_field =
2651 yac_unique_id_to_pointer(send_field_id, "send_field_id");
2652
2653 if (yac_get_coupling_field_exchange_type(send_cpl_field) != SOURCE) {
2654 yac_cget(recv_field_id, collection_size, recv_field, recv_info, ierr);
2655 return;
2656 }
2657
2658 YAC_ASSERT(
2660 "ERROR(yac_cexchange_frac): "
2661 "collection size does not match with coupling configuration.")
2662
2663 YAC_ASSERT(
2664 yac_get_coupling_field_num_puts(send_cpl_field) == 1,
2665 "ERROR(yac_cexchange_frac): more than one put per field is not supported "
2666 "for yac_cexchange_frac.")
2667
2668 int send_action;
2669 int send_ierr;
2670 double *** send_field_acc;
2671 double *** send_frac_mask_acc;
2672 struct yac_interpolation * put_interpolation =
2674 send_cpl_field, 0, collection_size, send_field,
2675 &send_field_acc, send_frac_mask, &send_frac_mask_acc,
2676 &send_action, &send_ierr);
2677
2678 *send_info = MAX(*send_info, send_action);
2679 *ierr = MAX(*ierr, send_ierr);
2680
2681 /* ------------------------------------------------------------------
2682 return in case we are already beyond the end of the run for the puts
2683 or there is nothing to be done for the current put
2684 ------------------------------------------------------------------ */
2685 if ((send_action == OUT_OF_BOUND) ||
2686 (send_action == NONE) ||
2687 (send_action == REDUCTION)) {
2688 yac_cget(recv_field_id, collection_size, recv_field, recv_info, ierr);
2689 return;
2690 }
2691
2692 /* ------------------------------------------------------------------
2693 check the get
2694 ------------------------------------------------------------------ */
2695
2696 struct yac_interpolation * get_interpolation =
2697 yac_cget_pre_processing(recv_field_id, collection_size, recv_info, ierr);
2698
2699 /* ------------------------------------------------------------------
2700 do the required exchanges
2701 ------------------------------------------------------------------ */
2702
2703 if (*ierr == 0) {
2704
2705 double *** send_field_ptr =
2706 (send_field_acc == NULL)?send_field:send_field_acc;
2707 double *** send_frac_mask_ptr =
2708 (send_frac_mask_acc == NULL)?send_frac_mask:send_frac_mask_acc;
2709
2710 int with_frac_mask =
2711 yac_interpolation_with_frac_mask(put_interpolation);
2712
2713 // if the get is active
2714 if (get_interpolation != NULL) {
2715
2716 YAC_ASSERT(
2717 get_interpolation == put_interpolation,
2718 "ERROR(yac_cexchange): send_field_id and recv_field_id do not match")
2719
2721 (with_frac_mask && (send_frac_mask != NULL)) ||
2722 !with_frac_mask,
2723 "ERROR: interpolation for field \"%s\" was built for dynamic "
2724 "fractional masking, but no mask was provided",
2725 yac_get_coupling_field_name(send_cpl_field));
2727 (!with_frac_mask && (send_frac_mask == NULL)) ||
2728 with_frac_mask,
2729 "ERROR: interpolation for field \"%s\" was not built for dynamic "
2730 "fractional masking, but a mask was provided",
2731 yac_get_coupling_field_name(send_cpl_field));
2732
2733 if (with_frac_mask)
2735 put_interpolation, send_field_ptr, send_frac_mask_ptr, recv_field);
2736 else
2738 put_interpolation, send_field_ptr, recv_field);
2739
2740 } else {
2741
2743 (with_frac_mask && (send_frac_mask != NULL)) ||
2744 !with_frac_mask,
2745 "ERROR: interpolation for field \"%s\" was built for dynamic "
2746 "fractional masking, but no mask was provided",
2747 yac_get_coupling_field_name(send_cpl_field));
2749 (!with_frac_mask && (send_frac_mask == NULL)) ||
2750 with_frac_mask,
2751 "ERROR: interpolation for field \"%s\" was not built for dynamic "
2752 "fractional masking, but a mask was provided",
2753 yac_get_coupling_field_name(send_cpl_field));
2754
2755 // just execute the put
2756 if (with_frac_mask)
2758 put_interpolation, send_field_ptr, send_frac_mask_ptr);
2759 else
2760 yac_interpolation_execute_put(put_interpolation, send_field_ptr);
2761 }
2762 }
2763}
2764
2765
2766
2767void yac_cexchange ( int const send_field_id,
2768 int const recv_field_id,
2769 int const collection_size,
2770 double *** const send_field, // send_field[collection_size]
2771 // [nPointSets][Points]
2772 double ** recv_field, // recv_field[collection_size][Points]
2773 int *send_info,
2774 int *recv_info,
2775 int *ierr ) {
2776
2778 send_field_id, recv_field_id, collection_size,
2779 send_field, NULL, recv_field, send_info, recv_info, ierr);
2780}
2781
2782/* ---------------------------------------------------------------------- */
2783
2784void yac_csync_def_instance ( int yac_instance_id ){
2786 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"));
2787}
2788
2793
2794
2795/* ---------------------------------------------------------------------- */
2796
2797void yac_cenddef_instance(int yac_instance_id) {
2798
2800 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"));
2801}
2802
2803void yac_cenddef (void) {
2804
2805 check_default_instance_id("yac_cenddef");
2807}
2808
2810 int yac_instance_id, int emit_flags, char ** config) {
2811
2812 *config =
2814 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id"),
2815 emit_flags);
2816}
2817
2818void yac_cenddef_and_emit_config ( int emit_flags, char ** config ) {
2819
2820 check_default_instance_id("yac_cenddef");
2822 default_instance_id, emit_flags, config);
2823}
2824
2825/* ----------------------------------------------------------------------
2826 query functions
2827 ----------------------------------------------------------------------*/
2828
2829int yac_cget_field_id_instance(int yac_instance_id, const char* comp_name,
2830 const char* grid_name, const char* field_name){
2831 struct yac_instance * instance =
2832 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2833 struct coupling_field* cpl_field =
2834 yac_instance_get_field(instance, comp_name, grid_name, field_name);
2835 YAC_ASSERT_F(cpl_field != NULL,
2836 "ERROR(yac_cget_field_id_instance): "
2837 "no field '%s' defined on the local process for "
2838 "component '%s' and grid '%s'", field_name, comp_name, grid_name);
2839 return yac_lookup_pointer(cpl_field);
2840}
2841
2842int yac_cget_field_id(const char* comp_name, const char* grid_name, const char* field_name){
2843 check_default_instance_id("yac_cget_field_id");
2845 grid_name, field_name);
2846}
2847
2848/* ---------------------------------------------------------------------- */
2849
2850int yac_cget_nbr_comps_instance ( int yac_instance_id ) {
2851 struct yac_instance * instance =
2852 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2853 struct yac_couple_config * couple_config =
2855 return yac_couple_config_get_num_components(couple_config);
2856}
2857
2859 check_default_instance_id("yac_cget_nbr_comps");
2861}
2862
2863int yac_cget_nbr_grids_instance ( int yac_instance_id ) {
2864 struct yac_instance * instance =
2865 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2866 struct yac_couple_config * couple_config =
2868 return yac_couple_config_get_num_grids(couple_config);
2869}
2870
2872 check_default_instance_id("yac_cget_nbr_grids");
2874}
2875
2876int yac_cget_comp_nbr_grids_instance ( int yac_instance_id,
2877 const char* comp_name ) {
2878 struct yac_instance * instance =
2879 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2880 struct yac_couple_config * couple_config =
2882 YAC_ASSERT(comp_name != NULL,
2883 "ERROR(yac_cget_comp_grid_names_instance):"
2884 "Invalid comp_name. (NULL is not allowed)");
2885 int nbr_grids = 0;
2886 for(int i=0; i<yac_couple_config_get_num_grids(couple_config); ++i){
2887 const char* grid_name = yac_couple_config_get_grid_name(couple_config, i);
2888 if (yac_cget_nbr_fields_instance(yac_instance_id, comp_name, grid_name) > 0)
2889 nbr_grids++;
2890 }
2891 return nbr_grids;
2892}
2893
2894int yac_cget_comp_nbr_grids ( const char* comp_name ){
2895 check_default_instance_id("yac_cget_comp_nbr_grids");
2897}
2898
2899int yac_cget_nbr_fields_instance ( int yac_instance_id, const char* comp_name,
2900 const char* grid_name) {
2901 struct yac_instance * instance =
2902 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2903 struct yac_couple_config * couple_config =
2905 size_t comp_idx = yac_couple_config_get_component_idx(couple_config, comp_name);
2906 int nbr_fields = 0;
2907 size_t nbr_comp_fields =
2908 yac_couple_config_get_num_fields(couple_config, comp_idx);
2909 for(size_t field_idx=0; field_idx<nbr_comp_fields; ++field_idx)
2910 if(yac_couple_config_field_is_valid(couple_config, comp_idx, field_idx) &&
2911 !strcmp(
2912 grid_name,
2914 couple_config, comp_idx, field_idx)))
2915 nbr_fields++;
2916 return nbr_fields;
2917}
2918
2919int yac_cget_nbr_fields ( const char* comp_name, const char* grid_name ) {
2920 check_default_instance_id("yac_cget_nbr_fields");
2921 return yac_cget_nbr_fields_instance(default_instance_id, comp_name, grid_name);
2922}
2923
2924void yac_cget_comp_names_instance ( int yac_instance_id, int nbr_comps,
2925 const char ** comp_names ) {
2926 struct yac_instance * instance =
2927 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2928 struct yac_couple_config * couple_config =
2930 for(size_t i=0;i<nbr_comps;++i) {
2931 comp_names[i] = yac_couple_config_get_component_name(couple_config, i);
2932 }
2933}
2934
2935void yac_cget_comp_names ( int nbr_comps, const char ** comp_names ) {
2936 check_default_instance_id("yac_cget_comp_names");
2938 comp_names );
2939}
2940
2941void yac_cget_grid_names_instance ( int yac_instance_id,
2942 int nbr_grids, const char ** grid_names ) {
2943 struct yac_instance * instance =
2944 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2945 struct yac_couple_config * couple_config =
2947 for(size_t i=0; i<nbr_grids; ++i){
2948 grid_names[i] = yac_couple_config_get_grid_name(couple_config, i);
2949 }
2950}
2951
2952void yac_cget_grid_names ( int nbr_grids, const char ** grid_names ) {
2953 check_default_instance_id("yac_cget_grid_names");
2954 yac_cget_grid_names_instance(default_instance_id, nbr_grids, grid_names);
2955}
2956
2957void yac_cget_comp_grid_names_instance ( int yac_instance_id, const char* comp_name,
2958 int nbr_grids, const char ** grid_names ) {
2959 struct yac_instance * instance =
2960 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2961 struct yac_couple_config * couple_config =
2963 size_t idx = 0;
2964 YAC_ASSERT(comp_name != NULL,
2965 "ERROR(yac_cget_comp_grid_names_instance):"
2966 "Invalid comp_name. (NULL is not allowed)");
2967 for(size_t i=0; i<yac_couple_config_get_num_grids(couple_config); ++i){
2968 const char* grid_name = yac_couple_config_get_grid_name(couple_config, i);
2969 if (yac_cget_nbr_fields_instance(yac_instance_id, comp_name, grid_name) > 0){
2970 grid_names[idx] = grid_name;
2971 idx++;
2972 }
2973 }
2974}
2975
2976void yac_cget_comp_grid_names ( const char* comp_name, int nbr_grids,
2977 const char ** grid_names ) {
2978 check_default_instance_id("yac_cget_grid_names");
2979 yac_cget_comp_grid_names_instance(default_instance_id, comp_name, nbr_grids, grid_names);
2980}
2981
2982void yac_cget_field_names_instance ( int yac_instance_id,
2983 const char * comp_name, const char* grid_name,
2984 int nbr_fields, const char ** field_names ) {
2985 struct yac_instance * instance =
2986 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
2987 struct yac_couple_config * couple_config =
2989 size_t comp_idx = yac_couple_config_get_component_idx(couple_config, comp_name);
2990
2991 size_t nbr_comp_fields =
2992 yac_couple_config_get_num_fields(couple_config, comp_idx);
2993
2994 for(size_t field_idx=0; field_idx<nbr_comp_fields; ++field_idx) {
2995 if(yac_couple_config_field_is_valid(couple_config, comp_idx, field_idx) &&
2996 !strcmp(
2997 grid_name,
2999 couple_config, comp_idx, field_idx))) {
3000 *field_names =
3002 couple_config, comp_idx, field_idx);
3003 field_names++;
3004 }
3005 }
3006}
3007
3008void yac_cget_field_names ( const char* comp_name, const char* grid_name,
3009 int nbr_fields, const char ** field_names ) {
3010 check_default_instance_id("yac_cget_field_names");
3012 comp_name, grid_name, nbr_fields, field_names );
3013}
3014
3015const char* yac_cget_component_name_from_field_id ( int field_id ) {
3016 struct coupling_field * field =
3017 yac_unique_id_to_pointer(field_id, "field_id");
3018 YAC_ASSERT(field != NULL, "ERROR: field ID not defined!");
3020}
3021
3022const char* yac_cget_grid_name_from_field_id ( int field_id ) {
3023 struct coupling_field * field =
3024 yac_unique_id_to_pointer(field_id, "field_id");
3025 YAC_ASSERT(field != NULL, "ERROR: field ID not defined!");
3027 return yac_basic_grid_get_name(grid);
3028}
3029
3030const char* yac_cget_field_name_from_field_id ( int field_id ) {
3031 struct coupling_field * field =
3032 yac_unique_id_to_pointer(field_id, "field_id");
3033 YAC_ASSERT(field != NULL, "ERROR: field ID not defined!");
3034 return yac_get_coupling_field_name(field);
3035}
3036
3037const char* yac_cget_timestep_from_field_id ( int field_id ){
3038 struct coupling_field * field =
3039 yac_unique_id_to_pointer(field_id, "field_id");
3040 YAC_ASSERT(field != NULL, "ERROR: field ID not defined!");
3041 return yac_get_coupling_field_timestep(field);
3042}
3043
3045 struct coupling_field * field =
3046 yac_unique_id_to_pointer(field_id, "field_id");
3047 YAC_ASSERT(field != NULL, "ERROR: field ID not defined!");
3049}
3050
3051int yac_cget_role_from_field_id ( int field_id ){
3052 struct coupling_field * field =
3053 yac_unique_id_to_pointer(field_id, "field_id");
3054 YAC_ASSERT(field != NULL, "ERROR: field ID not defined!");
3056}
3057
3058/* ---------------------------------------------------------------------- */
3059
3061 int yac_instance_id, const char* comp_name, const char* grid_name,
3062 const char* field_name ) {
3063 struct yac_instance * instance =
3064 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
3065 struct yac_couple_config * couple_config =
3067 return
3069 couple_config, comp_name, grid_name, field_name);
3070}
3071
3072const char* yac_cget_field_timestep ( const char* comp_name, const char* grid_name,
3073 const char* field_name ) {
3074 check_default_instance_id("yac_cget_field_timestep");
3076 grid_name, field_name);
3077}
3078
3080 int yac_instance_id, const char* comp_name, const char* grid_name,
3081 const char* field_name) {
3082 struct yac_instance * instance =
3083 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
3084 return
3087 comp_name, grid_name, field_name);
3088}
3089
3091 const char* comp_name, const char* grid_name, const char* field_name ) {
3092 struct yac_instance * instance =
3093 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
3094 return
3097 comp_name, grid_name, field_name);
3098}
3099
3101 const char* comp_name, const char* grid_name, const char* field_name) {
3102 check_default_instance_id("yac_cget_field_frac_mask_fallback_value");
3103 return
3105 default_instance_id, comp_name, grid_name, field_name);
3106}
3107
3108int yac_cget_field_collection_size ( const char* comp_name,
3109 const char* grid_name, const char* field_name ) {
3110 check_default_instance_id("yac_cget_field_collection_size");
3112 grid_name, field_name);
3113}
3114
3115int yac_cget_field_role_instance ( int yac_instance_id, const char* comp_name,
3116 const char* grid_name, const char* field_name ) {
3117 struct yac_instance * instance =
3118 yac_unique_id_to_pointer(yac_instance_id, "yac_instance_id");
3119 struct yac_couple_config * couple_config =
3121 return
3123 couple_config, comp_name, grid_name, field_name);
3124}
3125
3126int yac_cget_field_role ( const char* comp_name, const char* grid_name,
3127 const char* field_name ) {
3128 check_default_instance_id("yac_cget_field_role");
3130 grid_name, field_name);
3131}
3132
3133/* ---------------------------------------------------------------------- */
3134
3136 const char * grid_name, int nbr_vertices[2], int cyclic[2],
3137 double *x_vertices, double *y_vertices, int *grid_id) {
3138
3139 size_t nbr_vertices_size_t[2] =
3140 {(size_t)nbr_vertices[0], (size_t)nbr_vertices[1]};
3141
3142 check_x_vertices(x_vertices, nbr_vertices[0], "yac_cdef_grid_reg2d");
3143 check_y_vertices(y_vertices, nbr_vertices[1], "yac_cdef_grid_reg2d");
3144
3145 *grid_id =
3148 nbr_vertices_size_t, cyclic, x_vertices, y_vertices));
3149}
3150
3151/* ---------------------------------------------------------------------- */
3152
3154 const char * grid_name, int nbr_vertices[2], int cyclic[2],
3155 double *x_vertices, double *y_vertices, int *grid_id) {
3156
3157 size_t nbr_vertices_size_t[2] =
3158 {(size_t)nbr_vertices[0], (size_t)nbr_vertices[1]};
3159
3160 check_x_vertices(x_vertices, nbr_vertices[0], "yac_cdef_grid_curve2d");
3161 check_y_vertices(y_vertices, nbr_vertices[1], "yac_cdef_grid_curve2d");
3162
3163 *grid_id =
3166 nbr_vertices_size_t, cyclic, x_vertices, y_vertices));
3167}
3168
3169/* ---------------------------------------------------------------------- */
3170
3172 const char * grid_name, int nbr_vertices,
3173 int nbr_cells, int *num_vertices_per_cell, double *x_vertices,
3174 double *y_vertices, int *cell_to_vertex, int *grid_id) {
3175
3176 check_x_vertices(x_vertices, nbr_vertices, "yac_cdef_grid_unstruct");
3177 check_y_vertices(y_vertices, nbr_vertices, "yac_cdef_grid_unstruct");
3178
3179 *grid_id =
3181 grid_name,
3183 (size_t)nbr_vertices, (size_t)nbr_cells, num_vertices_per_cell,
3184 x_vertices, y_vertices, cell_to_vertex));
3185}
3186
3187/* ---------------------------------------------------------------------- */
3188
3190 const char * grid_name, int nbr_vertices,
3191 int nbr_cells, int *num_vertices_per_cell, double *x_vertices,
3192 double *y_vertices, int *cell_to_vertex, int *grid_id) {
3193
3194 check_x_vertices(x_vertices, nbr_vertices, "yac_cdef_grid_unstruct_ll");
3195 check_y_vertices(y_vertices, nbr_vertices, "yac_cdef_grid_unstruct_ll");
3196
3197 *grid_id =
3199 grid_name,
3201 (size_t)nbr_vertices, (size_t)nbr_cells, num_vertices_per_cell,
3202 x_vertices, y_vertices, cell_to_vertex));
3203}
3204
3205/* ---------------------------------------------------------------------- */
3206
3208 int const * global_index, int location, int grid_id) {
3209
3210 struct yac_basic_grid_data * grid_data =
3212
3213 yac_int ** grid_global_ids;
3214 size_t count;
3215
3216 YAC_ASSERT(
3217 (location == YAC_LOC_CELL) ||
3218 (location == YAC_LOC_CORNER) ||
3219 (location == YAC_LOC_EDGE),
3220 "ERROR(yac_cset_global_index): invalid location")
3221 switch (location) {
3222 case (YAC_LOC_CELL): {
3223 grid_global_ids = &(grid_data->cell_ids);
3224 count = grid_data->num_cells;
3225 break;
3226 }
3227 case (YAC_LOC_CORNER): {
3228 grid_global_ids = &(grid_data->vertex_ids);
3229 count = grid_data->num_vertices;
3230 break;
3231 }
3232 default:
3233 case (YAC_LOC_EDGE): {
3234 grid_global_ids = &(grid_data->edge_ids);
3235 count = grid_data->num_edges;
3236 break;
3237 }
3238 }
3239
3240 size_t global_ids_size = count * sizeof(**grid_global_ids);
3241 if (*grid_global_ids == NULL) *grid_global_ids = xmalloc(global_ids_size);
3242 for (size_t i = 0; i < count; ++i)
3243 (*grid_global_ids)[i] = (yac_int)(global_index[i]);
3244}
3245
3246/* ---------------------------------------------------------------------- */
3247
3249 int const * is_core, int location, int grid_id) {
3250
3251 struct yac_basic_grid_data * grid_data =
3253
3254 int ** grid_core_mask;
3255 size_t count;
3256
3257 YAC_ASSERT(
3258 (location == YAC_LOC_CELL) ||
3259 (location == YAC_LOC_CORNER) ||
3260 (location == YAC_LOC_EDGE),
3261 "ERROR(yac_cset_core_mask): invalid location")
3262 switch (location) {
3263 case (YAC_LOC_CELL): {
3264 grid_core_mask = &(grid_data->core_cell_mask);
3265 count = grid_data->num_cells;
3266 break;
3267 }
3268 case (YAC_LOC_CORNER): {
3269 grid_core_mask = &(grid_data->core_vertex_mask);
3270 count = grid_data->num_vertices;
3271 break;
3272 }
3273 default:
3274 case (YAC_LOC_EDGE): {
3275 grid_core_mask = &(grid_data->core_edge_mask);
3276 count = grid_data->num_edges;
3277 break;
3278 }
3279 }
3280
3281 size_t core_mask_size = count * sizeof(**grid_core_mask);
3282 if (*grid_core_mask == NULL) *grid_core_mask = xmalloc(core_mask_size);
3283 memcpy(*grid_core_mask, is_core, core_mask_size);
3284}
3285
3286/* ---------------------------------------------------------------------- */
3287
3288size_t yac_get_grid_size ( int located, int grid_id ) {
3289
3290 struct yac_basic_grid * grid =
3291 yac_unique_id_to_pointer(grid_id, "grid_id");
3292 enum yac_location location = yac_get_location(located);
3293
3294 return yac_basic_grid_get_data_size(grid, location);
3295}
3296
3297/* ---------------------------------------------------------------------- */
3298
3299size_t yac_get_points_size ( int points_id ) {
3300
3302 yac_unique_id_to_pointer(points_id, "points_id");
3303 struct yac_basic_grid * grid = points->grid;
3304 enum yac_location location = points->location;
3305
3306 return yac_basic_grid_get_data_size(grid, location);
3307}
3308
3309/* ---------------------------------------------------------------------- */
3310
3324
3325void yac_cfree_interp_stack_config(int interp_stack_config_id) {
3326
3327 struct yac_interp_stack_config * interp_stack_config =
3329 interp_stack_config_id, "interp_stack_config_id");
3330 yac_interp_stack_config_delete(interp_stack_config);
3331
3332 int flag = 0;
3333 for (size_t i = 0; i < num_interp_stack_configs; ++i) {
3334 if (interp_stack_configs[i] == interp_stack_config)
3335 interp_stack_configs[i] = NULL;
3336 flag |= (interp_stack_configs[i] != NULL);
3337 }
3338 if (!flag) {
3340 interp_stack_configs = NULL;
3342 }
3343}
3344
3346 int interp_stack_config_id,
3347 int reduction_type, int partial_coverage) {
3348
3349 struct yac_interp_stack_config * interp_stack_config =
3351 interp_stack_config_id, "interp_stack_config_id");
3352
3353 YAC_ASSERT(
3354 (reduction_type == YAC_INTERP_AVG_ARITHMETIC) ||
3355 (reduction_type == YAC_INTERP_AVG_DIST) ||
3356 (reduction_type == YAC_INTERP_AVG_BARY),
3357 "ERROR(yac_add_interp_stack_config_average): invalid reduction type")
3358
3360 interp_stack_config, (enum yac_interp_avg_weight_type)reduction_type,
3361 partial_coverage);
3362}
3363
3365 int interp_stack_config_id,
3366 int weight_type, int partial_coverage) {
3367
3368 struct yac_interp_stack_config * interp_stack_config =
3370 interp_stack_config_id, "interp_stack_config_id");
3371
3372 YAC_ASSERT(
3373 (weight_type == YAC_INTERP_NCC_AVG) ||
3374 (weight_type == YAC_INTERP_NCC_DIST),
3375 "ERROR(yac_add_interp_stack_config_ncc): invalid reduction type")
3376
3378 interp_stack_config, (enum yac_interp_ncc_weight_type)weight_type,
3379 partial_coverage);
3380}
3381
3383 int interp_stack_config_id,
3384 int type, size_t n, double scale) {
3385
3386 struct yac_interp_stack_config * interp_stack_config =
3388 interp_stack_config_id, "interp_stack_config_id");
3389
3390 YAC_ASSERT(
3391 (type == YAC_INTERP_NNN_AVG) ||
3394 (type == YAC_INTERP_NNN_RBF) ||
3396 "ERROR(yac_add_interp_stack_config_nnn): invalid weightening type")
3397
3399 interp_stack_config, (enum yac_interp_nnn_weight_type)type, n, scale);
3400}
3401
3403 int interp_stack_config_id, int order, int enforced_conserv,
3404 int partial_coverage, int normalisation) {
3405
3406 struct yac_interp_stack_config * interp_stack_config =
3408 interp_stack_config_id, "interp_stack_config_id");
3409
3410 YAC_ASSERT(
3411 (normalisation == YAC_INTERP_CONSERV_DESTAREA) ||
3412 (normalisation == YAC_INTERP_CONSERV_FRACAREA),
3413 "ERROR(yac_add_interp_stack_config_conservative):"
3414 "invalid normalisation type")
3415
3417 interp_stack_config, order, enforced_conserv, partial_coverage,
3418 (enum yac_interp_method_conserv_normalisation)normalisation);
3419}
3420
3422 int interp_stack_config_id, double spread_distance,
3423 double max_search_distance, int weight_type) {
3424
3425 struct yac_interp_stack_config * interp_stack_config =
3427 interp_stack_config_id, "interp_stack_config_id");
3428
3429 YAC_ASSERT(
3430 (weight_type == YAC_INTERP_SPMAP_AVG) ||
3431 (weight_type == YAC_INTERP_SPMAP_DIST),
3432 "ERROR(yac_add_interp_stack_config_spmap):"
3433 "invalid weightening type")
3434
3436 interp_stack_config, spread_distance, max_search_distance,
3437 (enum yac_interp_spmap_weight_type)weight_type);
3438}
3439
3440void yac_cadd_interp_stack_config_hcsbb(int interp_stack_config_id) {
3441
3442 struct yac_interp_stack_config * interp_stack_config =
3444 interp_stack_config_id, "interp_stack_config_id");
3445
3446 yac_interp_stack_config_add_hcsbb(interp_stack_config);
3447}
3448
3450 int interp_stack_config_id, char const * filename, char const * src_grid_name,
3451 char const * tgt_grid_name) {
3452
3453 struct yac_interp_stack_config * interp_stack_config =
3455 interp_stack_config_id, "interp_stack_config_id");
3456
3458 interp_stack_config, filename, src_grid_name,
3459 tgt_grid_name);
3460}
3461
3463 int interp_stack_config_id, double value) {
3464
3465 struct yac_interp_stack_config * interp_stack_config =
3467 interp_stack_config_id, "interp_stack_config_id");
3468
3469 yac_interp_stack_config_add_fixed(interp_stack_config, value);
3470}
3471
3473 int interp_stack_config_id, char const * constructor_key,
3474 char const * do_search_key) {
3475
3476 struct yac_interp_stack_config * interp_stack_config =
3478 interp_stack_config_id, "interp_stack_config_id");
3479
3481 interp_stack_config, constructor_key, do_search_key);
3482}
3483
3485 int interp_stack_config_id, int creep_distance) {
3486
3487 struct yac_interp_stack_config * interp_stack_config =
3489 interp_stack_config_id, "interp_stack_config_id");
3490
3491 yac_interp_stack_config_add_creep(interp_stack_config, creep_distance);
3492}
3493
3495 int interp_stack_config_id, char const * func_compute_weights_key) {
3496
3497 struct yac_interp_stack_config * interp_stack_config =
3499 interp_stack_config_id, "interp_stack_config_id");
3500
3502 interp_stack_config, func_compute_weights_key);
3503}
3504
3505/* ---------------------------------------------------------------------- */
3506
3508 yac_func_compute_weights compute_weights_callback,
3509 void * user_data, char const * key) {
3510
3512 compute_weights_callback, user_data, key);
3513}
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
Definition basic_grid.c:45
struct yac_basic_grid_data * yac_basic_grid_get_data(struct yac_basic_grid *grid)
Definition basic_grid.c:132
size_t yac_basic_grid_add_mask(struct yac_basic_grid *grid, enum yac_location location, int const *mask, size_t count, char const *mask_name)
Definition basic_grid.c:279
size_t yac_basic_grid_add_coordinates_nocpy(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates)
Definition basic_grid.c:203
char const * yac_basic_grid_get_name(struct yac_basic_grid *grid)
Definition basic_grid.c:123
size_t yac_basic_grid_get_data_size(struct yac_basic_grid *grid, enum yac_location location)
Definition basic_grid.c:142
void yac_basic_grid_delete(struct yac_basic_grid *grid)
Definition basic_grid.c:65
struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
Definition grid_reg2d.c:65
struct yac_basic_grid_data yac_generate_basic_grid_data_unstruct_ll(size_t nbr_vertices, size_t nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex)
struct yac_basic_grid_data yac_generate_basic_grid_data_curve_2d(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
struct yac_basic_grid_data yac_generate_basic_grid_data_unstruct(size_t nbr_vertices, size_t nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex)
int YAC_YAML_EMITTER_JSON
emit to JSON format
Definition config_yaml.c:35
void yac_yaml_read_coupling(struct yac_couple_config *couple_config, const char *yaml_filename, int parse_flags)
int YAC_YAML_PARSER_DEFAULT
default parse flags (YAML format)
Definition config_yaml.c:36
int YAC_YAML_PARSER_JSON_FORCE
assume JSON format
Definition config_yaml.c:38
int YAC_YAML_EMITTER_DEFAULT
emit to YAML format
Definition config_yaml.c:34
char const * yac_time_to_ISO(char const *time, enum yac_time_unit_type time_unit)
Definition event.c:329
@ COUPLING
Definition config_yaml.c:71
void yac_couple_config_grid_set_metadata(struct yac_couple_config *couple_config, char const *grid_name, const char *metadata)
int yac_couple_config_field_is_valid(struct yac_couple_config *couple_config, size_t component_idx, size_t field_idx)
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)
size_t yac_couple_config_get_num_fields(struct yac_couple_config *couple_config, size_t component_idx)
char const * yac_couple_config_get_field_timestep(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
int yac_couple_config_get_field_role(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
void yac_couple_config_field_set_metadata(struct yac_couple_config *couple_config, const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
char const * yac_couple_config_get_field_name(struct yac_couple_config *couple_config, size_t component_idx, size_t field_idx)
void yac_couple_config_component_set_metadata(struct yac_couple_config *couple_config, char const *comp_name, const char *metadata)
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)
const char * yac_couple_config_field_get_metadata(struct yac_couple_config *couple_config, const char *comp_name, const char *grid_name, const char *field_name)
const char * yac_couple_config_grid_get_metadata(struct yac_couple_config *couple_config, const char *grid_name)
const char * yac_couple_config_component_get_metadata(struct yac_couple_config *couple_config, const char *comp_name)
size_t yac_couple_config_get_component_idx(struct yac_couple_config *couple_config, char const *component_name)
char const * yac_couple_config_get_grid_name(struct yac_couple_config *couple_config, size_t grid_idx)
char const * yac_couple_config_get_component_name(struct yac_couple_config *couple_config, size_t component_idx)
size_t yac_couple_config_get_num_grids(struct yac_couple_config *couple_config)
char const * yac_couple_config_get_field_grid_name(struct yac_couple_config *couple_config, size_t component_idx, size_t field_idx)
size_t yac_couple_config_get_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_components(struct yac_couple_config *couple_config)
@ TIME_NONE
@ TIME_ACCUMULATE
@ TIME_MAXIMUM
@ TIME_MINIMUM
@ TIME_AVERAGE
yac_time_unit_type
@ C_SECOND
@ C_HOUR
@ C_DAY
@ C_MILLISECOND
@ C_MINUTE
@ C_MONTH
@ C_ISO_FORMAT
@ C_YEAR
int yac_get_event_time_operation(struct event *event)
Definition event.c:284
enum yac_action_type yac_event_check(struct event *event)
Definition event.c:171
void yac_event_update(struct event *event)
Definition event.c:159
yac_action_type
Definition event.h:17
@ REDUCTION
Definition event.h:19
@ RESTART
Definition event.h:21
@ OUT_OF_BOUND
Definition event.h:26
@ GET_FOR_CHECKPOINT
Definition event.h:24
@ NONE
Definition event.h:18
@ PUT_FOR_RESTART
Definition event.h:23
@ GET_FOR_RESTART
Definition event.h:22
@ PUT_FOR_CHECKPOINT
Definition event.h:25
unsigned yac_get_coupling_field_collection_size(struct coupling_field *field)
Definition fields.c:86
const char * yac_get_coupling_field_timestep(struct coupling_field *field)
Definition fields.c:91
unsigned yac_get_coupling_field_num_puts(struct coupling_field *field)
Definition fields.c:434
char const * yac_get_coupling_field_comp_name(struct coupling_field *field)
Definition fields.c:119
int yac_get_coupling_field_put_op_time_accumulation_count(struct coupling_field *field, unsigned put_idx)
Definition fields.c:409
double *** yac_get_coupling_field_put_op_send_frac_mask_acc(struct coupling_field *field, unsigned put_idx)
Definition fields.c:205
struct yac_basic_grid * yac_coupling_field_get_basic_grid(struct coupling_field *field)
Definition fields.c:113
size_t yac_coupling_field_get_num_interp_fields(struct coupling_field *field)
Definition fields.c:96
struct yac_interpolation * yac_get_coupling_field_put_op_interpolation(struct coupling_field *field, unsigned put_idx)
Definition fields.c:397
enum yac_location yac_get_coupling_field_get_interp_field_location(struct coupling_field *field, size_t interp_field_idx)
Definition fields.c:102
struct event * yac_get_coupling_field_get_op_event(struct coupling_field *field)
Definition fields.c:442
size_t yac_coupling_field_get_data_size(struct coupling_field *field, enum yac_location location)
Definition fields.c:136
struct yac_interp_field const * yac_coupling_field_get_interp_fields(struct coupling_field *cpl_field)
Definition fields.c:505
int * yac_get_coupling_field_get_mask(struct coupling_field *field)
Definition fields.c:306
struct event * yac_get_coupling_field_put_op_event(struct coupling_field *field, unsigned put_idx)
Definition fields.c:385
char * yac_coupling_field_get_datetime(struct coupling_field *cpl_field)
Definition fields.c:511
void yac_init_coupling_field_put_op_send_field_acc(struct coupling_field *field, unsigned put_idx, double init_value)
Definition fields.c:343
struct yac_interpolation * yac_get_coupling_field_get_op_interpolation(struct coupling_field *field)
Definition fields.c:452
void yac_set_coupling_field_put_op_time_accumulation_count(struct coupling_field *field, unsigned put_idx, int count)
Definition fields.c:422
enum yac_field_exchange_type yac_get_coupling_field_exchange_type(struct coupling_field *field)
Definition fields.c:125
const char * yac_get_coupling_field_name(struct coupling_field *field)
Definition fields.c:108
int ** yac_get_coupling_field_put_mask(struct coupling_field *field)
Definition fields.c:261
void yac_init_coupling_field_put_op_send_frac_mask_acc(struct coupling_field *field, unsigned put_idx, double init_value)
Definition fields.c:364
double *** yac_get_coupling_field_put_op_send_field_acc(struct coupling_field *field, unsigned put_idx)
Definition fields.c:195
yac_field_exchange_type
Definition fields.h:13
@ SOURCE
Definition fields.h:15
@ TARGET
Definition fields.h:16
@ NOTHING
Definition fields.h:14
static void LLtoXYZ(double lon, double lat, double p_out[])
Definition geometry.h:287
void yac_instance_delete(struct yac_instance *instance)
Definition instance.c:1222
char * yac_instance_setup_and_emit_config(struct yac_instance *instance, int emit_flags)
Definition instance.c:1180
char * yac_instance_get_start_datetime(struct yac_instance *instance)
Definition instance.c:1262
char * yac_instance_get_end_datetime(struct yac_instance *instance)
Definition instance.c:1267
void yac_instance_def_datetime(struct yac_instance *instance, const char *start_datetime, const char *end_datetime)
Definition instance.c:1254
void yac_instance_sync_def(struct yac_instance *instance)
Definition instance.c:1149
struct yac_instance * yac_instance_new(MPI_Comm comm)
Definition instance.c:1197
int yac_instance_components_are_defined(struct yac_instance *instance)
Definition instance.c:1294
void yac_instance_setup(struct yac_instance *instance)
Definition instance.c:1157
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)
Definition instance.c:1299
void yac_instance_dummy_new(MPI_Comm comm)
Definition instance.c:1216
void yac_instance_def_components(struct yac_instance *instance, char const **comp_names, size_t num_comps)
Definition instance.c:1272
struct yac_couple_config * yac_instance_get_couple_config(struct yac_instance *instance)
Definition instance.c:1239
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)
Definition instance.c:1358
MPI_Comm yac_instance_get_comps_comm(struct yac_instance *instance, char const **comp_names, size_t num_comp_names)
Definition instance.c:1188
struct coupling_field * yac_instance_get_field(struct yac_instance *instance, const char *comp_name, const char *grid_name, const char *field_name)
Definition instance.c:1379
yac_interp_avg_weight_type
@ YAC_INTERP_AVG_DIST
@ YAC_INTERP_AVG_ARITHMETIC
@ YAC_INTERP_AVG_BARY
void * user_data
char * key
void yac_interp_method_callback_add_compute_weights_callback(yac_func_compute_weights compute_weights_callback, void *user_data, char const *key)
void(* yac_func_compute_weights)(double const tgt_coords[3], int src_cell_id, size_t src_cell_idx, int const **global_results_points, double **result_weights, size_t *result_count, void *user_data)
struct @8::@9 value
enum callback_type type
yac_interp_method_conserv_normalisation
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
yac_interp_ncc_weight_type
@ YAC_INTERP_NCC_DIST
distance weighted average of n source points
@ YAC_INTERP_NCC_AVG
average of n source points
yac_interp_nnn_weight_type
@ YAC_INTERP_NNN_GAUSS
distance with Gauss weights of n source points
@ YAC_INTERP_NNN_RBF
radial basis functions
@ YAC_INTERP_NNN_AVG
average of n source points
@ YAC_INTERP_NNN_DIST
distance weighted average of n source points
@ YAC_INTERP_NNN_ZERO
all weights are set to zero
yac_interp_spmap_weight_type
@ YAC_INTERP_SPMAP_AVG
@ YAC_INTERP_SPMAP_DIST
void yac_interp_stack_config_add_check(struct yac_interp_stack_config *interp_stack_config, char const *constructor_key, char const *do_search_key)
void yac_interp_stack_config_add_user_file(struct yac_interp_stack_config *interp_stack_config, char const *filename, char const *src_grid_name, char const *tgt_grid_name)
void yac_interp_stack_config_add_spmap(struct yac_interp_stack_config *interp_stack_config, double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type)
void yac_interp_stack_config_add_nnn(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_nnn_weight_type type, size_t n, double scale)
void yac_interp_stack_config_add_fixed(struct yac_interp_stack_config *interp_stack_config, double value)
void yac_interp_stack_config_add_hcsbb(struct yac_interp_stack_config *interp_stack_config)
void yac_interp_stack_config_add_average(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_avg_weight_type reduction_type, int partial_coverage)
void yac_interp_stack_config_add_creep(struct yac_interp_stack_config *interp_stack_config, int creep_distance)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
void yac_interp_stack_config_add_conservative(struct yac_interp_stack_config *interp_stack_config, int order, int enforced_conserv, int partial_coverage, enum yac_interp_method_conserv_normalisation normalisation)
void yac_interp_stack_config_add_ncc(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_ncc_weight_type weight_type, int partial_coverage)
void yac_interp_stack_config_add_user_callback(struct yac_interp_stack_config *interp_stack_config, char const *func_compute_weights_key)
struct yac_interp_stack_config * yac_interp_stack_config_new()
void yac_interpolation_execute(struct yac_interpolation *interp, double ***src_fields, double **tgt_field)
int yac_interpolation_with_frac_mask(struct yac_interpolation *interpolation)
int yac_interpolation_execute_put_test(struct yac_interpolation *interp)
void yac_interpolation_execute_wait(struct yac_interpolation *interp)
void yac_interpolation_execute_frac(struct yac_interpolation *interp, double ***src_fields, double ***src_frac_masks, double **tgt_field)
void yac_interpolation_execute_get(struct yac_interpolation *interp, double **tgt_field)
void yac_interpolation_execute_get_async(struct yac_interpolation *interp, double **tgt_field)
void yac_interpolation_execute_put_frac(struct yac_interpolation *interp, double ***src_fields, double ***src_frac_masks)
void yac_interpolation_execute_put(struct yac_interpolation *interp, double ***src_fields)
int yac_interpolation_execute_get_test(struct yac_interpolation *interp)
enum yac_location yac_get_location(int const location)
Definition location.c:44
yac_location
Definition location.h:10
@ YAC_LOC_CORNER
Definition location.h:13
@ YAC_LOC_EDGE
Definition location.h:14
@ YAC_LOC_CELL
Definition location.h:12
void yac_mpi_handshake(MPI_Comm comm, size_t n, char const **group_names, MPI_Comm *group_comms)
#define xrealloc(ptr, size)
Definition ppm_xfuncs.h:67
#define xmalloc(size)
Definition ppm_xfuncs.h:66
double *** send_field_acc
Definition fields.c:39
double *** send_frac_mask_acc
Definition fields.c:40
enum yac_field_exchange_type exchange_type
Definition fields.c:31
unsigned num_puts
Definition fields.c:42
size_t num_interp_fields
Definition fields.c:23
size_t collection_size
number of vertical levels or bundles
Definition fields.c:24
Definition event.c:18
enum yac_reduction_type time_operation
Definition event.c:24
enum yac_action_type action
Definition event.c:25
struct yac_instance * instance
enum yac_location location
struct yac_basic_grid * grid
enum yac_location location
struct yac_basic_grid * grid
enum yac_location location
Definition basic_grid.h:16
size_t coordinates_idx
Definition basic_grid.h:17
#define YAC_ASSERT_F(exp, format,...)
#define MAX(a, b)
#define YAC_ASSERT(exp, msg)
static char * yac_version
Definition version.h:7
int const YAC_YEAR_OF_365_DAYS
int const YAC_ACTION_PUT_FOR_CHECKPOINT
int const YAC_REDUCTION_TIME_AVERAGE
void yac_cenddef_and_emit_config(int emit_flags, char **config)
static int yac_lookup_pointer(void const *pointer)
#define NO_CHECK
void yac_cinit_comm_dummy(MPI_Comm comm)
void yac_cget_grid_names(int nbr_grids, const char **grid_names)
void yac_cadd_interp_stack_config_ncc(int interp_stack_config_id, int weight_type, int partial_coverage)
void yac_cget_ext_couple_config_scale_factor(int ext_couple_config_id, double *scale_factor)
const char * yac_cget_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cput_frac(int const field_id, int const collection_size, double ***const send_field, double ***const send_frac_mask, int *info, int *ierr)
int const YAC_NCC_AVG
#define SUM
static struct yac_interpolation * yac_cget_pre_processing(int const field_id, int collection_size, int *info, int *ierr)
size_t yac_get_points_size(int points_id)
void yac_cenddef(void)
static int yac_init(MPI_Comm comm)
static void get_send_field_pointers_ptr_(int const field_id, int const collection_size, double **send_field, double **send_frac_mask, double ****send_field_, double ****send_frac_mask_)
void yac_cenable_field_frac_mask(const char *comp_name, const char *grid_name, const char *field_name, double frac_mask_fallback_value)
int const YAC_ACTION_OUT_OF_BOUND
void yac_cget_ext_couple_config_mapping_side(int ext_couple_config_id, int *mapping_side)
static void get_send_field_pointers(int const field_id, int const collection_size, double *send_field, double *send_frac_mask, double ****send_field_, double ****send_frac_mask_)
void yac_cpredef_comp_instance(int yac_instance_id, char const *name, int *comp_id)
char * yac_cget_start_datetime_instance(int yac_instance_id)
void yac_cdef_field_mask(char const *name, int const comp_id, int const *point_ids, int const *mask_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_cset_global_index(int const *global_index, int location, int grid_id)
int const YAC_NNN_RBF
void yac_cdef_datetime_instance(int yac_instance_id, const char *start_datetime, const char *end_datetime)
int yac_cget_role_from_field_id(int field_id)
void yac_cget_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
int yac_cget_nbr_grids_instance(int yac_instance_id)
void yac_cfree_ext_couple_config(int ext_couple_config_id)
const char * yac_cget_grid_metadata_instance(int yac_instance_id, const char *grid_name)
char * yac_cget_end_datetime_instance(int yac_instance_id)
void yac_cdef_datetime(const char *start_datetime, const char *end_datetime)
void yac_cget_ext_couple_config_mask_name(int ext_couple_config_id, char const **tgt_mask_name)
void yac_get_comp_comm_f2c(int comp_id, MPI_Fint *comp_comm_f)
int const YAC_LOCATION_CELL
int const YAC_REDUCTION_TIME_MINIMUM
void yac_cset_ext_couple_config_tgt_mask_name(int ext_couple_config_id, char const *tgt_mask_name)
void yac_cdef_couple_custom_instance_(int yac_instance_id, 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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, struct yac_ext_couple_config *ext_couple_config)
static int user_input_data_add_mask(struct yac_basic_grid *grid, enum yac_location location, int const *is_valid, size_t nbr_points, char const *name)
void yac_cdef_grid_metadata(const char *grid_name, const char *metadata)
int const YAC_TIME_UNIT_MINUTE
void yac_cdef_grid_curve2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
void yac_cread_config_json(const char *yaml_filename)
void * yac_get_field_get_mask_c2f(int field_id)
void yac_cget_grid_names_instance(int yac_instance_id, int nbr_grids, const char **grid_names)
void yac_cset_ext_couple_config_scale_factor(int ext_couple_config_id, double scale_factor)
static void yac_free_masks()
int const YAC_NCC_DIST
int const YAC_ACTION_GET_FOR_CHECKPOINT
void yac_cadd_interp_stack_config_creep(int interp_stack_config_id, int creep_distance)
static void check_default_instance_id(char const *routine_name)
void yac_cput_frac_(int const field_id, int const collection_size, double *send_field, double *send_frac_mask, int *info, int *ierr)
void yac_cdef_component_metadata(const char *comp_name, const char *metadata)
int const YAC_TIME_UNIT_YEAR
static void yac_free_components()
void yac_cget_comps_comm_instance_f2c(int yac_instance_id, char const **comp_names, int num_comps, MPI_Fint *comps_comm_f)
void * yac_get_field_put_mask_c2f(int field_id)
int yac_cget_field_role(const char *comp_name, const char *grid_name, const char *field_name)
void yac_ccleanup()
int const YAC_AVG_ARITHMETIC
void yac_cadd_compute_weights_callback(yac_func_compute_weights compute_weights_callback, void *user_data, char const *key)
void yac_cmpi_handshake(MPI_Comm comm, size_t n, char const **group_names, MPI_Comm *group_comms)
int const YAC_REDUCTION_TIME_MAXIMUM
void yac_cset_ext_couple_config_scale_summand_(struct yac_ext_couple_config *ext_couple_config, double scale_summand)
int const YAC_TIME_UNIT_MILLISECOND
void yac_cexchange_frac(int const send_field_id, int const recv_field_id, int const collection_size, double ***const send_field, double ***const send_frac_mask, double **recv_field, int *send_info, int *recv_info, int *ierr)
int yac_cget_field_id_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
int yac_cget_comp_nbr_grids_instance(int yac_instance_id, const char *comp_name)
void yac_cdef_grid_unstruct_ll(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
const char * yac_cget_timestep_from_field_id(int field_id)
static struct user_input_data_component ** components
int yac_cget_nbr_fields(const char *comp_name, const char *grid_name)
#define ASSIGN
int const YAC_NNN_GAUSS
void yac_cinit_comm_dummy_f2c(MPI_Fint comm_f)
void yac_csync_def_instance(int yac_instance_id)
void yac_cset_ext_couple_config_src_mask_names_(struct yac_ext_couple_config *ext_couple_config, size_t num_src_mask_names, char const *const *src_mask_names)
static void cleanup()
void yac_cpredef_comp(char const *name, int *comp_id)
int yac_cyaml_get_emitter_flag_default_c2f()
void yac_csync_def(void)
static double ** get_recv_field_pointers(int const field_id, int const collection_size, double *recv_field)
int const YAC_TIME_UNIT_HOUR
void yac_cinit(void)
int const YAC_YEAR_OF_360_DAYS
void yac_cfinalize_instance(int yac_instance_id)
static struct user_input_data_masks ** masks
static void init_ext_couple_config(struct yac_ext_couple_config *ext_couple_config)
void yac_cfinalize()
const char * yac_cget_field_name_from_field_id(int field_id)
void yac_cadd_interp_stack_config_check(int interp_stack_config_id, char const *constructor_key, char const *do_search_key)
void yac_cenddef_instance(int yac_instance_id)
void yac_cset_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t num_src_mask_names, char const *const *src_mask_names)
int yac_cget_nbr_comps_instance(int yac_instance_id)
int yac_cget_nbr_fields_instance(int yac_instance_id, const char *comp_name, const char *grid_name)
void yac_cget_ext_couple_config(int *ext_couple_config_id)
static size_t num_masks
static void yac_get(int const field_id, int collection_size, double **recv_field, int is_async, int *info, int *ierr)
size_t num_grids
void yac_cdef_grid_metadata_instance(int yac_instance_id, const char *grid_name, const char *metadata)
void yac_cset_ext_couple_config_weight_file(int ext_couple_config_id, char const *weight_file)
const char * yac_cget_component_metadata_instance(int yac_instance_id, const char *comp_name)
void yac_cread_config_yaml_instance(int yac_instance_id, const char *yaml_filename)
static struct user_input_data_component * get_user_input_data_component(int comp_id, char const *routine)
int const YAC_LOCATION_CORNER
void yac_cdef_couple_custom(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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, int ext_couple_config_id)
const char * yac_cget_field_timestep_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cset_ext_couple_config_scale_summand(int ext_couple_config_id, double scale_summand)
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
const char * yac_cget_field_datetime(int field_id)
int const YAC_SPMAP_AVG
int const YAC_CONSERV_DESTAREA
void yac_cget(int const field_id, int collection_size, double **recv_field, int *info, int *ierr)
static size_t num_components
size_t yac_get_grid_size(int located, int grid_id)
int const YAC_EXCHANGE_TYPE_SOURCE
void yac_cdef_comp_instance(int yac_instance_id, char const *comp_name, int *comp_id)
void yac_cupdate(int field_id)
void yac_cget_action(int field_id, int *action)
static void yac_free_interp_stack_configs()
void yac_cexchange_(int const send_field_id, int const recv_field_id, int const collection_size, double *send_field, double *recv_field, int *send_info, int *recv_info, int *ierr)
int const YAC_REDUCTION_TIME_ACCUMULATE
int yac_cget_field_id(const char *comp_name, const char *grid_name, const char *field_name)
void yac_cget_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t *num_src_mask_names, char const *const **src_mask_names)
const char * yac_cget_grid_name_from_field_id(int field_id)
int yac_cget_collection_size_from_field_id(int field_id)
void yac_cdef_grid_reg2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
void yac_cmpi_handshake_f2c(MPI_Fint comm, int n, char const **group_names, MPI_Fint *group_comms)
int const YAC_EXCHANGE_TYPE_NONE
void yac_cdef_couple_custom_instance(int yac_instance_id, 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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, int ext_couple_config_id)
static int yac_pointer_to_unique_id(void *pointer)
void check_mpi_initialised(char const *routine_name)
void yac_cdef_points_reg2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
void yac_cget_comps_comm(const char **comp_names, int num_comps, MPI_Comm *comps_comm)
void yac_cexchange_ptr_(int const send_field_id, int const recv_field_id, int const collection_size, double **send_field, double **recv_field, int *send_info, int *recv_info, int *ierr)
void yac_cinit_comm_instance(MPI_Comm comm, int *yac_instance_id)
void yac_cadd_interp_stack_config_nnn(int interp_stack_config_id, int type, size_t n, double scale)
static struct user_input_data_points ** points
int const YAC_EXCHANGE_TYPE_TARGET
void yac_cread_config_json_instance(int yac_instance_id, const char *yaml_filename)
void yac_cset_ext_couple_config_scale_factor_(struct yac_ext_couple_config *ext_couple_config, double scale_factor)
const char * yac_cget_grid_metadata(const char *grid_name)
void yac_cenable_field_frac_mask_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, double frac_mask_fallback_value)
char * yac_cget_start_datetime(void)
void yac_ccheck_field_dimensions(int field_id, int collection_size, int num_interp_fields, int const *interp_field_sizes)
int const YAC_TIME_UNIT_MONTH
int const YAC_TIME_UNIT_SECOND
int const YAC_ACTION_RESTART
void yac_cadd_interp_stack_config_conservative(int interp_stack_config_id, int order, int enforced_conserv, int partial_coverage, int normalisation)
void yac_cput_frac_ptr_(int const field_id, int const collection_size, double **send_field, double **send_frac_mask, int *info, int *ierr)
void yac_cset_ext_couple_config_mapping_side_(struct yac_ext_couple_config *ext_couple_config, int mapping_side)
static void yac_free_points()
void yac_cdef_grid_unstruct(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
static int yac_instance_count
void yac_cexchange(int const send_field_id, int const recv_field_id, int const collection_size, double ***const send_field, double **recv_field, int *send_info, int *recv_info, int *ierr)
void yac_cdef_points_unstruct(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
char * yac_cget_version(void)
static int pointer_lookup_table_size
int const YAC_LOCATION_EDGE
void yac_cput(int const field_id, int const collection_size, double ***const send_field, int *info, int *ierr)
void yac_cget_async(int const field_id, int collection_size, double **recv_field, int *info, int *ierr)
void yac_cread_config_yaml(const char *yaml_filename)
void yac_cset_ext_couple_config_weight_file_(struct yac_ext_couple_config *ext_couple_config, char const *weight_file)
int yac_cget_default_instance_id()
static size_t num_interp_stack_configs
void yac_cadd_interp_stack_config_spmap(int interp_stack_config_id, double spread_distance, double max_search_distance, int weight_type)
void yac_cexchange_frac_(int const send_field_id, int const recv_field_id, int const collection_size, double *send_field, double *send_frac_mask, double *recv_field, int *send_info, int *recv_info, int *ierr)
const char * yac_cget_component_name_from_field_id(int field_id)
void yac_cinit_comm_instance_f2c(MPI_Fint comm, int *yac_instance_id)
#define AGGREGATE(EXTRA_CHECK, ACCU_OP)
int yac_cget_field_collection_size(const char *comp_name, const char *grid_name, const char *field_name)
void yac_cdef_component_metadata_instance(int yac_instance_id, const char *comp_name, const char *metadata)
void yac_cdef_couple_(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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, char const *weight_file, int mapping_side, double scale_factor, double scale_summand, int num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name)
void yac_cenddef_and_emit_config_instance(int yac_instance_id, int emit_flags, char **config)
void yac_cexchange_frac_ptr_(int const send_field_id, int const recv_field_id, int const collection_size, double **send_field, double **send_frac_mask, double **recv_field, int *send_info, int *recv_info, int *ierr)
char * yac_cget_end_datetime(void)
int const YAC_ACTION_NONE
int yac_cyaml_get_emitter_flag_json_c2f()
void yac_cdef_calendar(int calendar)
void yac_cset_core_mask(int const *is_core, int location, int grid_id)
void yac_cinit_comm_f2c(MPI_Fint comm_f)
void yac_cwait(int field_id)
void yac_cdef_couple_instance_(int yac_instance_id, 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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, char const *weight_file, int mapping_side, double scale_factor, double scale_summand, int num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name)
void yac_cget_comp_names(int nbr_comps, const char **comp_names)
static int yac_add_grid(const char *grid_name, struct yac_basic_grid_data grid_data)
void yac_cdef_comps(char const **comp_names, int num_comps, int *comp_ids)
const char * yac_cget_field_metadata(const char *comp_name, const char *grid_name, const char *field_name)
int const YAC_ACTION_REDUCTION
int const YAC_ACTION_GET_FOR_RESTART
void yac_cput_(int const field_id, int const collection_size, double *send_field, int *info, int *ierr)
void yac_cget_comps_comm_f2c(char const **comp_names, int num_comps, MPI_Fint *comps_comm_f)
int const YAC_PROLEPTIC_GREGORIAN
void yac_cget_comp_grid_names_instance(int yac_instance_id, const char *comp_name, int nbr_grids, const char **grid_names)
double yac_cget_field_frac_mask_fallback_value(const char *comp_name, const char *grid_name, const char *field_name)
void yac_cset_mask(int const *is_valid, int points_id)
void yac_cget_async_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
void yac_cadd_interp_stack_config_hcsbb(int interp_stack_config_id)
void yac_cget_comps_comm_instance(int yac_instance_id, char const **comp_names, int num_comps, MPI_Comm *comps_comm)
void yac_cadd_interp_stack_config_fixed(int interp_stack_config_id, double value)
int const YAC_TIME_UNIT_DAY
static size_t num_points
void yac_get_(int const field_id, int const collection_size, double *recv_field, int is_async, int *info, int *ierr)
static void yac_cupdate_(struct coupling_field *cpl_field, struct event *event, int is_source)
int yac_cget_comp_nbr_grids(const char *comp_name)
int const YAC_ACTION_COUPLING
double yac_cget_field_frac_mask_fallback_value_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
static int user_input_data_add_points(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates)
int const YAC_TIME_UNIT_ISO_FORMAT
int const YAC_AVG_DIST
int yac_cget_field_role_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
static void yac_check_version(MPI_Comm comm)
void yac_cdef_mask(int const grid_id, int const nbr_points, int const located, int const *is_valid, int *mask_id)
static void * yac_unique_id_to_pointer(int id, char const *id_name)
int const YAC_CONSERV_FRACAREA
void yac_cadd_interp_stack_config_user_callback(int interp_stack_config_id, char const *func_compute_weights_key)
void yac_cdef_points_curve2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
void yac_cset_ext_couple_config_mapping_side(int ext_couple_config_id, int mapping_side)
void yac_cdef_mask_named(int const grid_id, int const nbr_points, int const located, int const *is_valid, char const *name, int *mask_id)
void yac_ccleanup_instance(int yac_instance_id)
int yac_cget_field_collection_size_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
static void check_y_vertices(double const *y_vertices, size_t count, char const *routine_name)
void yac_cfree_interp_stack_config(int interp_stack_config_id)
int const YAC_CALENDAR_NOT_SET
int const YAC_NNN_AVG
void yac_cadd_interp_stack_config_user_file(int interp_stack_config_id, char const *filename, char const *src_grid_name, char const *tgt_grid_name)
void yac_cget_ext_couple_config_scale_summand(int ext_couple_config_id, double *scale_summand)
void yac_cinit_instance(int *yac_instance_id)
void yac_ctest(int field_id, int *flag)
void yac_cget_interp_stack_config(int *interp_stack_config_id)
static void yac_free_pointer_unique_lookup()
void yac_cinit_dummy(void)
void yac_cadd_interp_stack_config_average(int interp_stack_config_id, int reduction_type, int partial_coverage)
int const YAC_ACTION_PUT_FOR_RESTART
#define WEIGHT_ACC(ACC, EXTRA_CHECK)
int const YAC_NNN_ZERO
void yac_cdef_comp(char const *comp_name, int *comp_id)
static struct yac_interp_stack_config ** interp_stack_configs
int const YAC_SPMAP_DIST
void yac_cdef_field(char const *name, int const comp_id, int const *point_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_cdef_couple_instance(int yac_instance_id, 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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag)
void yac_cdef_couple(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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag)
int yac_cget_nbr_comps(void)
static int default_instance_id
void yac_cdef_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
int const YAC_AVG_BARY
static void check_x_vertices(double const *x_vertices, size_t count, char const *routine_name)
void yac_cset_ext_couple_config_tgt_mask_name_(struct yac_ext_couple_config *ext_couple_config, char const *tgt_mask_name)
void yac_cput_ptr_(int const field_id, int const collection_size, double **send_field, int *info, int *ierr)
struct yac_basic_grid ** grids
int const YAC_NNN_DIST
void yac_cget_comp_grid_names(const char *comp_name, int nbr_grids, const char **grid_names)
int yac_cget_nbr_grids()
void yac_cget_field_names_instance(int yac_instance_id, const char *comp_name, const char *grid_name, int nbr_fields, const char **field_names)
void yac_cdef_comps_instance(int yac_instance_id, char const **comp_names, int num_comps, int *comp_ids)
int const YAC_REDUCTION_TIME_NONE
void yac_cget_comp_names_instance(int yac_instance_id, int nbr_comps, const char **comp_names)
void yac_cdef_field_metadata(const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
static struct yac_interpolation * yac_cput_pre_processing(struct coupling_field *cpl_field, unsigned put_idx, int const collection_size, double ***send_field, double ****send_field_acc_, double ***send_frac_mask, double ****send_frac_mask_acc_, int *info, int *ierr)
static void yac_ccleanup_instance_(int yac_instance_id)
const char * yac_cget_component_metadata(const char *comp_name)
const char * yac_cget_field_timestep(const char *comp_name, const char *grid_name, const char *field_name)
void yac_cget_field_names(const char *comp_name, const char *grid_name, int nbr_fields, const char **field_names)
void ** pointer_lookup_table
void yac_cget_ext_couple_config_weight_file(int ext_couple_config_id, char const **weight_file)
void yac_cinit_comm(MPI_Comm comm)
static void yac_free_grids()
#define YAC_MAX_CHARLEN
void yac_mpi_finalize()
Definition yac_mpi.c:108
void yac_mpi_cleanup()
Definition yac_mpi.c:95
int yac_mpi_is_initialised()
Definition yac_mpi.c:32
void yac_yaxt_init(MPI_Comm comm)
Definition yac_mpi.c:40
void yac_mpi_init()
Definition yac_mpi.c:77
#define yac_mpi_call(call, comm)
Xt_int yac_int
Definition yac_types.h:11
double(* yac_coordinate_pointer)[3]
Definition yac_types.h:15