29#define YAC_RAD (0.01745329251994329576923690768489)
32utest_generate_ref_weights();
34static void utest_submain_src(
37static void utest_submain_tgt(
43 9,10,16,17, 10,11,17,18, 15,16,22,23, 16,17,23,24, 17,18,24,25, 18,19,25,26,
44 22,23,29,30, 23,24,30,31, 24,25,31,32, 25,26,32,33, 30,31,37,38, 31,32,38,39};
46 8,8,8,8, 9,9,9,9, 13,13,13,13, 14,14,14,14, 15,15,15,15, 16,16,16,16,
47 19,19,19,19, 20,20,20,20, 21,21,21,21, 22,22,22,22, 26,26,26,26, 27,27,27,27};
49 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4,
50 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4,
51 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4, 0.1,0.2,0.3,0.4};
53 "test_interpolation_parallel3_weight_file_in.nc";
55 "test_interpolation_parallel3_weight_file_out.nc";
112int main(
int argc,
char *argv[]) {
115 PUT_ERR(
"wrong number of arguments\n");
123 PUT_ERR(
"invalid argument (has to be either \"src\" or \"tgt\")\n");
127 MPI_Init(NULL, NULL);
129 xt_initialize(MPI_COMM_WORLD);
131 int comm_rank, comm_size;
132 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
133 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
134 MPI_Barrier(MPI_COMM_WORLD);
136 if (comm_size != 8) {
137 PUT_ERR(
"ERROR: wrong number of processes");
145 for (
size_t i = 0; i < 6; ++i)
146 for (
size_t j = 0; j < 6; ++j)
150 utest_generate_ref_weights();
154 int comp_flag = comm_rank < 4;
160 if (comp_flag) utest_submain_src(
split_comm, reorder_type);
161 else utest_submain_tgt(
split_comm, reorder_type);
170static void utest_submain_tgt(
174 MPI_Comm_rank(comp_comm, &my_rank);
176 size_t local_start[4][2] = {{0,0},{3,0},{0,3},{3,3}};
177 size_t local_count[4][2] = {{3,3},{3,3},{3,3},{3,3}};
180 utest_generate_basic_grid_data_reg2d(
182 local_start[my_rank], local_count[my_rank],
with_halo);
205 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
207 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = SIZE_MAX};
227 weights, reorder_type, 1,
236 double * target_data_field =
238 double * target_data[1] = {target_data_field};
239 for (
size_t i = 0;
i <
num_cells; ++
i) target_data_field[i] = -1.0;
251 double ref_global_target_data[6*6];
253 for (
size_t i = 0;
i < 6*6; ++
i) {
254 ref_global_target_data[
i] = 0;
255 for (
size_t j = 0; j < 4; ++j)
256 ref_global_target_data[i] +=
264 ref_global_target_data[
grid_data.cell_ids[i]]) > 1e-10)
265 PUT_ERR(
"error in interpolated data on target side\n");
267 if (target_data[0][i] != -1.0)
268 PUT_ERR(
"error in interpolated data on target side\n");
276 free(target_data_field);
291static void utest_submain_src(
295 MPI_Comm_rank(comp_comm, &my_rank);
301 int * tgt_id_fixed = NULL;
302 unsigned num_fixed_tgt = 0;
303 double * fixed_values = NULL;
304 int * num_tgt_per_fixed_value = NULL;
305 unsigned num_fixed_values = 0;
309 fixed_values, num_tgt_per_fixed_value, num_fixed_values,
313 size_t local_start[4][2] = {{0,0},{1,0},{3,0},{5,0}};
314 size_t local_count[4][2] = {{1,6},{2,6},{2,6},{1,6}};
317 utest_generate_basic_grid_data_reg2d(
319 local_start[my_rank], local_count[my_rank],
with_halo);
335 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
337 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = SIZE_MAX};
357 weights, reorder_type, 1,
367 double * source_data_field =
368 xmalloc(num_vertices *
sizeof(*source_data_field));
369 double * source_data_pointset[1] = {source_data_field};
370 double ** source_data[1] = {source_data_pointset};
371 for (
size_t i = 0;
i < num_vertices; ++
i)
372 source_data_field[i] =
374 ((double)(
grid_data.vertex_ids[i])):(-1.0);
402 free(source_data_field);
424utest_generate_ref_weights() {
426 for (
unsigned i = 0;
i < 6; ++
i) {
427 for (
unsigned j = 0; j < 6; ++j) {
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
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)
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)
Delete an interpolation stack and free its resources (but not the pointer array).
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
Perform weight computation using given interpolation stack and 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_file_new(char const *weight_file_name, enum yac_interp_file_on_missing_file on_missing_file, enum yac_interp_file_on_success on_success)
#define YAC_INTERP_FILE_ON_SUCCESS_DEFAULT
#define YAC_INTERP_FILE_ON_MISSING_FILE_DEFAULT
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)
void yac_interp_weights_write_to_file(struct yac_interp_weights *weights, char const *filename, char const *src_grid_name, char const *tgt_grid_name, size_t src_grid_size, size_t tgt_grid_size, enum yac_weight_file_on_existing on_existing)
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
@ YAC_WEIGHT_FILE_ERROR
error when weight file existis already
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[]
static MPI_Comm split_comm
int const * ref_tgt_address_fixed
unsigned ref_num_fixed_values
unsigned const num_links_file
int ref_src_address[4 *36]
char const src_grid_name[]
char const tgt_grid_name[]
char const weight_file_out[]
double cell_coordinates_y[]
double ref_weights[4 *36]
int const * ref_num_tgt_per_fixed_value
double const * ref_fixed_values
int ref_tgt_address[4 *36]
double cell_coords[36][3]
double cell_coordinates_x[]
char const weight_file_in[]
double(* yac_coordinate_pointer)[3]