YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
perf_toy_cube.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#include <mpi.h>
6#include <stdio.h>
7#include "yac.h"
8#include "yac_utils.h"
9#include "perf_toy_common.h"
10#include "perf_toy_cube.h"
11
13 int comp_id, size_t n_cube, int * cell_point_id, int * corner_point_id) {
14
15 // get cube component communicator
16 MPI_Comm comp_comm;
17 yac_cget_comp_comm(comp_id, &comp_comm);
18 int comp_rank;
19 MPI_Comm_rank(comp_comm,&comp_rank);
20
21 // generate cubed sphere grid filename based on edge length
22 char cube_grid_filename[256];
23 sprintf(cube_grid_filename, "c_%zu.nc", n_cube);
24
25 // check on root process if the grid file already exists
26 if ((comp_rank == 0) && !yac_file_exists(cube_grid_filename)) {
27
28 // generate cubed sphere grid and write it to file
29 // (file format matches the one of the ICON grid, so that the same reading
30 // function can be used)
31 void * write_timer =
32 start_timer(MPI_COMM_SELF, "%s;%zu", "write_cube_grid", n_cube);
33 yac_write_cubed_sphere_grid(n_cube, cube_grid_filename);
34 stop_timer(write_timer);
35 }
36
37 // wait for rank 0 to finish writing the grid file (if not already existing)
38 MPI_Barrier(comp_comm);
39
40 // initialize grid data and register it with YAC
42 comp_id, "cube_grid", cube_grid_filename, cell_point_id, corner_point_id);
43}
void yac_write_cubed_sphere_grid(unsigned n, char const *filename)
int yac_file_exists(const char *filename)
Check whether a file exists.
Definition io_utils.c:394
void * start_timer(MPI_Comm comm, char const *fmt,...)
Starts a timer and returns a pointer to the timer data.
void init_grid(int comp_id, char const *grid_name, char const *grid_filename, int *cell_point_id, int *corner_point_id)
Initializes grid data and registers it with YAC.
void stop_timer(void *timer_)
Stops the timer and prints the timing results.
void init_cube(int comp_id, size_t n_cube, int *cell_point_id, int *corner_point_id)
Initializes cube grid data and registers it with YAC.
int cell_point_id
int comp_id
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
Definition yac.c:1132