Skip to content
Snippets Groups Projects
Commit ae6fef98 authored by Moritz Hanke's avatar Moritz Hanke
Browse files

WIP: improves test coverage of routine yac_basic_grid_to_file_parallel

parent e7d8bc7e
No related branches found
No related tags found
No related merge requests found
......@@ -343,6 +343,98 @@ int main(void) {
} // decomp
}
{ // check grid with varying number of corners per cell
size_t nbr_vertices[NUM_PROCS] = {4,5,3};
size_t nbr_cells[NUM_PROCS] = {1,1,1};
int num_vertices_per_cell[NUM_PROCS][1] = {{4},{5},{3}};
double lon_vertices[NUM_PROCS][5] = {{0,1,1,0}, {1,2,2,1.5,1}, {0,1,1.5}};
double lat_vertices[NUM_PROCS][5] = {{0,0,1,1}, {0,0,1,1.5,1}, {1,1,1.5}};
int cell_to_vertex[NUM_PROCS][5] = {{0,1,2,3}, {0,1,2,3,4}, {0,1,2}};
char const * grid_name = "test_grid";
struct yac_basic_grid * grid =
yac_basic_grid_unstruct_deg_new(
grid_name, nbr_vertices[comm_rank], nbr_cells[comm_rank],
num_vertices_per_cell[comm_rank], lon_vertices[comm_rank],
lat_vertices[comm_rank], cell_to_vertex[comm_rank]);
yac_int cell_global_ids[NUM_PROCS][1] = {{0}, {1}, {2}};
int core_cell_mask[NUM_PROCS][1] = {{1}, {1}, {1}};
yac_int vertex_global_ids[NUM_PROCS][5] = {{0,1,4,3}, {1,2,5,6,4}, {3,4,6}};
int core_vertex_mask[NUM_PROCS][5] = {{1,1,1,1}, {1,1,1,1,1}, {1,1,1}};
yac_int edge_global_ids[NUM_PROCS][5] = {{0,1,3,5}, {2,3,4,8,7}, {5,6,7}};
int core_edge_mask[NUM_PROCS][5] = {{1,1,1,1}, {1,1,1,1,1}, {1,1,1}};
struct yac_basic_grid_data * grid_data = yac_basic_grid_get_data(grid);
grid_data->cell_ids =
to_pointer(
cell_global_ids[comm_rank],
grid_data->num_cells * sizeof(cell_global_ids[0]));
grid_data->core_cell_mask =
to_pointer(
core_cell_mask[comm_rank],
grid_data->num_cells * sizeof(core_cell_mask[0]));
grid_data->vertex_ids =
to_pointer(
vertex_global_ids[comm_rank],
grid_data->num_vertices * sizeof(vertex_global_ids[0]));
grid_data->core_vertex_mask =
to_pointer(
core_vertex_mask[comm_rank],
grid_data->num_vertices * sizeof(core_vertex_mask[0]));
grid_data->edge_ids =
to_pointer(
edge_global_ids[comm_rank],
grid_data->num_edges * sizeof(edge_global_ids[0]));
grid_data->core_edge_mask =
to_pointer(
core_edge_mask[comm_rank],
grid_data->num_edges * sizeof(core_edge_mask[0][0]));
// set up io configuration
clear_yac_io_env();
setenv("YAC_IO_RANK_LIST", "0,2", 1);
setenv("YAC_IO_MAX_NUM_RANKS_PER_NODE", "3", 1);
// write distributed grid to file
char const * grid_filename = "test_basic_grid_parallel.nc";
yac_basic_grid_to_file_parallel(grid, grid_filename, MPI_COMM_WORLD);
yac_basic_grid_delete(grid);
MPI_Barrier(MPI_COMM_WORLD);
if (comm_rank == 0) {
enum {NUM_CELLS = 3, NUM_CRN = 5};
double ref_clo[NUM_CELLS][NUM_CRN] =
{{0,1,1,0,DBL_MAX},{1,2,2,1.5,1},{0,1,1.5,DBL_MAX,DBL_MAX}};
double ref_cla[NUM_CELLS][NUM_CRN] =
{{0,0,1,1,DBL_MAX},{0,0,1,1.5,1},{1,1,1.5,DBL_MAX,DBL_MAX}};
int ref_cell_global_ids[NUM_CELLS] = {0,1,2};
int ref_core_cell_mask[NUM_CELLS] = {1,1,1};
int ref_vertex_global_ids[NUM_CELLS][NUM_CRN] =
{{0,1,4,3,INT_MAX},{1,2,5,6,4},{3,4,6,INT_MAX,INT_MAX}};
int ref_core_vertex_mask[NUM_CELLS][NUM_CRN] =
{{1,1,1,1,INT_MAX},{1,1,1,1,1},{1,1,1,INT_MAX,INT_MAX}};
int ref_edge_global_ids[NUM_CELLS][NUM_CRN] =
{{0,3,5,1,INT_MAX}, {2,4,8,7,3}, {5,7,6,INT_MAX,INT_MAX}};
int ref_core_edge_mask[NUM_CELLS][NUM_CRN] =
{{1,1,1,1,INT_MAX},{1,1,1,1,1},{1,1,1,INT_MAX,INT_MAX}};
check_grid_file(
grid_filename, grid_name, NUM_CELLS, NUM_CRN,
&ref_cla[0][0], &ref_clo[0][0], NULL, NULL,
ref_cell_global_ids, ref_core_cell_mask,
&ref_vertex_global_ids[0][0], &ref_core_vertex_mask[0][0],
&ref_edge_global_ids[0][0], &ref_core_edge_mask[0][0]);
}
MPI_Barrier(MPI_COMM_WORLD);
delete_file(grid_filename);
}
xt_finalize();
MPI_Finalize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment