35static void utest_compute_weights_callback(
36 double const tgt_coords[3],
int src_cell_id,
size_t src_cell_idx,
37 int const ** global_results_points,
double ** result_weights,
40int main(
int argc,
char** argv) {
44 xt_initialize(MPI_COMM_WORLD);
46 int comm_rank, comm_size;
47 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
48 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
53 PUT_ERR(
"ERROR: missing grid file directory");
60 char * grid_filenames[] ={
"icon_grid_0030_R02B03_G.nc",
"icon_grid_0043_R02B04_G.nc"};
61 for (
int i = 0;
i < 2; ++
i)
65 malloc(strlen(argv[1]) + strlen(grid_filenames[i]) + 2), argv[1]),
70 for (
int i = 0;
i < 2; ++
i)
73 filenames[i], MPI_COMM_WORLD);
84 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
86 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
117 for (
int i = 0;
i < 2; ++
i) {
124 char const * weight_file_empty =
125 "test_interp_method_parallel_weights_empty.nc";
126 char const * weight_file_fixed =
127 "test_interp_method_parallel_weights_fixed.nc";
133 if (comm_rank == 0) {
136 int * tgt_indices = NULL;
137 int * src_indices = NULL;
139 size_t num_links = 0;
143 NUM_SRC_FIELDS =
sizeof(src_locations) /
sizeof(src_locations[0])};
145 int * tgt_id_fixed = NULL;
146 size_t num_fixed_tgt = 0;
147 double * fixed_values = NULL;
148 int * num_tgt_per_fixed_value = NULL;
149 size_t num_fixed_values = 0;
152 weight_file_empty, src_indices, tgt_indices, weights, num_links,
154 num_fixed_tgt, fixed_values, num_tgt_per_fixed_value,
159 int * tgt_indices = NULL;
160 int * src_indices = NULL;
162 size_t num_links = 0;
166 NUM_SRC_FIELDS =
sizeof(src_locations) /
sizeof(src_locations[0])};
168 int tgt_id_fixed[] = {0, 1, 2, 3};
169 size_t num_fixed_tgt = 4;
170 double fixed_values[] = {999.0};
171 int num_tgt_per_fixed_value[] = {4};
172 size_t num_fixed_values = 1;
175 weight_file_fixed, src_indices, tgt_indices, weights, num_links,
177 num_fixed_tgt, fixed_values, num_tgt_per_fixed_value,
183 size_t num_vertices[2] = {3,3};
194 double cell_coords_x[] = {0.5, 1.5};
195 double cell_coords_y[] = {0.5, 1.5};
196 for (
int i = 0, k = 0;
i < 2; ++
i)
197 for (
int j = 0; j < 2; ++j, ++k)
207 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
209 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = SIZE_MAX};
265 "error in handling of interpolation_complete argument by do_search");
278 if (comm_rank == 0) {
279 unlink(weight_file_empty);
280 unlink(weight_file_fixed);
291static void utest_compute_weights_callback(
292 double const tgt_coords[3],
int src_cell_id,
size_t src_cell_idx,
293 int const ** global_results_points,
double ** result_weights,
294 size_t * result_count,
void *
user_data) {
299 UNUSED(global_results_points);
304 PUT_ERR(
"ERROR: in handling interpolation_complete in do_search_callback");
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_reg_2d_deg_new(char const *name, size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
size_t yac_basic_grid_add_coordinates(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates, size_t count)
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)
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)
#define YAC_INTERP_AVG_PARTIAL_COVERAGE_DEFAULT
yac_interp_avg_weight_type
#define YAC_INTERP_AVG_WEIGHT_TYPE_DEFAULT
struct interp_method * yac_interp_method_callback_new(yac_func_compute_weights compute_weights_callback, void *user_data)
struct interp_method * yac_interp_method_check_new(func_constructor constructor_callback, void *constructor_user_data, func_do_search do_search_callback, void *do_search_user_data)
struct interp_method * yac_interp_method_conserv_new(int order, int enforced_conserv, int partial_coverage, enum yac_interp_method_conserv_normalisation normalisation)
#define YAC_INTERP_CONSERV_NORMALISATION_DEFAULT
#define YAC_INTERP_CONSERV_ENFORCED_CONSERV_DEFAULT
#define YAC_INTERP_CONSERV_PARTIAL_COVERAGE_DEFAULT
#define YAC_INTERP_CONSERV_ORDER_DEFAULT
yac_interp_method_conserv_normalisation
struct interp_method * yac_interp_method_creep_new(int creep_distance)
#define YAC_INTERP_CREEP_DISTANCE_DEFAULT
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)
@ YAC_INTERP_FILE_MISSING_ERROR
abort on missing file
@ YAC_INTERP_FILE_SUCCESS_CONT
@ YAC_INTERP_FILE_SUCCESS_STOP
struct interp_method * yac_interp_method_fixed_new(double value)
#define YAC_INTERP_FIXED_VALUE_DEFAULT
struct interp_method * yac_interp_method_hcsbb_new()
struct interp_method * yac_interp_method_ncc_new(enum yac_interp_ncc_weight_type weight_type, int partial_coverage)
#define YAC_INTERP_NCC_PARTIAL_COVERAGE_DEFAULT
#define YAC_INTERP_NCC_WEIGHT_TYPE_DEFAULT
yac_interp_ncc_weight_type
struct interp_method * yac_interp_method_nnn_new(struct yac_nnn_config config)
#define YAC_INTERP_NNN_WEIGHTED_DEFAULT
yac_interp_nnn_weight_type
#define YAC_INTERP_NNN_MAX_SEARCH_DISTANCE_DEFAULT
#define YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT
#define YAC_INTERP_NNN_N_DEFAULT
struct interp_method * yac_interp_method_spmap_new(struct yac_interp_spmap_config const *default_config, struct yac_spmap_overwrite_config const *const *overwrite_configs)
#define YAC_INTERP_SPMAP_OVERWRITE_DEFAULT
#define YAC_INTERP_SPMAP_DEFAULT_CONFIG
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)
size_t yac_interp_weights_get_interp_count(struct yac_interp_weights *weights)
@ 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.
double const YAC_FRAC_MASK_NO_VALUE
struct yac_basic_grid_data yac_read_icon_basic_grid_data_parallel(const char *filename, MPI_Comm comm)
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
void set_even_io_rank_list(MPI_Comm comm)
char const src_grid_name[]
char const tgt_grid_name[]
double cell_coords[36][3]
void write_weight_file(char const *file_name, int const *src_id, int const *tgt_id, double const *weights, unsigned num_links, enum yac_location const *src_locations, unsigned num_src_fields, int const *num_links_per_src_field, int *tgt_id_fixed, unsigned num_fixed_tgt, double *fixed_values, int *num_tgt_per_fixed_value, unsigned num_fixed_values, enum yac_location tgt_location, char const *src_grid_name, char const *tgt_grid_name)
struct yac_basic_grid ** grids