21#define YAC_RAD (0.01745329251994329576923690768489)
30 {
"even",
"odd",
"none"};
33 double value,
int idx,
int collection_idx,
int with_field_mask);
35 double value,
int idx,
int collection_idx,
int with_field_mask,
38static int utest_check_src_no_mask(
39 double value,
int idx,
int collection_idx,
int with_field_mask);
40static int utest_check_src_even_mask(
41 double value,
int idx,
int collection_idx,
int with_field_mask);
42static int utest_check_src_odd_mask(
43 double value,
int idx,
int collection_idx,
int with_field_mask);
44static int utest_check_tgt_no_mask(
45 double value,
int idx,
int collection_idx,
int with_field_mask,
47static int utest_check_tgt_even_mask(
48 double value,
int idx,
int collection_idx,
int with_field_mask,
50static int utest_check_tgt_odd_mask(
51 double value,
int idx,
int collection_idx,
int with_field_mask,
55 utest_check_src_even_mask,
56 utest_check_src_odd_mask,
57 utest_check_src_no_mask};
59 utest_check_tgt_even_mask,
60 utest_check_tgt_odd_mask,
61 utest_check_tgt_no_mask};
63int main(
int argc,
char** argv) {
69 PUT_ERR(
"ERROR: missing config file directory");
77 malloc(strlen(argv[1]) + 32), argv[1]),
"coupling_test9.yaml");
82 MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
83 MPI_Comm_size ( MPI_COMM_WORLD, &size );
86 fputs(
"wrong number of processes (has to be 2)\n", stderr);
90 int is_target =
rank == 1;
94 char const * src_comp_name =
"source_comp";
95 char const * tgt_comp_name =
"target_comp";
109 char const * src_grid_rot_name =
"source_grid_rot";
110 char const * tgt_grid_rot_name =
"target_grid_rot";
112 (is_target)?tgt_grid_rot_name:src_grid_rot_name, (int[2]){3,3}, (
int[2]){0,0},
125 int point_id_named_reg2d, point_id_named_curve2d;
126 int point_id_named_unstruct, point_id_named_reg2d_rot;
131 "pointset_reg2d", &point_id_named_reg2d);
133 PUT_ERR(
"ERROR in yac_cdef_points_reg2d_named");
143 "pointset_curve2d", &point_id_named_curve2d);
145 PUT_ERR(
"ERROR in yac_cdef_points_curve2d_named");
155 "pointset_unstruct", &point_id_named_unstruct);
157 PUT_ERR(
"ERROR in yac_cdef_points_unstruct_named");
164 "pointset_reg2d_rot", &point_id_named_reg2d_rot);
166 PUT_ERR(
"ERROR in yac_cdef_points_reg2d_rot_named");
169 int default_mask_id, dummy_mask_id;
172 (
int[3*3]){1,0,0, 0,0,0, 0,0,0}, &default_mask_id);
173 char const * even_mask_name =
"even_mask";
176 (
int[3*3]){1,0,1, 0,1,0, 1,0,1}, even_mask_name, &dummy_mask_id);
177 char const * odd_mask_name =
"odd_mask";
180 (
int[3*3]){0,1,0, 1,0,1, 0,1,0}, odd_mask_name, &dummy_mask_id);
183 int field_ids[2][2][3][3];
184 for (
int config_from_file = 0; config_from_file < 2; ++config_from_file) {
185 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
186 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
187 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
188 char field_name[128];
190 field_name,
"src2tgt_%s_%s_field_mask_%s_src_mask_%s_tgt_mask",
191 config_from_file?
"yaml":
"manual",
192 with_field_mask?
"with":
"without",
195 if (with_field_mask) {
197 field_name,
comp_id, &point_id_named_reg2d,
200 &field_ids[config_from_file]
208 &field_ids[config_from_file]
219 int interp_stack_config;
223 int ext_couple_config;
225 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
226 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
227 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
228 if (source_mask_type != 2)
230 ext_couple_config, 1, source_mask_type?&odd_mask_name:&even_mask_name);
233 if (target_mask_type != 2)
235 ext_couple_config, target_mask_type?odd_mask_name:even_mask_name);
239 size_t num_src_maks_names;
240 char const *
const * src_mask_names;
242 ext_couple_config, &num_src_maks_names, &src_mask_names);
243 if ((num_src_maks_names != (source_mask_type != 2)) ||
244 ((source_mask_type == 2) && (src_mask_names != NULL)) ||
245 ((source_mask_type != 2) &&
246 strcmp(src_mask_names[0],
247 source_mask_type?odd_mask_name:even_mask_name)))
248 PUT_ERR(
"ERROR in yac_cget_ext_couple_config_src_mask_names");
249 char const * tgt_mask_name;
251 if (((target_mask_type == 2) && (tgt_mask_name != NULL)) ||
252 ((target_mask_type != 2) &&
253 strcmp(tgt_mask_name, target_mask_type?odd_mask_name:even_mask_name)))
254 PUT_ERR(
"ERROR in yac_cget_ext_couple_config_tgt_mask_name");
256 char field_name[128];
258 field_name,
"src2tgt_manual_%s_field_mask_%s_src_mask_%s_tgt_mask",
259 with_field_mask?
"with":
"without",
266 interp_stack_config, 0, 0, ext_couple_config);
270 char const * dummy_mask_name =
"dummy_src_mask";
272 ext_couple_config, 1, &dummy_mask_name);
279 {{{ 0, 1, 2, 3, 4, 5, 6, 7, 8}},
280 {{10,11,12,13,14,15,16,17,18}},
281 {{20,21,22,23,24,25,26,27,28}}};
284 for (
int t = 0;
t < 4; ++
t) {
288 for (
int config_from_file = 0; config_from_file < 2; ++config_from_file) {
289 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
290 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
291 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
295 field_ids[config_from_file]
301 field_ids[config_from_file]
306 PUT_ERR(
"error in yac_cput_: wrong info");
314 for (
int config_from_file = 0; config_from_file < 2; ++config_from_file) {
315 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
316 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
317 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
323 recv_field[j][k] = -1;
328 field_ids[config_from_file]
335 field_ids[config_from_file]
347 PUT_ERR(
"error in yac_cget_: wrong info");
352 if (utest_check_tgt[target_mask_type](
353 recv_field[j][k], k, j, with_field_mask,
354 utest_check_src[source_mask_type]))
355 PUT_ERR(
"error in yac_cget_: wrong recv_field");
368static int utest_check_src_even_mask(
369 double value,
int idx,
int collection_idx,
int with_field_mask) {
374 return (
int)
value & 1;
377static int utest_check_src_odd_mask(
378 double value,
int idx,
int collection_idx,
int with_field_mask) {
383 return !((int)
value & 1);
386static int utest_check_src_no_mask(
387 double value,
int idx,
int collection_idx,
int with_field_mask) {
391 ((int)
value != (10 * collection_idx)):
392 ((int)
value != idx + 10 * collection_idx);
395static int utest_check_tgt_even_mask(
396 double value,
int idx,
int collection_idx,
int with_field_mask,
402 utest_check_src(
value, idx, collection_idx, with_field_mask);
405static int utest_check_tgt_odd_mask(
406 double value,
int idx,
int collection_idx,
int with_field_mask,
411 utest_check_src(
value, idx, collection_idx, with_field_mask):(
value != -1.0);
414static int utest_check_tgt_no_mask(
415 double value,
int idx,
int collection_idx,
int with_field_mask,
419 (with_field_mask && idx)?
421 utest_check_src(
value, idx, collection_idx, with_field_mask);
static char const * mask_types[3]
int(* func_check_tgt_ptr)(double value, int idx, int collection_idx, int with_field_mask, func_check_src_ptr utest_check_src)
int(* func_check_src_ptr)(double value, int idx, int collection_idx, int with_field_mask)
char const src_grid_name[]
char const tgt_grid_name[]
void yac_cdef_field_mask(char const *name, int const comp_id, int const *point_ids, int const *mask_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_cget_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
void yac_cfree_ext_couple_config(int ext_couple_config_id)
void yac_cset_ext_couple_config_tgt_mask_name(int ext_couple_config_id, char const *tgt_mask_name)
void yac_cdef_points_curve2d_named(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, char const *name, int *point_id)
void yac_cdef_points_reg2d_rot_named(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, double x_north_pole, double y_north_pole, char const *name, int *point_id)
void yac_cdef_grid_reg2d_rot(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, double x_north_pole, double y_north_pole, int *grid_id)
void yac_cfinalize()
Finalises YAC.
void yac_cset_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t num_src_mask_names, char const *const *src_mask_names)
void yac_cdef_points_unstruct_named(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, char const *name, int *point_id)
void yac_cget_ext_couple_config(int *ext_couple_config_id)
void yac_cdef_points_reg2d_named(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, char const *name, int *point_id)
int const YAC_LOCATION_CORNER
void yac_cdef_couple_custom(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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, int ext_couple_config_id)
void yac_cget_ext_couple_config_tgt_mask_name(int ext_couple_config_id, char const **tgt_mask_name)
void yac_cget_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t *num_src_mask_names, char const *const **src_mask_names)
void yac_cdef_grid_reg2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
void yac_cdef_points_reg2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
int const YAC_TIME_UNIT_SECOND
void yac_cread_config_yaml(const char *yaml_filename)
void yac_cdef_calendar(int calendar)
void yac_cwait(int field_id)
void yac_cput_(int const field_id, int const collection_size, double *send_field, int *info, int *ierr)
int const YAC_PROLEPTIC_GREGORIAN
void yac_cget_async_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
int const YAC_ACTION_COUPLING
data exchange
void yac_cdef_mask(int const grid_id, int const nbr_points, int const located, int const *is_valid, int *mask_id)
void yac_cdef_mask_named(int const grid_id, int const nbr_points, int const located, int const *is_valid, char const *name, int *mask_id)
void yac_cfree_interp_stack_config(int interp_stack_config_id)
void yac_cadd_interp_stack_config_nnn(int interp_stack_config_id, int type, size_t n, double max_search_distance, double scale)
void yac_cget_interp_stack_config(int *interp_stack_config_id)
void yac_cdef_comp(char const *comp_name, int *comp_id)
void yac_cdef_field(char const *name, int const comp_id, int const *point_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
size_t yac_cget_points_size(int points_id)
int const YAC_REDUCTION_TIME_NONE