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";
115 int default_mask_id, dummy_mask_id;
118 (
int[3*3]){1,0,0, 0,0,0, 0,0,0}, &default_mask_id);
119 char const * even_mask_name =
"even_mask";
122 (
int[3*3]){1,0,1, 0,1,0, 1,0,1}, even_mask_name, &dummy_mask_id);
123 char const * odd_mask_name =
"odd_mask";
126 (
int[3*3]){0,1,0, 1,0,1, 0,1,0}, odd_mask_name, &dummy_mask_id);
129 int field_ids[2][2][3][3];
130 for (
int config_from_file = 0; config_from_file < 2; ++config_from_file) {
131 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
132 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
133 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
134 char field_name[128];
136 field_name,
"src2tgt_%s_%s_field_mask_%s_src_mask_%s_tgt_mask",
137 config_from_file?
"yaml":
"manual",
138 with_field_mask?
"with":
"without",
141 if (with_field_mask) {
145 &field_ids[config_from_file]
153 &field_ids[config_from_file]
164 int interp_stack_config;
168 int ext_couple_config;
170 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
171 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
172 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
173 if (source_mask_type != 2)
175 ext_couple_config, 1, source_mask_type?&odd_mask_name:&even_mask_name);
178 if (target_mask_type != 2)
180 ext_couple_config, target_mask_type?odd_mask_name:even_mask_name);
184 size_t num_src_maks_names;
185 char const *
const * src_mask_names;
187 ext_couple_config, &num_src_maks_names, &src_mask_names);
188 if ((num_src_maks_names != (source_mask_type != 2)) ||
189 ((source_mask_type == 2) && (src_mask_names != NULL)) ||
190 ((source_mask_type != 2) &&
191 strcmp(src_mask_names[0],
192 source_mask_type?odd_mask_name:even_mask_name)))
193 PUT_ERR(
"ERROR in yac_cget_ext_couple_config_src_mask_names");
194 char const * tgt_mask_name;
196 if (((target_mask_type == 2) && (tgt_mask_name != NULL)) ||
197 ((target_mask_type != 2) &&
198 strcmp(tgt_mask_name, target_mask_type?odd_mask_name:even_mask_name)))
199 PUT_ERR(
"ERROR in yac_cget_ext_couple_config_tgt_mask_name");
201 char field_name[128];
203 field_name,
"src2tgt_manual_%s_field_mask_%s_src_mask_%s_tgt_mask",
204 with_field_mask?
"with":
"without",
211 interp_stack_config, 0, 0, ext_couple_config);
215 char const * dummy_mask_name =
"dummy_src_mask";
217 ext_couple_config, 1, &dummy_mask_name);
224 {{{ 0, 1, 2, 3, 4, 5, 6, 7, 8}},
225 {{10,11,12,13,14,15,16,17,18}},
226 {{20,21,22,23,24,25,26,27,28}}};
229 for (
int t = 0;
t < 4; ++
t) {
233 for (
int config_from_file = 0; config_from_file < 2; ++config_from_file) {
234 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
235 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
236 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
240 field_ids[config_from_file]
246 field_ids[config_from_file]
251 PUT_ERR(
"error in yac_cput_: wrong info");
259 for (
int config_from_file = 0; config_from_file < 2; ++config_from_file) {
260 for (
int with_field_mask = 0; with_field_mask < 2; ++with_field_mask) {
261 for (
int source_mask_type = 0; source_mask_type < 3; ++source_mask_type) {
262 for (
int target_mask_type = 0; target_mask_type < 3; ++target_mask_type) {
268 recv_field[j][k] = -1;
273 field_ids[config_from_file]
280 field_ids[config_from_file]
292 PUT_ERR(
"error in yac_cget_: wrong info");
297 if (utest_check_tgt[target_mask_type](
298 recv_field[j][k], k, j, with_field_mask,
299 utest_check_src[source_mask_type]))
300 PUT_ERR(
"error in yac_cget_: wrong recv_field");
313static int utest_check_src_even_mask(
314 double value,
int idx,
int collection_idx,
int with_field_mask) {
319 return (
int)
value & 1;
322static int utest_check_src_odd_mask(
323 double value,
int idx,
int collection_idx,
int with_field_mask) {
328 return !((int)
value & 1);
331static int utest_check_src_no_mask(
332 double value,
int idx,
int collection_idx,
int with_field_mask) {
336 ((int)
value != (10 * collection_idx)):
337 ((int)
value != idx + 10 * collection_idx);
340static int utest_check_tgt_even_mask(
341 double value,
int idx,
int collection_idx,
int with_field_mask,
347 utest_check_src(
value, idx, collection_idx, with_field_mask);
350static int utest_check_tgt_odd_mask(
351 double value,
int idx,
int collection_idx,
int with_field_mask,
356 utest_check_src(
value, idx, collection_idx, with_field_mask):(
value != -1.0);
359static int utest_check_tgt_no_mask(
360 double value,
int idx,
int collection_idx,
int with_field_mask,
364 (with_field_mask && idx)?
366 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_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_cget_ext_couple_config(int *ext_couple_config_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)
int const YAC_REDUCTION_TIME_NONE