YAC 3.18.0
Yet Another Coupler
Loading...
Searching...
No Matches
test_instance_parallel1.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 <unistd.h>
12#include <string.h>
13
14#include <mpi.h>
15#include <yaxt.h>
16
17#include "tests.h"
18#include "test_common.h"
19#include "instance.h"
20#include "yac.h"
21#include "yac_mpi.h"
22#include "dist_grid_utils.h"
23#include "weight_file_common.h"
24#include "grid_file_common.h"
25#include "config_yaml.h"
27#include "event.h"
28#include "geometry.h"
29#include "fields.h"
31
38static void compute_weights_callback(
39 double const tgt_coords[3], int src_cell_id, size_t src_cell_idx,
40 int const ** global_results_points, double ** result_weights,
41 size_t * result_count, void * user_data);
42
43static void do_search_callback(yac_int const * global_ids,
44 double const (*coordinates_xyz)[3], size_t count, void * user_data);
45
46int main(int argc, char** argv) {
47
48 enum {NUM_PROCS = 3};
49
50 MPI_Init(NULL, NULL);
51 xt_initialize(MPI_COMM_WORLD);
52 int rank, size;
53 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
54 MPI_Comm_size(MPI_COMM_WORLD, &size);
55
56 if (size != NUM_PROCS) {
57
58 PUT_ERR("ERROR: wrong number of processes\n");
59 return TEST_EXIT_CODE;
60 }
61
62 if (argc != 2) {
63 PUT_ERR("ERROR: missing config file directory");
64 xt_finalize();
65 MPI_Finalize();
66 return TEST_EXIT_CODE;
67 }
68
70 int collection_size = 1;
71 char const * timestep_iso8601 = yac_time_to_ISO("1", C_SECOND);
72
73 { // tests with instance_test_1_1.yaml
74
75 { // no process defines a components
76 struct yac_instance * instance =
77 yac_instance_new(MPI_COMM_WORLD);
78
79 int compare_result;
80 MPI_Comm_compare(
81 MPI_COMM_WORLD, yac_instance_get_comm(instance), &compare_result);
82 if (compare_result != MPI_CONGRUENT)
83 PUT_ERR("error in yac_instance_get_comm");
84
85 struct yac_couple_config * couple_config =
87 char * yaml_filename =
88 strcat(
89 strcpy(
90 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_1.yaml");
93 free(yaml_filename);
94 yac_instance_set_couple_config(instance, couple_config);
95
96 yac_instance_def_components(instance, NULL, 0);
97
98 yac_instance_setup(instance, NULL, 0);
99
100 yac_instance_delete(instance);
101 }
102
103 { // first two process define component comp_1 and last defines comp_2
104 struct yac_instance * instance =
105 yac_instance_new(MPI_COMM_WORLD);
107
108 char const * component_names[2] = {"comp_1", "comp_2"};
110 instance, &(component_names[rank >> 1]), 1);
111
112 size_t num_vertices[2] = {2,2};
113 int cyclic[2] = {0,0};
114 double coordinates_x[3][2] = {{0,1},{1,2},{0.5,1.5}};
115 double coordinates_y[3][2] = {{0,1},{0,1},{0,1}};
116 yac_int global_cell_ids [3][1] = {{0},{1},{0}};
117 yac_int global_corner_ids[3][4] = {{0,1,3,4},{1,2,4,5},{0,1,2,3}};
118 int cell_core_mask[1] = {1};
119
123 grid_data.cell_ids = TO_POINTER(global_cell_ids[rank]);
124 grid_data.vertex_ids = TO_POINTER(global_corner_ids[rank]);
125 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
126
127 char * grid_name[2] = {"grid1", "grid2"};
128 struct yac_basic_grid * grid =
129 yac_basic_grid_new(grid_name[rank>>1], grid_data);
130
131 struct yac_interp_field interp_fields[1];
132 interp_fields[0].location = YAC_LOC_CORNER;
133 interp_fields[0].coordinates_idx = SIZE_MAX;
134 interp_fields[0].masks_idx = SIZE_MAX;
135
137 instance, "field_1", component_names[rank >> 1], grid,
138 interp_fields, 1, collection_size, timestep_iso8601);
139
140 char * yaml_filename =
141 strcat(
142 strcpy(
143 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_1.yaml");
144 char const * grid_filename = "instance_test_1_1_grid2.nc";
149 yac_instance_get_couple_config(instance), "grid2", grid_filename);
150 free(yaml_filename);
151
152 yac_instance_setup(instance, &grid, 1);
153
154 yac_instance_delete(instance);
155
157
158 MPI_Barrier(MPI_COMM_WORLD);
159 if (rank == 0) {
160
161 unlink("comp_1.err");
162 unlink("comp_2.err");
163 unlink("comp_1.log");
164 unlink("comp_2.log");
165
167 grid_filename, "grid2", 1, 4,
168 (double[]){0,0,1,1}, (double[]){0.5,1.5,1.5,0.5}, NULL, NULL,
169 (int[]){0}, (int[]){1}, NULL, NULL, NULL, NULL);
170 unlink(grid_filename);
171 }
172 MPI_Barrier(MPI_COMM_WORLD);
173 }
174 }
175
176 { // tests with instance_test_1_2.yaml
177
178 { // each process has its own component and data exchange occurs in a
179 // round robin fashion
180 struct yac_instance * instance =
181 yac_instance_new(MPI_COMM_WORLD);
182
183 char const * component_names[3] = {"comp_1", "comp_2", "comp_3"};
185 instance, &(component_names[rank]), 1);
186
187 size_t num_vertices[2] = {2,2};
188 int cyclic[2] = {0,0};
189 double coordinates_x[2] = {0,1};
190 double coordinates_y[2] = {0,1};
191 yac_int global_cell_ids [1] = {0};
192 yac_int global_corner_ids[4] = {0,1,2,3};
193 int cell_core_mask[1] = {1};
194
198 grid_data.cell_ids = TO_POINTER(global_cell_ids);
199 grid_data.vertex_ids = TO_POINTER(global_corner_ids);
200 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
201
202 char * grid_name[3] = {"grid1", "grid2", "grid3"};
203 struct yac_basic_grid * grid =
204 yac_basic_grid_new(grid_name[rank], grid_data);
205
206 struct yac_interp_field interp_fields[1];
207 interp_fields[0].location = YAC_LOC_CORNER;
208 interp_fields[0].coordinates_idx = SIZE_MAX;
209 interp_fields[0].masks_idx = SIZE_MAX;
210
211 char * field_name[3] = {"field_1", "field_2", "field_3"};
213 instance, field_name[rank], component_names[0], grid,
214 interp_fields, 1, collection_size, timestep_iso8601);
216 instance, field_name[(rank + 2) % 3], component_names[rank], grid,
217 interp_fields, 1, collection_size, timestep_iso8601);
218
219 char * yaml_filename =
220 strcat(
221 strcpy(
222 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_2.yaml");
226 free(yaml_filename);
227
228 yac_instance_setup(instance, &grid, 1);
229
230 yac_instance_delete(instance);
231
233 }
234 }
235
236 { // tests with instance_test_1_3.yaml
237
238 { // each process has its own component and data exchange occurs in a
239 // round robin fashion
240 struct yac_instance * instance =
241 yac_instance_new(MPI_COMM_WORLD);
242
243 char const * component_names[3] = {"comp_1", "comp_2", "comp_3"};
245 instance, &(component_names[rank]), 1);
246
247 size_t num_vertices[2] = {2,2};
248 int cyclic[2] = {0,0};
249 double coordinates_x[2] = {0,1};
250 double coordinates_y[2] = {0,1};
251 yac_int global_cell_ids [1] = {0};
252 yac_int global_corner_ids[4] = {0,1,2,3};
253 int cell_core_mask[1] = {1};
254
258 grid_data.cell_ids = TO_POINTER(global_cell_ids);
259 grid_data.vertex_ids = TO_POINTER(global_corner_ids);
260 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
261
262 char * grid_name[3] = {"grid1", "grid2", "grid3"};
263 struct yac_basic_grid * grid =
264 yac_basic_grid_new(grid_name[rank], grid_data);
265
266 struct yac_interp_field interp_fields[1];
267 interp_fields[0].location = YAC_LOC_CORNER;
268 interp_fields[0].coordinates_idx = SIZE_MAX;
269 interp_fields[0].masks_idx = SIZE_MAX;
270
271 char * field_name[6] = {"field_1", "field_2", "field_3",
272 "field_4", "field_5", "field_6"};
274 instance, field_name[rank], component_names[rank], grid,
275 interp_fields, 1, collection_size, timestep_iso8601);
277 instance, field_name[(rank + 2) % 3], component_names[rank], grid,
278 interp_fields, 1, collection_size, timestep_iso8601);
280 instance, field_name[rank + 3], component_names[rank], grid,
281 interp_fields, 1, collection_size, timestep_iso8601);
283 instance, field_name[((rank + 2) % 3) + 3], component_names[rank], grid,
284 interp_fields, 1, collection_size, timestep_iso8601);
285
286 char * yaml_filename =
287 strcat(
288 strcpy(
289 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_3.yaml");
293 free(yaml_filename);
294
295 yac_instance_setup(instance, &grid, 1);
296
297 yac_instance_delete(instance);
298
300 }
301 }
302
303 { // tests with instance_test_1_4.yaml
304
305 { // each process has its own component
306 // process one has one field that is to be sent to both other
307 // processes in the same put
308 struct yac_instance * instance =
309 yac_instance_new(MPI_COMM_WORLD);
310
311 char const * component_names[3] = {"comp_1", "comp_2", "comp_3"};
313 instance, &(component_names[rank]), 1);
314
315 size_t num_vertices[2] = {2,2};
316 int cyclic[2] = {0,0};
317 double coordinates_x[2] = {0,1};
318 double coordinates_y[2] = {0,1};
319 yac_int global_cell_ids [1] = {0};
320 yac_int global_corner_ids[4] = {0,1,2,3};
321 int cell_core_mask[1] = {1};
322
326 grid_data.cell_ids = TO_POINTER(global_cell_ids);
327 grid_data.vertex_ids = TO_POINTER(global_corner_ids);
328 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
329
330 char * grid_name[3] = {"grid1", "grid2", "grid3"};
331 struct yac_basic_grid * grid =
332 yac_basic_grid_new(grid_name[rank], grid_data);
333
334 struct yac_interp_field interp_fields[1];
335 interp_fields[0].location = YAC_LOC_CORNER;
336 interp_fields[0].coordinates_idx = SIZE_MAX;
337 interp_fields[0].masks_idx = SIZE_MAX;
338
340 instance, "field_1", component_names[rank], grid,
341 interp_fields, 1, collection_size, timestep_iso8601);
342
343 char * yaml_filename =
344 strcat(
345 strcpy(
346 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_4.yaml");
350 free(yaml_filename);
351
352 yac_instance_setup(instance, &grid, 1);
353
354 yac_instance_delete(instance);
355
357 }
358 }
359
360 { // tests with instance_test_1_5.yaml
361
362 { // each process has its own component
363 // process one has one field that is to be sent to both other
364 // processes in the same put
365 struct yac_instance * instance =
366 yac_instance_new(MPI_COMM_WORLD);
367
368 char const * component_names[3] = {"comp_1", "comp_2", "comp_3"};
370 instance, &(component_names[rank]), 1);
371
372 size_t num_vertices[2] = {5,5};
373 int cyclic[2] = {0,0};
374 double coordinates_x[5] = {0,1,2,3,4};
375 double coordinates_y[5] = {0,1,2,3,4};
376
380
381 char * grid_name[3] = {"grid1", "grid2", "grid3"};
382 struct yac_basic_grid * grid =
383 yac_basic_grid_new(grid_name[rank], grid_data);
384
385 struct yac_interp_field interp_fields[1];
386 interp_fields[0].location = YAC_LOC_CORNER;
387 interp_fields[0].coordinates_idx = SIZE_MAX;
388 interp_fields[0].masks_idx = SIZE_MAX;
389
391 instance, "field_1", component_names[rank], grid,
392 interp_fields, 1, collection_size, timestep_iso8601);
393
394 char * yaml_filename =
395 strcat(
396 strcpy(
397 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_5.yaml");
401 free(yaml_filename);
402
403 yac_instance_setup(instance, &grid, 1);
404
405 yac_instance_delete(instance);
406
408 }
409 }
410
411 { // tests with instance_test_1_6.yaml
412
413 { // first two process define component comp_1 and last defines comp_2
414 struct yac_instance * instance =
415 yac_instance_new(MPI_COMM_WORLD);
416
417 char const * component_names[2] = {"comp_1", "comp_2"};
419 instance, &(component_names[rank >> 1]), 1);
420
421 size_t num_vertices[2] = {2,2};
422 int cyclic[2] = {0,0};
423 double coordinates_x[3][2] = {{0,1},{1,2},{0.5,1.5}};
424 double coordinates_y[3][2] = {{0,1},{0,1},{0,1}};
425 yac_int global_cell_ids [3][1] = {{0},{1},{0}};
426 yac_int global_corner_ids[3][4] = {{0,1,3,4},{1,2,4,5},{0,1,2,3}};
427 int cell_core_mask[1] = {1};
428
432 grid_data.cell_ids = TO_POINTER(global_cell_ids[rank]);
433 grid_data.vertex_ids = TO_POINTER(global_corner_ids[rank]);
434 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
435
436 char * grid_name[2] = {"grid1", "grid2"};
437 struct yac_basic_grid * grid =
438 yac_basic_grid_new(grid_name[rank>>1], grid_data);
439
440 struct yac_interp_field interp_fields[1];
441 interp_fields[0].location = YAC_LOC_CORNER;
442 interp_fields[0].coordinates_idx = SIZE_MAX;
443 interp_fields[0].masks_idx = SIZE_MAX;
444
445 char * weight_file_name = "test_instance_parallel1_weight_file.nc";
446
447 // delete weight file if it extists
448 if (rank == 0) unlink(weight_file_name);
449
451 instance, "field_1", component_names[rank >> 1], grid,
452 interp_fields, 1, collection_size, timestep_iso8601);
453
454 char * yaml_filename =
455 strcat(
456 strcpy(
457 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_6.yaml");
461 free(yaml_filename);
462
463 yac_instance_setup(instance, &grid, 1);
464
465 // ensure that the weight file has been written
466 MPI_Barrier(MPI_COMM_WORLD);
467
468 // check whether weight file exists
469 if (rank == 0) {
470 if (access(weight_file_name, F_OK ) == -1)
471 PUT_ERR("weight file is missing\n");
472 // delete weight file if it extists
473 unlink(weight_file_name);
474 }
475
476 yac_instance_delete(instance);
477
479 }
480 }
481
482 { // tests with instance_test_1_7.yaml
483
484 { // first two process define component comp_1 and last defines comp_2
485 struct yac_instance * instance =
486 yac_instance_new(MPI_COMM_WORLD);
487
488 char const * component_names[2] = {"comp_1", "comp_2"};
490 instance, &(component_names[rank >> 1]), 1);
491
492 size_t num_vertices[2] = {2,2};
493 int cyclic[2] = {0,0};
494 double coordinates_x[3][2] = {{0,1},{1,2},{0.5,1.5}};
495 double coordinates_y[3][2] = {{0,1},{0,1},{0,1}};
496 yac_int global_cell_ids [3][1] = {{0},{1},{0}};
497 yac_int global_corner_ids[3][4] = {{0,1,3,4},{1,2,4,5},{0,1,2,3}};
498 int cell_core_mask[1] = {1};
499
503 grid_data.cell_ids = TO_POINTER(global_cell_ids[rank]);
504 grid_data.vertex_ids = TO_POINTER(global_corner_ids[rank]);
505 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
506
507 char * grid_name[2] = {"grid1", "grid2"};
508 struct yac_basic_grid * grid =
509 yac_basic_grid_new(grid_name[rank>>1], grid_data);
510
511 struct yac_interp_field interp_fields[1];
512 interp_fields[0].location = YAC_LOC_CORNER;
513 interp_fields[0].coordinates_idx = SIZE_MAX;
514 interp_fields[0].masks_idx = SIZE_MAX;
515
516 char * field_name[3] = {"field_1", "field_2", "field_3"};
517
518 char * weight_file_name[3] =
519 {NULL, "test_instance_parallel1_weight_file_1.nc",
520 "test_instance_parallel1_weight_file_2.nc"};
521
522 char * yaml_filename =
523 strcat(
524 strcpy(
525 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_7.yaml");
529 free(yaml_filename);
530
531 // delete weight file if it exists
532 for (unsigned i = 0; i < 3; ++i) {
533
534 if ((rank == 0) && (weight_file_name[i] != NULL))
535 unlink(weight_file_name[i]);
536
538 instance, field_name[i], component_names[rank >> 1], grid,
539 interp_fields, 1, collection_size, timestep_iso8601);
540 }
541
542 yac_instance_setup(instance, &grid, 1);
543
544 // ensure that the weight file has been written
545 MPI_Barrier(MPI_COMM_WORLD);
546
547 // check whether weight file exists
548 if (rank == 0) {
549 for (unsigned i = 0; i < 3; ++i) {
550 if (weight_file_name[i] == NULL) continue;
551 if (access(weight_file_name[i], F_OK ) == -1)
552 PUT_ERR("weight file is missing\n");
553 // delete weight file if it extists
554 unlink(weight_file_name[i]);
555 }
556 }
557
558 yac_instance_delete(instance);
559
561 }
562 }
563
564 { // tests with instance_test_1_8.yaml
565
566 { // all processes define comp_1, but the yaml lists comp_1 and comp_2
567 struct yac_instance * instance =
568 yac_instance_new(MPI_COMM_WORLD);
569
570 char const * component_names[1] = {"comp_1"};
572
573 size_t num_vertices[2] = {2,2};
574 int cyclic[2] = {0,0};
575 double coordinates_x[3][2] = {{0,1},{1,2},{2,3}};
576 double coordinates_y[3][2] = {{0,1},{0,1},{0,1}};
577 yac_int global_cell_ids [3][1] = {{0},{1},{2}};
578 yac_int global_corner_ids[3][4] = {{0,1,4,5},{1,2,5,6},{2,3,6,7}};
579 int cell_core_mask[1] = {1};
580
584 grid_data.cell_ids = TO_POINTER(global_cell_ids[rank]);
585 grid_data.vertex_ids = TO_POINTER(global_corner_ids[rank]);
586 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
587
588 char * grid_name[1] = {"grid1"};
589 struct yac_basic_grid * grid =
590 yac_basic_grid_new(grid_name[0], grid_data);
591
592 struct yac_interp_field interp_fields[1];
593 interp_fields[0].location = YAC_LOC_CORNER;
594 interp_fields[0].coordinates_idx = SIZE_MAX;
595 interp_fields[0].masks_idx = SIZE_MAX;
596
597 char * field_name[3] = {"field_1", "field_2", "field_3"};
598
599 for (unsigned i = 0; i < 3; ++i)
601 instance, field_name[i], component_names[0], grid,
602 interp_fields, 1, collection_size, timestep_iso8601);
603
604 char * yaml_filename =
605 strcat(
606 strcpy(
607 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_8.yaml");
611 free(yaml_filename);
612
613 yac_instance_setup(instance, &grid, 1);
614
615 yac_instance_delete(instance);
616
618 }
619 }
620
621 { // tests with instance_test_1_9.yaml
622
623 { // tests various interpolation methods
624 struct yac_instance * instance =
625 yac_instance_new(MPI_COMM_WORLD);
626
627 int comp_idx = rank >> 1;
628 char const * component_names[2] = {"comp_1", "comp_2"};
630 instance, &(component_names[comp_idx]), 1);
631
632 double coordinates_x[5] = {0.0,1.0,2.0,3.0,4.0};
633 double coordinates_y[5] = {0.0,1.0,2.0,3.0,4.0};
634 size_t const num_cells[2] = {4,4};
635 size_t local_start[3][2] = {{0,0},{2,0}, {0,0}};
636 size_t local_count[3][2] = {{2,4},{2,4}, {4,4}};
637 int with_halo = 0;
638 for (size_t i = 0; i < 5; ++i) coordinates_x[i] *= YAC_RAD;
639 for (size_t i = 0; i < 5; ++i) coordinates_y[i] *= YAC_RAD;
640
644 local_start[rank], local_count[rank], with_halo);
645
646 char * grid_name[2] = {"grid1", "grid2"};
647 struct yac_basic_grid * grid =
648 yac_basic_grid_new(grid_name[comp_idx], grid_data);
649
650 yac_coordinate_pointer cell_middle_points =
651 xmalloc(grid_data.num_cells * sizeof(*cell_middle_points));
652 for (size_t i = 0; i < grid_data.num_cells; ++i) {
653 for (size_t j = 0; j < 3; ++j) cell_middle_points[i][j] = 0.0;
654 for (int j = 0; j < grid_data.num_vertices_per_cell[i]; ++j)
655 for (size_t k = 0; k < 3; ++k)
656 cell_middle_points[i][k] +=
657 grid_data.vertex_coordinates[
659 grid_data.cell_to_vertex_offsets[i] + j]][k];
660 normalise_vector(cell_middle_points[i]);
661 }
662
663 struct yac_interp_field interp_fields[2];
664 interp_fields[0].location = YAC_LOC_CORNER;
665 interp_fields[0].coordinates_idx = SIZE_MAX;
666 interp_fields[0].masks_idx = SIZE_MAX;
667 interp_fields[1].location = YAC_LOC_CELL;
668 interp_fields[1].coordinates_idx =
670 grid, YAC_LOC_CELL, cell_middle_points, grid_data.num_cells);
671 interp_fields[1].masks_idx = SIZE_MAX;
672 free(cell_middle_points);
673
674 char const * weight_file_name = "instance_test_1_9.nc";
675 if (rank == 0) {
676
677 int src_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
678 int tgt_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
679 double weights[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
680 size_t num_links = 16;
681 enum yac_location src_locations[1] = {YAC_LOC_CELL};
682 enum yac_location tgt_location = YAC_LOC_CELL;
683 unsigned num_src_fields = 1;
684 int num_links_per_field[1] = {num_links};
685 int * tgt_id_fixed = NULL;
686 size_t num_fixed_tgt = 0;
687 double * fixed_values = NULL;
688 int * num_tgt_per_fixed_value = NULL;
689 size_t num_fixed_values = 0;
690
692 weight_file_name, src_indices, tgt_indices, weights, num_links,
693 src_locations, num_src_fields, num_links_per_field, tgt_id_fixed,
694 num_fixed_tgt, fixed_values, num_tgt_per_fixed_value,
695 num_fixed_values, tgt_location, grid_name[0], grid_name[1]);
696 }
697
698 // register weight computation callback routine
699 if (comp_idx == 0)
701 compute_weights_callback, NULL, "compute_weights_callback");
702
703 char * field_name[] = {"AVG_ARITHMETIC",
704 "AVG_DIST",
705 "AVG_BARY",
706 "4NN_ARITHMETIC",
707 "4NN_DIST",
708 "4NN_GAUSS",
709 "HCSBB",
710 "RBF_4_GAUSS",
711 "FIXED",
712 "SPMAP",
713 "CONSERV_FRACAREA",
714 "CONSERV_DESTAREA",
715 "CONSERV2ND",
716 "USER_FILE",
717 "CREEP",
718 "USER_CALLBACK"};
719 size_t const field_count = 16;
720
721 for (size_t i = 0; i < 9; ++i)
723 instance, field_name[i], component_names[comp_idx], grid,
724 &(interp_fields[0]), 1, collection_size, timestep_iso8601);
725 for (size_t i = 9; i < 15; ++i)
727 instance, field_name[i], component_names[comp_idx], grid,
728 &(interp_fields[1]), 1, collection_size, timestep_iso8601);
729
730 // two source fields and one target field
731 if (comp_idx == 0) {
732 for (size_t i = 15; i < field_count; ++i)
734 instance, field_name[i], component_names[comp_idx], grid,
735 &(interp_fields[0]), 2, collection_size, timestep_iso8601);
736 } else {
737 for (size_t i = 15; i < field_count; ++i)
739 instance, field_name[i], component_names[comp_idx], grid,
740 &(interp_fields[0]), 1, collection_size, timestep_iso8601);
741 }
742
743 char * yaml_filename =
744 strcat(
745 strcpy(
746 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_9.yaml");
750 free(yaml_filename);
751
752 yac_instance_setup(instance, &grid, 1);
753
754 yac_instance_delete(instance);
755 if (rank == 0) unlink(weight_file_name);
756
758 }
759 }
760
761 { // tests with instance_test_1_10.yaml
762
763 { // first two process define component comp_1 and last defines comp_2
764 // configuration file contains a coupling, however only source field
765 // is defined
766
767 size_t num_vertices[2] = {2,2};
768 int cyclic[2] = {0,0};
769 double coordinates_x[3][2] = {{0,1},{1,2},{0.5,1.5}};
770 double coordinates_y[3][2] = {{0,1},{0,1},{0,1}};
771 yac_int global_cell_ids [3][1] = {{0},{1},{0}};
772 yac_int global_corner_ids[3][4] = {{0,1,3,4},{1,2,4,5},{0,1,2,3}};
773 int cell_core_mask[1] = {1};
774
778 grid_data.cell_ids = TO_POINTER(global_cell_ids[rank]);
779 grid_data.vertex_ids = TO_POINTER(global_corner_ids[rank]);
780 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
781
782 char * grid_name[2] = {"grid1", "grid2"};
783 struct yac_basic_grid * grid =
784 yac_basic_grid_new(grid_name[rank>>1], grid_data);
785
786 // define field only on source/target component
787 for (int i = 0; i < 2; ++i) {
788
789 struct yac_instance * instance =
790 yac_instance_new(MPI_COMM_WORLD);
791
792 char const * component_names[2] = {"comp_1", "comp_2"};
794 instance, &(component_names[rank >> 1]), 1);
795
796 if ((rank >> 1) == i) {
797
798 struct yac_interp_field interp_fields[1];
799 interp_fields[0].location = YAC_LOC_CORNER;
800 interp_fields[0].coordinates_idx = SIZE_MAX;
801 interp_fields[0].masks_idx = SIZE_MAX;
802
804 instance, "field", component_names[rank >> 1], grid,
805 interp_fields, 1, collection_size, timestep_iso8601);
806 }
807
808 char * yaml_filename =
809 strcat(
810 strcpy(
811 malloc(strlen(argv[1]) + 32), argv[1]), "instance_test_1_10.yaml");
815 free(yaml_filename);
816
817 yac_instance_setup(instance, &grid, 1);
818
819 yac_instance_delete(instance);
820 }
821
823 }
824 }
825
826 { // test case where multiple target components share the same grid
827
828 size_t num_vertices[2] = {2,2};
829 int cyclic[2] = {0,0};
830 double coordinates_x[2] = {0,1};
831 double coordinates_y[2] = {0,1};
832 yac_int global_cell_ids [1] = {0};
833 yac_int global_corner_ids[4] = {0,1,2,3};
834 int cell_core_mask[1] = {1};
835
836 struct yac_basic_grid_data src_grid_data =
839 src_grid_data.cell_ids = TO_POINTER(global_cell_ids);
840 src_grid_data.vertex_ids = TO_POINTER(global_corner_ids);
842 struct yac_basic_grid_data tgt_grid_data =
845 tgt_grid_data.cell_ids = TO_POINTER(global_cell_ids);
846 tgt_grid_data.vertex_ids = TO_POINTER(global_corner_ids);
848
849 char const * src_grid_name = "src_grid";
850 char const * tgt_grid_name = "tgt_grid";
851 struct yac_basic_grid * src_grid =
852 yac_basic_grid_new(src_grid_name, src_grid_data);
853 struct yac_basic_grid * tgt_grid =
854 yac_basic_grid_new(tgt_grid_name, tgt_grid_data);
855
856 struct yac_instance * instance =
857 yac_instance_new(MPI_COMM_WORLD);
858
859 char * src_component_name = "src_comp";
860 char tgt_component_name[32];
861 char const * component_names[2] = {src_component_name, tgt_component_name};
862 sprintf(tgt_component_name, "tgt_comp_%d", rank);
864
865 struct yac_interp_field interp_fields[1] =
867 .coordinates_idx = SIZE_MAX,
868 .masks_idx = SIZE_MAX}};
869
870 char const * src_field_name = "src_field";
871 char tgt_field_name[32];
872 sprintf(tgt_field_name, "tgt_field_%d", rank);
873 struct coupling_field * src_field =
875 instance, src_field_name, src_component_name, src_grid,
876 interp_fields, 1, collection_size, timestep_iso8601);
877 struct coupling_field * tgt_field =
879 instance, tgt_field_name, tgt_component_name, tgt_grid,
880 interp_fields, 1, collection_size, timestep_iso8601);
881
883 instance, "2008-03-09T16:05:07", "2008-03-10T16:05:07");
886 char * coupling_period = strdup(yac_time_to_ISO("60", C_SECOND));
887 int do_search_count = 0;
889 do_search_callback, &do_search_count, "do_search_key");
890 yac_interp_stack_config_add_check(interp_stack, NULL, "do_search_key");
895 yac_interp_stack_config_add_fixed(interp_stack, -1.0);
897 instance, src_component_name, src_grid_name, src_field_name,
898 tgt_component_name, tgt_grid_name, tgt_field_name,
899 coupling_period, YAC_REDUCTION_TIME_NONE, interp_stack, 60, 60,
900 NULL, YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE, 0, 1.0, 0.0, 0,
901 NULL, NULL, NULL, NULL, 0);
902 yac_interp_stack_config_delete(interp_stack);
903 free(coupling_period);
904
905 struct yac_basic_grid * grids[2] = {src_grid, tgt_grid};
906 yac_instance_setup(instance, grids, 2);
907
908 // weight should only be calculated once
909 if (do_search_count != 1) PUT_ERR("ERROR in yac_instance_setup");
910
911 for (unsigned put_idx = 0;
912 put_idx < yac_get_coupling_field_num_puts(src_field); ++put_idx) {
913
914 double *** send_field =
916 for (int i = 0; i < 4; ++i) send_field[0][0][i] = (double)i;
919 src_field, put_idx), send_field);
920 }
921
922 {
923 double recv_field_data[4] = {-1.0, -1.0, -1.0, -1.0};
924 double * recv_field = recv_field_data;
926 yac_get_coupling_field_get_op_interpolation(tgt_field), &recv_field);
927
928 for (int i = 0; i < 4;++i)
929 if (recv_field[i] != (double)i)
930 PUT_ERR("ERROR in yac_instance_setup");
931 }
932
933 yac_instance_delete(instance);
934
935 yac_basic_grid_delete(src_grid);
936 yac_basic_grid_delete(tgt_grid);
937 }
938
939 { // test case where multiple source and target components share the same grid
940
941 size_t num_vertices[2] = {2,2};
942 int cyclic[2] = {0,0};
943 double coordinates_x[2] = {0,1};
944 double coordinates_y[2] = {0,1};
945 yac_int global_cell_ids [1] = {0};
946 yac_int global_corner_ids[4] = {0,1,2,3};
947 int cell_core_mask[1] = {1};
948
949 struct yac_basic_grid_data src_grid_data =
952 src_grid_data.cell_ids = TO_POINTER(global_cell_ids);
953 src_grid_data.vertex_ids = TO_POINTER(global_corner_ids);
955 struct yac_basic_grid_data tgt_grid_data =
958 tgt_grid_data.cell_ids = TO_POINTER(global_cell_ids);
959 tgt_grid_data.vertex_ids = TO_POINTER(global_corner_ids);
961
962 char const * src_grid_name = "src_grid";
963 char const * tgt_grid_name = "tgt_grid";
964 struct yac_basic_grid * src_grid =
965 yac_basic_grid_new(src_grid_name, src_grid_data);
966 struct yac_basic_grid * tgt_grid =
967 yac_basic_grid_new(tgt_grid_name, tgt_grid_data);
968
969 struct yac_instance * instance =
970 yac_instance_new(MPI_COMM_WORLD);
971
972 char src_component_name[32];
973 char tgt_component_name[32];
974 char const * component_names[2] = {src_component_name, tgt_component_name};
975 sprintf(src_component_name, "src_comp_%d", rank);
976 sprintf(tgt_component_name, "tgt_comp_%d", rank);
978
979 struct yac_interp_field interp_fields[1] =
981 .coordinates_idx = SIZE_MAX,
982 .masks_idx = SIZE_MAX}};
983
984 char const * src_field_name = "src_field";
985 char const * tgt_field_name = "tgt_field";
986 struct coupling_field * src_field =
988 instance, src_field_name, src_component_name, src_grid,
989 interp_fields, 1, collection_size, timestep_iso8601);
990 struct coupling_field * tgt_field =
992 instance, tgt_field_name, tgt_component_name, tgt_grid,
993 interp_fields, 1, collection_size, timestep_iso8601);
994
996 instance, "2008-03-09T16:05:07", "2008-03-10T16:05:07");
999 char * coupling_period = strdup(yac_time_to_ISO("60", C_SECOND));
1000 int do_search_count = 0;
1002 do_search_callback, &do_search_count, "do_search_key_2");
1003 yac_interp_stack_config_add_check(interp_stack, NULL, "do_search_key_2");
1005 interp_stack, YAC_INTERP_NNN_WEIGHTED_DEFAULT,
1008 yac_interp_stack_config_add_fixed(interp_stack, -1.0);
1010 instance, src_component_name, src_grid_name, src_field_name,
1011 tgt_component_name, tgt_grid_name, tgt_field_name,
1012 coupling_period, YAC_REDUCTION_TIME_NONE, interp_stack, 60, 60,
1013 NULL, YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE, 0, 1.0, 0.0, 0,
1014 NULL, NULL, NULL, NULL, 0);
1015 yac_interp_stack_config_delete(interp_stack);
1016 free(coupling_period);
1017
1018 struct yac_basic_grid * grids[2] = {src_grid, tgt_grid};
1019 yac_instance_setup(instance, grids, 2);
1020
1021 // weight should only be calculated once
1022 if (do_search_count != 1) PUT_ERR("ERROR in yac_instance_setup");
1023
1024 for (unsigned put_idx = 0;
1025 put_idx < yac_get_coupling_field_num_puts(src_field); ++put_idx) {
1026
1027 double *** send_field =
1029 for (int i = 0; i < 4; ++i)
1030 send_field[0][0][i] = (double)(i + rank * NUM_PROCS);
1033 src_field, put_idx), send_field);
1034 }
1035
1036 {
1037 double recv_field_data[4] = {-1.0, -1.0, -1.0, -1.0};
1038 double * recv_field = recv_field_data;
1041 &recv_field);
1042
1043 for (int i = 0; i < 4;++i)
1044 if (recv_field[i] != (double)(i + rank * NUM_PROCS))
1045 PUT_ERR("ERROR in yac_instance_setup");
1046 }
1047
1048 yac_instance_delete(instance);
1049
1050 yac_basic_grid_delete(src_grid);
1051 yac_basic_grid_delete(tgt_grid);
1052 }
1053
1054 { // test case where a single source field is received by three different
1055 // target fields on the same target component with different collection
1056 // selections (all, first, last)
1057
1058 enum {SRC_COLLECTION_SIZE = 4, SRC_RANK = 0, TGT_RANK = 1};
1059 int is_src = (rank == SRC_RANK);
1060 int is_tgt = (rank == TGT_RANK);
1061
1062 // Simple 2x2 grid for each
1063 size_t num_vertices[2] = {2, 2};
1064 int cyclic[2] = {0, 0};
1065 double coordinates_x[2] = {0, 1};
1066 double coordinates_y[2] = {0, 1};
1067 yac_int global_cell_ids[1] = {0};
1068 yac_int global_corner_ids[4] = {0, 1, 2, 3};
1069 int cell_core_mask[1] = {1};
1070
1074 grid_data.cell_ids = TO_POINTER(global_cell_ids);
1075 grid_data.vertex_ids = TO_POINTER(global_corner_ids);
1076 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
1077
1078 char const * src_grid_name = "src_grid";
1079 char const * tgt_grid_name = "tgt_grid";
1080 struct yac_basic_grid * grid;
1081 if (is_src || is_tgt) {
1084 } else {
1085 grid = yac_basic_grid_new("empty_grid", grid_data);
1086 }
1087
1088 // Setup: 3 procs, each with its own component and grid
1089 struct yac_instance *instance = yac_instance_new(MPI_COMM_WORLD);
1090
1091 char const *component_names[3] = {"src_comp", "tgt_comp", "dummy_comp"};
1093 instance, &component_names[rank], 1);
1094
1095 struct yac_interp_field interp_fields[1] =
1097 .coordinates_idx = SIZE_MAX,
1098 .masks_idx = SIZE_MAX}};
1099
1100 struct coupling_field * src_field = NULL;
1101 if (is_src) {
1102 // Add source field to src_comp
1104 instance, "src_field", component_names[0], grid,
1105 interp_fields, 1, SRC_COLLECTION_SIZE, timestep_iso8601);
1106 }
1107
1108 struct coupling_field * tgt_field_all = NULL;
1109 struct coupling_field * tgt_field_first = NULL;
1110 struct coupling_field * tgt_field_last = NULL;
1111 if (is_tgt) {
1112
1113 // define three different collection selections for target fields
1114 struct yac_collection_selection * collection_selection_all =
1115 yac_collection_selection_new(SRC_COLLECTION_SIZE, NULL);
1116 struct yac_collection_selection * collection_selection_first =
1117 yac_collection_selection_new(1, (size_t[]){0});
1118 struct yac_collection_selection * collection_selection_last =
1119 yac_collection_selection_new(1, (size_t[]){SRC_COLLECTION_SIZE-1});
1120
1121 // Add three target fields to tgt_comp,
1122 // each with different collection selection
1123 tgt_field_all =
1125 instance, "tgt_field_all", component_names[1], grid,
1126 interp_fields, 1,
1128 collection_selection_all), timestep_iso8601);
1129 tgt_field_first =
1131 instance, "tgt_field_first", component_names[1], grid,
1132 interp_fields, 1,
1134 collection_selection_first), timestep_iso8601);
1135 tgt_field_last =
1137 instance, "tgt_field_last", component_names[1], grid,
1138 interp_fields, 1,
1140 collection_selection_last), timestep_iso8601);
1141
1142 // Define datetime and coupling
1144 instance, "2008-03-09T16:05:07", "2008-03-10T16:05:07");
1148 interp_stack, YAC_INTERP_NNN_WEIGHTED_DEFAULT,
1151 char *coupling_period = strdup(yac_time_to_ISO("60", C_SECOND));
1152
1153 // Define three couples, each with different collection selection
1155 instance, component_names[0], src_grid_name, "src_field",
1156 component_names[1], tgt_grid_name, "tgt_field_all",
1157 coupling_period, YAC_REDUCTION_TIME_NONE, interp_stack, 60, 60,
1158 NULL, YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE, 0, 1.0, 0.0, 0,
1159 NULL, NULL, NULL, collection_selection_all, 0);
1161 instance, component_names[0], src_grid_name, "src_field",
1162 component_names[1], tgt_grid_name, "tgt_field_first",
1163 coupling_period, YAC_REDUCTION_TIME_NONE, interp_stack, 60, 60,
1164 NULL, YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE, 0, 1.0, 0.0, 0,
1165 NULL, NULL, NULL, collection_selection_first, 0);
1167 instance, component_names[0], src_grid_name, "src_field",
1168 component_names[1], tgt_grid_name, "tgt_field_last",
1169 coupling_period, YAC_REDUCTION_TIME_NONE, interp_stack, 60, 60,
1170 NULL, YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE, 0, 1.0, 0.0, 0,
1171 NULL, NULL, NULL, collection_selection_last, 0);
1172
1173 yac_collection_selection_delete(collection_selection_all);
1174 yac_collection_selection_delete(collection_selection_first);
1175 yac_collection_selection_delete(collection_selection_last);
1176 yac_interp_stack_config_delete(interp_stack);
1177 free(coupling_period);
1178 }
1179
1180 // Setup instance
1181 // (includes weight calculation and setting up of exchange patterns)
1182 yac_instance_setup(instance, &grid, 1);
1183
1184 // Only source
1185 if (is_src) {
1186 for (unsigned put_idx = 0;
1187 put_idx < yac_get_coupling_field_num_puts(src_field); ++put_idx) {
1188 double ***send_field =
1190 for (size_t i = 0; i < SRC_COLLECTION_SIZE; ++i) {
1191 for (size_t j = 0; j < 4; ++j) {
1192 send_field[i][0][j] = (double)(i * 4 + j);
1193 }
1194 }
1197 send_field);
1198 }
1199 }
1200
1201 // Only target
1202 if (is_tgt) {
1203 // ALL: should receive whole source collection
1204 double recv_field_all[SRC_COLLECTION_SIZE][4];
1205 double *recv_ptr_all[SRC_COLLECTION_SIZE];
1206 for (size_t i = 0; i < SRC_COLLECTION_SIZE; ++i) {
1207 for (size_t j = 0; j < 4; ++j) {
1208 recv_field_all[i][j] = -1.0;
1209 }
1210 recv_ptr_all[i] = recv_field_all[i];
1211 }
1214 recv_ptr_all);
1215 for (size_t i = 0; i < SRC_COLLECTION_SIZE; ++i) {
1216 for (int j = 0; j < 4; ++j) {
1217 if (recv_field_all[i][j] != (double)(i * 4 + j))
1218 PUT_ERR("ERROR in tgt_field_all");
1219 }
1220 }
1221
1222 // FIRST: should receive first entry from the source collection
1223 double recv_field_first[4] = {-1.0, -1.0, -1.0, -1.0};
1224 double *recv_ptr_first = recv_field_first;
1227 &recv_ptr_first);
1228 for (int i = 0; i < 4; ++i){
1229 if (recv_field_first[i] != (double)i)
1230 PUT_ERR("ERROR in tgt_field_first");
1231 }
1232
1233 // LAST: should receive last entry from the source collection
1234 double recv_field_last[4] = {-1.0, -1.0, -1.0, -1.0};
1235 double *recv_ptr_last = recv_field_last;
1238 &recv_ptr_last);
1239 for (int i = 0; i < 4; ++i) {
1240 if (recv_field_last[i] != (double)((SRC_COLLECTION_SIZE - 1) * 4 + i))
1241 PUT_ERR("ERROR in tgt_field_last");
1242 }
1243 }
1244
1245 yac_instance_delete(instance);
1247 }
1248
1249 { // test for yac_instance_def_sync_comps
1250 // * each of the three process defines its own component
1251 // * each component adds one field
1252 // * the first two components synchronise definitions
1253
1254 char const *comp_names[3] = {"comp_0", "comp_1", "comp_2"};
1255 char const *grid_names[3] = {"grid_0", "grid_1", "grid_2"};
1256 char const *field_names[3] = {"field_0", "field_1", "field_2"};
1257 struct yac_instance *instance = yac_instance_new(MPI_COMM_WORLD);
1258
1259 // Each process defines its own component
1260 yac_instance_def_components(instance, &comp_names[rank], 1);
1261
1262 // Each process defines a simple 2x2 grid
1263 size_t num_vertices[2] = {2, 2};
1264 int cyclic[2] = {0, 0};
1265 double coordinates_x[2] = {0, 1};
1266 double coordinates_y[2] = {0, 1};
1267 yac_int global_cell_ids[1] = {0};
1268 yac_int global_corner_ids[4] = {0, 1, 2, 3};
1269 int cell_core_mask[1] = {1};
1270
1274 grid_data.cell_ids = TO_POINTER(global_cell_ids);
1275 grid_data.vertex_ids = TO_POINTER(global_corner_ids);
1276 grid_data.core_cell_mask = TO_POINTER(cell_core_mask);
1277
1278 struct yac_basic_grid *grid =
1280
1281 struct yac_interp_field interp_fields[1] = {
1283 .coordinates_idx = SIZE_MAX,
1284 .masks_idx = SIZE_MAX}};
1285
1287 instance, field_names[rank], comp_names[rank], grid,
1288 interp_fields, 1, collection_size, timestep_iso8601);
1289
1290 for (int test_idx = 0; test_idx < 3; ++test_idx) {
1291
1292 switch (test_idx) {
1293
1294 default:
1295 case (0): {
1296 // no synchronisation in the first iteration
1297 break;
1298 }
1299 case (1): {
1300 // sychronisation between first two components in second iteration
1301 if (rank < 2){
1302 yac_instance_sync_def_comps(instance, &(comp_names[0]), 2);
1303 }
1304 break;
1305 }
1306 case (2): {
1307 // sychronisation between last two components in theird iteration
1308 if (rank > 0) {
1309 yac_instance_sync_def_comps(instance, &(comp_names[1]), 2);
1310 }
1311 break;
1312 }
1313 }
1314
1315 // get couple_config
1316 struct yac_couple_config *couple_config =
1318
1319 // Check for "known" fields in the couple_config
1320 int found_field[3];
1321 for (size_t i = 0; i < 3; ++i) {
1322 size_t comp_idx =
1323 yac_couple_config_get_component_idx(couple_config, comp_names[i]);
1324 switch (yac_couple_config_get_num_fields(couple_config, comp_idx)) {
1325 case (0):
1326 found_field[i] = 0;
1327 break;
1328 case (1):
1329 if (strcmp(
1330 field_names[i],
1331 yac_couple_config_get_field_name(couple_config, i, 0))) {
1332 PUT_ERR("ERROR in yac_instance_sync_def_comps");
1333 } else {
1334 found_field[i] = 1;
1335 }
1336 break;
1337 default:
1338 PUT_ERR("ERROR in yac_instance_sync_def_comps");
1339 break;
1340 }
1341 }
1342
1343 // Check results
1344 {
1345 int ref_found_field[3][3][3] = {{{1,0,0},{0,1,0},{0,0,1}},
1346 {{1,1,0},{1,1,0},{0,0,1}},
1347 {{1,1,0},{1,1,1},{1,1,1}}};
1348 for (size_t i = 0; i < 3; ++i) {
1349 if (ref_found_field[test_idx][rank][i] != found_field[i]) {
1350 PUT_ERR("ERROR in yac_instance_def_sync_comps");
1351 }
1352 }
1353 }
1354 } // for test_idx
1355
1356 yac_instance_setup(instance, &grid, 1);
1357
1358 yac_instance_delete(instance);
1360 }
1361
1362 xt_finalize();
1363 MPI_Finalize();
1364
1365 return TEST_EXIT_CODE;
1366}
1367
1369 double const tgt_coords[3], int src_cell_id, size_t src_cell_idx,
1370 int const ** global_results_points, double ** result_weights,
1371 size_t * result_count, void * user_data) {
1372
1373 UNUSED(tgt_coords);
1374 UNUSED(src_cell_id);
1375 UNUSED(src_cell_idx);
1377
1378 for (size_t i = 0; i < 2; ++i) {
1379 global_results_points[i] = NULL;
1380 result_weights[i] = NULL;
1381 result_count[i] = 0;
1382 }
1383}
1384
1386 yac_int const * global_ids, double const (*coordinates_xyz)[3],
1387 size_t count, void * user_data) {
1388
1389 UNUSED(global_ids);
1390 UNUSED(coordinates_xyz);
1391 UNUSED(count);
1392
1393 int * call_count = user_data;
1394 *call_count += 1;
1395}
char const * grid_names[]
char const * component_names[]
char const * field_names[8]
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
Definition basic_grid.c:57
size_t yac_basic_grid_add_coordinates(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates, size_t count)
Definition basic_grid.c:239
void yac_basic_grid_delete(struct yac_basic_grid *grid)
Definition basic_grid.c:77
struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d_deg(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
Definition grid_reg2d.c:74
void yac_yaml_read_coupling(struct yac_couple_config *couple_config, const char *yaml_filename, int parse_flags)
int const YAC_YAML_PARSER_DEFAULT
default parse flags (YAML format)
Definition config_yaml.c:61
char const * yac_time_to_ISO(char const *time, enum yac_time_unit_type time_unit)
Definition event.c:336
#define UNUSED(x)
Definition core.h:72
void yac_couple_config_set_grid_output_filename(struct yac_couple_config *couple_config, char const *grid_name, const char *output_filename)
size_t yac_couple_config_get_component_idx(struct yac_couple_config const *couple_config, char const *component_name)
char const * yac_couple_config_get_field_name(struct yac_couple_config const *couple_config, size_t component_idx, size_t field_idx)
size_t yac_couple_config_get_num_fields(struct yac_couple_config const *couple_config, size_t component_idx)
struct yac_couple_config * yac_couple_config_new()
@ C_SECOND
struct yac_basic_grid_data yac_generate_basic_grid_data_reg2d(double const *global_coords_x, double const *global_coords_y, size_t const num_global_cells_[2], size_t const local_start[2], size_t const local_count[2], int with_halo)
#define YAC_RAD
unsigned yac_get_coupling_field_num_puts(struct coupling_field *field)
Definition fields.c:507
struct yac_interpolation * yac_get_coupling_field_put_op_interpolation(struct coupling_field *field, unsigned put_idx)
Definition fields.c:416
struct yac_interpolation * yac_get_coupling_field_get_op_interpolation(struct coupling_field *field)
Definition fields.c:550
double *** yac_get_coupling_field_put_op_send_field_acc(struct coupling_field *field, unsigned put_idx)
Definition fields.c:212
static void normalise_vector(double v[])
Definition geometry.h:743
void check_grid_file(char const *filename, char const *grid_name, size_t ref_num_cells, size_t ref_num_corners_per_cell, double *ref_cla, double *ref_clo, double *ref_lat, double *ref_lon, int *ref_cell_global_ids, int *ref_core_cell_mask, int *ref_vertex_global_ids, int *ref_core_vertex_mask, int *ref_edge_global_ids, int *ref_core_edge_mask)
size_t yac_collection_selection_get_collection_size(struct yac_collection_selection const *collection_selection)
Get the size of the collection selection.
void yac_collection_selection_delete(struct yac_collection_selection *collection_selection)
Delete a collection selection object.
struct yac_collection_selection * yac_collection_selection_new(size_t collection_size, size_t const *selection_indices)
Create a new collection selection.
void yac_instance_delete(struct yac_instance *instance)
Definition instance.c:1483
void yac_instance_def_datetime(struct yac_instance *instance, const char *start_datetime, const char *end_datetime)
Definition instance.c:1570
void yac_instance_setup(struct yac_instance *instance, struct yac_basic_grid **grids, size_t num_grids)
Definition instance.c:1374
struct yac_instance * yac_instance_new(MPI_Comm comm)
Definition instance.c:1456
MPI_Comm yac_instance_get_comm(struct yac_instance *instance)
Definition instance.c:1503
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:1625
void yac_instance_set_couple_config(struct yac_instance *instance, struct yac_couple_config *couple_config)
Definition instance.c:1529
void yac_instance_def_components(struct yac_instance *instance, char const **comp_names, size_t num_comps)
Definition instance.c:1588
struct yac_couple_config * yac_instance_get_couple_config(struct yac_instance *instance)
Definition instance.c:1523
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 weight_file_on_existing, int mapping_on_source, double scale_factor, double scale_summand, size_t num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name, char const *yaxt_exchanger_name, struct yac_collection_selection const *collection_selection, int use_raw_exchange)
Definition instance.c:1692
void yac_instance_sync_def_comps(struct yac_instance *instance, char const **comp_names, size_t num_comp_names)
Definition instance.c:1350
void * user_data
void yac_interp_method_check_add_do_search_callback(func_do_search do_search_callback, void *user_data, char const *key)
#define YAC_INTERP_NNN_WEIGHTED_DEFAULT
#define YAC_INTERP_NNN_MAX_SEARCH_DISTANCE_DEFAULT
#define YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT
#define YAC_INTERP_NNN_N_DEFAULT
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_fixed(struct yac_interp_stack_config *interp_stack_config, double value)
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 max_search_distance, double scale)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
Free an interpolation stack configuration object.
struct yac_interp_stack_config * yac_interp_stack_config_new()
Allocate a new empty interpolation stack configuration object.
#define YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE
void yac_interpolation_execute_get(struct yac_interpolation *interp, double **tgt_field)
Complete interpolation and write results to the target field (get phase).
void yac_interpolation_execute_put(struct yac_interpolation *interp, double ***src_fields)
Provide source field data and start asynchronous execution of interpolation (put phase).
yac_location
Definition location.h:12
@ YAC_LOC_CORNER
Definition location.h:15
@ YAC_LOC_CELL
Definition location.h:14
#define xmalloc(size)
Definition ppm_xfuncs.h:66
struct yac_basic_grid * grid
Definition fields.c:24
struct yac_interp_field * interp_fields
Definition fields.c:26
enum yac_location location
Definition basic_grid.h:16
#define TO_POINTER(a)
Definition test_common.h:14
int collection_size
char * yaml_filename
char const * weight_file_name
static void compute_weights_callback(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)
static void do_search_callback(yac_int const *global_ids, double const (*coordinates_xyz)[3], size_t count, void *user_data)
char const src_grid_name[]
char const tgt_grid_name[]
double coordinates_x[]
size_t num_cells[2]
double coordinates_y[]
unsigned cyclic[2]
#define TEST_EXIT_CODE
Definition tests.h:15
#define PUT_ERR(string)
Definition tests.h:10
int * cell_core_mask
void write_weight_file(char const *file_name, int const *src_id, int const *tgt_id, double const *weights, unsigned num_links, enum yac_location const *src_locations, unsigned num_src_fields, int const *num_links_per_src_field, int *tgt_id_fixed, unsigned num_fixed_tgt, double *fixed_values, int *num_tgt_per_fixed_value, unsigned num_fixed_values, enum yac_location tgt_location, char const *src_grid_name, char const *tgt_grid_name)
void yac_cadd_compute_weights_callback(yac_func_compute_weights compute_weights_callback, void *user_data, char const *key)
Definition yac.c:6685
void yac_cdef_calendar(int calendar)
Definition yac.c:1063
int const YAC_PROLEPTIC_GREGORIAN
Definition yac.c:72
int const YAC_REDUCTION_TIME_NONE
Definition yac.c:56
YAC_INT yac_int
Definition yac_types.h:15
double(* yac_coordinate_pointer)[3]
Definition yac_types.h:21