A test for the parallel conservativeā interpolation method.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "tests.h"
#include "dist_grid_utils.h"
#include <mpi.h>
#include <yaxt.h>
char const src_grid_name[] = "src_grid";
char const tgt_grid_name[] = "tgt_grid";
static void test1();
static void test2();
static void test3();
static void test4();
static void test5();
static void test6();
static void test7();
static void test8();
static void test9();
static void test10();
static void test11();
static void test12();
static void test13();
static void test14();
MPI_Init(NULL, NULL);
xt_initialize(MPI_COMM_WORLD);
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
test10();
test11();
test12();
test13();
test14();
xt_finalize();
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void test1() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 2) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 2;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank == 1;
int is_target = comm_rank == 0;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1,0,1};
double coordinates_y[] = {-1,0,1};
size_t const num_cells[2] = {2,2};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{2,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-0.5,0.5};
double coordinates_y[] = {-0.5,0.5};
size_t const num_cells[2] = {1,1};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{1,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 1;
int enforced_conserv = 0;
int partial_coverage = 0;
order, enforced_conserv, partial_coverage, normalisation), NULL};
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
double * src_field =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_field[i] =
(double)(src_grid_data->
cell_ids[i] + 1) +
(double)(collection_idx * 4):
-1.0;
src_data[collection_idx][0] = src_field;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[1] = {2.5};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 4;
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
(double)offset) - tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test2() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 3) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 3;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1,0,1};
double coordinates_y[] = {-1,0,1};
size_t const num_cells[2] = {2,2};
size_t local_start[2][2] = {{0,0},{1,0}};
size_t local_count[2][2] = {{1,2},{1,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-0.5,0.5};
double coordinates_y[] = {-0.5,0.5};
size_t const num_cells[2] = {1,1};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{1,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 1;
int enforced_conserv = 1;
int partial_coverage = 0;
order, enforced_conserv, partial_coverage, normalisation), NULL};
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(double)(src_grid_data->
cell_ids[i] + 1) +
(double)(collection_idx * 4):
-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[1] = {2.5};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 4;
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
(double)offset) - tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test3() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 5) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 5;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 2;
int is_target = comm_rank < 2;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1.5,-0.5,0.5,1.5};
double coordinates_y[] = {-1.5,-0.5,0.5,1.5};
size_t const num_cells[2] = {3,3};
size_t local_start[3][2] = {{0,0},{1,0},{2,0}};
size_t local_count[3][2] = {{1,3},{1,3},{1,3}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-1,0,1};
double coordinates_y[] = {-1,0,1};
size_t const num_cells[2] = {2,2};
size_t local_start[2][2] = {{0,0},{0,1}};
size_t local_count[2][2] = {{2,1},{2,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 1;
int enforced_conserv = 0;
int partial_coverage = 0;
order, enforced_conserv, partial_coverage, normalisation), NULL};
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(double)(src_grid_data->
cell_ids[i] + 1) +
(double)(collection_idx * 9):
-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[4] = {3,4,6,7};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 9;
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
(double)offset) - tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test4() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 8) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 5;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 2;
int is_target = comm_rank < 2;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {0,1,2,3,4};
double coordinates_y[] = {0,1,2,3,4};
size_t const num_cells[2] = {4,4};
size_t local_start[3][2] = {{0,0},{0,1},{0,3}};
size_t local_count[3][2] = {{4,1},{4,2},{4,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {0.5,1.5,2.5,3.5};
double coordinates_y[] = {0.5,1.5,2.5,3.5};
size_t const num_cells[2] = {3,3};
size_t local_start[2][2] = {{0,0},{0,1}};
size_t local_count[2][2] = {{3,1},{3,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
int * src_cell_mask = NULL;
if (is_source) {
int global_src_mask [] = {1,1,1,1,
0,1,1,1,
0,0,1,1,
0,0,0,1};
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_cell_mask[i] = global_src_mask[src_grid_data->
cell_ids[i]];
}
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
for (int partial_coverage = 0; partial_coverage <= 1; ++partial_coverage) {
for (int norm_idx = 0; norm_idx <= 1; ++norm_idx) {
int order = 1;
int enforced_conserv = 0;
order, enforced_conserv, partial_coverage,
normalisation[norm_idx]), NULL};
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(double)(collection_idx * 16):
-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[2][2][9] =
{{{-1,3.5,4.5,-1,-1,8.5,-1,-1,-1},
{1.5,3.5,4.5,1.25,5.25,8.5,-1,2.5,9.0}},
{{-1,3.5,4.5,-1,-1,8.5,-1,-1,-1},
{2.0,3.5,4.5,5.0,7.0,8.5,-1,10.0,12.0}}};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 16;
(ref_tgt_field[norm_idx]
[partial_coverage]
[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[norm_idx]
[partial_coverage]
(double)offset) -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test5() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 5) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 5;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 2;
int is_target = comm_rank < 2;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {0,1,2,3,4};
double coordinates_y[] = {0,1,2,3,4};
size_t const num_cells[2] = {4,4};
size_t local_start[3][2] = {{0,0},{0,1},{0,3}};
size_t local_count[3][2] = {{4,1},{4,2},{4,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {0.5,1.5,2.5,3.5};
double coordinates_y[] = {0.5,1.5,2.5,3.5};
size_t const num_cells[2] = {3,3};
size_t local_start[2][2] = {{0,0},{0,1}};
size_t local_count[2][2] = {{3,1},{3,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
int * src_cell_mask = NULL, * tgt_cell_mask = NULL;
if (is_source) {
int global_src_mask [] = {1,1,1,1,
0,1,1,1,
0,0,1,1,
0,0,0,1};
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_cell_mask[i] = global_src_mask[src_grid_data->
cell_ids[i]];
}
if (is_target) {
int global_tgt_mask [] = {1,1,1,
0,0,0,
0,0,0};
double coordinates_x [] = {1.0,2.0,3.0};
double coordinates_y [] = {1.0,2.0,3.0};
for (
size_t i = 0; i < tgt_grid_data->
num_cells; ++i) {
tgt_cell_mask[i] = global_tgt_mask[tgt_grid_data->
cell_ids[i]];
coordinates_x[tgt_grid_data->
cell_ids[i]%3],
coordinates_y[tgt_grid_data->
cell_ids[i]/3],
tgt_cell_coords[i]);
}
}
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
for (int partial_coverage = 0; partial_coverage <= 1; ++partial_coverage) {
for (int norm_idx = 0; norm_idx <= 1; ++norm_idx) {
int order = 1;
int enforced_conserv = 0;
order, enforced_conserv, partial_coverage,
normalisation[norm_idx]), NULL};
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(double)(collection_idx * 16):
-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[2][2][9] =
{{{-1,3.5,4.5,-1,-1,-1,-1,-1,-1},
{1.5,3.5,4.5,-1,-1,-1,-1,-1,-1}},
{{-1,3.5,4.5,-1,-1,-1,-1,-1,-1},
{2.0,3.5,4.5,-1,-1,-1,-1,-1,-1}}};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 16;
(ref_tgt_field[norm_idx]
[partial_coverage]
[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[norm_idx]
[partial_coverage]
(double)offset) -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test6() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 2) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 2;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1.5,-0.5,0.5,1.5};
double coordinates_y[] = {-1.5,-0.5,0.5,1.5};
size_t const num_cells[2] = {3,3};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{3,3}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-0.5,0,0.5};
double coordinates_y[] = {-0.5,0,0.5};
size_t const num_cells[2] = {2,2};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{2,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 2;
int enforced_conserv = 0;
int partial_coverage = 0;
order, enforced_conserv, partial_coverage, normalisation), NULL};
#define NUM_TESTS (4)
for (size_t t = 0; t < NUM_TESTS; ++t) {
for (size_t j = 0; j < 2; ++j) {
double global_field_data[NUM_TESTS][9] = {
{1,1,1, 1,1,1, 1,1,1},
{0,0,0, 1,1,1, 2,2,2},
{0,1,2, 0,1,2, 0,1,2},
{0,1,2, 1,2,3, 2,3,4}};
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
double * src_field =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_field[i] =
global_field_data[t][src_grid_data->
cell_ids[i]]:-1.0;
src_data[collection_idx][0] = src_field;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[NUM_TESTS][4] = {
{1,1,
1,1},
{0.75,0.75,
1.25,1.25},
{0.75,1.25,
0.75,1.25},
{1.5,2.0,
2.0,2.5}};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
(ref_tgt_field[t][tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[t][tgt_grid_data->
cell_ids[j]]) -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
#undef NUM_TESTS
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test7() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 4) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 4;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1.5,-0.5,0.5,1.5};
double coordinates_y[] = {-1.5,-0.5,0.5,1.5};
size_t const num_cells[2] = {3,3};
size_t local_start[3][2] = {{0,0},{0,1},{0,2}};
size_t local_count[3][2] = {{3,1},{3,1},{3,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-0.5,0,0.5};
double coordinates_y[] = {-0.5,0,0.5};
size_t const num_cells[2] = {2,2};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{2,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 2;
int enforced_conserv = 0;
int partial_coverage = 0;
order, enforced_conserv, partial_coverage, normalisation), NULL};
#define NUM_TESTS (4)
for (size_t t = 0; t < NUM_TESTS; ++t) {
for (size_t j = 0; j < 2; ++j) {
double global_field_data[NUM_TESTS][9] = {
{1,1,1, 1,1,1, 1,1,1},
{0,0,0, 1,1,1, 2,2,2},
{0,1,2, 0,1,2, 0,1,2},
{0,1,2, 1,2,3, 2,3,4}};
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
global_field_data[t][src_grid_data->
cell_ids[i]]:-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[NUM_TESTS][4] = {
{1,1,
1,1},
{0.75,0.75,
1.25,1.25},
{0.75,1.25,
0.75,1.25},
{1.5,2.0,
2.0,2.5}};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
(ref_tgt_field[t][tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[t][tgt_grid_data->
cell_ids[j]]) -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
#undef NUM_TESTS
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test8() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 4) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 4;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-2.5,-1.5,-0.5,0.5,1.5,2.5};
double coordinates_y[] = {-2.5,-1.5,-0.5,0.5,1.5,2.5};
size_t const num_cells[2] = {5,5};
size_t local_start[3][2] = {{0,0},{0,2},{3,2}};
size_t local_count[3][2] = {{5,2},{3,3},{2,3}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-2,-1,0,1,2,3};
double coordinates_y[] = {-3,-2,-1,0,1,2};
size_t const num_cells[2] = {5,5};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{5,5}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 2;
int enforced_conserv = 0;
int partial_coverage = 1;
order, enforced_conserv, partial_coverage, normalisation), NULL};
#define NUM_TESTS (4)
for (size_t t = 0; t < NUM_TESTS; ++t) {
for (size_t j = 0; j < 2; ++j) {
double global_src_field_data[NUM_TESTS][25] =
{{1,1,1,1,1,
1,1,1,1,1,
1,1,1,1,1,
1,1,1,1,1,
1,1,1,1,1},
{0.00,0.25,0.50,0.75,1.00,
0.00,0.25,0.50,0.75,1.00,
0.00,0.25,0.50,0.75,1.00,
0.00,0.25,0.50,0.75,1.00,
0.00,0.25,0.50,0.75,1.00},
{0.00,0.00,0.00,0.00,0.00,
0.25,0.25,0.25,0.25,0.25,
0.50,0.50,0.50,0.50,0.50,
0.75,0.75,0.75,0.75,0.75,
1.00,1.00,1.00,1.00,1.00},
{0.00,0.25,0.50,0.75,1.00,
0.25,0.50,0.75,1.00,1.25,
0.50,0.75,1.00,1.25,1.50,
0.75,1.00,1.25,1.50,1.75,
1.00,1.25,1.50,1.75,2.00}};
size_t src_neighs[25][4] =
{{0,1,5,0},{1,2,6,0},{2,3,7,1},{3,4,8,2},{4,4,9,3},
{0,6,10,5},{1,7,11,5},{2,8,12,6},{3,9,13,7},{4,9,14,8},
{5,11,15,10},{6,12,16,10},{7,13,17,11},{8,14,18,12},{9,14,19,13},
{10,16,20,15},{11,17,21,15},{12,18,22,16},{13,19,23,17},{14,19,24,18},
{15,21,20,20},{16,22,21,20},{17,23,22,21},{18,24,23,22},{19,24,24,23}};
double src_gradient_weights_signs[4][4] =
{{-1.0,1.0,1.0,-1.0},{-1.0,-1.0,1.0,1.0},
{1.0,1.0,-1.0,-1.0},{1.0,-1.0,-1.0,1.0}};
double src_gradient_weights[25][4] =
{{0.25,0,0.25,0},{0.25,0.125,0.25,0.125},{0.25,0.125,0.25,0.125},
{0.25,0.125,0.25,0.125},{0.25,0.25,0.25,0.25},
{0.125,0,0.125,0},{0.125,0.125,0.125,0.125},{0.125,0.125,0.125,0.125},
{0.125,0.125,0.125,0.125},{0.125,0.25,0.125,0.25},
{0.125,0,0.125,0},{0.125,0.125,0.125,0.125},{0.125,0.125,0.125,0.125},
{0.125,0.125,0.125,0.125},{0.125,0.25,0.125,0.25},
{0.125,0,0.125,0},{0.125,0.125,0.125,0.125},{0.125,0.125,0.125,0.125},
{0.125,0.125,0.125,0.125},{0.125,0.25,0.125,0.25},
{0,0,0,0},{0,0.125,0,0.125},{0,0.125,0,0.125},
{0,0.125,0,0.125},{0,0.25,0,0.25}};
size_t tgt_to_src[25][4] =
{{SIZE_MAX,SIZE_MAX,0,1}, {SIZE_MAX,SIZE_MAX,1,2},
{SIZE_MAX,SIZE_MAX,2,3},{SIZE_MAX,SIZE_MAX,3,4},
{SIZE_MAX,SIZE_MAX,4,SIZE_MAX},
{0,1,5,6},{1,2,6,7},{2,3,7,8},{3,4,8,9},{4,SIZE_MAX,9,SIZE_MAX},
{5,6,10,11},{6,7,11,12},{7,8,12,13},{8,9,13,14},
{9,SIZE_MAX,14,SIZE_MAX},
{10,11,15,16},{11,12,16,17},{12,13,17,18},{13,14,18,19},
{14,SIZE_MAX,19,SIZE_MAX},
{15,16,20,21},{16,17,21,22},{17,18,22,23},{18,19,23,24},
{19,SIZE_MAX,24,SIZE_MAX}};
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
global_src_field_data[t][src_grid_data->
cell_ids[i]]:-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[25];
for (size_t i = 0; i < 25; ++i) {
double tgt_field_value = 0.0;
for (size_t j = 0; j < 4; ++j) {
size_t src_global_id = tgt_to_src[i][j];
if (src_global_id != SIZE_MAX) {
tgt_field_value +=
global_src_field_data[t][src_global_id];
for (size_t k = 0; k < 4; ++k)
tgt_field_value +=
global_src_field_data[t][src_neighs[src_global_id][k]] *
src_gradient_weights_signs[j][k] *
src_gradient_weights[src_global_id][k];
}
}
ref_tgt_field[i] = tgt_field_value / 4.0;
}
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]]) -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
#undef NUM_TESTS
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test9() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 8) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 8;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 4;
int is_target = comm_rank < 4;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-3,-2,-1,0,1,2,3};
double coordinates_y[] = {-3,-2,-1,0,1,2};
size_t const num_cells[2] = {6,5};
size_t local_start[4][2] = {{0,0},{3,0},{0,2},{3,2}};
size_t local_count[4][2] = {{3,2},{3,2},{3,3},{3,3}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-2.5,-1.5,-0.5,0.5,1.5,2.5};
double coordinates_y[] = {-2.5,-1.5,-0.5,0.5,1.5,2.5,3.5};
size_t const num_cells[2] = {5,6};
size_t local_start[4][2] = {{0,0},{3,0},{0,3},{2,3}};
size_t local_count[4][2] = {{3,2},{3,2},{3,3},{3,3}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name, yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 1;
int enforced_conserv = 0;
int partial_coverage = 0;
order, enforced_conserv, partial_coverage, normalisation), NULL};
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(double)(collection_idx * 30):
-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[30] = {
(0+1+6+7)/4.0,(1+2+7+8)/4.0,(2+3+8+9)/4.0,
(3+4+9+10)/4.0,(4+5+10+11)/4.0,
(6+7+12+13)/4.0,(7+8+13+14)/4.0,(8+9+14+15)/4.0,
(9+10+15+16)/4.0,(10+11+16+17)/4.0,
(12+13+18+19)/4.0,(13+14+19+20)/4.0,(14+15+20+21)/4.0,
(15+16+21+22)/4.0,(16+17+22+23)/4.0,
(18+19+24+25)/4.0,(19+20+25+26)/4.0,(20+21+26+27)/4.0,
(21+22+27+28)/4.0,(22+23+28+29)/4.0,
-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 30;
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
(double)offset) - tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test10() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 2) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 2;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank == 1;
int is_target = comm_rank == 0;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {0.0,1.0,2.0,3.0};
double coordinates_y[] = {0.0,1.0,2.0,3.0};
size_t const num_cells[2] = {3,3};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{3,3}};
int cell_mask[] = {0,0,0, 0,0,0, 0,0,1};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {0.0,0.5,1.0};
double coordinates_y[] = {0.0,0.5,1.0};
size_t const num_cells[2] = {2,2};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{2,2}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
for (int config = 0; config < (1 << 4); ++config) {
int order = ((config >> 0) & 1) + 1;
int enforced_conserv = (config >> 1) & 1;
int partial_coverage = (config >> 2) & 1;
if ((order == 2) && (enforced_conserv == 1)) continue;
order, enforced_conserv, partial_coverage, normalisation),
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
double * src_field =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_field[i] =
(double)(src_grid_data->
cell_ids[i] + 1) +
(double)(collection_idx * 4):
-1.0;
src_data[collection_idx][0] = src_field;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[4] = {-2.0, -2.0, -2.0, -2.0};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs(ref_tgt_field[tgt_grid_data->
cell_ids[j]] -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test11() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 2) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 2;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank == 1;
int is_target = comm_rank == 0;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1.5,-0.5,0.5,1.5};
double coordinates_y[] = {-1.5,-0.5,0.5,1.5};
size_t const num_cells[2] = {3,3};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{3,3}};
int cell_mask[] = {1,1,1, 1,0,1, 1,1,1};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-0.49,0.49};
double coordinates_y[] = {-0.49,0.49};
size_t const num_cells[2] = {1,1};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{1,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
for (int config = 0; config < (1 << 4); ++config) {
int order = ((config >> 0) & 1) + 1;
int enforced_conserv = (config >> 1) & 1;
int partial_coverage = (config >> 2) & 1;
if ((order == 2) && (enforced_conserv == 1)) continue;
order, enforced_conserv, partial_coverage, normalisation),
for (size_t j = 0; j < 2; ++j) {
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
double * src_field =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_field[i] =
(double)(src_grid_data->
cell_ids[i] + 1) +
(double)(collection_idx * 4):
-1.0;
src_data[collection_idx][0] = src_field;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[1] = {-2.0};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -2.0)) {
if (fabs(ref_tgt_field[tgt_grid_data->
cell_ids[j]] -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -2.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test12() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 4) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 4;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1.0,0.0,1.5,2.0};
double coordinates_y[] = {-1.0,0.0,1.5,2.0};
size_t const num_cells[2] = {3,3};
size_t local_start[3][2] = {{0,0},{0,1},{0,2}};
size_t local_count[3][2] = {{3,1},{3,1},{3,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
double coordinates_x[] = {-3.0,-2.0,-1.0,1.0,1.5};
double coordinates_y[] = {-3.0,-2.0,-1.0,1.0,1.5};
size_t const num_cells[2] = {4,4};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{4,4}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_source) {
int global_src_mask [] = {1,1,1,
1,0,1,
1,1,1};
int * src_cell_mask =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_cell_mask[i] = global_src_mask[src_grid_data->
cell_ids[i]];
}
if (is_target) {
int global_tgt_mask [] = {0,0,1,1,
0,1,1,1,
1,1,1,1,
1,1,1,0};
double coordinates_x[] = {-2.5,-1.75,-0.75,0.25};
double coordinates_y[] = {-2.5,-1.75,-0.75,0.25};
int * tgt_cell_mask =
for (
size_t i = 0; i < tgt_grid_data->
num_cells; ++i) {
tgt_cell_mask[i] = global_tgt_mask[tgt_grid_data->
cell_ids[i]];
coordinates_x[tgt_grid_data->
cell_ids[i]%4],
coordinates_y[tgt_grid_data->
cell_ids[i]/4],
tgt_cell_coords[i]);
}
}
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 2;
int enforced_conserv = 0;
int partial_coverage = 1;
order, enforced_conserv, partial_coverage, normalisation),
#define NUM_TESTS (4)
for (size_t t = 0; t < NUM_TESTS; ++t) {
for (size_t j = 0; j < 2; ++j) {
double global_field_data[NUM_TESTS][9] = {
{1,1,1, 1,1,1, 1,1,1},
{0,0,0, 1,1,1, 2,2,2},
{0,1,2, 0,1,2, 0,1,2},
{0,1,2, 1,2,3, 2,3,4}};
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
global_field_data[t][src_grid_data->
cell_ids[i]]:-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[NUM_TESTS][16] = {
{-1.0,-1.0,-2.0,-2.0,
-1.0,-2.0,-2.0,-2.0,
-2.0,-2.0,1.0,1.0,
-2.0,-2.0,1.0,-1.0},
{-1.0,-1.0,-2.0,-2.0,
-1.0,-2.0,-2.0,-2.0,
-2.0,-2.0,(0.0+0.0+1.0)/3.0,0.0,
-2.0,-2.0,1.0,-1.0},
{-1.0,-1.0,-2.0,-2.0,
-1.0,-2.0,-2.0,-2.0,
-2.0,-2.0,(0.0+1.0+0.0)/3.0,1.0,
-2.0,-2.0,0.0,-1.0},
{-1.0,-1.0,-2.0,-2.0,
-1.0,-2.0,-2.0,-2.0,
-2.0,-2.0,(0.0+1.0+1.0)/3.0,1.0,
-2.0,-2.0,1.0,-1.0}};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (
size_t j = 0; j < tgt_grid_data->
num_cells; ++j) {
(ref_tgt_field[t][tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[t][tgt_grid_data->
cell_ids[j]]) -
tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
}
}
#undef NUM_TESTS
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test13() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 2) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 2;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-0.1,0.1};
double coordinates_y[] = {-0.1,0.1};
size_t const num_cells[2] = {1,1};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{1,1}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
src_grid =
src_grid_name,
yac_generate_basic_grid_data_reg2d(
coordinates_x, coordinates_y, num_cells,
local_start[comm_rank], local_count[comm_rank], with_halo));
if (is_target) {
enum {NBR_VERTICES = 15, NBR_CELLS = 8, NUM_VERTICES_PER_CELL = 4};
int num_vertices_per_cell[NBR_CELLS] = {NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL,
NUM_VERTICES_PER_CELL};
double coordinates_x[NBR_VERTICES] = {-3,-2,0,2,3, -3,-2,0,2,3, -3,-2,0,2,3};
double coordinates_y[NBR_VERTICES] = {-1,-1,-1,-1,-1, 0,0,0,0,0, 1,1,1,1,1};
int cell_to_vertex[NBR_CELLS][NUM_VERTICES_PER_CELL] =
{{0,1,6,5}, {1,2,7,6}, {2,3,8,7}, {3,4,9,8},
{5,6,11,10}, {6,7,12,11}, {7,8,13,12}, {8,9,14,13}};
for (size_t i = 0; i < NBR_CELLS; ++i)
tgt_grid =
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 1;
int enforced_conserv = 0;
int partial_coverage = 1;
order, enforced_conserv, partial_coverage, normalisation), NULL};
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(double)(src_grid_data->
cell_ids[i] + 1) +
(double)(collection_idx * 9):
-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[8] = {-1,1,1,-1,-1,1,1,-1};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 9;
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
(double)offset) - tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
MPI_Comm_free(&split_comm);
MPI_Comm_free(&global_comm);
}
static void test14() {
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_size < 2) {
PUT_ERR("ERROR: too few processes");
xt_finalize();
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int is_active = comm_rank < 2;
MPI_Comm global_comm;
MPI_Comm_split(MPI_COMM_WORLD, is_active, 0, &global_comm);
if (!is_active) {
MPI_Comm_free(&global_comm);
return;
}
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
int is_source = comm_rank >= 1;
int is_target = comm_rank < 1;
MPI_Comm split_comm;
MPI_Comm_split(global_comm, is_target, 0, &split_comm);
MPI_Comm_rank(split_comm, &comm_rank);
MPI_Comm_size(split_comm, &comm_size);
if (is_source) {
double coordinates_x[] = {-1.5,-0.5,0.5,1.5};
double coordinates_y[] = {-1.5,-0.5,0.5,1.5};
size_t const num_cells[2] = {3,3};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{3,3}};
int with_halo = 1;
for (
size_t i = 0; i <= num_cells[0]; ++i) coordinates_x[i] *=
YAC_RAD;
for (
size_t i = 0; i <= num_cells[1]; ++i) coordinates_y[i] *=
YAC_RAD;
int cell_core_mask[] = {1,1,1,
1,1,1,
1,0,1};
yac_generate_basic_grid_data_reg2d(
local_start[comm_rank], local_count[comm_rank], with_halo);
for (
size_t i = 0; i < grid_data.
num_cells; ++i)
src_grid =
if (is_target) {
double coordinates_x[] = {-2,0,2};
double coordinates_y[] = {-2,0,2};
size_t local_start[1][2] = {{0,0}};
size_t local_count[1][2] = {{2,2}};
int with_halo = 1;
tgt_grid =
tgt_grid_name,
yac_generate_basic_grid_data_reg2d(
local_start[comm_rank], local_count[comm_rank], with_halo));
size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
int order = 2;
int enforced_conserv = 0;
int partial_coverage = 1;
order, enforced_conserv, partial_coverage, normalisation), NULL};
src_data[i] =
xmalloc(1 *
sizeof(**src_data));
++collection_idx) {
src_data[collection_idx][0] =
for (
size_t i = 0; i < src_grid_data->
num_cells; ++i)
src_data[collection_idx][0][i] =
(1.0 + (double)(collection_idx * 4)):-1.0;
}
++collection_idx) {
free(src_data[collection_idx][0]);
free(src_data[collection_idx]);
}
free(src_data);
}
if (is_target) {
double ref_tgt_field[4] = {1,1,1,1};
double ** tgt_data =
xmalloc(collection_size *
sizeof(*tgt_data));
++collection_idx) {
tgt_data[collection_idx] =
for (
size_t k = 0; k < tgt_grid_data->
num_cells; ++k)
tgt_data[collection_idx][k] = -1;
}
++collection_idx) {
for (size_t j = 0, offset = collection_idx * 4;
(ref_tgt_field[tgt_grid_data->
cell_ids[j]] != -1.0)) {
if (fabs((ref_tgt_field[tgt_grid_data->
cell_ids[j]] +
(double)offset) - tgt_data[collection_idx][j]) > 1e-3)
PUT_ERR("wrong interpolation result");
} else {
if (tgt_data[collection_idx][j] != -1.0)
PUT_ERR("wrong interpolation result");
}
}
}
++collection_idx)
free(tgt_data[collection_idx]);
free(tgt_data);
}
MPI_Comm_free(&split_comm);
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)
int main(int argc, char **argv)
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)
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)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
struct yac_interpolation * yac_interp_weights_get_interpolation(struct yac_interp_weights *weights, enum yac_interp_weights_reorder_type reorder, size_t collection_size, double frac_mask_fallback_value, double scaling_factor, double scaling_summand, char const *yaxt_exchanger_name)
yac_interp_weights_reorder_type
@ YAC_MAPPING_ON_TGT
weights will be applied at target processes
@ YAC_MAPPING_ON_SRC
weights will be appied at source processes
void yac_interpolation_delete(struct yac_interpolation *interp)
void yac_interpolation_execute_get(struct yac_interpolation *interp, double **tgt_field)
void yac_interpolation_execute_put(struct yac_interpolation *interp, double ***src_fields)
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[]
double(* yac_coordinate_pointer)[3]