30static void utest_test1();
33static void utest_test2();
36static void utest_test3();
41static void utest_test4();
46static void utest_test5();
49static void utest_test6();
52static void utest_test7();
55static void utest_test8();
59static void utest_test9();
62static void utest_test10();
63static void utest_test11();
66static void utest_test12();
70static void utest_test13();
73static void utest_test14();
79 xt_initialize(MPI_COMM_WORLD);
102static void utest_test1() {
104 int comm_rank, comm_size;
105 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
106 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
107 MPI_Barrier(MPI_COMM_WORLD);
110 PUT_ERR(
"ERROR: too few processes");
116 int is_active = comm_rank < 2;
118 MPI_Comm global_comm;
119 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
122 MPI_Comm_free(&global_comm);
126 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
127 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
129 int is_source = comm_rank == 1;
130 int is_target = comm_rank == 0;
133 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
157 size_t local_start[1][2] = {{0,0}};
158 size_t local_count[1][2] = {{2,2}};
169 local_start[comm_rank], local_count[comm_rank],
with_halo));
177 size_t local_start[1][2] = {{0,0}};
178 size_t local_count[1][2] = {{1,1}};
188 local_start[comm_rank], local_count[comm_rank],
with_halo));
196 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
198 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
205 int enforced_conserv = 0;
206 int partial_coverage = 0;
212 order, enforced_conserv, partial_coverage, normalisation), NULL};
222 for (
size_t j = 0; j < 2; ++j) {
235 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
244 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
247 (double)(src_grid_data->
cell_ids[i] + 1) +
248 (double)(collection_idx * 4):
257 free(src_data[collection_idx][0]);
258 free(src_data[collection_idx]);
263 double ref_tgt_field[1] = {2.5};
271 tgt_data[collection_idx] =
273 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
274 tgt_data[collection_idx][k] = -1;
281 for (
size_t j = 0, offset = collection_idx * 4;
284 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
285 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
286 (
double)offset) - tgt_data[collection_idx][j]) > 1e-3)
287 PUT_ERR(
"wrong interpolation result");
289 if (tgt_data[collection_idx][j] != -1.0)
290 PUT_ERR(
"wrong interpolation result");
297 free(tgt_data[collection_idx]);
312 MPI_Comm_free(&global_comm);
315static void utest_test2() {
317 int comm_rank, comm_size;
318 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
319 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
320 MPI_Barrier(MPI_COMM_WORLD);
323 PUT_ERR(
"ERROR: too few processes");
329 int is_active = comm_rank < 3;
331 MPI_Comm global_comm;
332 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
335 MPI_Comm_free(&global_comm);
339 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
340 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
342 int is_source = comm_rank >= 1;
343 int is_target = comm_rank < 1;
346 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
371 size_t local_start[2][2] = {{0,0},{1,0}};
372 size_t local_count[2][2] = {{1,2},{1,2}};
382 local_start[comm_rank], local_count[comm_rank],
with_halo));
390 size_t local_start[1][2] = {{0,0}};
391 size_t local_count[1][2] = {{1,1}};
401 local_start[comm_rank], local_count[comm_rank],
with_halo));
409 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
411 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
418 int enforced_conserv = 1;
419 int partial_coverage = 0;
425 order, enforced_conserv, partial_coverage, normalisation), NULL};
435 for (
size_t j = 0; j < 2; ++j) {
448 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
455 src_data[collection_idx][0] =
457 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
458 src_data[collection_idx][0][i] =
460 (double)(src_grid_data->
cell_ids[i] + 1) +
461 (double)(collection_idx * 4):
469 free(src_data[collection_idx][0]);
470 free(src_data[collection_idx]);
475 double ref_tgt_field[1] = {2.5};
483 tgt_data[collection_idx] =
485 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
486 tgt_data[collection_idx][k] = -1;
493 for (
size_t j = 0, offset = collection_idx * 4;
496 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
497 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
498 (
double)offset) - tgt_data[collection_idx][j]) > 1e-3)
499 PUT_ERR(
"wrong interpolation result");
501 if (tgt_data[collection_idx][j] != -1.0)
502 PUT_ERR(
"wrong interpolation result");
509 free(tgt_data[collection_idx]);
524 MPI_Comm_free(&global_comm);
527static void utest_test3() {
529 int comm_rank, comm_size;
530 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
531 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
532 MPI_Barrier(MPI_COMM_WORLD);
535 PUT_ERR(
"ERROR: too few processes");
541 int is_active = comm_rank < 5;
543 MPI_Comm global_comm;
544 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
547 MPI_Comm_free(&global_comm);
551 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
552 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
554 int is_source = comm_rank >= 2;
555 int is_target = comm_rank < 2;
558 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
587 size_t local_start[3][2] = {{0,0},{1,0},{2,0}};
588 size_t local_count[3][2] = {{1,3},{1,3},{1,3}};
598 local_start[comm_rank], local_count[comm_rank],
with_halo));
618 size_t local_start[2][2] = {{0,0},{0,1}};
619 size_t local_count[2][2] = {{2,1},{2,1}};
629 local_start[comm_rank], local_count[comm_rank],
with_halo));
637 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
639 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
646 int enforced_conserv = 0;
647 int partial_coverage = 0;
653 order, enforced_conserv, partial_coverage, normalisation), NULL};
663 for (
size_t j = 0; j < 2; ++j) {
676 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
683 src_data[collection_idx][0] =
685 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
686 src_data[collection_idx][0][i] =
688 (double)(src_grid_data->
cell_ids[i] + 1) +
689 (double)(collection_idx * 9):
697 free(src_data[collection_idx][0]);
698 free(src_data[collection_idx]);
703 double ref_tgt_field[4] = {3,4,6,7};
711 tgt_data[collection_idx] =
713 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
714 tgt_data[collection_idx][k] = -1;
721 for (
size_t j = 0, offset = collection_idx * 9;
724 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
725 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
726 (
double)offset) - tgt_data[collection_idx][j]) > 1e-3)
727 PUT_ERR(
"wrong interpolation result");
729 if (tgt_data[collection_idx][j] != -1.0)
730 PUT_ERR(
"wrong interpolation result");
737 free(tgt_data[collection_idx]);
752 MPI_Comm_free(&global_comm);
755static void utest_test4() {
757 int comm_rank, comm_size;
758 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
759 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
760 MPI_Barrier(MPI_COMM_WORLD);
763 PUT_ERR(
"ERROR: too few processes");
769 int is_active = comm_rank < 5;
771 MPI_Comm global_comm;
772 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
775 MPI_Comm_free(&global_comm);
779 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
780 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
782 int is_source = comm_rank >= 2;
783 int is_target = comm_rank < 2;
786 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
831 size_t local_start[3][2] = {{0,0},{0,1},{0,3}};
832 size_t local_count[3][2] = {{4,1},{4,2},{4,1}};
842 local_start[comm_rank], local_count[comm_rank],
with_halo));
865 size_t local_start[2][2] = {{0,0},{0,1}};
866 size_t local_count[2][2] = {{3,1},{3,2}};
876 local_start[comm_rank], local_count[comm_rank],
with_halo));
879 int * src_cell_mask = NULL;
881 int global_src_mask [] = {1,1,1,1,
890 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
891 src_cell_mask[i] = global_src_mask[src_grid_data->
cell_ids[i]];
900 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
902 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
912 for (
int partial_coverage = 0; partial_coverage <= 1; ++partial_coverage) {
913 for (
int norm_idx = 0; norm_idx <= 1; ++norm_idx) {
916 int enforced_conserv = 0;
920 order, enforced_conserv, partial_coverage,
921 normalisation[norm_idx]), NULL};
931 for (
size_t j = 0; j < 2; ++j) {
943 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
950 src_data[collection_idx][0] =
952 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
953 src_data[collection_idx][0][i] =
955 (double)(src_grid_data->
cell_ids[i]) +
956 (double)(collection_idx * 16):
964 free(src_data[collection_idx][0]);
965 free(src_data[collection_idx]);
971 double ref_tgt_field[2][2][9] =
972 {{{-1,3.5,4.5,-1,-1,8.5,-1,-1,-1},
973 {1.5,3.5,4.5,1.25,5.25,8.5,-1,2.5,9.0}},
974 {{-1,3.5,4.5,-1,-1,8.5,-1,-1,-1},
975 {2.0,3.5,4.5,5.0,7.0,8.5,-1,10.0,12.0}}};
983 tgt_data[collection_idx] =
985 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
986 tgt_data[collection_idx][k] = -1;
993 for (
size_t j = 0, offset = collection_idx * 16;
996 (ref_tgt_field[norm_idx]
998 [tgt_grid_data->
cell_ids[j]] != -1.0)) {
999 if (fabs((ref_tgt_field[norm_idx]
1003 tgt_data[collection_idx][j]) > 1e-3)
1004 PUT_ERR(
"wrong interpolation result");
1006 if (tgt_data[collection_idx][j] != -1.0)
1007 PUT_ERR(
"wrong interpolation result");
1014 free(tgt_data[collection_idx]);
1030 MPI_Comm_free(&global_comm);
1033static void utest_test5() {
1035 int comm_rank, comm_size;
1036 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1037 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1038 MPI_Barrier(MPI_COMM_WORLD);
1040 if (comm_size < 5) {
1041 PUT_ERR(
"ERROR: too few processes");
1047 int is_active = comm_rank < 5;
1049 MPI_Comm global_comm;
1050 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
1053 MPI_Comm_free(&global_comm);
1057 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1058 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1060 int is_source = comm_rank >= 2;
1061 int is_target = comm_rank < 2;
1064 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
1109 size_t local_start[3][2] = {{0,0},{0,1},{0,3}};
1110 size_t local_count[3][2] = {{4,1},{4,2},{4,1}};
1120 local_start[comm_rank], local_count[comm_rank],
with_halo));
1153 size_t local_start[2][2] = {{0,0},{0,1}};
1154 size_t local_count[2][2] = {{3,1},{3,2}};
1164 local_start[comm_rank], local_count[comm_rank],
with_halo));
1167 int * src_cell_mask = NULL, * tgt_cell_mask = NULL;
1169 int global_src_mask [] = {1,1,1,1,
1177 src_cell_mask =
xmalloc(src_grid_data->
num_cells *
sizeof(*src_cell_mask));
1178 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
1179 src_cell_mask[i] = global_src_mask[src_grid_data->
cell_ids[i]];
1183 int global_tgt_mask [] = {1,1,1,
1192 tgt_cell_mask =
xmalloc(tgt_grid_data->
num_cells *
sizeof(*tgt_cell_mask));
1195 for (
size_t i = 0;
i < tgt_grid_data->
num_cells; ++
i) {
1196 tgt_cell_mask[
i] = global_tgt_mask[tgt_grid_data->
cell_ids[
i]];
1200 tgt_cell_coords[i]);
1213 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
1215 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = 0};
1225 for (
int partial_coverage = 0; partial_coverage <= 1; ++partial_coverage) {
1226 for (
int norm_idx = 0; norm_idx <= 1; ++norm_idx) {
1229 int enforced_conserv = 0;
1233 order, enforced_conserv, partial_coverage,
1234 normalisation[norm_idx]), NULL};
1244 for (
size_t j = 0; j < 2; ++j) {
1256 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
1263 src_data[collection_idx][0] =
1265 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
1266 src_data[collection_idx][0][i] =
1268 (double)(src_grid_data->
cell_ids[i]) +
1269 (double)(collection_idx * 16):
1277 free(src_data[collection_idx][0]);
1278 free(src_data[collection_idx]);
1284 double ref_tgt_field[2][2][9] =
1285 {{{-1,3.5,4.5,-1,-1,-1,-1,-1,-1},
1286 {1.5,3.5,4.5,-1,-1,-1,-1,-1,-1}},
1287 {{-1,3.5,4.5,-1,-1,-1,-1,-1,-1},
1288 {2.0,3.5,4.5,-1,-1,-1,-1,-1,-1}}};
1296 tgt_data[collection_idx] =
1298 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
1299 tgt_data[collection_idx][k] = -1;
1306 for (
size_t j = 0, offset = collection_idx * 16;
1309 (ref_tgt_field[norm_idx]
1311 [tgt_grid_data->
cell_ids[j]] != -1.0)) {
1312 if (fabs((ref_tgt_field[norm_idx]
1316 tgt_data[collection_idx][j]) > 1e-3)
1317 PUT_ERR(
"wrong interpolation result");
1319 if (tgt_data[collection_idx][j] != -1.0)
1320 PUT_ERR(
"wrong interpolation result");
1327 free(tgt_data[collection_idx]);
1343 MPI_Comm_free(&global_comm);
1346static void utest_test6() {
1348 int comm_rank, comm_size;
1349 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1350 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1351 MPI_Barrier(MPI_COMM_WORLD);
1353 if (comm_size < 2) {
1354 PUT_ERR(
"ERROR: too few processes");
1360 int is_active = comm_rank < 2;
1362 MPI_Comm global_comm;
1363 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
1366 MPI_Comm_free(&global_comm);
1370 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1371 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1373 int is_source = comm_rank >= 1;
1374 int is_target = comm_rank < 1;
1377 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
1406 size_t local_start[1][2] = {{0,0}};
1407 size_t local_count[1][2] = {{3,3}};
1417 local_start[comm_rank], local_count[comm_rank],
with_halo));
1437 size_t local_start[1][2] = {{0,0}};
1438 size_t local_count[1][2] = {{2,2}};
1448 local_start[comm_rank], local_count[comm_rank],
with_halo));
1456 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
1458 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
1465 int enforced_conserv = 0;
1466 int partial_coverage = 0;
1472 order, enforced_conserv, partial_coverage, normalisation), NULL};
1482#define NUM_TESTS (4)
1485 for (
size_t j = 0; j < 2; ++j) {
1496 double global_field_data[
NUM_TESTS][9] = {
1497 {1,1,1, 1,1,1, 1,1,1},
1498 {0,0,0, 1,1,1, 2,2,2},
1499 {0,1,2, 0,1,2, 0,1,2},
1500 {0,1,2, 1,2,3, 2,3,4}};
1504 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
1513 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
1516 global_field_data[
t][src_grid_data->
cell_ids[
i]]:-1.0;
1517 src_data[collection_idx][0] =
src_field;
1524 free(src_data[collection_idx][0]);
1525 free(src_data[collection_idx]);
1546 tgt_data[collection_idx] =
1548 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
1549 tgt_data[collection_idx][k] = -1;
1556 for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
1558 (ref_tgt_field[t][tgt_grid_data->
cell_ids[j]] != -1.0)) {
1559 if (fabs((ref_tgt_field[t][tgt_grid_data->
cell_ids[j]]) -
1560 tgt_data[collection_idx][j]) > 1e-3)
1561 PUT_ERR(
"wrong interpolation result");
1563 if (tgt_data[collection_idx][j] != -1.0)
1564 PUT_ERR(
"wrong interpolation result");
1571 free(tgt_data[collection_idx]);
1587 MPI_Comm_free(&global_comm);
1590static void utest_test7() {
1592 int comm_rank, comm_size;
1593 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1594 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1595 MPI_Barrier(MPI_COMM_WORLD);
1597 if (comm_size < 4) {
1598 PUT_ERR(
"ERROR: too few processes");
1604 int is_active = comm_rank < 4;
1606 MPI_Comm global_comm;
1607 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
1610 MPI_Comm_free(&global_comm);
1614 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1615 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1617 int is_source = comm_rank >= 1;
1618 int is_target = comm_rank < 1;
1621 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
1650 size_t local_start[3][2] = {{0,0},{0,1},{0,2}};
1651 size_t local_count[3][2] = {{3,1},{3,1},{3,1}};
1661 local_start[comm_rank], local_count[comm_rank],
with_halo));
1681 size_t local_start[1][2] = {{0,0}};
1682 size_t local_count[1][2] = {{2,2}};
1692 local_start[comm_rank], local_count[comm_rank],
with_halo));
1700 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
1702 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
1709 int enforced_conserv = 0;
1710 int partial_coverage = 0;
1716 order, enforced_conserv, partial_coverage, normalisation), NULL};
1726#define NUM_TESTS (4)
1729 for (
size_t j = 0; j < 2; ++j) {
1740 double global_field_data[
NUM_TESTS][9] = {
1741 {1,1,1, 1,1,1, 1,1,1},
1742 {0,0,0, 1,1,1, 2,2,2},
1743 {0,1,2, 0,1,2, 0,1,2},
1744 {0,1,2, 1,2,3, 2,3,4}};
1747 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
1754 src_data[collection_idx][0] =
1756 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
1757 src_data[collection_idx][0][i] =
1759 global_field_data[
t][src_grid_data->
cell_ids[
i]]:-1.0;
1766 free(src_data[collection_idx][0]);
1767 free(src_data[collection_idx]);
1788 tgt_data[collection_idx] =
1790 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
1791 tgt_data[collection_idx][k] = -1;
1798 for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
1800 (ref_tgt_field[t][tgt_grid_data->
cell_ids[j]] != -1.0)) {
1801 if (fabs((ref_tgt_field[t][tgt_grid_data->
cell_ids[j]]) -
1802 tgt_data[collection_idx][j]) > 1e-3)
1803 PUT_ERR(
"wrong interpolation result");
1805 if (tgt_data[collection_idx][j] != -1.0)
1806 PUT_ERR(
"wrong interpolation result");
1813 free(tgt_data[collection_idx]);
1829 MPI_Comm_free(&global_comm);
1832static void utest_test8() {
1834 int comm_rank, comm_size;
1835 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1836 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1837 MPI_Barrier(MPI_COMM_WORLD);
1839 if (comm_size < 4) {
1840 PUT_ERR(
"ERROR: too few processes");
1846 int is_active = comm_rank < 4;
1848 MPI_Comm global_comm;
1849 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
1852 MPI_Comm_free(&global_comm);
1856 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
1857 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
1859 int is_source = comm_rank >= 1;
1860 int is_target = comm_rank < 1;
1863 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
1900 size_t local_start[3][2] = {{0,0},{0,2},{3,2}};
1901 size_t local_count[3][2] = {{5,2},{3,3},{2,3}};
1911 local_start[comm_rank], local_count[comm_rank],
with_halo));
1922 size_t local_start[1][2] = {{0,0}};
1923 size_t local_count[1][2] = {{5,5}};
1933 local_start[comm_rank], local_count[comm_rank],
with_halo));
1941 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
1943 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
1950 int enforced_conserv = 0;
1951 int partial_coverage = 1;
1957 order, enforced_conserv, partial_coverage, normalisation), NULL};
1967#define NUM_TESTS (4)
1970 for (
size_t j = 0; j < 2; ++j) {
1979 double global_src_field_data[
NUM_TESTS][25] =
1985 {0.00,0.25,0.50,0.75,1.00,
1986 0.00,0.25,0.50,0.75,1.00,
1987 0.00,0.25,0.50,0.75,1.00,
1988 0.00,0.25,0.50,0.75,1.00,
1989 0.00,0.25,0.50,0.75,1.00},
1990 {0.00,0.00,0.00,0.00,0.00,
1991 0.25,0.25,0.25,0.25,0.25,
1992 0.50,0.50,0.50,0.50,0.50,
1993 0.75,0.75,0.75,0.75,0.75,
1994 1.00,1.00,1.00,1.00,1.00},
1995 {0.00,0.25,0.50,0.75,1.00,
1996 0.25,0.50,0.75,1.00,1.25,
1997 0.50,0.75,1.00,1.25,1.50,
1998 0.75,1.00,1.25,1.50,1.75,
1999 1.00,1.25,1.50,1.75,2.00}};
2001 size_t src_neighs[25][4] =
2002 {{0,1,5,0},{1,2,6,0},{2,3,7,1},{3,4,8,2},{4,4,9,3},
2003 {0,6,10,5},{1,7,11,5},{2,8,12,6},{3,9,13,7},{4,9,14,8},
2004 {5,11,15,10},{6,12,16,10},{7,13,17,11},{8,14,18,12},{9,14,19,13},
2005 {10,16,20,15},{11,17,21,15},{12,18,22,16},{13,19,23,17},{14,19,24,18},
2006 {15,21,20,20},{16,22,21,20},{17,23,22,21},{18,24,23,22},{19,24,24,23}};
2007 double src_gradient_weights_signs[4][4] =
2008 {{-1.0,1.0,1.0,-1.0},{-1.0,-1.0,1.0,1.0},
2009 {1.0,1.0,-1.0,-1.0},{1.0,-1.0,-1.0,1.0}};
2010 double src_gradient_weights[25][4] =
2011 {{0.25,0,0.25,0},{0.25,0.125,0.25,0.125},{0.25,0.125,0.25,0.125},
2012 {0.25,0.125,0.25,0.125},{0.25,0.25,0.25,0.25},
2013 {0.125,0,0.125,0},{0.125,0.125,0.125,0.125},{0.125,0.125,0.125,0.125},
2014 {0.125,0.125,0.125,0.125},{0.125,0.25,0.125,0.25},
2015 {0.125,0,0.125,0},{0.125,0.125,0.125,0.125},{0.125,0.125,0.125,0.125},
2016 {0.125,0.125,0.125,0.125},{0.125,0.25,0.125,0.25},
2017 {0.125,0,0.125,0},{0.125,0.125,0.125,0.125},{0.125,0.125,0.125,0.125},
2018 {0.125,0.125,0.125,0.125},{0.125,0.25,0.125,0.25},
2019 {0,0,0,0},{0,0.125,0,0.125},{0,0.125,0,0.125},
2020 {0,0.125,0,0.125},{0,0.25,0,0.25}};
2021 size_t tgt_to_src[25][4] =
2022 {{SIZE_MAX,SIZE_MAX,0,1}, {SIZE_MAX,SIZE_MAX,1,2},
2023 {SIZE_MAX,SIZE_MAX,2,3},{SIZE_MAX,SIZE_MAX,3,4},
2024 {SIZE_MAX,SIZE_MAX,4,SIZE_MAX},
2025 {0,1,5,6},{1,2,6,7},{2,3,7,8},{3,4,8,9},{4,SIZE_MAX,9,SIZE_MAX},
2026 {5,6,10,11},{6,7,11,12},{7,8,12,13},{8,9,13,14},
2027 {9,SIZE_MAX,14,SIZE_MAX},
2028 {10,11,15,16},{11,12,16,17},{12,13,17,18},{13,14,18,19},
2029 {14,SIZE_MAX,19,SIZE_MAX},
2030 {15,16,20,21},{16,17,21,22},{17,18,22,23},{18,19,23,24},
2031 {19,SIZE_MAX,24,SIZE_MAX}};
2037 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
2044 src_data[collection_idx][0] =
2046 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
2047 src_data[collection_idx][0][i] =
2049 global_src_field_data[
t][src_grid_data->
cell_ids[
i]]:-1.0;
2056 free(src_data[collection_idx][0]);
2057 free(src_data[collection_idx]);
2063 double ref_tgt_field[25];
2065 for (
size_t i = 0;
i < 25; ++
i) {
2066 double tgt_field_value = 0.0;
2067 for (
size_t j = 0; j < 4; ++j) {
2068 size_t src_global_id = tgt_to_src[
i][j];
2069 if (src_global_id != SIZE_MAX) {
2071 global_src_field_data[
t][src_global_id];
2072 for (
size_t k = 0; k < 4; ++k)
2074 global_src_field_data[t][src_neighs[src_global_id][k]] *
2075 src_gradient_weights_signs[j][k] *
2076 src_gradient_weights[src_global_id][k];
2079 ref_tgt_field[
i] = tgt_field_value / 4.0;
2088 tgt_data[collection_idx] =
2090 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
2091 tgt_data[collection_idx][k] = -1;
2098 for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
2100 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]]) -
2101 tgt_data[collection_idx][j]) > 1e-3)
2102 PUT_ERR(
"wrong interpolation result");
2104 if (tgt_data[collection_idx][j] != -1.0)
2105 PUT_ERR(
"wrong interpolation result");
2112 free(tgt_data[collection_idx]);
2128 MPI_Comm_free(&global_comm);
2131static void utest_test9() {
2133 int comm_rank, comm_size;
2134 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2135 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2136 MPI_Barrier(MPI_COMM_WORLD);
2138 if (comm_size < 8) {
2139 PUT_ERR(
"ERROR: too few processes");
2145 int is_active = comm_rank < 8;
2147 MPI_Comm global_comm;
2148 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
2151 MPI_Comm_free(&global_comm);
2155 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2156 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2158 int is_source = comm_rank >= 4;
2159 int is_target = comm_rank < 4;
2162 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
2214 size_t local_start[4][2] = {{0,0},{3,0},{0,2},{3,2}};
2215 size_t local_count[4][2] = {{3,2},{3,2},{3,3},{3,3}};
2225 local_start[comm_rank], local_count[comm_rank],
with_halo));
2277 size_t local_start[4][2] = {{0,0},{3,0},{0,3},{2,3}};
2278 size_t local_count[4][2] = {{3,2},{3,2},{3,3},{3,3}};
2287 local_start[comm_rank], local_count[comm_rank],
with_halo));
2295 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
2297 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
2304 int enforced_conserv = 0;
2305 int partial_coverage = 0;
2311 order, enforced_conserv, partial_coverage, normalisation), NULL};
2321 for (
size_t j = 0; j < 2; ++j) {
2334 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
2341 src_data[collection_idx][0] =
2343 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
2344 src_data[collection_idx][0][i] =
2346 (double)(src_grid_data->
cell_ids[i]) +
2347 (double)(collection_idx * 30):
2355 free(src_data[collection_idx][0]);
2356 free(src_data[collection_idx]);
2361 double ref_tgt_field[30] = {
2362 (0+1+6+7)/4.0,(1+2+7+8)/4.0,(2+3+8+9)/4.0,
2363 (3+4+9+10)/4.0,(4+5+10+11)/4.0,
2364 (6+7+12+13)/4.0,(7+8+13+14)/4.0,(8+9+14+15)/4.0,
2365 (9+10+15+16)/4.0,(10+11+16+17)/4.0,
2366 (12+13+18+19)/4.0,(13+14+19+20)/4.0,(14+15+20+21)/4.0,
2367 (15+16+21+22)/4.0,(16+17+22+23)/4.0,
2368 (18+19+24+25)/4.0,(19+20+25+26)/4.0,(20+21+26+27)/4.0,
2369 (21+22+27+28)/4.0,(22+23+28+29)/4.0,
2379 tgt_data[collection_idx] =
2381 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
2382 tgt_data[collection_idx][k] = -1;
2389 for (
size_t j = 0, offset = collection_idx * 30;
2392 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
2393 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
2394 (
double)offset) - tgt_data[collection_idx][j]) > 1e-3)
2395 PUT_ERR(
"wrong interpolation result");
2397 if (tgt_data[collection_idx][j] != -1.0)
2398 PUT_ERR(
"wrong interpolation result");
2405 free(tgt_data[collection_idx]);
2420 MPI_Comm_free(&global_comm);
2423static void utest_test10() {
2425 int comm_rank, comm_size;
2426 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2427 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2428 MPI_Barrier(MPI_COMM_WORLD);
2430 if (comm_size < 2) {
2431 PUT_ERR(
"ERROR: too few processes");
2437 int is_active = comm_rank < 2;
2439 MPI_Comm global_comm;
2440 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
2443 MPI_Comm_free(&global_comm);
2447 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2448 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2450 int is_source = comm_rank == 1;
2451 int is_target = comm_rank == 0;
2454 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
2483 size_t local_start[1][2] = {{0,0}};
2484 size_t local_count[1][2] = {{3,3}};
2485 int cell_mask[] = {0,0,0, 0,0,0, 0,0,1};
2495 local_start[comm_rank], local_count[comm_rank],
with_halo));
2504 size_t local_start[1][2] = {{0,0}};
2505 size_t local_count[1][2] = {{2,2}};
2515 local_start[comm_rank], local_count[comm_rank],
with_halo));
2523 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
2525 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
2531 for (
int config = 0; config < (1 << 4); ++config) {
2533 int order = ((config >> 0) & 1) + 1;
2534 int enforced_conserv = (config >> 1) & 1;
2535 int partial_coverage = (config >> 2) & 1;
2539 if ((order == 2) && (enforced_conserv == 1))
continue;
2543 order, enforced_conserv, partial_coverage, normalisation),
2554 for (
size_t j = 0; j < 2; ++j) {
2567 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
2576 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
2579 (double)(src_grid_data->
cell_ids[i] + 1) +
2580 (double)(collection_idx * 4):
2582 src_data[collection_idx][0] =
src_field;
2589 free(src_data[collection_idx][0]);
2590 free(src_data[collection_idx]);
2595 double ref_tgt_field[4] = {-2.0, -2.0, -2.0, -2.0};
2603 tgt_data[collection_idx] =
2605 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
2606 tgt_data[collection_idx][k] = -1;
2613 for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
2615 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
2616 if (fabs(ref_tgt_field[tgt_grid_data->
cell_ids[j]] -
2617 tgt_data[collection_idx][j]) > 1e-3)
2618 PUT_ERR(
"wrong interpolation result");
2620 if (tgt_data[collection_idx][j] != -1.0)
2621 PUT_ERR(
"wrong interpolation result");
2628 free(tgt_data[collection_idx]);
2644 MPI_Comm_free(&global_comm);
2647static void utest_test11() {
2649 int comm_rank, comm_size;
2650 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2651 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2652 MPI_Barrier(MPI_COMM_WORLD);
2654 if (comm_size < 2) {
2655 PUT_ERR(
"ERROR: too few processes");
2661 int is_active = comm_rank < 2;
2663 MPI_Comm global_comm;
2664 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
2667 MPI_Comm_free(&global_comm);
2671 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2672 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2674 int is_source = comm_rank == 1;
2675 int is_target = comm_rank == 0;
2678 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
2707 size_t local_start[1][2] = {{0,0}};
2708 size_t local_count[1][2] = {{3,3}};
2709 int cell_mask[] = {1,1,1, 1,0,1, 1,1,1};
2719 local_start[comm_rank], local_count[comm_rank],
with_halo));
2728 size_t local_start[1][2] = {{0,0}};
2729 size_t local_count[1][2] = {{1,1}};
2739 local_start[comm_rank], local_count[comm_rank],
with_halo));
2747 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
2749 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
2755 for (
int config = 0; config < (1 << 4); ++config) {
2757 int order = ((config >> 0) & 1) + 1;
2758 int enforced_conserv = (config >> 1) & 1;
2759 int partial_coverage = (config >> 2) & 1;
2763 if ((order == 2) && (enforced_conserv == 1))
continue;
2767 order, enforced_conserv, partial_coverage, normalisation),
2778 for (
size_t j = 0; j < 2; ++j) {
2791 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
2800 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
2803 (double)(src_grid_data->
cell_ids[i] + 1) +
2804 (double)(collection_idx * 4):
2806 src_data[collection_idx][0] =
src_field;
2813 free(src_data[collection_idx][0]);
2814 free(src_data[collection_idx]);
2819 double ref_tgt_field[1] = {-2.0};
2827 tgt_data[collection_idx] =
2829 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
2830 tgt_data[collection_idx][k] = -1;
2837 for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
2839 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -2.0)) {
2840 if (fabs(ref_tgt_field[tgt_grid_data->
cell_ids[j]] -
2841 tgt_data[collection_idx][j]) > 1e-3)
2842 PUT_ERR(
"wrong interpolation result");
2844 if (tgt_data[collection_idx][j] != -2.0)
2845 PUT_ERR(
"wrong interpolation result");
2852 free(tgt_data[collection_idx]);
2868 MPI_Comm_free(&global_comm);
2871static void utest_test12() {
2873 int comm_rank, comm_size;
2874 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2875 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2876 MPI_Barrier(MPI_COMM_WORLD);
2878 if (comm_size < 4) {
2879 PUT_ERR(
"ERROR: too few processes");
2885 int is_active = comm_rank < 4;
2887 MPI_Comm global_comm;
2888 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
2891 MPI_Comm_free(&global_comm);
2895 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
2896 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
2898 int is_source = comm_rank >= 1;
2899 int is_target = comm_rank < 1;
2902 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
2931 size_t local_start[3][2] = {{0,0},{0,1},{0,2}};
2932 size_t local_count[3][2] = {{3,1},{3,1},{3,1}};
2942 local_start[comm_rank], local_count[comm_rank],
with_halo));
2970 size_t local_start[1][2] = {{0,0}};
2971 size_t local_count[1][2] = {{4,4}};
2981 local_start[comm_rank], local_count[comm_rank],
with_halo));
2985 int global_src_mask [] = {1,1,1,
2992 int * src_cell_mask =
2994 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
2995 src_cell_mask[i] = global_src_mask[src_grid_data->
cell_ids[i]];
3001 int global_tgt_mask [] = {0,0,1,1,
3011 int * tgt_cell_mask =
3015 for (
size_t i = 0;
i < tgt_grid_data->
num_cells; ++
i) {
3016 tgt_cell_mask[
i] = global_tgt_mask[tgt_grid_data->
cell_ids[
i]];
3020 tgt_cell_coords[i]);
3033 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
3035 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = 0};
3042 int enforced_conserv = 0;
3043 int partial_coverage = 1;
3049 order, enforced_conserv, partial_coverage, normalisation),
3060#define NUM_TESTS (4)
3063 for (
size_t j = 0; j < 2; ++j) {
3074 double global_field_data[
NUM_TESTS][9] = {
3075 {1,1,1, 1,1,1, 1,1,1},
3076 {0,0,0, 1,1,1, 2,2,2},
3077 {0,1,2, 0,1,2, 0,1,2},
3078 {0,1,2, 1,2,3, 2,3,4}};
3081 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
3088 src_data[collection_idx][0] =
3090 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
3091 src_data[collection_idx][0][i] =
3093 global_field_data[
t][src_grid_data->
cell_ids[
i]]:-1.0;
3100 free(src_data[collection_idx][0]);
3101 free(src_data[collection_idx]);
3107 {-1.0,-1.0,-2.0,-2.0,
3108 -1.0,-2.0,-2.0,-2.0,
3110 -2.0,-2.0,1.0,-1.0},
3111 {-1.0,-1.0,-2.0,-2.0,
3112 -1.0,-2.0,-2.0,-2.0,
3113 -2.0,-2.0,(0.0+0.0+1.0)/3.0,0.0,
3114 -2.0,-2.0,1.0,-1.0},
3115 {-1.0,-1.0,-2.0,-2.0,
3116 -1.0,-2.0,-2.0,-2.0,
3117 -2.0,-2.0,(0.0+1.0+0.0)/3.0,1.0,
3118 -2.0,-2.0,0.0,-1.0},
3119 {-1.0,-1.0,-2.0,-2.0,
3120 -1.0,-2.0,-2.0,-2.0,
3121 -2.0,-2.0,(0.0+1.0+1.0)/3.0,1.0,
3122 -2.0,-2.0,1.0,-1.0}};
3130 tgt_data[collection_idx] =
3132 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
3133 tgt_data[collection_idx][k] = -1;
3140 for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
3142 (ref_tgt_field[t][tgt_grid_data->
cell_ids[j]] != -1.0)) {
3143 if (fabs((ref_tgt_field[t][tgt_grid_data->
cell_ids[j]]) -
3144 tgt_data[collection_idx][j]) > 1e-3)
3145 PUT_ERR(
"wrong interpolation result");
3147 if (tgt_data[collection_idx][j] != -1.0)
3148 PUT_ERR(
"wrong interpolation result");
3155 free(tgt_data[collection_idx]);
3171 MPI_Comm_free(&global_comm);
3174static void utest_test13() {
3176 int comm_rank, comm_size;
3177 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
3178 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
3179 MPI_Barrier(MPI_COMM_WORLD);
3181 if (comm_size < 2) {
3182 PUT_ERR(
"ERROR: too few processes");
3188 int is_active = comm_rank < 2;
3190 MPI_Comm global_comm;
3191 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
3194 MPI_Comm_free(&global_comm);
3198 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
3199 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
3201 int is_source = comm_rank >= 1;
3202 int is_target = comm_rank < 1;
3205 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
3226 size_t local_start[1][2] = {{0,0}};
3227 size_t local_count[1][2] = {{1,1}};
3237 local_start[comm_rank], local_count[comm_rank],
with_halo));
3255 int num_vertices_per_cell[
NBR_CELLS] = {NUM_VERTICES_PER_CELL,
3256 NUM_VERTICES_PER_CELL,
3257 NUM_VERTICES_PER_CELL,
3258 NUM_VERTICES_PER_CELL,
3259 NUM_VERTICES_PER_CELL,
3260 NUM_VERTICES_PER_CELL,
3261 NUM_VERTICES_PER_CELL,
3262 NUM_VERTICES_PER_CELL};
3263 double coordinates_x[
NBR_VERTICES] = {-3,-2,0,2,3, -3,-2,0,2,3, -3,-2,0,2,3};
3264 double coordinates_y[
NBR_VERTICES] = {-1,-1,-1,-1,-1, 0,0,0,0,0, 1,1,1,1,1};
3266 {{0,1,6,5}, {1,2,7,6}, {2,3,8,7}, {3,4,9,8},
3267 {5,6,11,10}, {6,7,12,11}, {7,8,13,12}, {8,9,14,13}};
3286 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
3288 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
3295 int enforced_conserv = 0;
3296 int partial_coverage = 1;
3302 order, enforced_conserv, partial_coverage, normalisation), NULL};
3319 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
3326 src_data[collection_idx][0] =
3328 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
3329 src_data[collection_idx][0][i] =
3331 (double)(src_grid_data->
cell_ids[i] + 1) +
3332 (double)(collection_idx * 9):
3340 free(src_data[collection_idx][0]);
3341 free(src_data[collection_idx]);
3346 double ref_tgt_field[8] = {-1,1,1,-1,-1,1,1,-1};
3354 tgt_data[collection_idx] =
3356 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
3357 tgt_data[collection_idx][k] = -1;
3364 for (
size_t j = 0, offset = collection_idx * 9;
3368 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
3369 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
3370 (
double)offset) - tgt_data[collection_idx][j]) > 1e-3)
3371 PUT_ERR(
"wrong interpolation result");
3373 if (tgt_data[collection_idx][j] != -1.0)
3374 PUT_ERR(
"wrong interpolation result");
3381 free(tgt_data[collection_idx]);
3394 MPI_Comm_free(&global_comm);
3397static void utest_test14() {
3399 int comm_rank, comm_size;
3400 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
3401 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
3402 MPI_Barrier(MPI_COMM_WORLD);
3404 if (comm_size < 2) {
3405 PUT_ERR(
"ERROR: too few processes");
3411 int is_active = comm_rank < 2;
3413 MPI_Comm global_comm;
3414 MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
3417 MPI_Comm_free(&global_comm);
3421 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
3422 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
3424 int is_source = comm_rank >= 1;
3425 int is_target = comm_rank < 1;
3428 MPI_Comm_split(global_comm, is_target, 0, &
split_comm);
3467 size_t local_start[1][2] = {{0,0}};
3468 size_t local_count[1][2] = {{3,3}};
3479 local_start[comm_rank], local_count[comm_rank],
with_halo);
3505 size_t local_start[1][2] = {{0,0}};
3506 size_t local_count[1][2] = {{2,2}};
3516 local_start[comm_rank], local_count[comm_rank],
with_halo));
3524 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
3526 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
3533 int enforced_conserv = 0;
3534 int partial_coverage = 1;
3540 order, enforced_conserv, partial_coverage, normalisation), NULL};
3557 src_data[i] =
xmalloc(1 *
sizeof(**src_data));
3564 src_data[collection_idx][0] =
3566 for (
size_t i = 0;
i < src_grid_data->
num_cells; ++
i)
3567 src_data[collection_idx][0][i] =
3569 (1.0 + (double)(collection_idx * 4)):-1.0;
3576 free(src_data[collection_idx][0]);
3577 free(src_data[collection_idx]);
3582 double ref_tgt_field[4] = {1,1,1,1};
3590 tgt_data[collection_idx] =
3592 for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
3593 tgt_data[collection_idx][k] = -1;
3600 for (
size_t j = 0, offset = collection_idx * 4;
3603 (ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
3604 if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
3605 (
double)offset) - tgt_data[collection_idx][j]) > 1e-3)
3606 PUT_ERR(
"wrong interpolation result");
3608 if (tgt_data[collection_idx][j] != -1.0)
3609 PUT_ERR(
"wrong interpolation result");
3616 free(tgt_data[collection_idx]);
3629 MPI_Comm_free(&global_comm);
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
struct yac_basic_grid_data * yac_basic_grid_get_data(struct yac_basic_grid *grid)
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)
size_t yac_basic_grid_add_coordinates_nocpy(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
size_t yac_basic_grid_add_mask_nocpy(struct yac_basic_grid *grid, enum yac_location location, int const *mask, char const *mask_name)
struct yac_basic_grid_data yac_generate_basic_grid_data_unstruct_deg(size_t nbr_vertices, size_t nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex)
void yac_dist_grid_pair_delete(struct yac_dist_grid_pair *grid_pair)
struct yac_dist_grid_pair * yac_dist_grid_pair_new(struct yac_basic_grid *grid_a, struct yac_basic_grid *grid_b, MPI_Comm comm)
struct 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)
static void LLtoXYZ_deg(double lon, double lat, double p_out[])
void yac_interp_grid_delete(struct yac_interp_grid *interp_grid)
struct yac_interp_grid * yac_interp_grid_new(struct yac_dist_grid_pair *grid_pair, char const *src_grid_name, char const *tgt_grid_name, size_t num_src_fields, struct yac_interp_field const *src_fields, struct yac_interp_field const tgt_field)
void yac_interp_method_delete(struct interp_method **method)
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
struct interp_method * yac_interp_method_conserv_new(int order, int enforced_conserv, int partial_coverage, enum yac_interp_method_conserv_normalisation normalisation)
yac_interp_method_conserv_normalisation
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
struct interp_method * yac_interp_method_fixed_new(double value)
struct yac_interpolation * yac_interp_weights_get_interpolation(struct yac_interp_weights *weights, enum yac_interp_weights_reorder_type reorder, size_t collection_size, double frac_mask_fallback_value, double scaling_factor, double scaling_summand, char const *yaxt_exchanger_name, int is_source, int is_target)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
yac_interp_weights_reorder_type
@ YAC_MAPPING_ON_TGT
weights will be applied at target processes
@ YAC_MAPPING_ON_SRC
weights will be applied at source processes
void yac_interpolation_delete(struct yac_interpolation *interp)
Free an interpolation object and release all resources.
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).
double const YAC_FRAC_MASK_NO_VALUE
int * num_vertices_per_cell
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
char const src_grid_name[]
char const tgt_grid_name[]
static MPI_Comm split_comm
double(* yac_coordinate_pointer)[3]