29 yac_int const * global_ids,
double const (*coordinates_xyz)[3],
41static int utest_get_num_unique_configurations(
61 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
62 MPI_Comm_size(MPI_COMM_WORLD, &size);
68 PUT_ERR(
"ERROR: wrong number of processes\n");
72 int local_comp_idx =
rank % 3;
77 {.grid_idx = 1, .point_idx = 1},
78 {.grid_idx = 2, .point_idx = 2},
79 {.grid_idx = 3, .point_idx = 3}},
80 {{.grid_idx = 1, .point_idx = 1},
81 {.grid_idx = 1, .point_idx = 2},
82 {.grid_idx = 1, .point_idx = 2},
83 {.grid_idx = 3, .point_idx = 2}},
84 {{.grid_idx = 3, .point_idx = 2},
85 {.grid_idx = 3, .point_idx = 2},
86 {.grid_idx = 3, .point_idx = 2},
87 {.grid_idx = 3, .point_idx = 2}},
88 {{.grid_idx = 0, .point_idx = 0},
89 {.grid_idx = 0, .point_idx = 1},
90 {.grid_idx = 0, .point_idx = 2},
91 {.grid_idx = 0, .point_idx = 3}},
92 {{.grid_idx = 0, .point_idx = 0},
93 {.grid_idx = 1, .point_idx = 0},
94 {.grid_idx = 2, .point_idx = 0},
95 {.grid_idx = 3, .point_idx = 0}},
96 {{.grid_idx = 0, .point_idx = 2},
97 {.grid_idx = 1, .point_idx = 3},
98 {.grid_idx = 0, .point_idx = 2},
99 {.grid_idx = 1, .point_idx = 3}}};
101 NUM_TEST_CASES =
sizeof(test_cases) /
sizeof(test_cases[0]),
105 int check_constructor_call_count[2][3];
106 int check_do_search_call_count[2][3];
108 for (
int comp_offset = -1; comp_offset <= 1; comp_offset += 2) {
109 int other_comp_idx = (local_comp_idx + comp_offset + 3)%3;
110 for (
int direction = 0; direction < 2; ++direction) {
112 char check_constructor_key[256];
113 sprintf(check_constructor_key,
"check_constructor_%u_to_%u",
114 (direction ==
IN)?(other_comp_idx + 1):(local_comp_idx + 1),
115 (direction ==
IN)?(local_comp_idx + 1):(other_comp_idx + 1));
118 &(check_constructor_call_count[direction][other_comp_idx]),
119 check_constructor_key);
121 char check_do_search_key[256];
122 sprintf(check_do_search_key,
"check_do_search_%u_to_%u",
123 (direction ==
IN)?(other_comp_idx + 1):(local_comp_idx + 1),
124 (direction ==
IN)?(local_comp_idx + 1):(other_comp_idx + 1));
127 &(check_do_search_call_count[direction][other_comp_idx]),
128 check_do_search_key);
138 for (
int test_idx_in = 0; test_idx_in < NUM_TEST_CASES; ++test_idx_in) {
140 for (
int comp_idx = 0; comp_idx < 3; ++comp_idx)
141 test_idx[
IN][comp_idx] = test_idx_in;
144 for (
int test_idx_out = 0, test_run_out = 0;
145 test_run_out < (NUM_TEST_CASES + 2) / 3; ++test_run_out) {
147 for (
int comp_idx = 0; comp_idx < 3; ++comp_idx,
148 test_idx_out = (test_idx_out + 1)%NUM_TEST_CASES)
149 test_idx[
OUT][comp_idx] = test_idx_out;
151 for (
int direction = 0; direction < 2; ++direction)
152 for (
int comp_idx = 0; comp_idx < 3; ++comp_idx)
153 for (
int field_idx = 0; field_idx < 4; ++field_idx)
154 test_config[direction][comp_idx][field_idx] =
155 test_cases[test_idx[direction][comp_idx]][field_idx];
157 memset(check_constructor_call_count, 0,
158 sizeof(check_constructor_call_count));
159 memset(check_do_search_call_count, 0,
160 sizeof(check_do_search_call_count));
166 for (
int comp_offset = -1; comp_offset <= 1; comp_offset += 2) {
167 int other_comp_idx = (local_comp_idx + comp_offset + 3)%3;
168 for (
int direction = 0; direction < 2; ++direction)
169 if ((check_constructor_call_count[direction][other_comp_idx] !=
170 check_do_search_call_count[direction][other_comp_idx]) ||
171 (check_constructor_call_count[direction][other_comp_idx] !=
172 utest_get_num_unique_configurations(
173 test_config[direction][local_comp_idx ],
174 test_config[direction^1][other_comp_idx])))
195 yac_int const * global_ids,
double const (*coordinates_xyz)[3],
209 return (*((
const size_t*)a) > *((
const size_t*)b)) -
210 (*((
const size_t*)a) < *((
const size_t*)b));
233static int utest_get_num_unique_configurations(
239 for (
int i = 0;
i < 4; ++
i) {
240 field_configs[
i].src = field_config_a[
i];
241 field_configs[
i].tgt = field_config_b[
i];
247 int num_unique_config = 1;
248 for (
int i = 1;
i < 4; ++
i)
252 return num_unique_config;
258 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
260 int comp_idx = rank % 3;
267 instance,
"2008-03-09T16:05:07",
"2008-03-10T16:05:07");
268 char * coupling_period =
270 for (
size_t src_comp_idx = 0; src_comp_idx < 3; ++src_comp_idx) {
271 char src_comp_id =
'1' + (char)src_comp_idx;
272 for (
size_t tgt_comp_idx = 0; tgt_comp_idx < 3; ++tgt_comp_idx) {
273 char tgt_comp_id =
'1' + (char)tgt_comp_idx;
274 if (src_comp_id == tgt_comp_id)
continue;
275 char src_comp_name[32], tgt_comp_name[32];
276 sprintf(src_comp_name,
"comp_%c", src_comp_id);
277 sprintf(tgt_comp_name,
"comp_%c", tgt_comp_id);
278 char constructor_key[32], do_search_key[32];
279 sprintf(constructor_key,
"check_constructor_%c_to_%c",
280 src_comp_id, tgt_comp_id);
281 sprintf(do_search_key,
"check_do_search_%c_to_%c",
282 src_comp_id, tgt_comp_id);
286 interp_stack, constructor_key, do_search_key);
288 for (
size_t field_idx = 0; field_idx < 4; ++field_idx) {
289 char field_id =
'1' + (char)field_idx;
292 src_comp_id, test_config[
OUT][src_comp_idx][field_idx].
grid_idx+1);
294 tgt_comp_id, test_config[
IN][tgt_comp_idx][field_idx].
grid_idx+1);
296 sprintf(field_name,
"field_from_%c_to_%c_%c",
297 src_comp_id, tgt_comp_id,
field_id);
303 NULL, NULL, NULL, NULL, 0);
308 free(coupling_period);
315 MPI_Comm component_comm =
318 MPI_Comm_rank(component_comm, &comp_rank);
319 MPI_Comm_free(&component_comm);
321 size_t num_vertices[2] = {2,2};
329 yac_int global_cell_ids[1] = {comp_rank};
331 {4 * comp_rank + 0, 4 * comp_rank + 1,
332 4 * comp_rank + 2, 4 * comp_rank + 3};
334 int corner_core_mask[4] = {1,1,1,1};
344 char const * str_direction[2] = {
"in",
"out"};
347 for (
int direction = 0; direction < 2; ++direction) {
350 grid_name,
"grid_%d_%d_%s", comp_idx+1,
351 grid_idx+1, str_direction[direction]);
360 for (
int point_idx = 0; point_idx < 4; ++point_idx) {
361 size_t coordinates_idx =
365 interp_fields[direction]
368 interp_fields[direction]
371 interp_fields[direction]
378 for (
int comp_offset = -1; comp_offset <= 1; comp_offset += 2) {
379 int other_comp_idx = (comp_idx + comp_offset + 3) % 3;
380 for (
int field_idx = 0; field_idx < 4; ++field_idx) {
381 for (
int direction = 0; direction < 2; ++direction) {
382 char field_name[256];
383 sprintf(field_name,
"field_from_%u_to_%u_%u",
384 ((direction ==
IN)?other_comp_idx:comp_idx)+1,
385 ((direction ==
IN)?comp_idx:other_comp_idx)+1,
388 test_config[direction][comp_idx][field_idx];
406 for (
int direction = 0; direction < 2; ++direction)
char const * component_names[]
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(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)
struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d_deg(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
char const * yac_time_to_ISO(char const *time, enum yac_time_unit_type time_unit)
void yac_instance_delete(struct yac_instance *instance)
void yac_instance_def_datetime(struct yac_instance *instance, const char *start_datetime, const char *end_datetime)
void yac_instance_setup(struct yac_instance *instance, struct yac_basic_grid **grids, size_t num_grids)
struct yac_instance * yac_instance_new(MPI_Comm comm)
struct coupling_field * yac_instance_add_field(struct yac_instance *instance, char const *field_name, char const *comp_name, struct yac_basic_grid *grid, struct yac_interp_field *interp_fields, size_t num_interp_fields, int collection_size, char const *timestep)
void yac_instance_def_components(struct yac_instance *instance, char const **comp_names, size_t num_comps)
void yac_instance_def_couple(struct yac_instance *instance, char const *src_comp_name, char const *src_grid_name, char const *src_field_name, char const *tgt_comp_name, char const *tgt_grid_name, char const *tgt_field_name, char const *coupling_period, int time_reduction, struct yac_interp_stack_config *interp_stack_config, int src_lag, int tgt_lag, const char *weight_file_name, int weight_file_on_existing, int mapping_on_source, double scale_factor, double scale_summand, size_t num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name, char const *yaxt_exchanger_name, struct yac_collection_selection const *collection_selection, int use_raw_exchange)
MPI_Comm yac_instance_get_comps_comm(struct yac_instance *instance, char const **comp_names, size_t num_comp_names)
void yac_interp_method_cleanup()
void yac_interp_method_check_add_constructor_callback(func_constructor constructor_callback, void *user_data, char const *key)
void yac_interp_method_check_add_do_search_callback(func_do_search do_search_callback, void *user_data, char const *key)
void yac_interp_stack_config_add_check(struct yac_interp_stack_config *interp_stack_config, char const *constructor_key, char const *do_search_key)
void yac_interp_stack_config_add_fixed(struct yac_interp_stack_config *interp_stack_config, double value)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
struct yac_interp_stack_config * yac_interp_stack_config_new()
#define YAC_WEIGHT_FILE_ON_EXISTING_DEFAULT_VALUE
struct field_config src tgt
enum yac_location location
static int compare_size_t(const void *a, const void *b)
static void check_do_search(yac_int const *global_ids, double const (*coordinates_xyz)[3], size_t count, void *user_data)
static void check_constructor(void *user_data)
static void run_test_configuration(struct field_config test_config[2][3][4])
static int compare_field_config_src_tgt(const void *a, const void *b)
static int compare_field_config(const void *a, const void *b)
char const src_grid_name[]
char const tgt_grid_name[]
void yac_cdef_calendar(int calendar)
int const YAC_PROLEPTIC_GREGORIAN
int const YAC_REDUCTION_TIME_NONE
void yac_yaxt_init(MPI_Comm comm)