23#define YAC_RAD (0.01745329251994329576923690768489)
25#define MAX_COLLECTION_SIZE (10)
30static void utest_target_main(
33static void utest_source_main(
36int main(
int argc,
char *argv[]) {
39 PUT_ERR(
"wrong number of arguments\n");
47 PUT_ERR(
"invalid argument (has to be either \"src\" or \"tgt\")\n");
53 xt_initialize(MPI_COMM_WORLD);
55 int comm_rank, comm_size;
56 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
57 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
58 MPI_Barrier(MPI_COMM_WORLD);
61 PUT_ERR(
"ERROR: wrong number of processes");
69 int tgt_flag = comm_rank < 2;
72 MPI_Comm_split(MPI_COMM_WORLD, tgt_flag, 0, &
split_comm);
74 if (tgt_flag) utest_target_main(
split_comm, reorder_type);
75 else utest_source_main(
split_comm, reorder_type);
107static void utest_source_main(
111 MPI_Comm_rank(source_comm, &my_source_rank);
116 size_t local_start[2][2] = {{0,0},{3,0}};
117 size_t local_count[2][2] = {{3,4},{2,4}};
125 local_start[my_source_rank], local_count[my_source_rank],
with_halo);
136 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
138 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
164 src_data[collection_idx] =
xmalloc(1 *
sizeof(**src_data));
165 src_data[collection_idx][0] =
167 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
168 src_data[collection_idx][0][i] =
170 ((double)(
grid_data.vertex_ids[i]) + (double)(collection_idx * 30)):
206 free(src_data[collection_idx][0]);
207 free(src_data[collection_idx]);
237static void utest_target_main(
241 MPI_Comm_rank(target_comm, &my_target_rank);
246 size_t local_start[2][2] = {{0,0},{3,0}};
247 size_t local_count[2][2] = {{3,3},{3,3}};
255 local_start[my_target_rank], local_count[my_target_rank],
with_halo);
266 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
268 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
291 target_data[i] = target_field[i];
307 for (
size_t k = 0; k < 2; ++k) {
310 for (
unsigned j = 0; j < 16; ++j)
311 target_field[i][j] = -1;
319 double ref_target_data[2][16] = {{3.5,4.5,5.5,6.5,
322 21.5,22.5,23.5,24.5},
326 24.5,25.5,1337,1337}};
329 for (
unsigned j = 0; j < 16; ++j) {
333 ref_target_data[my_target_rank][j]))
334 PUT_ERR(
"error in interpolated data on target side\n");
338 ref_target_data[my_target_rank][j] + (
double)(i * 30)))
339 PUT_ERR(
"error in interpolated data on target side\n");
345 for (
int i = 0;
i < 2; ++
i)
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
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)
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_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
struct yac_interpolation * yac_interpolation_copy(struct yac_interpolation *interp)
Create a deep copy of an interpolation object.
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
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
int double_are_unequal(double a, double b)
int double_are_equal(double a, double b)
static MPI_Comm split_comm
char const grid_name_tgt[]
#define MAX_COLLECTION_SIZE
char const grid_name_src[]