51 interp_method_name_ctor_map,
72#define YAC_ASSERT_VTABLE_FUNC(CONFIG, FUNC) \
74 (CONFIG)->vtable, "yac_interp_method_config_" #FUNC, "vtable is NULL"); \
76 (CONFIG)->vtable->FUNC, "yac_interp_method_config_" #FUNC, \
77 #FUNC " function pointer is NULL")
101 void const *a,
void const *b) {
112 int (*compare)(
void const *,
void const *) =
124 if (a_type != b_type) {
125 return ((a_type > b_type) - (a_type < b_type));
127 return compare(a, b);
133 int type_pack_size = 0;
134 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &type_pack_size), comm);
135 size_t pack_size = (size_t)type_pack_size;
140 YAC_ASSERT(root_param != NULL,
"failed to get method parameter tree");
150 void *
buffer,
int buffer_size,
int *position, MPI_Comm comm) {
158 MPI_Pack(&
type, 1, MPI_INT,
buffer, buffer_size, position, comm), comm);
160 if (
config == NULL)
return;
163 YAC_ASSERT(root_param != NULL,
"failed to get method parameter tree");
169 void *
buffer,
int buffer_size,
int *position, MPI_Comm comm) {
173 MPI_Unpack(
buffer, buffer_size, position, &
type, 1, MPI_INT, comm), comm);
176 char const * method_name =
178 interp_method_name_ctor_map, interp_method_name_ctor_map_size,
type);
185 YAC_ASSERT_F(root_param != NULL,
"failed to get method parameter tree");
219 char const *method_name) {
221 YAC_ASSERT(method_name != NULL,
"method_name is NULL");
225 interp_method_name_ctor_map, interp_method_name_ctor_map_size,
228 type_int != INT_MAX,
"unknown interpolation method name \"%s\"",
237 type <
YAC_LAST,
"method name \"%s\" maps to invalid type %d",
242 ctor != NULL,
"method name \"%s\" maps to NULL constructor", method_name);
264#define YAC_PARAM_PATH_COMPONENT_MAX 128
271 if (!str || !*str)
return 0;
272 for (
char const *
p = str; *
p; ++
p)
273 if (*
p <
'0' || *
p >
'9')
return 0;
274 unsigned long v = strtoul(str, NULL, 10);
290 struct yac_param * root,
char const * path,
char const * routine) {
296 char const * seg_start = path;
298 char const * dot = strchr(seg_start,
'.');
299 size_t seg_len = dot ? (size_t)(dot - seg_start) : strlen(seg_start);
303 "invalid path component length in path \"%s\"", path);
306 memcpy(component, seg_start, seg_len);
307 component[seg_len] =
'\0';
315 "failed to navigate to index %zu in path \"%s\": %s",
321 "failed to navigate to \"%s\" in path \"%s\": %s",
334 char const *path,
char const *
value) {
341 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
347 ierr == 0,
"failed to set \"%s\" to \"%s\": %s",
353 char const *path,
int value) {
359 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
365 ierr == 0,
"failed to set \"%s\" to %d: %s",
371 char const *path,
double value) {
377 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
394 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
401 ierr == 0,
"failed to get \"%s\" as int: %s",
415 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
422 ierr == 0,
"failed to get \"%s\" as double: %s",
436 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
445 ierr == 0,
"failed to get \"%s\" as string: %s",
461 YAC_ASSERT(buflen > 0,
"buflen must be positive");
464 strncpy(buf, str, (
size_t)buflen);
465 buf[buflen - 1] =
'\0';
477 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
484 ierr == 0,
"failed to get list size at \"%s\": %s",
498 YAC_ASSERT(root != NULL,
"failed to get parameter tree");
505 ierr == 0,
"failed to append element to list at \"%s\": %s",
511 ierr == 0,
"failed to get list size after append at \"%s\": %s",
#define YAC_ASSERT(exp, msg)
int yac_name_type_pair_get_type(struct yac_name_type_pair const *pairs, size_t count, char const *name)
#define DEF_NAME_TYPE_PAIR(NAME, TYPE)
char const * yac_name_type_pair_get_name(struct yac_name_type_pair const *pairs, size_t count, int type)
#define DEF_NAME_TYPE_PAIRS(NAME,...)
@ YAC_N_NEAREST_NEIGHBOR
N-nearest-neighbor interpolation.
@ YAC_CREEP
Creep-fill interpolation.
@ YAC_USER_FILE
User-supplied weights from file.
@ YAC_LAST
Sentinel value for the end of the list.
@ YAC_SOURCE_TO_TARGET_MAP
Source-to-target mapping (inverse N-nearest-neighbor)
@ YAC_CONSERVATIVE
Conservative remapping (area/flux conserving)
@ YAC_FIXED_VALUE
Assigns a fixed value to all targets.
@ YAC_UNDEFINED
Undefined interpolation method.
@ YAC_CHECK
Diagnostic check method (for testing)
@ YAC_BERNSTEIN_BEZIER
Bernstein-Bezier interpolation.
@ YAC_DISTANCE_NEAREST_NEIGHBOR
Distance-nearest-neighbor interpolation.
@ YAC_NEAREST_CORNER_CELLS
Nearest-corner-cell interpolation.
@ YAC_RADIAL_BASIS_FUNCTION
Radial basis function interpolation.
@ YAC_AVERAGE
Simple averaging (or linear) interpolation.
struct yac_interp_method_config * yac_interp_method_config_default_avg_new(void)
Creates an average interpolation method configuration with default parameters.
yac_func_compute_weights callback
struct yac_interp_method_config * yac_interp_method_config_default_callback_new(void)
Creates a callback interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_check_new(void)
Creates a check interpolation method configuration with default parameters.
int yac_interp_method_config_compare(const struct yac_interp_method_config *a, const struct yac_interp_method_config *b)
#define YAC_PARAM_PATH_COMPONENT_MAX
void yac_interp_method_config_set_param_int(struct yac_interp_method_config *config, char const *path, int value)
struct yac_interp_method_config *(* interp_method_default_ctor)(void)
void yac_interp_method_config_get_param_str_f2c(struct yac_interp_method_config const *config, char const *path, char *buf, int buflen)
static int yac_interp_method_config_undefined_compare(void const *a, void const *b)
struct yac_param * yac_interp_method_config_get_param(struct yac_interp_method_config const *config)
static struct yac_param * navigate_param_path(struct yac_param *root, char const *path, char const *routine)
enum yac_interpolation_list yac_interp_method_config_get_type(struct yac_interp_method_config const *config)
double yac_interp_method_config_get_param_dble(struct yac_interp_method_config const *config, char const *path)
size_t yac_interp_method_config_append_list_element(struct yac_interp_method_config *config, char const *path)
int yac_interp_method_config_get_param_int(struct yac_interp_method_config const *config, char const *path)
void yac_interp_method_config_pack(const struct yac_interp_method_config *config, void *buffer, int buffer_size, int *position, MPI_Comm comm)
size_t yac_interp_method_config_get_pack_size(const struct yac_interp_method_config *config, MPI_Comm comm)
struct yac_interp_method_config * yac_interp_method_config_copy(const struct yac_interp_method_config *config)
static interp_method_default_ctor const interp_method_default_ctors[]
static int parse_index(char const *str, size_t *idx)
#define YAC_ASSERT_VTABLE_FUNC(CONFIG, FUNC)
void yac_interp_method_config_set_param_dble(struct yac_interp_method_config *config, char const *path, double value)
char * yac_interp_method_config_get_param_str(struct yac_interp_method_config const *config, char const *path)
struct yac_interp_method_config * yac_interp_method_config_unpack(void *buffer, int buffer_size, int *position, MPI_Comm comm)
struct yac_interp_method_config * yac_interp_method_config_default_from_name_new(char const *method_name)
struct interp_method * yac_interp_method_config_generate(const struct yac_interp_method_config *config)
void yac_interp_method_config_set_param_str(struct yac_interp_method_config *config, char const *path, char const *value)
size_t yac_interp_method_config_get_list_size(struct yac_interp_method_config const *config, char const *path)
Defines the interface for interpolation method configuration "base class" in YAC.
void yac_interp_method_config_delete(struct yac_interp_method_config *config)
struct yac_interp_method_config * yac_interp_method_config_default_conserv_new(void)
Creates a conservative interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_creep_new(void)
Creates a creep-fill interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_dnn_new(void)
Creates a distance-nearest-neighbour (DNN) interpolation method configuration with default parameters...
struct yac_interp_method_config * yac_interp_method_config_default_file_new(void)
Creates a file-based interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_fixed_new(void)
Creates a fixed-value interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_hcsbb_new(void)
Creates an HCSBB interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_ncc_new(void)
Creates a nearest-corner-cells interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_nnn_new(void)
Creates a nearest-neighbour interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_rbf_new(void)
Creates a radial-basis-function interpolation method configuration with default parameters.
struct yac_interp_method_config * yac_interp_method_config_default_spmap_new(void)
Creates a source-point-mapping interpolation method configuration with default parameters.
int yac_param_get_scalar_dble(const struct yac_param *param, double *value)
Get the value of a scalar parameter as a double.
void yac_param_delete(struct yac_param *param)
int yac_param_get_sub_by_index(struct yac_param *param, size_t idx, struct yac_param **sub_param)
Get a handle to a subparameter by index.
int yac_param_get_scalar(const struct yac_param *param, char *buf, size_t buflen)
Get the value of a scalar parameter as a string.
int yac_param_set_scalar(struct yac_param *param, const char *value_str)
Set the value of a scalar parameter from a string.
int yac_param_append(struct yac_param *param, struct yac_param **sub_param)
Append a new default subparameter to a list parameter and return a handle to it.
int yac_param_set_scalar_int(struct yac_param *param, int value)
Set the value of a scalar parameter as an int.
int yac_param_get_sub_count(const struct yac_param *param, size_t *count)
Get the number of subparameters.
int yac_param_set_scalar_dble(struct yac_param *param, double value)
Set the value of a scalar parameter as a double.
const char * yac_param_get_last_error(void)
Retrieve the last error message for the calling thread.
int yac_param_get_scalar_int(const struct yac_param *param, int *value)
Get the value of a scalar parameter as an int.
int yac_param_get_sub_by_name(struct yac_param *param, const char *name, struct yac_param **sub_param)
Get a handle to a subparameter by name.
Public interface for YAC parameters.
void yac_param_pack(struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
Public function to pack a parameter record into a buffer.
size_t yac_param_get_pack_size(struct yac_param *param, MPI_Comm comm, char const *routine)
Public function to get the size in bytes required to pack a parameter record.
void yac_param_unpack(struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
Unpack a parameter from an MPI buffer and apply its values to the given parameter.
int(* compare)(void const *a, void const *b)
struct yac_interp_method_config *(* copy)(struct yac_interp_method_config const *config)
struct yac_param *(* get_param)(struct yac_interp_method_config const *config)
enum yac_interpolation_list(* get_type)(void)
void(* delete)(struct yac_interp_method_config *config)
struct interp_method *(* generate)(struct yac_interp_method_config const *config)
struct yac_param * root_param_cache
struct yac_interp_method_config_vtable const * vtable
static struct yac_interp_method_config * config
double(* p)(double lon, double lat)
#define YAC_ASSERT_F(exp, format,...)
#define YAC_ASSERT_F_FUNC(exp, func, format,...)
#define yac_mpi_call(call, comm)