27 "comp3-grid3",
"comp3-grid4",
"comp3-grid5",
29char const *
grid_names[] = {
"grid1",
"grid2",
"grid3",
"grid4",
"grid5"};
37}
grid_config[] = {{.field_names = {
"A_1",
"D_1",
"E_1",
"J_1",
38 "A_2",
"D_2",
"E_2",
"J_2"},
40 .file_name =
"icon_grid_R02B01.nc"},
41 {.field_names = {
"A_1",
"B_1",
"F_1",
"I_1",
42 "A_2",
"B_2",
"F_2",
"I_2"},
44 .file_name =
"icon_grid_R02B01.nc"},
45 {.field_names = {
"B_1",
"C_1",
"D_1",
"G_1",
46 "B_2",
"C_2",
"D_2",
"G_2"},
48 .file_name =
"icon_grid_R03B01.nc"},
49 {.field_names = {
"C_1",
"E_1",
"F_1",
"H_1",
50 "C_2",
"E_2",
"F_2",
"H_2"},
52 .file_name =
"icon_grid_R02B01.nc"},
53 {.field_names = {
"G_1",
"H_1",
"I_1",
"J_1",
54 "G_2",
"H_2",
"I_2",
"J_2"},
56 .file_name =
"icon_grid_R02B01.nc"}};
62#define STR_USAGE "Usage: %s -c configFilename -g gridDirectory\n"
63#define YAC_ASSERT(exp, msg) \
66 fprintf(stderr, "ERROR: %s\n" STR_USAGE, msg, argv[0]); \
75 int argc,
char ** argv,
char const ** configFilename,
76 char const ** gridDirname);
79int main (
int argc,
char *argv[]) {
85 char const * configFilename =
"toy_OASIS3_MCT.yaml";
86 char const * gridDirname =
"";
89 int global_rank, global_size;
90 MPI_Comm_rank(MPI_COMM_WORLD, &global_rank);
91 MPI_Comm_size(MPI_COMM_WORLD, &global_size);
93 if (global_size != 38) {
94 fprintf(stderr,
"Wrong number of processes (should be 38)\n");
100 char const * local_component_names[3];
101 int component_ids[3];
104 local_component_names[i] =
108 int component_ranks[3], component_sizes[3];
110 MPI_Comm component_comm;
112 MPI_Comm_rank(component_comm, &component_ranks[i]);
113 MPI_Comm_size(component_comm, &component_sizes[i]);
119 unsigned num_fields_per_grid[3];
122 double * field_data[3][8];
128 num_fields_per_grid[
i] = 0;
134 int * num_vertices_per_cell;
142 int * global_cell_id;
144 int * global_corner_id;
145 int * corner_core_mask;
147 char * grid_filename =
149 strlen(gridDirname) +
154 grid_filename,
"%s%s", gridDirname,
158 &nbr_vertices, &nbr_cells, &num_vertices_per_cell, &
cell_to_vertex,
159 &x_vertices, &y_vertices, &x_cells, &y_cells, &global_cell_id, &
cell_mask,
161 component_ranks[i], component_sizes[i]);
167 nbr_vertices, nbr_cells, num_vertices_per_cell,
185 num_fields_per_grid[
i] =
188 for (
unsigned j = 0; j < num_fields_per_grid[
i]; ++j) {
196 field_data[
i][j] = malloc(nbr_cells *
sizeof(*(field_data[i][j])));
197 for (
int k = 0; k < nbr_cells; ++k)
198 field_data[i][j][k] =
207 &num_vertices_per_cell,
221 for (
unsigned t = 0;
t < 100; ++
t) {
225 double *point_set_data[1];
226 double **collection_data[1] = {point_set_data};
229 for (
unsigned j = 0; j < num_fields_per_grid[
i]; ++j, ++k) {
234 point_set_data[0] = field_data[
i][j];
235 yac_cput(field_ids[k], 1, collection_data, &
info, &err);
244 for (
unsigned j = 0; j < num_fields_per_grid[
i]; ++j, ++k) {
249 yac_cget(field_ids[k], 1, &(field_data[i][j]), &
info, &err);
259 for (
unsigned j = 0; j < num_fields_per_grid[
i]; ++j)
260 free(field_data[i][j]);
271 for (; rank < 6; ++rank) {
276 for (; rank < 12; ++rank) {
281 for (; rank < 22; ++rank) {
290 for (; rank < 27; ++rank) {
299 for (; rank < 31; ++rank) {
306 for (; rank < 34; ++rank) {
311 for (; rank < 38; ++rank) {
319 int argc,
char ** argv,
char const ** configFilename,
320 char const ** gridDirname) {
323 while ((opt = getopt(argc, argv,
"c:g:")) != -1) {
324 YAC_ASSERT((opt ==
'c') || (opt ==
'g'),
"invalid command argument")
328 *configFilename = optarg;
331 *gridDirname = optarg;
char const * grid_names[]
static void parse_arguments(int argc, char **argv, char const **configFilename, char const **gridDirname)
unsigned component_idx[3]
struct @3 config_per_global_rank[38]
char const * component_names[]
char const * field_names[8]
static void setup_process_config()
#define YAC_ASSERT(exp, msg)
void yac_delete_icon_grid_data(int **cell_mask, int **global_cell_id, int **global_cell_id_rank, int **num_vertices_per_cell, int **global_corner_id, int **global_corner_id_rank, int **cell_to_vertex, double **x_cells, double **y_cells, double **x_vertices, double **y_vertices)
void yac_read_part_icon_grid_information(const char *filename, int *nbr_vertices, int *nbr_cells, int **num_vertices_per_cell, int **cell_to_vertex, double **x_vertices, double **y_vertices, double **x_cells, double **y_cells, int **global_cell_id, int **cell_mask, int **cell_core_mask, int **global_corner_id, int **corner_core_mask, int rank, int size)
double yac_test_func_deg(double lon, double lat)
void yac_cset_global_index(int const *global_index, int location, int grid_id)
int yac_cget_role_from_field_id(int field_id)
int const YAC_LOCATION_CELL
void yac_cfinalize()
Finalises YAC.
int const YAC_LOCATION_CORNER
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_EXCHANGE_TYPE_SOURCE
int const YAC_EXCHANGE_TYPE_TARGET
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_cread_config_yaml(const char *yaml_filename)
void yac_cset_core_mask(int const *is_core, int location, int grid_id)
void yac_cdef_comps(char const **comp_names, int num_comps, int *comp_ids)
void yac_cset_mask(int const *is_valid, int points_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)