73 cpl_field->
name =
xmalloc((strlen(field_name) + 1));
74 strcpy(cpl_field->
name, field_name);
82 cpl_field->
pak = NULL;
88 "num_interp_fields > 0 but no interpolation field provided")
102 return field->collection_size;
107 return field->timestep;
112 return field->num_interp_fields;
119 return field->interp_fields[interp_field_idx].location;
135 YAC_ASSERT(field->component_name,
"component name undefined")
137 return field->component_name;
143 return field->exchange_type;
159 struct coupling_field * field,
double init_value,
double *** acc) {
161 size_t num_interp_fields = field->num_interp_fields;
165 for (
size_t j = 0; j < num_interp_fields; j++) {
171 for (
size_t m = 0; m < num_points; m++ ) {
172 acc[h][j][m] = init_value;
181 char const * routine_name,
double **** acc) {
184 field->exchange_type ==
SOURCE, routine_name,
"wrong field exchange type")
187 put_idx < field->exchange_data.put.num_puts, routine_name,
188 "put_idx is invalid")
190 if (*acc != NULL)
return;
192 size_t num_interp_fields = field->num_interp_fields;
201 (*acc)[h] =
xmalloc(num_interp_fields *
sizeof(***acc));
203 for (
size_t j = 0; j < num_interp_fields; j++)
207 field->interp_fields[j], field->grid) *
sizeof(****acc));
218 field, put_idx, __func__,
219 &(field->exchange_data.put.puts[put_idx].send_field_acc));
221 return field->exchange_data.put.puts[put_idx].send_field_acc;
228 field, put_idx, __func__,
229 &(field->exchange_data.put.puts[put_idx].send_frac_mask_acc));
231 return field->exchange_data.put.puts[put_idx].send_frac_mask_acc;
237 int const * core_mask =
239 field->grid, field->interp_fields[field_idx].location);
244 if (core_mask != NULL) {
250 for (
size_t i = 0; (i < field_size) && !
flag; ++i)
251 flag = core_mask[i] != 1;
260 int const * field_mask =
262 field->grid, field->interp_fields[field_idx]);
267 if (field_mask != NULL) {
273 for (
size_t i = 0; (i < field_size) && !
flag; ++i)
274 flag = field_mask[i] != 1;
284 if (field->exchange_data.put.mask != NULL)
285 return field->exchange_data.put.mask;
287 size_t num_interp_fields = field->num_interp_fields;
291 for (
size_t i = 0; (i < num_interp_fields) && !has_mask; ++i)
301 for (
size_t i = 0; i < num_interp_fields; ++i) {
302 int const * core_mask =
304 field->grid, field->interp_fields[i].location);
305 int const * field_mask =
307 field->grid, field->interp_fields[i]);
311 for (
size_t j = 0; j < field_size; ++j)
312 mask[i][j] = ((core_mask == NULL) || (core_mask[j] != 0)) &&
313 ((field_mask == NULL) || (field_mask[j] != 0));
317 field->exchange_data.put.mask =
mask;
326 if (field->exchange_data.get.mask != NULL)
327 return field->exchange_data.get.mask;
337 int const * core_mask =
339 field->grid, field->interp_fields[0].location);
340 int const * field_mask =
342 field->grid, field->interp_fields[0]);
346 for (
size_t i = 0; i < field_size; ++i)
347 mask[i] = ((core_mask == NULL) || (core_mask[i] != 0)) &&
348 ((field_mask == NULL) || (field_mask[i] != 0));
351 field->exchange_data.get.mask =
mask;
357 struct coupling_field * field,
unsigned put_idx,
double init_value) {
361 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
363 double *** send_field_acc =
364 (field->exchange_data.put.puts[put_idx].send_field_acc == NULL)?
366 field->exchange_data.put.puts[put_idx].send_field_acc;
372 struct coupling_field * field,
unsigned put_idx,
double init_value) {
376 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
378 double *** send_frac_mask_acc =
379 (field->exchange_data.put.puts[put_idx].send_frac_mask_acc == NULL)?
381 field->exchange_data.put.puts[put_idx].send_frac_mask_acc;
391 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
393 return field->exchange_data.put.puts[put_idx].event;
400 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
402 !field->exchange_data.put.puts[put_idx].use_raw_exchange,
403 "exchange is configured to use raw data exchange")
405 return field->exchange_data.put.puts[put_idx].interpolation;
413 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
415 field->exchange_data.put.puts[put_idx].use_raw_exchange,
416 "exchange is not configured to use raw data exchange")
418 return field->exchange_data.put.puts[put_idx].interpolation_exchange;
425 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
427 return field->exchange_data.put.puts[put_idx].time_accumulation_count;
434 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
436 return field->exchange_data.put.puts[put_idx].use_raw_exchange;
443 YAC_ASSERT(put_idx < field->exchange_data.put.num_puts,
"put_idx is invalid")
445 field->exchange_data.put.puts[put_idx].time_accumulation_count =
count;
452 return field->exchange_data.put.num_puts;
460 return field->exchange_data.get.event;
468 return field->exchange_data.get.use_raw_exchange;
477 field->exchange_data.get.interp_weights_data.frac_mask_fallback_value);
485 !field->exchange_data.get.use_raw_exchange,
486 "exchange is configured to use raw data exchange")
488 return field->exchange_data.get.interpolation;
497 field->exchange_data.get.use_raw_exchange,
498 "exchange is not configured to use raw data exchange")
500 return field->exchange_data.get.interpolation_exchange;
509 field->exchange_data.get.use_raw_exchange,
510 "exchange is not configured to use raw data exchange")
513 field->exchange_data.get.interp_weights_data;
522 field->exchange_data.get.interp_weights_data.num_src_fields =
num_src_fields;
523 field->exchange_data.get.interp_weights_data.src_field_buffer_size =
526 field->exchange_data.get.interp_weights_data.src_field_buffer_size,
527 src_field_buffer_sizes,
num_src_fields *
sizeof(*src_field_buffer_sizes));
534 size_t const ** src_field_buffer_sizes) {
538 field->exchange_data.get.use_raw_exchange,
539 "exchange is not configured to use raw data exchange")
542 field->exchange_data.get.interp_weights_data.num_src_fields;
543 if (src_field_buffer_sizes)
544 *src_field_buffer_sizes =
545 field->exchange_data.get.interp_weights_data.src_field_buffer_size;
552 int use_raw_exchange) {
555 field->exchange_type !=
TARGET,
556 "a get operation has already been set (field \"%s\")", field->name)
558 if (field->exchange_type ==
NOTHING) {
559 field->exchange_data.put.puts = NULL;
560 field->exchange_data.put.num_puts = 0;
561 field->exchange_type =
SOURCE;
562 field->exchange_data.put.mask = NULL;
565 unsigned num_puts = field->exchange_data.put.num_puts;
566 field->exchange_data.put.num_puts++;
568 field->exchange_data.put.puts =
569 xrealloc(field->exchange_data.put.puts, (num_puts + 1) *
570 sizeof(*(field->exchange_data.put.puts)));
572 field->exchange_data.put.puts[num_puts].event =
event;
573 field->exchange_data.put.puts[num_puts].interpolation = interpolation;
574 field->exchange_data.put.puts[num_puts].interpolation_exchange = interpolation_exchange;
575 field->exchange_data.put.puts[num_puts].time_accumulation_count = 0;
576 field->exchange_data.put.puts[num_puts].send_field_acc = NULL;
577 field->exchange_data.put.puts[num_puts].send_frac_mask_acc = NULL;
578 field->exchange_data.put.puts[num_puts].use_raw_exchange = use_raw_exchange;
586 field,
event, interpolation, NULL, 0);
594 field,
event, NULL, interpolation_exchange, 1);
602 int use_raw_exchange) {
605 field->exchange_type ==
NOTHING,
606 "a put or get operation has already been set (field \"%s\")", field->name)
608 field->exchange_type =
TARGET;
609 field->exchange_data.get.event =
event;
610 field->exchange_data.get.interpolation = interpolation;
611 field->exchange_data.get.interpolation_exchange = interpolation_exchange;
613 field->exchange_data.get.mask = NULL;
614 field->exchange_data.get.use_raw_exchange = use_raw_exchange;
623 .scaling_factor = 1.0,
624 .scaling_summand = 0.0,
626 .num_fixed_values = 0,
627 .fixed_values = NULL,
628 .num_tgt_per_fixed_value = NULL,
629 .tgt_idx_fixed = NULL,
633 .num_src_per_tgt = NULL,
635 .src_field_idx = NULL,
638 .src_field_buffer_size = NULL
642 field,
event, interpolation, NULL, dummy_interp_weights_data, 0);
665 "datetime is not defined for non-exchanged fields (field \"%s\")",
709 double ***send_field_acc =
711 double ***send_frac_mask_acc =
714 if (send_field_acc != NULL) {
716 for (
size_t j = 0; j < num_interp_fields; ++j)
717 free(send_field_acc[h][j]);
718 free(send_field_acc[h]);
720 free(send_field_acc);
723 if (send_frac_mask_acc != NULL) {
725 for (
size_t j = 0; j < num_interp_fields; ++j)
726 free(send_frac_mask_acc[h][j]);
727 free(send_frac_mask_acc[h]);
729 free(send_frac_mask_acc);
735 interpolation_exchange,
"yac_coupling_field_delete");
740 for (
size_t i = 0; i < num_interp_fields; ++i)
751 "yac_coupling_field_delete");
758 free(cpl_field->
name);
768 return cpl_field ? cpl_field->
pak : NULL;
775 cpl_field->
pak = pak;
#define YAC_ASSERT(exp, msg)
int const * yac_basic_grid_get_field_mask(struct yac_basic_grid *grid, struct yac_interp_field field)
size_t yac_basic_grid_get_data_size(struct yac_basic_grid *grid, enum yac_location location)
int const * yac_basic_grid_get_core_mask(struct yac_basic_grid *grid, enum yac_location location)
void yac_event_delete(struct event *event)
char * yac_get_event_current_datetime(struct event *event, char *datetime_str)
char * yac_get_event_previous_datetime(struct event *event, char *datetime_str)
enum yac_action_type yac_event_check(struct event *event)
struct yac_interpolation_exchange * yac_get_coupling_field_put_op_interpolation_exchange(struct coupling_field *field, unsigned put_idx)
void yac_set_coupling_field_put_op(struct coupling_field *field, struct event *event, struct yac_interpolation *interpolation)
static void yac_set_coupling_field_get_op_(struct coupling_field *field, struct event *event, struct yac_interpolation *interpolation, struct yac_interpolation_exchange *interpolation_exchange, struct yac_interp_weights_data interp_weights_data, int use_raw_exchange)
unsigned yac_get_coupling_field_collection_size(struct coupling_field *field)
static int check_core_mask(struct coupling_field *field, size_t field_idx)
static struct event * get_exchange_event(struct coupling_field *cpl_field)
const char * yac_get_coupling_field_timestep(struct coupling_field *field)
unsigned yac_get_coupling_field_num_puts(struct coupling_field *field)
void yac_set_coupling_field_get_op(struct coupling_field *field, struct event *event, struct yac_interpolation *interpolation)
char const * yac_get_coupling_field_comp_name(struct coupling_field *field)
int yac_get_coupling_field_put_op_time_accumulation_count(struct coupling_field *field, unsigned put_idx)
struct yac_pak * yac_coupling_field_get_pak(struct coupling_field *cpl_field)
int yac_coupling_field_get_action(struct coupling_field *cpl_field)
double *** yac_get_coupling_field_put_op_send_frac_mask_acc(struct coupling_field *field, unsigned put_idx)
struct yac_basic_grid * yac_coupling_field_get_basic_grid(struct coupling_field *field)
static void yac_set_coupling_field_put_op_(struct coupling_field *field, struct event *event, struct yac_interpolation *interpolation, struct yac_interpolation_exchange *interpolation_exchange, int use_raw_exchange)
size_t yac_coupling_field_get_num_interp_fields(struct coupling_field *field)
struct yac_interpolation * yac_get_coupling_field_put_op_interpolation(struct coupling_field *field, unsigned put_idx)
enum yac_location yac_get_coupling_field_get_interp_field_location(struct coupling_field *field, size_t interp_field_idx)
struct event * yac_get_coupling_field_get_op_event(struct coupling_field *field)
static size_t get_interp_field_size(struct yac_interp_field field, struct yac_basic_grid *grid)
void yac_set_coupling_field_put_op_raw(struct coupling_field *field, struct event *event, struct yac_interpolation_exchange *interpolation_exchange)
size_t yac_coupling_field_get_data_size(struct coupling_field *field, enum yac_location location)
struct yac_interp_field const * yac_coupling_field_get_interp_fields(struct coupling_field *cpl_field)
struct coupling_field * yac_coupling_field_new(char const *field_name, char const *component_name, struct yac_basic_grid *grid, struct yac_interp_field *interp_fields, unsigned num_interp_fields, size_t collection_size, const char *timestep)
int * yac_get_coupling_field_get_mask(struct coupling_field *field)
static void init_put_op_acc(struct coupling_field *field, double init_value, double ***acc)
struct event * yac_get_coupling_field_put_op_event(struct coupling_field *field, unsigned put_idx)
char * yac_coupling_field_get_datetime(struct coupling_field *cpl_field)
void yac_init_coupling_field_put_op_send_field_acc(struct coupling_field *field, unsigned put_idx, double init_value)
struct yac_interpolation * yac_get_coupling_field_get_op_interpolation(struct coupling_field *field)
void yac_coupling_field_get_src_field_buffer_sizes(struct coupling_field *field, size_t *num_src_fields, size_t const **src_field_buffer_sizes)
void yac_set_coupling_field_put_op_time_accumulation_count(struct coupling_field *field, unsigned put_idx, int count)
int yac_get_coupling_field_get_op_use_raw_exchange(struct coupling_field *field)
char * yac_coupling_field_get_prev_datetime(struct coupling_field *cpl_field)
struct yac_interpolation_exchange * yac_get_coupling_field_get_op_interpolation_exchange(struct coupling_field *field)
int yac_get_coupling_field_get_op_with_frac_mask(struct coupling_field *field)
enum yac_field_exchange_type yac_get_coupling_field_exchange_type(struct coupling_field *field)
void yac_coupling_field_set_pak(struct coupling_field *cpl_field, struct yac_pak *pak)
const char * yac_get_coupling_field_name(struct coupling_field *field)
void yac_set_coupling_field_get_op_raw(struct coupling_field *field, struct event *event, struct yac_interpolation_exchange *interpolation_exchange, struct yac_interp_weights_data interp_weights_data)
static int check_field_mask(struct coupling_field *field, size_t field_idx)
void yac_coupling_field_delete(struct coupling_field *cpl_field)
int ** yac_get_coupling_field_put_mask(struct coupling_field *field)
struct yac_interp_weights_data yac_get_coupling_field_get_op_interp_weights_data(struct coupling_field *field)
void yac_init_coupling_field_put_op_send_frac_mask_acc(struct coupling_field *field, unsigned put_idx, double init_value)
static void get_put_op_acc(struct coupling_field *field, unsigned put_idx, char const *routine_name, double ****acc)
double *** yac_get_coupling_field_put_op_send_field_acc(struct coupling_field *field, unsigned put_idx)
int yac_get_coupling_field_put_op_use_raw_exchange(struct coupling_field *field, unsigned put_idx)
void yac_interp_weights_data_init(struct yac_interp_weights_data *interp_weights_data)
void yac_interp_weights_data_free(struct yac_interp_weights_data interp_weights_data)
void yac_interpolation_delete(struct yac_interpolation *interp)
Free an interpolation object and release all resources.
double const YAC_FRAC_MASK_UNDEF
void yac_interpolation_exchange_delete(struct yac_interpolation_exchange *exchange, char const *routine)
Delete an interpolation exchange and release resources.
Interpolation exchange object for temporary buffers and MPI exchanges.
Defines internal basic interpolation definitions.
#define YAC_FRAC_MASK_VALUE_IS_VALID(value)
Test whether a fractional mask value is valid.
#define xrealloc(ptr, size)
double *** send_field_acc
struct coupling_field::@63::@64::@66 * puts
struct coupling_field::@63::@64 put
char prev_datetime[MAX_DATETIME_STR_LEN]
int time_accumulation_count
double *** send_frac_mask_acc
struct yac_interpolation_exchange * interpolation_exchange
struct yac_basic_grid * grid
struct coupling_field::@63::@65 get
char current_datetime[MAX_DATETIME_STR_LEN]
struct yac_interp_field * interp_fields
enum yac_field_exchange_type exchange_type
struct yac_interp_weights_data interp_weights_data
size_t collection_size
number of vertical levels or bundles
struct yac_interpolation * interpolation
union coupling_field::@63 exchange_data
struct yac_pak * pak
Borrowed pointer to the YAC PAK object from the owning instance (may be NULL)
double frac_mask_fallback_value
double frac_mask_fallback_value
#define YAC_ASSERT_F(exp, format,...)
#define YAC_ASSERT_FUNC(exp, func, msg)