24#define DUMMY_VALUE (-1337.0)
26static void utest_run_setup(
char local_comp_id,
char comp_groups[2][2]);
35 int comm_rank, comm_size;
36 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
37 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
39 if (comm_size != 15) {
40 fputs(
"wrong number of processes (has to be 15)\n", stderr);
45 if (comm_rank < 6) local_comp_id =
'A';
46 else if (comm_rank < 10) local_comp_id =
'B';
47 else if (comm_rank < 13) local_comp_id =
'C';
48 else local_comp_id =
'D';
51 utest_run_setup(local_comp_id, (
char[2][2]){{
'A',
'B'},{
'C',
'D'}});
54 utest_run_setup(local_comp_id, (
char[2][2]){{
'A',
'C'},{
'B',
'D'}});
57 utest_run_setup(local_comp_id, (
char[2][2]){{
'A',
'D'},{
'B',
'C'}});
65 char const * grid_name,
int comm_rank,
int comm_size,
67 int remote_test_func_idx,
double ** field_data_out,
68 double ** ref_field_data_in,
size_t * field_data_size) {
72 unsigned nbr_vertices;
74 unsigned * num_vertices_per_cell;
82 int * corner_core_mask;
84 int * global_corner_id;
87 n, &nbr_vertices, &nbr_cells, &num_vertices_per_cell, &
cell_to_vertex,
88 &x_vertices, &y_vertices, &x_cells, &y_cells, &global_cell_id,
90 comm_rank, comm_size);
93 grid_name, nbr_vertices, nbr_cells, (
int*)num_vertices_per_cell,
103 double (*test_func[4])(double, double) =
109 *field_data_out =
xmalloc(nbr_cells *
sizeof(**field_data_out));
110 for (
unsigned i = 0; i < nbr_cells; ++i)
111 (*field_data_out)[i] =
113 (*(test_func[local_test_func_idx]))(x_cells[i], y_cells[i]):
115 *ref_field_data_in =
xmalloc(nbr_cells *
sizeof(**ref_field_data_in));
116 for (
unsigned i = 0; i < nbr_cells; ++i)
117 (*ref_field_data_in)[i] =
119 (*(test_func[remote_test_func_idx]))(x_cells[i], y_cells[i]):
121 *field_data_size = nbr_cells;
123 free(corner_core_mask);
124 free(global_cell_id);
125 free(global_corner_id);
130 free(num_vertices_per_cell);
135 char local_comp_id,
char remote_comp_id, MPI_Comm comm) {
137 int comm_rank, comm_size;
138 MPI_Comm_rank(comm, &comm_rank);
139 MPI_Comm_size(comm, &comm_size);
147 char local_comp_name[16], local_grid_name[16];
148 char remote_comp_name[16], remote_grid_name[16];
149 char field_out_name[16], field_in_name[16];
150 sprintf(local_comp_name,
"comp%c", local_comp_id);
151 sprintf(local_grid_name,
"grid%c", local_comp_id);
152 sprintf(remote_comp_name,
"comp%c", remote_comp_id);
153 sprintf(remote_grid_name,
"grid%c", remote_comp_id);
154 sprintf(field_out_name,
"field_%c_to_%c", local_comp_id, remote_comp_id);
155 sprintf(field_in_name,
"field_%c_to_%c", remote_comp_id, local_comp_id);
156 int interp_stack_config_id;
159 interp_stack_config_id,
YAC_NNN_AVG, 1, 0.0, -1.0);
161 local_comp_name, local_grid_name, field_out_name,
162 remote_comp_name, remote_grid_name, field_out_name,
164 interp_stack_config_id, 0, 0);
172 int comp_rank, comp_size;
174 MPI_Comm_rank(comp_comm, &comp_rank);
175 MPI_Comm_size(comp_comm, &comp_size);
176 MPI_Comm_free(&comp_comm);
180 double * field_data_out, * ref_field_data_in;
183 (
int)(local_comp_id -
'A'), (
int)(remote_comp_id -
'A'),
184 &field_data_out, &ref_field_data_in, &field_data_size);
187 int field_out_id, field_in_id;
197 double * field_data_in =
xmalloc(field_data_size *
sizeof(*field_data_in));
200 for (
int t = 0; t < 10; ++t) {
204 double *point_set_data[1];
205 double **collection_data[1] = {point_set_data};
206 point_set_data[0] = field_data_out;
207 yac_cput(field_out_id, 1, collection_data, &info, &err);
215 double *collection_data[1] = {field_data_in};
216 yac_cget(field_in_id, 1, collection_data, &info, &err);
219 if(fabs(field_data_in[i] - ref_field_data_in[i]) > 1e-3) {
220 fputs(
"data data_mismatch\n", stderr);
227 free(field_data_out);
228 free(ref_field_data_in);
236static void utest_run_setup(
char local_comp_id,
char comp_groups[2][2]) {
238 int group_idx = (local_comp_id == comp_groups[1][0]) ||
239 (local_comp_id == comp_groups[1][1]);
242 MPI_Comm_split(MPI_COMM_WORLD, group_idx, 0, &group_comm);
244 char remote_comp_id =
245 comp_groups[group_idx][comp_groups[group_idx][0] == local_comp_id];
249 MPI_Comm_free(&group_comm);
void yac_generate_part_cube_grid_information(unsigned n, unsigned *nbr_vertices, unsigned *nbr_cells, unsigned **num_vertices_per_cell, unsigned **cell_to_vertex, double **x_vertices, double **y_vertices, double **x_cells, double **y_cells, int **global_cell_id, int **cell_core_mask, int **global_corner_id, int **corner_core_mask, int rank, int size)
double yac_test_ana_fcos(double lon, double lat)
double yac_test_harmonic(double lon, double lat)
double yac_test_vortex(double lon, double lat)
double yac_test_gulfstream(double lon, double lat)
static void def_grid(char const *grid_name, int comm_rank, int comm_size, int *grid_id, int *cell_point_id, int local_test_func_idx, int remote_test_func_idx, double **field_data_out, double **ref_field_data_in, size_t *field_data_size)
static void run_component(char local_comp_id, char remote_comp_id, MPI_Comm comm)
void yac_cset_global_index(int const *global_index, int location, int grid_id)
void yac_cdef_datetime(const char *start_datetime, const char *end_datetime)
int const YAC_LOCATION_CELL
void yac_cfinalize()
Finalises YAC.
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
void yac_cget(int const field_id, int collection_size, double **recv_field, int *info, int *ierr)
int const YAC_TIME_UNIT_SECOND
void yac_cdef_grid_unstruct(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
void yac_cdef_points_unstruct(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
void yac_cput(int const field_id, int const collection_size, double ***const send_field, int *info, int *ierr)
void yac_cdef_calendar(int calendar)
void yac_cset_core_mask(int const *is_core, int location, int grid_id)
int const YAC_PROLEPTIC_GREGORIAN
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)
void yac_cdef_couple(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 const YAC_REDUCTION_TIME_NONE
void yac_cinit_comm(MPI_Comm comm)