25 "invalid name (NULL or empty string is not allowed)")
28 grid->output_filename = NULL;
29 grid->metadata = NULL;
36 YAC_ASSERT((grids != NULL) && (num_grids != NULL),
"invalid argument")
40 for (
size_t i = 0; i < *num_grids; ++i)
41 if (!strcmp((*grids)[i].
name,
name))
return i;
45 *grids =
xrealloc(*grids, (*num_grids) *
sizeof(**grids));
53 char const * output_filename) {
56 (output_filename != NULL) && (output_filename[0] !=
'\0'),
57 "invalid output filename for grid \"%s\" "
58 "(NULL or empty string is not allowed)",
61 (grid->output_filename == NULL) ||
62 (!strcmp(grid->output_filename, output_filename)),
63 "output file name for grid \"%s\" has already been set "
65 grid->name, grid->output_filename, output_filename);
67 if (grid->output_filename == NULL)
68 grid->output_filename =
xstrdup(output_filename);
73 char const * metadata) {
77 "invalid metadata for grid \"%s\" (NULL is not allowed)",
80 (grid->metadata == NULL) || (!strcmp(grid->metadata, metadata)),
81 "metadata for grid \"%s\" has already been set "
83 grid->name, grid->metadata, metadata);
85 if (grid->metadata == NULL)
86 grid->metadata =
xstrdup(metadata);
90 void * grid_, MPI_Comm comm) {
96 "yac_couple_config_get_grid_pack_size", grid->name, comm, 1);
100 void * grid_,
void *
buffer,
int buffer_size,
int * position, MPI_Comm comm) {
105 "yac_couple_config_pack_grid", grid->name,
buffer, buffer_size,
110 void *
buffer,
int buffer_size,
int * position,
void * grid_,
125 "invalid name (NULL is not allowed)");
131 void * a_,
void * b_, MPI_Comm comm) {
149 free((
void*)grid->name);
151 free((
void*)grid->output_filename);
152 grid->output_filename = NULL;
153 free(grid->metadata);
154 grid->metadata = NULL;
173 YAC_ASSERT((grids != NULL) && (num_grids != NULL),
"invalid argument")
175 size_t * old_to_new_idx;
176 void * p_grids = *grids;
178 num_grids, &p_grids,
sizeof((*grids)[0]),
182 for (
size_t comp_idx = 0; comp_idx <
num_components; ++comp_idx) {
184 components + comp_idx, old_to_new_idx);
187 free(old_to_new_idx);
193 YAC_ASSERT((grids != NULL) && (num_grids != NULL),
"invalid argument")
195 for (
size_t i = 0; i < *num_grids; ++i)
#define YAC_ASSERT(exp, msg)
void yac_couple_config_component_update_all_grid_idx(struct yac_couple_config_component *component, size_t const *old_to_new_idx)
static void yac_couple_config_grid_merge(void *a_, void *b_, MPI_Comm comm)
void yac_couple_config_grids_free(struct yac_couple_config_grid **grids, size_t *num_grids)
static int yac_couple_config_grid_compare(void const *a, void const *b)
static size_t yac_couple_config_get_grid_pack_size(void *grid_, MPI_Comm comm)
static struct yac_dist_merge_vtable dist_merge_vtable_grid
void yac_couple_config_grid_free(struct yac_couple_config_grid *grid)
void yac_couple_config_set_grid_metadata_value(struct yac_couple_config_grid *grid, char const *metadata)
static void yac_couple_config_unpack_grid(void *buffer, int buffer_size, int *position, void *grid_, MPI_Comm comm)
size_t yac_couple_config_grid_append(struct yac_couple_config_grid **grids, size_t *num_grids, char const *name)
void yac_couple_config_set_grid_output_filename_value(struct yac_couple_config_grid *grid, char const *output_filename)
static void yac_couple_config_pack_grid(void *grid_, void *buffer, int buffer_size, int *position, MPI_Comm comm)
static void yac_couple_config_grid_init(struct yac_couple_config_grid *grid, char const *name)
void yac_couple_config_grids_merge(struct yac_couple_config_grid **grids, size_t *num_grids, struct yac_couple_config_component *components, size_t num_components, MPI_Comm comm)
void yac_couple_config_sync_string(char const *string_name, char **string, MPI_Comm comm)
void yac_dist_merge(size_t *count, void **array, size_t element_size, MPI_Comm comm, struct yac_dist_merge_vtable *vtable, size_t **idx_old_to_new)
#define xrealloc(ptr, size)
char const * output_filename
size_t(* get_pack_size)(void *element, MPI_Comm comm)
char * yac_string_dup(char const *string)
#define YAC_ASSERT_F(exp, format,...)
size_t yac_string_get_pack_size(char const *caller, char const *string, MPI_Comm comm, int allow_null)
Compute number of bytes required to pack a string for MPI transport.
char * yac_string_unpack(void const *buffer, int buffer_size, int *position, MPI_Comm comm)
Unpack a C string from a buffer packed with yac_string_pack.
void yac_string_pack(char const *caller, char const *string, void *buffer, int buffer_size, int *position, MPI_Comm comm, int allow_null)
Pack a C string into a provided buffer using MPI_Pack semantics.