27static char const *
grid_names[2] = {
"src_grid",
"tgt_grid"};
33 xt_initialize(MPI_COMM_WORLD);
35 int comm_rank, comm_size;
36 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
37 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
38 MPI_Barrier(MPI_COMM_WORLD);
41 PUT_ERR(
"ERROR: wrong number of processes");
48 MPI_Comm_split(MPI_COMM_WORLD, comm_rank < 2, 0, &
split_comm);
50 int split_comm_rank, split_comm_size;
73 int is_tgt = split_comm_size == 1;
75 double coordinates_y[] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0};
76 double tgt_cell_coordinates_x[] = {0.5,1.5,2.5};
77 double tgt_cell_coordinates_y[] = {0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5};
78 double tgt_cell_coordinates[24][3];
79 int tgt_cell_mask[24] = {1, 1, 1,
87 size_t const num_cells[2][2] = {{3,2}, {3,8}};
88 size_t local_start[2][2][2] = {{{0,0},{1,0}}, {{0,0}}};
89 size_t local_count[2][2][2] = {{{2,2},{2,2}}, {{3,8}}};
99 local_start[is_tgt][split_comm_rank],
100 local_count[is_tgt][split_comm_rank],
with_halo);
107 for (
size_t i = 0, k = 0;
i <
num_cells[is_tgt][1]; ++
i)
108 for (
size_t j = 0; j <
num_cells[is_tgt][0]; ++j, ++k)
110 tgt_cell_coordinates_x[j], tgt_cell_coordinates_y[i],
111 tgt_cell_coordinates[k]);
122 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
124 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = 0};
130 for (
int creep_distance = -1; creep_distance <= 7; ++creep_distance) {
143 for (
size_t i = 0;
i < 2; ++
i) {
147 weights, reorder_type[i], 1,
155 double * ref_tgt_field = NULL;
156 double ref_global_tgt_field[9][24] =
236 ref_global_tgt_field[creep_distance+1][
grid_data.cell_ids[
i]];
240 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
241 src_field[i] = (
double)(
grid_data.vertex_ids[
i]);
248 if (fabs(ref_tgt_field[i] - tgt_field[i]) > 1e-9)
249 PUT_ERR(
"wrong interpolation result");
279 int is_tgt = split_comm_size == 1;
280 double coordinates_x[2][8] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},
281 {0.5,1.5,2.5,3.5,4.5,5.5,6.5}};
282 double coordinates_y[2][8] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},
283 {0.5,1.5,2.5,3.5,4.5,5.5,6.5}};
300 size_t const num_cells[2][2] = {{7,7}, {6,6}};
301 size_t local_start[2][2][2] = {{{0,0},{3,0}}, {{0,0}}};
302 size_t local_count[2][2][2] = {{{3,7},{4,7}}, {{6,6}}};
312 local_start[is_tgt][split_comm_rank],
313 local_count[is_tgt][split_comm_rank],
with_halo);
319 int temp_vertex_mask[8*8];
320 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
321 temp_vertex_mask[i] = vertex_mask[is_tgt][
grid_data.vertex_ids[i]];
328 {{.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = 0}};
329 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
331 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = 0};
337 for (
int creep_distance = -1; creep_distance <= 3; ++creep_distance) {
350 for (
size_t i = 0;
i < 2; ++
i) {
354 weights, reorder_type[i], 1,
362 double * ref_tgt_field = NULL;
363 double ref_global_tgt_field[5][7*7] =
364 {{ 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
365 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
366 20.5, 20.5, 13.5, -2.0, 17.5, 26.5, 26.5,
367 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
368 36.5, 36.5, 45.5, -2.0, 49.5, 42.5, 42.5,
369 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
370 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
371 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
372 12.5, -1.0, -1.0, -1.0, -1.0, -1.0, 18.5,
373 20.5, -1.0, -1.0, -2.0, -1.0, -1.0, 26.5,
374 28.5, -1.0, -2.0, -1.0, -2.0, -1.0, 34.5,
375 36.5, -1.0, -1.0, -2.0, -1.0, -1.0, 42.5,
376 44.5, -1.0, -1.0, -1.0, -1.0, -1.0, 50.5,
377 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
378 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
379 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
380 20.5, 20.5, -1.0, -2.0, -1.0, 26.5, 26.5,
381 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
382 36.5, 36.5, -1.0, -2.0, -1.0, 42.5, 42.5,
383 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
384 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
385 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
386 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
387 20.5, 20.5, 13.5, -2.0, 17.5, 26.5, 26.5,
388 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
389 36.5, 36.5, 45.5, -2.0, 49.5, 42.5, 42.5,
390 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
391 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
392 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
393 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
394 20.5, 20.5, 13.5, -2.0, 17.5, 26.5, 26.5,
395 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
396 36.5, 36.5, 45.5, -2.0, 49.5, 42.5, 42.5,
397 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
398 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5}};
403 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i) {
406 ref_global_tgt_field[creep_distance+1][
grid_data.vertex_ids[
i]];
410 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
411 src_field[i] = (
double)(
grid_data.vertex_ids[
i]);
417 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
418 if (fabs(ref_tgt_field[i] - tgt_field[i]) > 1e-9)
419 PUT_ERR(
"wrong interpolation result");
449 int is_tgt = split_comm_size == 1;
457 size_t const num_cells[2][2] = {{5,1}, {5,3}};
458 size_t local_start[2][2][2] = {{{0,0},{3,0}}, {{0,0}}};
459 size_t local_count[2][2][2] = {{{3,1},{2,1}}, {{5,3}}};
469 local_start[is_tgt][split_comm_rank],
470 local_count[is_tgt][split_comm_rank],
with_halo);
476 int temp_cell_mask[5*3];
485 {{.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = 0}};
486 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
488 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = 0};
494 for (
int creep_distance = -1; creep_distance <= 5; ++creep_distance) {
507 for (
size_t i = 0;
i < 2; ++
i) {
511 weights, reorder_type[i], 1,
519 double * ref_tgt_field = NULL;
520 double ref_global_tgt_field[7][7*7] =
521 {{ 0.0, 1.0 , 2.0 , 3.0 , 4.0,
522 0.0, 0.5 , -2.0 , 3.5 , 4.0,
523 0.0, 0.25, 2.0 , 3.75, 4.0},
524 { 0.0, -1.0 , 2.0 , -1.0 , 4.0,
525 -1.0, -1.0 , -2.0 , -1.0 , -1.0,
526 -1.0, -1.0 , -1.0 , -1.0 , -1.0},
527 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
528 0.0, -1.0 , -2.0 , -1.0 , 4.0,
529 -1.0, -1.0 , -1.0 , -1.0 , -1.0},
530 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
531 0.0, 0.5 , -2.0 , 3.5 , 4.0,
532 0.0, -1.0 , -1.0 , -1.0 , 4.0},
533 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
534 0.0, 0.5 , -2.0 , 3.5 , 4.0,
535 0.0, 0.25, -1.0 , 3.75, 4.0},
536 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
537 0.0, 0.5 , -2.0 , 3.5 , 4.0,
538 0.0, 0.25, 2.0 , 3.75, 4.0},
539 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
540 0.0, 0.5 , -2.0 , 3.5 , 4.0,
541 0.0, 0.25, 2.0 , 3.75, 4.0}};
549 ref_global_tgt_field[creep_distance+1][
grid_data.cell_ids[
i]];
554 src_field[i] = (
double)(
grid_data.cell_ids[
i]);
561 if (fabs(ref_tgt_field[i] - tgt_field[i]) > 1e-9)
562 PUT_ERR(
"wrong interpolation result");
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
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(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates, size_t count)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
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_avg_new(enum yac_interp_avg_weight_type weight_type, int partial_coverage)
@ YAC_INTERP_AVG_ARITHMETIC
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_CONSERV_DESTAREA
struct interp_method * yac_interp_method_creep_new(int creep_distance)
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_execute(struct yac_interpolation *interp, double ***src_fields, double **tgt_field)
Execute interpolation synchronously and write results to the target field.
void yac_interpolation_delete(struct yac_interpolation *interp)
Free an interpolation object and release all resources.
double const YAC_FRAC_MASK_NO_VALUE
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
static char const * grid_names[2]
static MPI_Comm split_comm
struct yac_basic_grid ** grids