YetAnotherCoupler 3.2.0_a
Loading...
Searching...
No Matches
test_couple_config.c

This example tests the generation of a coupling configuration.

// Copyright (c) 2024 The YAC Authors
//
// SPDX-License-Identifier: BSD-3-Clause
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <mpi.h>
#include "tests.h"
#include "yac.h"
#include "config_yaml.h"
#include "instance.h"
#include "event.h"
#include "geometry.h"
static void check_couple_config(struct yac_couple_config * couple_config);
static struct yac_couple_config * generate_couple_config_from_YAML_parallel(
char const * config_filename);
static struct yac_couple_config * generate_couple_config_from_YAML(
char const * config_filename, int parse_flags);
static void write_couple_config_to_YAML(
struct yac_couple_config * couple_config, char const * config_filename,
int emit_flags);
int main(int argc, char** argv) {
MPI_Init(NULL, NULL);
int size, rank;
MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
MPI_Comm_size ( MPI_COMM_WORLD, &size );
if (size != 2) {
fputs("ERROR wrong number of processes (has to be 2)", stderr);
exit(EXIT_FAILURE);
}
if (argc != 2) {
PUT_ERR("ERROR: missing config file directory");
xt_finalize();
MPI_Finalize();
return TEST_EXIT_CODE;
}
char const * filename = "couple_config_test.yaml";
char * config_filename = malloc(strlen(argv[1]) + 32);
struct yac_couple_config * couple_config =
generate_couple_config_from_YAML_parallel(
strcat(strcpy(config_filename, argv[1]), filename));
// check the emitting of coupling configurations (on rank zero only)
if (rank == 0) {
struct {
int emit_flags;
int parse_flags;
char const * ext;
} formats[] =
{{.emit_flags = YAC_YAML_EMITTER_DEFAULT,
.parse_flags = YAC_YAML_PARSER_DEFAULT,
.ext = "yaml"},
{.emit_flags = YAC_YAML_EMITTER_JSON,
.ext = "json"}};
enum {NUM_FORMATS = sizeof(formats) / sizeof(formats[0])};
for (int i = 0; i < NUM_FORMATS; ++i) {
sprintf(config_filename,
"temp_couple_config_test.%s", formats[i].ext);
write_couple_config_to_YAML(
couple_config, config_filename, formats[i].emit_flags);
check_couple_config(
generate_couple_config_from_YAML(
config_filename, formats[i].parse_flags));
unlink(config_filename);
}
}
free(config_filename);
check_couple_config(couple_config);
{ // reproduces a bug in routine dist_merge
struct yac_couple_config * couple_config = yac_couple_config_new();
struct yac_interp_stack_config * interp_stack_config =
yac_interp_stack_config_add_fixed(interp_stack_config, -1.0);
couple_config, "comp_a", "grid_a", "field_a",
"comp_b", "grid_b", "field_b", "1", YAC_REDUCTION_TIME_NONE,
interp_stack_config, 0, 0, NULL, 0, 1.0, 0.0, 0, NULL, NULL);
yac_interp_stack_config_delete(interp_stack_config);
couple_config, (rank == 0)?"comp_c":"comp_d");
yac_couple_config_sync(couple_config, MPI_COMM_WORLD);
yac_couple_config_delete(couple_config);
}
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void check_couple_config(struct yac_couple_config * couple_config) {
if (yac_couple_config_get_num_components(couple_config) != 4)
PUT_ERR("ERROR in yac_couple_config_get_num_components\n");
if (!yac_couple_config_component_name_is_valid(couple_config, "ICON-O"))
PUT_ERR("ERROR in yac_couple_config_component_name_is_valid\n");
if (!yac_couple_config_component_name_is_valid(couple_config, "ICON-A"))
PUT_ERR("ERROR in yac_couple_config_component_name_is_valid\n");
if (!yac_couple_config_component_name_is_valid(couple_config, "DUMMY"))
PUT_ERR("ERROR in yac_couple_config_component_name_is_valid\n");
if (!yac_couple_config_component_name_is_valid(couple_config, "DUMMY_2"))
PUT_ERR("ERROR in yac_couple_config_component_name_is_valid\n");
if (yac_couple_config_component_name_is_valid(couple_config, "INVALID"))
PUT_ERR("ERROR in yac_couple_config_component_name_is_valid\n");
if (!yac_couple_config_contains_grid_name(couple_config, "grid1"))
PUT_ERR("ERROR in yac_couple_config_contains_grid_name\n");
if (!yac_couple_config_contains_grid_name(couple_config, "grid2"))
PUT_ERR("ERROR in yac_couple_config_contains_grid_name\n");
if (!yac_couple_config_contains_grid_name(couple_config, "grid3"))
PUT_ERR("ERROR in yac_couple_config_contains_grid_name\n");
if (!yac_couple_config_contains_grid_name(couple_config, "grid4"))
PUT_ERR("ERROR in yac_couple_config_contains_grid_name\n");
if (yac_couple_config_contains_grid_name(couple_config, "grid5"))
PUT_ERR("ERROR in yac_couple_config_contains_grid_name\n");
if (strcmp("grid1_meta",
yac_couple_config_grid_get_metadata(couple_config, "grid1")))
PUT_ERR("ERROR in yac_couple_config_grid_get_metadata\n");
if (strcmp("grid2_meta",
yac_couple_config_grid_get_metadata(couple_config, "grid2")))
PUT_ERR("ERROR in yac_couple_config_grid_get_metadata\n");
char const * start_datetime =
if (!start_datetime || strcmp(start_datetime, "2008-03-09T16:05:07"))
PUT_ERR("ERROR in yac_couple_config_get_start_datetime\n");
char const * end_datetime =
if (!end_datetime || strcmp(end_datetime, "2008-03-10T16:05:07"))
PUT_ERR("ERROR in yac_couple_config_get_end_datetime\n");
couple_config, "2009-03-09T16:05:07", "2009-03-10T16:05:07");
if (strcmp(yac_couple_config_get_start_datetime(couple_config),
"2009-03-09T16:05:07"))
PUT_ERR("ERROR in yac_couple_config_get_start_datetime\n");
if (strcmp(yac_couple_config_get_end_datetime(couple_config),
"2009-03-10T16:05:07"))
PUT_ERR("ERROR in yac_couple_config_get_end_datetime\n");
size_t ref_num_couples = 2;
if (ref_num_couples !=
PUT_ERR("ERROR in yac_couple_config_get_num_couples\n");
char const * ref_component_names[2][2] =
{{"ICON-A", "ICON-O"}, {"ICON-O", "DUMMY"}};
size_t ref_num_field_couples[2] = {5, 2};
char const * ref_field_grid_names[2][5][2] =
{{{"grid1","grid3"},
{"grid3","grid1"},
{"grid1","grid3"},
{"grid3","grid2"},
{"grid2","grid3"}},
{{"grid2","grid4"},
{"grid4","grid2"}}};
char const * ref_field_component_names[2][5][2] =
{{{"ICON-O","ICON-A"},
{"ICON-A","ICON-O"},
{"ICON-O","ICON-A"},
{"ICON-A","ICON-O"},
{"ICON-O","ICON-A"}},
{{"ICON-O", "DUMMY"},
{"DUMMY", "ICON-O"}}};
double ref_frac_mask_fallback_value[2][5] =
double ref_scale_factor[2][5] = {{1.0,10.0, 1.0, 0.5,1.0}, {1.0,9.0/5.0}};
double ref_scale_summand[2][5] = {{0.0, 0.0,-1.0,-0.5,0.0}, {0.0,32.0}};
size_t ref_field_collection_size[2][5] = {{3,3,4,4,5},{5, 2}};
char const * ref_field_name[2][5] =
{{"sea_surface_temperature",
"wind_speed",
"water_flux_into_sea_water",
"grid_eastward_wind",
"grid_northward_wind"},
{"grid_northward_wind",
"manual_field"}};
int ref_mapping_on_source[2][5] = {{1,1,0,0,1},{1, 0}};
char const * ref_coupling_period[2][5] =
{{"10","20","30","40","50"},{"50", "60"}};
enum yac_reduction_type ref_coupling_period_operation[2][5] =
char const * ref_timestep[2][5][2] =
{{{"1","10"},{"2","20"},{"3","30"},{"4","40"},{"5","50"}},
{{"5","50"}, {"6", "60"}}};
int ref_lag[2][5][2] = {{{0,4},{1,3},{2,2},{3,1},{4,0}},{{4,0},{0,0}}};
int ref_enforce_write_weight_file[2][5] = {{1,0,1,0,1},{1,0}};
char const * ref_weight_file_name[2][5] =
{{"weights1.nc",
"weights2.nc",
"weights3.nc",
"weights4.nc",
"weights5.nc"},
{"weights6.nc",
"weights7.nc"}};
struct yac_interp_stack_config * ref_interp_stack_config[2][5];
size_t ref_num_src_mask_names[2][5] = {{1,3,0,0,0}, {0,2}};
char const * const * ref_src_mask_names[2][5] =
{{(char const*[]){"src_sst_mask"},
(char const*[]){"src_wind_mask1", "src_wind_mask2", "src_wind_mask3"},
NULL, NULL, NULL},
{NULL, (char const*[]){"src_mask1", "src_mask2"}}};
char const * ref_tgt_mask_name[2][5] =
{{"tgt_sst_mask", NULL, NULL, NULL, NULL}, {NULL, "tgt_mask"}};
ref_interp_stack_config[0][0] = yac_interp_stack_config_new();
ref_interp_stack_config[0][0], YAC_INTERP_NNN_AVG, 16,
ref_interp_stack_config[0][0], YAC_INTERP_AVG_ARITHMETIC, 0);
ref_interp_stack_config[0][0], 1, 0, 0, YAC_INTERP_CONSERV_DESTAREA);
ref_interp_stack_config[0][0]);
ref_interp_stack_config[0][0], "weights.nc", "grid1", "grid3");
ref_interp_stack_config[0][0], -1.0);
ref_interp_stack_config[0][1] = yac_interp_stack_config_new();
ref_interp_stack_config[0][1], YAC_INTERP_AVG_DIST, 1);
ref_interp_stack_config[0][1], YAC_INTERP_NNN_DIST, 2,
ref_interp_stack_config[0][1], 2, 1, 1, YAC_INTERP_CONSERV_FRACAREA);
ref_interp_stack_config[0][2] = yac_interp_stack_config_new();
ref_interp_stack_config[0][2], "", "");
ref_interp_stack_config[0][2], "check_constructor", "");
ref_interp_stack_config[0][2], "", "check_do_search");
ref_interp_stack_config[0][2], "check_constructor", "check_do_search");
ref_interp_stack_config[0][2], YAC_INTERP_NNN_RBF, 4,
ref_interp_stack_config[0][3] = yac_interp_stack_config_new();
ref_interp_stack_config[0][3], YAC_INTERP_NNN_GAUSS, 8, 0.2);
ref_interp_stack_config[0][3], 5.0 * YAC_RAD,
ref_interp_stack_config[0][3], YAC_INTERP_NCC_DIST, 1);
ref_interp_stack_config[0][4] = yac_interp_stack_config_new();
ref_interp_stack_config[0][4], 5);
ref_interp_stack_config[0][4], "compute_weights");
ref_interp_stack_config[0][4], -2.0);
ref_interp_stack_config[1][0] = yac_interp_stack_config_new();
ref_interp_stack_config[1][0], -1);
ref_interp_stack_config[1][0], "compute_weights");
ref_interp_stack_config[1][0], -1.0);
ref_interp_stack_config[1][1] = yac_interp_stack_config_new();
ref_interp_stack_config[1][1], YAC_INTERP_AVG_ARITHMETIC, 0);
ref_interp_stack_config[1][1], -1.0);
for (size_t ref_couple_idx = 0; ref_couple_idx < ref_num_couples;
++ref_couple_idx) {
// find matching couple
size_t couple_idx = SIZE_MAX;
for (size_t i = 0; (i < ref_num_couples) && (couple_idx == SIZE_MAX);
++i) {
char const * couple_comp_names[2];
couple_config, i, couple_comp_names);
if ((!strcmp(
couple_comp_names[0],
ref_component_names[ref_couple_idx][0]) &&
!strcmp(
couple_comp_names[1],
ref_component_names[ref_couple_idx][1])) ||
(!strcmp(
couple_comp_names[0],
ref_component_names[ref_couple_idx][1]) &&
!strcmp(
couple_comp_names[1],
ref_component_names[ref_couple_idx][0])))
couple_idx = i;
}
if (couple_idx == SIZE_MAX) {
PUT_ERR("ERROR: no matching couple found\n");
continue;
}
size_t num_field_couples =
yac_couple_config_get_num_couple_fields(couple_config, couple_idx);
if (ref_num_field_couples[ref_couple_idx] !=
yac_couple_config_get_num_couple_fields(couple_config, couple_idx))
PUT_ERR("ERROR in yac_couple_config_get_num_couple_fields\n");
for (size_t ref_field_couple_idx = 0;
ref_field_couple_idx < num_field_couples; ++ref_field_couple_idx) {
// find matching field couple
size_t field_couple_idx = SIZE_MAX;
char const * src_component_name, * tgt_component_name;
char const * src_grid_name, * tgt_grid_name;
char const * src_field_name, * tgt_field_name;
char const * ref_src_component_name = ref_field_component_names[ref_couple_idx][ref_field_couple_idx][0];
char const * ref_tgt_component_name = ref_field_component_names[ref_couple_idx][ref_field_couple_idx][1];
char const * ref_src_grid_name = ref_field_grid_names[ref_couple_idx][ref_field_couple_idx][0];
char const * ref_tgt_grid_name = ref_field_grid_names[ref_couple_idx][ref_field_couple_idx][1];
char const * ref_src_field_name = ref_field_name[ref_couple_idx][ref_field_couple_idx];
char const * ref_tgt_field_name = ref_field_name[ref_couple_idx][ref_field_couple_idx];
for (size_t i = 0;
(i < num_field_couples) && (field_couple_idx == SIZE_MAX); ++i) {
couple_config, couple_idx, i, &src_grid_name, &tgt_grid_name);
couple_config, couple_idx, i, &src_component_name, &tgt_component_name);
couple_config, couple_idx, i, &src_field_name, &tgt_field_name);
if (!strcmp(src_component_name, ref_src_component_name) &&
!strcmp(tgt_component_name, ref_tgt_component_name) &&
!strcmp(src_grid_name, ref_src_grid_name) &&
!strcmp(tgt_grid_name, ref_tgt_grid_name) &&
!strcmp(src_field_name, ref_src_field_name) &&
!strcmp(tgt_field_name, ref_tgt_field_name))
field_couple_idx = i;
}
if (field_couple_idx == SIZE_MAX) {
PUT_ERR("ERROR: no matching field couple found\n");
continue;
}
couple_config, src_component_name,
src_grid_name, src_field_name) !=
ref_frac_mask_fallback_value[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_get_frac_mask_fallback_value\n");
couple_config, src_component_name,
src_grid_name, src_field_name) !=
ref_field_collection_size[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_get_collection_size\n");
couple_config, src_component_name,
src_grid_name, src_field_name) != YAC_EXCHANGE_TYPE_SOURCE)
PUT_ERR("ERROR in yac_couple_config_get_field_role\n");
couple_config, tgt_component_name,
tgt_grid_name, tgt_field_name) != YAC_EXCHANGE_TYPE_TARGET)
PUT_ERR("ERROR in yac_couple_config_get_field_role\n");
couple_config, couple_idx, field_couple_idx) !=
ref_mapping_on_source[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_mapping_on_source\n");
if (strcmp(
couple_config, couple_idx, field_couple_idx),
ref_coupling_period[ref_couple_idx][ref_field_couple_idx],
PUT_ERR("ERROR in yac_couple_config_get_coupling_period\n");
couple_config, couple_idx, field_couple_idx) !=
ref_coupling_period_operation[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_get_coupling_period_operation\n");
char const * src_timestep =
couple_config, couple_idx, field_couple_idx);
int src_lag =
couple_config, couple_idx, field_couple_idx);
if (strcmp(
src_timestep,
ref_timestep[ref_couple_idx][ref_field_couple_idx][0],
C_SECOND)) ||
(src_lag != ref_lag[ref_couple_idx][ref_field_couple_idx][0]))
PUT_ERR("ERROR in yac_couple_config_get_source_timestep\n");
char const * tgt_timestep =
couple_config, couple_idx, field_couple_idx);
int tgt_lag =
couple_config, couple_idx, field_couple_idx);
if (strcmp(
tgt_timestep,
ref_timestep[ref_couple_idx][ref_field_couple_idx][1],
C_SECOND)) ||
(tgt_lag != ref_lag[ref_couple_idx][ref_field_couple_idx][1]))
PUT_ERR("ERROR in yac_couple_config_get_target_timestep\n");
couple_config, couple_idx, field_couple_idx) !=
ref_scale_factor[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_get_scale_factor");
couple_config, couple_idx, field_couple_idx) !=
ref_scale_summand[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_get_scale_summand");
couple_config, couple_idx, field_couple_idx) !=
ref_enforce_write_weight_file[ref_couple_idx][ref_field_couple_idx])
PUT_ERR("ERROR in yac_couple_config_enforce_write_weight_file\n");
if (ref_enforce_write_weight_file[ref_couple_idx][ref_field_couple_idx]) {
char const * weight_file_name =
couple_config, couple_idx, field_couple_idx);
if (strcmp(
weight_file_name, ref_weight_file_name[ref_couple_idx][ref_field_couple_idx]))
PUT_ERR("ERROR in yac_couple_config_get_weight_file_name\n");
}
ref_interp_stack_config[ref_couple_idx][ref_field_couple_idx],
couple_config, couple_idx, field_couple_idx)))
PUT_ERR("ERROR in yac_interp_stack_config");
ref_interp_stack_config[ref_couple_idx][ref_field_couple_idx]);
char const * const * src_mask_names;
size_t num_src_mask_names;
couple_config, couple_idx, field_couple_idx,
&src_mask_names, &num_src_mask_names);
if (ref_num_src_mask_names[ref_couple_idx][ref_field_couple_idx] !=
num_src_mask_names)
PUT_ERR("ERROR in yac_couple_config_get_src_mask_names");
for (size_t i = 0; i < num_src_mask_names; ++i)
if (strcmp(ref_src_mask_names[ref_couple_idx][ref_field_couple_idx][i],
src_mask_names[i]))
PUT_ERR("ERROR in yac_couple_config_get_src_mask_names");
char const * tgt_mask_name =
couple_config, couple_idx, field_couple_idx);
if ((ref_tgt_mask_name[ref_couple_idx][ref_field_couple_idx] == NULL) !=
(tgt_mask_name == NULL))
PUT_ERR("ERROR in yac_couple_config_get_tgt_mask_name");
if (tgt_mask_name != NULL)
if (strcmp(ref_tgt_mask_name[ref_couple_idx][ref_field_couple_idx],
tgt_mask_name))
PUT_ERR("ERROR in yac_couple_config_get_tgt_mask_name");
}
}
yac_couple_config_delete(couple_config);
}
static struct yac_couple_config * generate_couple_config_from_YAML_parallel(
char const * config_filename) {
int size, rank;
MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
MPI_Comm_size ( MPI_COMM_WORLD, &size );
struct yac_couple_config * couple_config = yac_couple_config_new();
yac_couple_config_add_grid(couple_config, "grid1");
yac_couple_config_add_grid(couple_config, "grid2");
yac_couple_config_add_grid(couple_config, "grid3");
yac_couple_config_add_grid(couple_config, "grid4");
if (rank == 0)
couple_config, "grid1", "grid1_meta");
if (rank == 1)
couple_config, "grid2", "grid2_meta");
yac_couple_config_add_component(couple_config, "ICON-O");
yac_couple_config_add_component(couple_config, "ICON-A");
yac_couple_config_add_component(couple_config, "DUMMY");
yac_couple_config_add_component(couple_config, "DUMMY_2");
// only rank 0 provides a valid collection size
couple_config, "ICON-O", "grid1", "sea_surface_temperature",
yac_time_to_ISO("1", C_SECOND), (rank == 0)?3:SIZE_MAX);
couple_config, "ICON-A", "grid3", "sea_surface_temperature",
yac_time_to_ISO("10", C_SECOND), (rank == 0)?3:SIZE_MAX);
// only rank 1 provides a valid collection size and
// fractional mask fallback value
couple_config, "ICON-A", "grid3", "wind_speed",
yac_time_to_ISO("2", C_SECOND), (rank == 1)?3:SIZE_MAX);
couple_config, "ICON-O", "grid1", "wind_speed",
yac_time_to_ISO("20", C_SECOND), (rank == 1)?3:SIZE_MAX);
if (rank == 1) {
couple_config, "ICON-A", "grid3", "wind_speed", 1.0);
couple_config, "ICON-O", "grid1", "wind_speed", 1.0);
}
// only rank 0 provides a valid timestep
couple_config, "ICON-O", "grid1", "water_flux_into_sea_water",
(rank == 0)?yac_time_to_ISO("3", C_SECOND):NULL, 4);
couple_config, "ICON-A", "grid3", "water_flux_into_sea_water",
(rank == 0)?yac_time_to_ISO("30", C_SECOND):NULL, 4);
couple_config, "ICON-O", "grid1", "water_flux_into_sea_water", 0.0);
couple_config, "ICON-A", "grid3", "water_flux_into_sea_water", 0.0);
// only rank 1 provides a valid timestep
couple_config, "ICON-A", "grid3", "grid_eastward_wind",
(rank == 1)?yac_time_to_ISO("4", C_SECOND):NULL, 4);
couple_config, "ICON-O", "grid2", "grid_eastward_wind",
(rank == 1)?yac_time_to_ISO("40", C_SECOND):NULL, 4);
couple_config, "ICON-A", "grid3", "grid_eastward_wind", 0.0);
couple_config, "ICON-O", "grid2", "grid_eastward_wind", 0.0);
couple_config, "ICON-O", "grid2", "grid_northward_wind",
couple_config, "ICON-A", "grid3", "grid_northward_wind",
couple_config, "ICON-O", "grid2", "grid_northward_wind",
couple_config, "DUMMY", "grid4", "grid_northward_wind",
// add couple by hand
if (rank == 0) {
couple_config, "ICON-O", "grid2", "manual_field",
struct yac_interp_stack_config * interp_stack =
yac_interp_stack_config_add_fixed(interp_stack, -1.0);
couple_config, "DUMMY", "grid4", "manual_field",
"ICON-O", "grid2", "manual_field",
interp_stack, 0, 0, NULL, 0, 9.0/5.0, 32.0,
2, (char const *[]){"src_mask1", "src_mask2"},
"tgt_mask");
} else if (rank == 1) {
couple_config, "DUMMY", "grid4", "manual_field",
}
// rank zero reads in couplings from YAML configuration file
if (rank == 0)
couple_config, config_filename, YAC_YAML_PARSER_DEFAULT);
// synchronise coupling configuration across all processes
yac_couple_config_sync(couple_config, MPI_COMM_WORLD);
return couple_config;
}
static void write_couple_config_to_YAML(
struct yac_couple_config * couple_config, char const * config_filename,
int emit_flags) {
FILE * yaml_file = fopen(config_filename, "w");
char * str_couple_config =
yac_yaml_emit_coupling(couple_config, emit_flags);
fputs(str_couple_config, yaml_file);
free(str_couple_config);
fclose(yaml_file);
}
static struct yac_couple_config * generate_couple_config_from_YAML(
char const * config_filename, int parse_flags) {
struct yac_couple_config * couple_config = yac_couple_config_new();
couple_config, config_filename, parse_flags);
// add stuff not included in the configuration file
yac_couple_config_add_component(couple_config, "DUMMY_2");
couple_config, "grid1", "grid1_meta");
couple_config, "grid2", "grid2_meta");
couple_config, "ICON-O", "grid1", "sea_surface_temperature",
couple_config, "ICON-A", "grid3", "sea_surface_temperature",
couple_config, "ICON-A", "grid3", "wind_speed",
couple_config, "ICON-A", "grid3", "wind_speed", 1.0);
couple_config, "ICON-O", "grid1", "wind_speed",
couple_config, "ICON-O", "grid1", "wind_speed", 1.0);
couple_config, "ICON-O", "grid1", "water_flux_into_sea_water",
couple_config, "ICON-O", "grid1", "water_flux_into_sea_water", 0.0);
couple_config, "ICON-A", "grid3", "water_flux_into_sea_water",
couple_config, "ICON-A", "grid3", "water_flux_into_sea_water", 0.0);
couple_config, "ICON-A", "grid3", "grid_eastward_wind",
couple_config, "ICON-A", "grid3", "grid_eastward_wind", 0.0);
couple_config, "ICON-O", "grid2", "grid_eastward_wind",
couple_config, "ICON-O", "grid2", "grid_eastward_wind", 0.0);
couple_config, "ICON-O", "grid2", "grid_northward_wind",
couple_config, "ICON-A", "grid3", "grid_northward_wind",
couple_config, "DUMMY", "grid4", "grid_northward_wind",
couple_config, "ICON-O", "grid2", "manual_field",
couple_config, "DUMMY", "grid4", "manual_field",
return couple_config;
}
int YAC_YAML_EMITTER_JSON
emit to JSON format
Definition config_yaml.c:47
void yac_yaml_read_coupling(struct yac_couple_config *couple_config, const char *yaml_filename, int parse_flags)
int YAC_YAML_PARSER_DEFAULT
default parse flags (YAML format)
Definition config_yaml.c:48
int YAC_YAML_PARSER_JSON_FORCE
assume JSON format
Definition config_yaml.c:50
int YAC_YAML_EMITTER_DEFAULT
emit to YAML format
Definition config_yaml.c:46
char const * yac_time_to_ISO(char const *time, enum yac_time_unit_type time_unit)
Definition event.c:329
char * yac_yaml_emit_coupling(struct yac_couple_config *couple_config, int emit_flags)
void yac_couple_config_grid_set_metadata(struct yac_couple_config *couple_config, char const *grid_name, const char *metadata)
void yac_couple_config_field_enable_frac_mask(struct yac_couple_config *couple_config, char const *comp_name, char const *grid_name, char const *field_name, double frac_mask_fallback_value)
void yac_couple_config_get_field_grid_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_grid_name, char const **tgt_grid_name)
int yac_couple_config_contains_grid_name(struct yac_couple_config *couple_config, char const *grid_name)
void yac_couple_config_sync(struct yac_couple_config *couple_config, MPI_Comm comm)
void yac_couple_config_set_datetime(struct yac_couple_config *couple_config, char const *start, char const *end)
void yac_couple_config_component_add_field(struct yac_couple_config *couple_config, const char *component_name, const char *grid_name, const char *name, char const *timestep, size_t collection_size)
int yac_couple_config_mapping_on_source(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_get_field_role(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
int yac_couple_config_component_name_is_valid(struct yac_couple_config *couple_config, char const *component_name)
char const * yac_couple_config_get_coupling_period(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
struct yac_interp_stack_config * yac_couple_config_get_interp_stack(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
size_t yac_couple_config_get_num_couple_fields(struct yac_couple_config *couple_config, size_t couple_idx)
void yac_couple_config_get_src_mask_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const *const **mask_names, size_t *num_mask_names)
size_t yac_couple_config_get_num_couples(struct yac_couple_config *couple_config)
int yac_couple_config_get_target_lag(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
double yac_couple_config_get_frac_mask_fallback_value(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
int yac_couple_config_get_source_lag(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_get_couple_component_names(struct yac_couple_config *couple_config, size_t couple_idx, char const *couple_component_names[2])
const char * yac_couple_config_grid_get_metadata(struct yac_couple_config *couple_config, const char *grid_name)
double yac_couple_config_get_scale_factor(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
char const * yac_couple_config_get_end_datetime(struct yac_couple_config *couple_config)
char const * yac_couple_config_get_tgt_mask_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_add_grid(struct yac_couple_config *couple_config, char const *name)
double yac_couple_config_get_scale_summand(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
enum yac_reduction_type yac_couple_config_get_coupling_period_operation(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
int yac_couple_config_enforce_write_weight_file(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_def_couple(struct yac_couple_config *couple_config, 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_period, int time_reduction, struct yac_interp_stack_config *interp_stack, int src_lag, int tgt_lag, const char *weight_file_name, int mapping_on_source, double scale_factor, double scale_summand, size_t num_src_mask_names, char const *const *src_mask_names, char const *tgt_mask_name)
void yac_couple_config_get_field_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_field_name, const char **tgt_field_name)
struct yac_couple_config * yac_couple_config_new()
char const * yac_couple_config_get_weight_file_name(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_get_field_couple_component_names(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx, char const **src_component_name, char const **tgt_component_name)
char const * yac_couple_config_get_source_timestep(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_add_component(struct yac_couple_config *couple_config, char const *name)
char const * yac_couple_config_get_start_datetime(struct yac_couple_config *couple_config)
size_t yac_couple_config_get_collection_size(struct yac_couple_config *couple_config, char const *component_name, char const *grid_name, char const *field_name)
char const * yac_couple_config_get_target_timestep(struct yac_couple_config *couple_config, size_t couple_idx, size_t field_couple_idx)
void yac_couple_config_delete(struct yac_couple_config *couple_config)
size_t yac_couple_config_get_num_components(struct yac_couple_config *couple_config)
yac_reduction_type
@ TIME_NONE
@ TIME_ACCUMULATE
@ TIME_MAXIMUM
@ TIME_MINIMUM
@ TIME_AVERAGE
@ C_SECOND
#define YAC_RAD
Definition geometry.h:30
@ YAC_INTERP_AVG_DIST
@ YAC_INTERP_AVG_ARITHMETIC
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
@ YAC_INTERP_NCC_DIST
distance weighted average of n source points
@ YAC_INTERP_NNN_GAUSS
distance with Gauss weights of n source points
@ YAC_INTERP_NNN_RBF
radial basis functions
@ YAC_INTERP_NNN_AVG
average of n source points
@ YAC_INTERP_NNN_DIST
distance weighted average of n source points
#define YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT
#define YAC_INTERP_RBF_SCALE_DEFAULT
#define YAC_INTERP_SPMAP_MAX_SEARCH_DISTANCE_DEFAULT
@ YAC_INTERP_SPMAP_NONE
weights are not scaled
@ YAC_INTERP_SPMAP_DIST
#define YAC_INTERP_SPMAP_SRC_SPHERE_RADIUS_DEFAULT
void yac_interp_stack_config_add_check(struct yac_interp_stack_config *interp_stack_config, char const *constructor_key, char const *do_search_key)
void yac_interp_stack_config_add_user_file(struct yac_interp_stack_config *interp_stack_config, char const *filename, char const *src_grid_name, char const *tgt_grid_name)
int yac_interp_stack_config_compare(void const *a_, void const *b_)
void yac_interp_stack_config_add_spmap(struct yac_interp_stack_config *interp_stack_config, double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, enum yac_interp_spmap_scale_type scale_type, double src_sphere_radius, double tgt_sphere_radius)
void yac_interp_stack_config_add_nnn(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_nnn_weight_type type, size_t n, double scale)
void yac_interp_stack_config_add_fixed(struct yac_interp_stack_config *interp_stack_config, double value)
void yac_interp_stack_config_add_hcsbb(struct yac_interp_stack_config *interp_stack_config)
void yac_interp_stack_config_add_average(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_avg_weight_type reduction_type, int partial_coverage)
void yac_interp_stack_config_add_creep(struct yac_interp_stack_config *interp_stack_config, int creep_distance)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
void yac_interp_stack_config_add_conservative(struct yac_interp_stack_config *interp_stack_config, int order, int enforced_conserv, int partial_coverage, enum yac_interp_method_conserv_normalisation normalisation)
void yac_interp_stack_config_add_ncc(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_ncc_weight_type weight_type, int partial_coverage)
void yac_interp_stack_config_add_user_callback(struct yac_interp_stack_config *interp_stack_config, char const *func_compute_weights_key)
struct yac_interp_stack_config * yac_interp_stack_config_new()
double const YAC_FRAC_MASK_NO_VALUE
int main(int argc, char **argv)
int const YAC_EXCHANGE_TYPE_SOURCE
Definition yac.c:32
int const YAC_EXCHANGE_TYPE_TARGET
Definition yac.c:33
void yac_cdef_calendar(int calendar)
Definition yac.c:562
int const YAC_PROLEPTIC_GREGORIAN
Definition yac.c:61
int const YAC_REDUCTION_TIME_NONE
Definition yac.c:45