YetAnotherCoupler 3.2.0_a
Loading...
Searching...
No Matches
yac.pyx
Go to the documentation of this file.
1# Copyright (c) 2024 The YAC Authors
2#
3# SPDX-License-Identifier: BSD-3-Clause
4
5import cython
6from enum import Enum
7import numpy as _np
8import logging
9from types import coroutine
10
11from libc.stdlib cimport malloc, free
12
13cdef import from "<mpi.h>" nogil:
14 ctypedef struct _mpi_comm_t
15 ctypedef _mpi_comm_t* MPI_Comm
16 int MPI_Comm_c2f(MPI_Comm)
17 MPI_Comm MPI_Comm_f2c(int)
18
19cdef extern from "Python.h":
20 int Py_AtExit(void (*)())
21
22cdef extern from "yac.h":
23 cdef const int _LOCATION_CELL "YAC_LOCATION_CELL"
24 cdef const int _LOCATION_CORNER "YAC_LOCATION_CORNER"
25 cdef const int _LOCATION_EDGE "YAC_LOCATION_EDGE"
26
27 cdef const int _EXCHANGE_TYPE_NONE "YAC_EXCHANGE_TYPE_NONE"
28 cdef const int _EXCHANGE_TYPE_SOURCE "YAC_EXCHANGE_TYPE_SOURCE"
29 cdef const int _EXCHANGE_TYPE_TARGET "YAC_EXCHANGE_TYPE_TARGET"
30
31 cdef const int _ACTION_NONE "YAC_ACTION_NONE"
32 cdef const int _ACTION_REDUCTION "YAC_ACTION_REDUCTION"
33 cdef const int _ACTION_COUPLING "YAC_ACTION_COUPLING"
34 cdef const int _ACTION_GET_FOR_RESTART "YAC_ACTION_GET_FOR_RESTART"
35 cdef const int _ACTION_PUT_FOR_RESTART "YAC_ACTION_PUT_FOR_RESTART"
36 cdef const int _ACTION_OUT_OF_BOUND "YAC_ACTION_OUT_OF_BOUND"
37
38 cdef const int _REDUCTION_TIME_NONE "YAC_REDUCTION_TIME_NONE"
39 cdef const int _REDUCTION_TIME_ACCUMULATE "YAC_REDUCTION_TIME_ACCUMULATE"
40 cdef const int _REDUCTION_TIME_AVERAGE "YAC_REDUCTION_TIME_AVERAGE"
41 cdef const int _REDUCTION_TIME_MINIMUM "YAC_REDUCTION_TIME_MINIMUM"
42 cdef const int _REDUCTION_TIME_MAXIMUM "YAC_REDUCTION_TIME_MAXIMUM"
43
44 cdef const int _CALENDAR_NOT_SET "YAC_CALENDAR_NOT_SET"
45 cdef const int _PROLEPTIC_GREGORIAN "YAC_PROLEPTIC_GREGORIAN"
46 cdef const int _YEAR_OF_365_DAYS "YAC_YEAR_OF_365_DAYS"
47 cdef const int _YEAR_OF_360_DAYS "YAC_YEAR_OF_365_DAYS"
48
49 cdef const int _TIME_UNIT_MILLISECOND "YAC_TIME_UNIT_MILLISECOND"
50 cdef const int _TIME_UNIT_SECOND "YAC_TIME_UNIT_SECOND"
51 cdef const int _TIME_UNIT_MINUTE "YAC_TIME_UNIT_MINUTE"
52 cdef const int _TIME_UNIT_HOUR "YAC_TIME_UNIT_HOUR"
53 cdef const int _TIME_UNIT_DAY "YAC_TIME_UNIT_DAY"
54 cdef const int _TIME_UNIT_MONTH "YAC_TIME_UNIT_MONTH"
55 cdef const int _TIME_UNIT_YEAR "YAC_TIME_UNIT_YEAR"
56 cdef const int _TIME_UNIT_ISO_FORMAT "YAC_TIME_UNIT_ISO_FORMAT"
57
58 cdef const int _AVG_ARITHMETIC "YAC_AVG_ARITHMETIC"
59 cdef const int _AVG_DIST "YAC_AVG_DIST"
60 cdef const int _AVG_BARY "YAC_AVG_BARY"
61
62 cdef const int _NCC_AVG "YAC_NCC_AVG"
63 cdef const int _NCC_DIST "YAC_NCC_DIST"
64
65 cdef const int _NNN_AVG "YAC_NNN_AVG"
66 cdef const int _NNN_DIST "YAC_NNN_DIST"
67 cdef const int _NNN_GAUSS "YAC_NNN_GAUSS"
68 cdef const int _NNN_RBF "YAC_NNN_RBF"
69
70 cdef const int _CONSERV_DESTAREA "YAC_CONSERV_DESTAREA"
71 cdef const int _CONSERV_FRACAREA "YAC_CONSERV_FRACAREA"
72
73 cdef const int _SPMAP_AVG "YAC_SPMAP_AVG"
74 cdef const int _SPMAP_DIST "YAC_SPMAP_DIST"
75
76 cdef const int _SPMAP_NONE "YAC_SPMAP_NONE"
77 cdef const int _SPMAP_SRCAREA "YAC_SPMAP_SRCAREA"
78 cdef const int _SPMAP_INVTGTAREA "YAC_SPMAP_INVTGTAREA"
79 cdef const int _SPMAP_FRACAREA "YAC_SPMAP_FRACAREA"
80
81 void yac_cinit ()
82 void yac_cinit_instance ( int * yac_instance_id )
83 void yac_cinit_comm (MPI_Comm comm )
84 void yac_cinit_comm_instance (MPI_Comm comm, int * yac_instance_id )
86 void yac_ccleanup_instance (int yac_instance_id)
87 void yac_cdef_comp_instance ( int yac_instance_id,
88 const char * comp_name,
89 int * comp_id )
90 void yac_cdef_comps_instance ( int yac_instance_id,
91 const char ** comp_names,
92 int num_comps,
93 int * comp_ids )
94 void yac_cpredef_comp_instance ( int yac_instance_id,
95 const char * comp_name,
96 int * comp_id )
97 void yac_cget_comp_comm ( int comp_id, MPI_Comm* comp_comm )
98 void yac_cdef_datetime_instance ( int yac_instance_id,
99 const char * start_datetime,
100 const char * end_datetime )
101 void yac_cget_comps_comm_instance( int yac_instance_id,
102 const char ** comp_names,
103 int num_comps,
104 MPI_Comm * comps_comm)
105 void yac_cdef_calendar ( int calendar )
106 void yac_cenddef_instance ( int yac_instance_id )
107 int yac_cget_nbr_comps_instance ( int yac_instance_id )
108 int yac_cget_nbr_grids_instance ( int yac_instance_id )
109 int yac_cget_comp_nbr_grids_instance ( int yac_instance_id, const char* comp_name )
110 int yac_cget_nbr_fields_instance ( int yac_instance_id, const char * comp_name,
111 const char* grid_name)
112 void yac_cget_comp_names_instance ( int yac_instance_id, int nbr_comps,
113 const char ** comp_names )
114 void yac_cget_grid_names_instance ( int yac_instance_id, int nbr_grids,
115 const char ** grid_names )
116 void yac_cget_comp_grid_names_instance ( int yac_instance_id, const char* comp_name,
117 int nbr_grids, const char ** grid_names )
118 void yac_cget_field_names_instance ( int yac_instance_id, const char* comp_name,
119 const char* grid_name,
120 int nbr_fields, const char ** field_names )
121 int yac_cget_field_id_instance ( int yac_instance_id, const char* comp_name,
122 const char* grid_name,
123 const char * field_name )
124 const char* yac_cget_field_timestep_instance ( int yac_instance_id, const char* comp_name,
125 const char* grid_name,
126 const char * field_name )
127 int yac_cget_field_role_instance ( int yac_instance_id, const char* comp_name,
128 const char* grid_name, const char* field_name )
129 void yac_cenable_field_frac_mask_instance ( int yac_instance_id,
130 const char* comp_name,
131 const char* grid_name,
132 const char * field_name,
133 double frac_mask_fallback_value)
134 int yac_cget_field_collection_size_instance ( int yac_instance_id,
135 const char* comp_name,
136 const char* grid_name,
137 const char * field_name )
138 double yac_cget_field_frac_mask_fallback_value_instance ( int yac_instance_id,
139 const char* comp_name,
140 const char* grid_name,
141 const char * field_name )
142 void yac_cdef_component_metadata_instance ( int yac_instance_id,
143 const char* comp_name,
144 const char* metadata)
145 void yac_cdef_grid_metadata_instance ( int yac_instance_id,
146 const char* grid_name,
147 const char* metadata)
148 void yac_cdef_field_metadata_instance ( int yac_instance_id,
149 const char* comp_name,
150 const char* grid_name,
151 const char* field_name,
152 const char* metadata)
153 const char* yac_cget_component_metadata_instance(int yac_instance_id,
154 const char* comp_name)
155 const char* yac_cget_grid_metadata_instance(int yac_instance_id,
156 const char* grid_name)
157 const char* yac_cget_field_metadata_instance(int yac_instance_id,
158 const char* comp_name,
159 const char* grid_name,
160 const char* field_name)
161 char * yac_cget_start_datetime_instance ( int yac_instance_id )
162 char * yac_cget_end_datetime_instance ( int yac_instance_id )
163 char * yac_cget_version ()
164 void yac_cdef_grid_reg2d ( const char * grid_name,
165 int nbr_vertices[2],
166 int cyclic[2],
167 double *x_vertices,
168 double *y_vertices,
169 int *grid_id)
170 void yac_cdef_points_reg2d ( const int grid_id,
171 int nbr_points[2],
172 const int location,
173 const double *x_points,
174 const double *y_points,
175 int *point_id )
176 void yac_cdef_grid_curve2d ( const char * grid_name,
177 int nbr_vertices[2],
178 int cyclic[2],
179 double *x_vertices,
180 double *y_vertices,
181 int *grid_id)
182 void yac_cdef_points_curve2d ( const int grid_id,
183 int nbr_points[2],
184 const int location,
185 const double *x_points,
186 const double *y_points,
187 int *point_id )
188 void yac_cdef_grid_unstruct ( const char * grid_name,
189 int nbr_vertices,
190 int nbr_cells,
191 int *num_vertices_per_cell,
192 double *x_vertices,
193 double *y_vertices,
194 int *cell_to_vertex,
195 int *grid_id)
196 void yac_cdef_grid_unstruct_ll ( const char * grid_name,
197 int nbr_vertices,
198 int nbr_cells,
199 int *num_vertices_per_cell,
200 double *x_vertices,
201 double *y_vertices,
202 int *cell_to_vertex,
203 int *grid_id)
204 void yac_cdef_points_unstruct ( const int grid_id,
205 const int nbr_points,
206 const int location,
207 const double *x_points,
208 const double *y_points,
209 int *point_id )
210 void yac_cset_global_index ( const int * global_index,
211 int location,
212 int grid_id)
213 void yac_cdef_field ( const char * field_name,
214 const int component_id,
215 const int * point_ids,
216 const int num_pointsets,
217 int collection_size,
218 const char* timestep,
219 int timeunit,
220 int * field_id )
221 void yac_cdef_field_mask ( const char * field_name,
222 const int component_id,
223 const int * point_ids,
224 const int * mask_ids,
225 const int num_pointsets,
226 int collection_size,
227 const char* timestep,
228 int timeunit,
229 int * field_id )
230 void yac_csync_def_instance ( int yac_instance_id )
231 void yac_cget_ext_couple_config(int * ext_couple_config_id)
232 void yac_cset_ext_couple_config_weight_file(int ext_couple_config_id,
233 const char * weight_file)
234 void yac_cset_ext_couple_config_mapping_side(int ext_couple_config_id,
235 int mapping_side)
236 void yac_cset_ext_couple_config_scale_factor(int ext_couple_config_id,
237 double scale_factor)
238 void yac_cset_ext_couple_config_scale_summand(int ext_couple_config_id,
239 double scale_summand)
241 int ext_couple_config_id, size_t num_src_mask_names,
242 const char * const * src_mask_names)
244 int ext_couple_config_id, const char * tgt_mask_name)
245 void yac_cfree_ext_couple_config(int ext_couple_config_id)
246 void yac_cdef_couple_custom_instance(int yac_instance_id,
247 const char * src_comp_name,
248 const char * src_grid_name,
249 const char * src_field_name,
250 const char * tgt_comp_name,
251 const char * tgt_grid_name,
252 const char * tgt_field_name,
253 const char * coupling_timestep,
254 int time_unit, int time_reduction,
255 int interp_stack_config_id,
256 int src_lag, int tgt_lag,
257 int ext_couple_config_id)
258 void yac_cget_ ( const int field_id,
259 const int collection_size,
260 double *recv_field,
261 int *info,
262 int *ierror ) nogil
263 void yac_cget_async_ ( const int field_id,
264 const int collection_size,
265 double *recv_field,
266 int *info,
267 int *ierror )
268 void yac_cput_ ( const int field_id,
269 const int collection_size,
270 const double * send_field,
271 int *info,
272 int *ierror ) nogil
273 void yac_cput_frac_ ( const int field_id,
274 const int collection_size,
275 double *send_field,
276 double *send_frac_mask,
277 int *info,
278 int *ierr ) nogil
279 void yac_ctest ( int field_id, int * flag )
280 void yac_cwait ( int field_id ) nogil
281 void yac_cupdate( int field_id )
282 const char* yac_cget_field_name_from_field_id ( int field_id )
283 int yac_cget_role_from_field_id ( int field_id )
284 const char* yac_cget_timestep_from_field_id ( int field_id )
285 size_t yac_cget_grid_size ( int location, int grid_id )
286 size_t yac_cget_points_size ( int points_id )
287 int yac_cget_collection_size_from_field_id ( const int field_id )
288 const char* yac_cget_field_datetime(int field_id)
289 void yac_cget_interp_stack_config(int * interp_stack_config_id)
291 int interp_stack_config_id, int reduction_type, int partial_coverage)
293 int interp_stack_config_id, int weight_type, int partial_coverage)
294 void yac_cadd_interp_stack_config_nnn(int interp_stack_config_id, int type,
295 unsigned int n, double scale)
297 int interp_stack_config_id, int order, int enforced_conserv,
298 int partial_coverage, int normalisation)
300 int interp_stack_config_id, double spread_distance,
301 double max_search_distance, int weight_type, int scale_type,
302 double src_sphere_radius, double tgt_sphere_radius)
303 void yac_cadd_interp_stack_config_hcsbb(int interp_stack_config_id)
305 int interp_stack_config_id, char * filename, char * src_grid_name,
306 char * tgt_grid_name)
308 int interp_stack_config_id, double value)
310 int interp_stack_config_id, char * constructor_key, char * do_search_key)
312 int interp_stack_config_id, int creep_distance)
313 void yac_cfree_interp_stack_config(int interp_stack_config_id)
314 void yac_cset_core_mask ( const int * is_core,
315 int location,
316 int grid_id)
317 void yac_cset_mask ( const int * is_valid,
318 int points_id )
319 void yac_cdef_mask_named ( const int grid_id,
320 const int nbr_points,
321 const int location,
322 const int * is_valid,
323 const char * name,
324 int *mask_id )
325 void yac_cfinalize()
326 ctypedef void (*yac_abort_func)(MPI_Comm comm, const char *msg,
327 const char *source, int line) except *
328 void yac_set_abort_handler(yac_abort_func custom_abort)
329 yac_abort_func yac_get_abort_handler()
330 void yac_cread_config_yaml_instance( int yac_instance_id,
331 const char * yaml_file)
332 void yac_cget_action( int field_id, int* action)
333
334# helper functions for py interface (not in yac_interface.h)
335cdef extern void yac_cget_comp_size_c2py(int comp_id, int* size)
336cdef extern void yac_cget_comp_rank_c2py(int comp_id, int* rank)
337
338_logger = logging.getLogger("yac")
339_logger.addHandler(logging.NullHandler())
340
341class Location(Enum):
342 """
343 Location for points
344
345 Refers to @ref YAC_LOCATION_CELL, @ref YAC_LOCATION_CORNER and @ref YAC_LOCATION_EDGE
346 """
347 CELL = _LOCATION_CELL
348 CORNER = _LOCATION_CORNER
349 EDGE = _LOCATION_EDGE
350
351class ExchangeType(Enum):
352 """
353 Exchange type of a field
354
355 Refers to @ref YAC_EXCHANGE_TYPE_NONE, @ref YAC_EXCHANGE_TYPE_SOURCE and @ref YAC_EXCHANGE_TYPE_TARGET
356 """
357 NONE = _EXCHANGE_TYPE_NONE
358 SOURCE = _EXCHANGE_TYPE_SOURCE
359 TARGET = _EXCHANGE_TYPE_TARGET
360
361class Action(Enum):
362 """
363 Refers to @ref YAC_ACTION_NONE, @ref YAC_ACTION_REDUCTION etc.
364 """
365 NONE = _ACTION_NONE
366 REDUCTION = _ACTION_REDUCTION
367 COUPLING = _ACTION_COUPLING
368 GET_FOR_RESTART = _ACTION_GET_FOR_RESTART
369 PUT_FOR_RESTART = _ACTION_PUT_FOR_RESTART
370 OUT_OF_BOUND = _ACTION_OUT_OF_BOUND
371
372class Reduction(Enum):
373 """
374 Reduction type for the definition of interpolations
375
376 Refers to @ref YAC_REDUCTION_TIME_NONE, @ref YAC_REDUCTION_TIME_ACCUMULATE etc.
377 """
378 TIME_NONE = _REDUCTION_TIME_NONE
379 TIME_ACCUMULATE = _REDUCTION_TIME_ACCUMULATE
380 TIME_AVERAGE = _REDUCTION_TIME_AVERAGE
381 TIME_MINIMUM = _REDUCTION_TIME_MINIMUM
382 TIME_MAXIMUM = _REDUCTION_TIME_MAXIMUM
383
384class Calendar(Enum):
385 """
386 Calendar type for use in def_calendar
387
388 Refers to @ref YAC_CALENDAR_NOT_SET, @ref YAC_PROLEPTIC_GREGORIAN etc.
389 """
390 CALENDAR_NOT_SET = _CALENDAR_NOT_SET
391 PROLEPTIC_GREGORIAN = _PROLEPTIC_GREGORIAN
392 YEAR_OF_365_DAYS = _YEAR_OF_365_DAYS
393 YEAR_OF_360_DAYS = _YEAR_OF_360_DAYS
394
395def def_calendar(calendar : Calendar):
396 """
397 @see yac_cdef_calendar
398 """
399 yac_cdef_calendar(Calendar(calendar).value)
400
401
402class TimeUnit(Enum):
403 """
404 Refers to @ref YAC_TIME_UNIT_MILLISECOND, @ref YAC_TIME_UNIT_SECOND etc.
405 """
406 MILLISECOND = _TIME_UNIT_MILLISECOND
407 SECOND = _TIME_UNIT_SECOND
408 MINUTE = _TIME_UNIT_MINUTE
409 HOUR = _TIME_UNIT_HOUR
410 DAY = _TIME_UNIT_DAY
411 MONTH = _TIME_UNIT_MONTH
412 YEAR = _TIME_UNIT_YEAR
413 ISO_FORMAT = _TIME_UNIT_ISO_FORMAT
414
416 """
417 Reduction type for average interpolation
418
419 Refers to @ref YAC_AVG_ARITHMETIC, @ref YAC_AVG_DIST and @ref YAC_AVG_BARY
420 """
421 AVG_ARITHMETIC = _AVG_ARITHMETIC
422 AVG_DIST = _AVG_DIST
423 AVG_BARY = _AVG_BARY
424
426 """
427 Reduction type for ncc interpolation
428
429 Refers to @ref YAC_NCC_AVG and @ref YAC_NCC_DIST
430 """
431 AVG = _NCC_AVG
432 DIST = _NCC_DIST
433
435 """
436 Reduction type for nnn interpolation
437
438 Refers to @ref YAC_NNN_AVG, @ref YAC_NNN_DIST etc.
439 """
440 AVG = _NNN_AVG
441 DIST = _NNN_DIST
442 GAUSS = _NNN_GAUSS
443 RBF = _NNN_RBF
444
446 """
447 Normalization type for conservative interpolation
448
449 Refers to @ref YAC_CONSERV_DESTAREA and @ref YAC_CONSERV_FRACAREA
450 """
451 DESTAREA = _CONSERV_DESTAREA
452 FRACAREA = _CONSERV_FRACAREA
453
454class SPMAPWeightType(Enum):
455 """
456 Refers to @ref YAC_SPMAP_AVG and @ref YAC_SPMAP_DIST
457 """
458 AVG = _SPMAP_AVG
459 DIST = _SPMAP_DIST
460
461class SPMAPScaleType(Enum):
462 """
463 Refers to @ref YAC_SPMAP_NONE, YAC_SPMAP_SRCAREA
464 YAC_SPMAP_INVTGTAREA, and @ref YAC_SPMAP_FRACAREA
465 """
466 NONE = _SPMAP_NONE
467 SRCAREA = _SPMAP_SRCAREA
468 INVTGTAREA = _SPMAP_INVTGTAREA
469 FRACAREA = _SPMAP_FRACAREA
470
471class YAC:
472 """
473 Initializies a YAC instance and provides further functionality
474
475 The destructor finalizes the YAC instance by calling yac_cfinalize_instance
476 """
477 def __init__(self, comm = None, default_instance = False):
478 """
479 @see yac_cinit_instance
480 """
481 cdef int instance_id
482 cdef MPI_Comm c_comm
483 if comm is None:
484 if default_instance:
485 _logger.debug("init")
486 yac_cinit()
487 instance_id = yac_cget_default_instance_id()
488 else:
489 _logger.debug("init_instance")
490 yac_cinit_instance(&instance_id)
491 else:
492 from mpi4py import MPI
493 if type(comm) is MPI.Intracomm:
494 comm = MPI.Comm.py2f(comm)
495 if default_instance:
496 _logger.debug("init_comm")
497 yac_cinit_comm(MPI_Comm_f2c(comm))
498 instance_id = yac_cget_default_instance_id()
499 else:
500 _logger.debug("init_comm_instance")
501 yac_cinit_comm_instance(MPI_Comm_f2c(comm), &instance_id)
502 _logger.debug(f"instance_id={instance_id}")
503 self.instance_id = instance_id
504 self.initialized = True
505
506 @classmethod
507 @property
509 yac = cls.__new__(cls)
510 yac.instance_id = yac_cget_default_instance_id()
511 yac.initialized = False
512 return yac
513
514 def __del__(self):
515 self.cleanup()
516
517 def cleanup(self):
518 """
519 @see yac_ccleanup_instance
520 """
521 if self.initialized:
522 _logger.debug(f"cleanup instance_id={self.instance_id}")
524 self.initialized = False
525
526 def def_comp(self, comp_name : str):
527 """
528 @see yac_cdef_comp_instance
529 """
530 cdef int comp_id
531 _logger.debug(f"def_comp: comp_name={comp_name}")
532 yac_cdef_comp_instance(self.instance_id, comp_name.encode(), &comp_id)
533 _logger.debug(f"comp_id={comp_id}")
534 return Component(comp_id)
535
536 def def_comps(self, comp_names = []):
537 """
538 @see yac_cdef_comps_instance
539 """
540 cdef int comp_len = len(comp_names)
541 cdef const char **c_comp_names = <const char **>malloc(comp_len * sizeof(const char *))
542 cdef int *c_comp_ids = <int*>malloc(comp_len * sizeof(int))
543 _logger.debug(f"def_comps: comp_names={comp_names}")
544 byte_comp_names = [c.encode() for c in comp_names]
545 for i in range(comp_len):
546 c_comp_names[i] = byte_comp_names[i]
547 yac_cdef_comps_instance(self.instance_id, c_comp_names, comp_len, c_comp_ids)
548 comp_list = [Component(c_comp_ids[i]) for i in range(comp_len) ]
549 free(c_comp_names)
550 free(c_comp_ids)
551 _logger.debug("comp_list={comp_list}")
552 return comp_list
553
554 def predef_comp(self, comp_name :str):
555 """
556 @see yac_cpredef_comp_instance
557 """
558 cdef int comp_id
559 _logger.debug(f"predef_comp: comp_name={comp_name}")
560 yac_cpredef_comp_instance(self.instance_id, comp_name.encode(), &comp_id)
561 _logger.debug("comp_id={comp_id}")
562 return Component(comp_id)
563
564 def def_datetime(self, start_datetime, end_datetime):
565 """
566 @see yac_cdef_datetime_instance
567
568 The parameters can be given either as a string in iso8601
569 format or as datetime objects
570 """
571 try:
572 import datetime
573 if(type(start_datetime) is datetime.datetime):
574 start_datetime = start_datetime.isoformat()
575 except:
576 pass
577 if start_datetime is not None:
578 _logger.debug(f"def_datetime start: {start_datetime}")
579 yac_cdef_datetime_instance ( self.instance_id,
580 start_datetime.encode(),
581 NULL)
582
583 try:
584 if(type(end_datetime) is datetime.datetime):
585 end_datetime = end_datetime.isoformat()
586 except:
587 pass
588 if end_datetime is not None:
589 _logger.debug(f"def_datetime end: {end_datetime}")
590 yac_cdef_datetime_instance ( self.instance_id,
591 NULL,
592 end_datetime.encode())
593
594 @property
595 def start_datetime(self):
596 """
597 @see yac_cget_start_datetime_instance (`datetime.datetime`, read-only).
598 """
600 return bytes.decode(start)
601
602 @property
603 def end_datetime(self):
604 """
605 @see yac_cget_end_datetime_instance (`datetime.datetime`, read-only).
606 """
608 return bytes.decode(end)
609
610 def sync_def(self):
611 """
612 @see yac_csync_def_instance
613 """
614 _logger.debug("sync_def")
616
617 def def_couple(self,
618 src_comp : str, src_grid : str, src_field,
619 tgt_comp : str, tgt_grid : str, tgt_field,
620 coupling_timestep : str, timeunit : TimeUnit,
621 time_reduction : Reduction,
622 interp_stack, src_lag = 0, tgt_lag = 0,
623 weight_file = None, mapping_on_source = 1,
624 scale_factor = 1.0, scale_summand = 0.0,
625 src_masks_names = None, tgt_mask_name = None):
626 """
627 @see yac_cdef_couple_instance
628 """
629 cdef char * weight_file_ptr
630 if weight_file is None:
631 weight_file_ptr = NULL
632 else:
633 weight_file_bytes = weight_file.encode()
634 weight_file_ptr = weight_file_bytes
635 cdef const char ** src_mask_names_ptr = NULL
636 cdef const char * tgt_mask_name_ptr = NULL
637 if tgt_mask_name is not None:
638 tgt_mask_enc = tgt_mask_name.encode()
639 tgt_mask_name = tgt_mask_enc
640 cdef int couple_config_id
641 yac_cget_ext_couple_config(&couple_config_id)
643 weight_file_ptr)
645 mapping_on_source)
647 scale_factor)
649 scale_summand)
650 if src_masks_names is not None:
651 if type(src_masks_names) is str:
652 src_masks = [src_masks_names]
653 src_masks_enc = [s.encode() for s in src_masks_names]
654 src_mask_names_ptr = <const char **>malloc(len(src_masks_enc) * sizeof(char*))
655 for i in range(len(src_masks_enc)):
656 src_mask_names_ptr[i] = src_masks_enc[i]
658 len(src_masks_enc),
659 src_mask_names_ptr)
660 free(src_mask_names_ptr)
661 if tgt_mask_name is not None:
662 yac_cset_ext_couple_config_tgt_mask_name(couple_config_id, tgt_mask_name.encode())
663 _logger.debug(f"def_couple {(src_comp.encode(), src_grid.encode(), src_field.encode())}, {(tgt_comp.encode(), tgt_grid.encode(), tgt_field.encode())}")
665 src_comp.encode(), src_grid.encode(), src_field.encode(),
666 tgt_comp.encode(), tgt_grid.encode(), tgt_field.encode(),
667 coupling_timestep.encode(), TimeUnit(timeunit).value,
668 Reduction(time_reduction).value,
669 interp_stack.interp_stack_id, src_lag, tgt_lag,
670 couple_config_id)
671 yac_cfree_ext_couple_config(couple_config_id)
672
673 def enddef(self):
674 """
675 @see yac_cenddef_instance
676 """
677 _logger.debug("enddef")
679
680 @property
682 """
683 @see yac_cget_comp_names
684 """
685 cdef int nbr_components = yac_cget_nbr_comps_instance(self.instance_id)
686 cdef const char **ret = <const char **>malloc(nbr_components * sizeof(const char *))
687 yac_cget_comp_names_instance(self.instance_id, nbr_components, ret)
688 comp_list = [bytes(ret[i]).decode('UTF-8') for i in range(nbr_components) ]
689 free(ret)
690 return comp_list
691
692 @property
693 def grid_names(self):
694 """
695 @see yac_cget_grid_names
696 """
697 cdef int nbr_grids = yac_cget_nbr_grids_instance(self.instance_id)
698 cdef const char **ret = <const char **>malloc(nbr_grids * sizeof(const char *))
699 yac_cget_grid_names_instance(self.instance_id, nbr_grids, ret)
700 grid_list = [bytes(ret[i]).decode('UTF-8') for i in range(nbr_grids) ]
701 free(ret)
702 return grid_list
703
704 def get_comp_grid_names(self, comp_name):
705 """
706 @see yac_cget_comp_grid_names
707 """
708 cdef int nbr_grids = yac_cget_comp_nbr_grids_instance(self.instance_id, comp_name.encode())
709 cdef const char **ret = <const char **>malloc(nbr_grids * sizeof(const char *))
710 yac_cget_comp_grid_names_instance(self.instance_id, comp_name.encode(), nbr_grids, ret)
711 grid_list = [bytes(ret[i]).decode('UTF-8') for i in range(nbr_grids) ]
712 free(ret)
713 return grid_list
714
715 def get_field_names(self, comp_name : str, grid_name : str):
716 """
717 @see yac_cget_field_names
718 """
719 cdef int nbr_fields = yac_cget_nbr_fields_instance(self.instance_id,
720 comp_name.encode(),
721 grid_name.encode())
722 cdef const char **ret = <const char **>malloc(nbr_fields * sizeof(const char *))
723 yac_cget_field_names_instance(self.instance_id, comp_name.encode(),
724 grid_name.encode(), nbr_fields, ret)
725 field_list = [bytes(ret[i]).decode('UTF-8') for i in range(nbr_fields) ]
726 free(ret)
727 return field_list
728
729 def get_field_id(self, comp_name : str, grid_name : str, field_name : str):
730 """
731 @see yac_cget_field_id
732 """
733 return yac_cget_field_id_instance (self.instance_id,
734 comp_name.encode(),
735 grid_name.encode(),
736 field_name.encode())
737
738 def get_field_timestep(self, comp_name : str, grid_name : str, field_name : str):
739 """
740 @see yac_cget_field_timestep
741 """
743 comp_name.encode(),
744 grid_name.encode(),
745 field_name.encode()).decode('UTF-8')
746
747 def get_field_role(self, comp_name : str, grid_name : str, field_name : str):
748 """
749 @see yac_cget_field_role
750 """
751 return ExchangeType(yac_cget_field_role_instance (self.instance_id,
752 comp_name.encode(),
753 grid_name.encode(),
754 field_name.encode()))
755
756 def get_field_collection_size(self, comp_name : str, grid_name : str, field_name : str):
757 """
758 @see yac_cget_field_collection_size
759 """
761 comp_name.encode(),
762 grid_name.encode(),
763 field_name.encode())
764
765 def get_field_frac_mask_fallback_value(self, comp_name : str, grid_name : str, field_name : str):
766 """
767 @see yac_cget_field_frac_mask_fallback_value
768 """
770 comp_name.encode(),
771 grid_name.encode(),
772 field_name.encode())
773
774 def enable_field_frac_mask(self, comp_name : str, grid_name : str, field_name : str,
775 frac_mask_fallback_value : _np.float64):
776 """
777 @see yac_cenable_field_frac_mask
778 """
779 _logger.debug(f"enable_field_frac_mask {(comp_name, grid_name, field_name)})")
781 comp_name.encode(),
782 grid_name.encode(),
783 field_name.encode(),
784 frac_mask_fallback_value)
785
786 def def_component_metadata(self, comp_name : str, metadata : bytes):
787 """
788 @see yac_cdef_component_metadata
789 """
790 _logger.debug(f"def_component_metadata comp_name={comp_name}")
792 comp_name.encode(), metadata)
793
794 def def_grid_metadata(self, grid_name : str, metadata : bytes):
795 """
796 @see yac_cdef_grid_metadata
797 """
798 _logger.debug(f"def_grid_metadata grid_name={grid_name}")
800 grid_name.encode(), metadata)
801
802 def def_field_metadata(self, comp_name : str, grid_name : str,
803 field_name : str,metadata : bytes):
804 """
805 @see yac_cdef_field_metadata
806 """
807 _logger.debug("def_field_metadata (comp_name, grid_name, field_name)="
808 f"{(comp_name, grid_name, field_name)}")
809 yac_cdef_field_metadata_instance(self.instance_id, comp_name.encode(),
810 grid_name.encode(), field_name.encode(),
811 metadata)
812
813 def get_component_metadata(self, comp_name : str):
814 """
815 @see yac_cget_component_metadata
816 """
817 cdef const char* metadata = yac_cget_component_metadata_instance(self.instance_id,
818 comp_name.encode())
819 return bytes(metadata).decode('UTF-8') if metadata != NULL else None
820
821 def get_grid_metadata(self, grid_name : str):
822 """
823 @see yac_cget_grid_metadata
824 """
825 cdef const char* metadata = yac_cget_grid_metadata_instance(self.instance_id,
826 grid_name.encode())
827 return bytes(metadata).decode('UTF-8') if metadata != NULL else None
828
829 def get_field_metadata(self, comp_name : str, grid_name : str, field_name :str):
830 """
831 @see yac_cget_field_metadata
832 """
833 cdef const char* metadata = yac_cget_field_metadata_instance(self.instance_id,
834 comp_name.encode(),
835 grid_name.encode(),
836 field_name.encode())
837 return bytes(metadata).decode('UTF-8') if metadata != NULL else None
838
839 def get_comps_comm(self, comp_names):
840 """
841 @see yac_cget_comps_comm
842 """
843 from mpi4py import MPI
844 cdef MPI_Comm comm
845 cptr = [c.encode() for c in comp_names]
846 cdef const char ** comp_names_c_ptr = <const char **>malloc(len(comp_names) * sizeof(const char *))
847 for i in range(len(comp_names)):
848 comp_names_c_ptr[i] = cptr[i]
849 yac_cget_comps_comm_instance(self.instance_id, comp_names_c_ptr, len(comp_names), &comm)
850 free(comp_names_c_ptr)
851 # convert to mpi4py communicator
852 return MPI.Comm.f2py(MPI_Comm_c2f(comm))
853
854 def read_config_yaml(self, yaml_file : str):
855 """
856 @see yac_cread_config_yaml_instance
857 """
858 _logger.debug(f"read_config_yaml yaml_file={yaml_file}")
859 yac_cread_config_yaml_instance(self.instance_id, yaml_file.encode())
860
862 """
863 Stores the component_id and provides further functionality
864 """
865 def __init__(self, comp_id):
866 self.comp_id = comp_id
867
868 @property
869 def comp_comm(self):
870 """
871 @see yac_cget_comp_comm (`MPI.Comm`, read-only)
872 """
873 from mpi4py import MPI
874 cdef MPI_Comm comm
875 yac_cget_comp_comm(self.comp_id, &comm)
876 # convert to mpi4py communicator
877 return MPI.Comm.f2py(MPI_Comm_c2f(comm))
878
879 @property
880 def size(self):
881 """
882 number of processes in this component
883 """
884 cdef int size
886 return size
887
888 @property
889 def rank(self):
890 """
891 process index in the component
892 """
893 cdef int rank
895 return rank
896
897class Mask:
898 """
899 Stores the mask_id
900 """
901 def __init__(self, mask_id):
902 self.mask_id = mask_id
903
904class Grid:
905 """
906 Stores the grid_id and provides further functionality
907
908 Base class for Reg2dGrid and UnstructuredGrid
909 """
910 def __init__(self, grid_id):
911 self.grid_id = grid_id
912
913 def set_global_index(self, global_index, location : Location):
914 """
915 @see yac_cset_global_index
916 """
917 cdef int[::1] global_index_view = _np.ascontiguousarray(global_index, dtype=_np.intc)
918 _logger.debug(f"set_global_index grid_id={self.grid_id}")
919 yac_cset_global_index(&global_index_view[0], location.value, self.grid_id)
920
921 @property
922 def nbr_cells(self):
923 """
924 @see yac_cget_grid_size (`int`, read-only)
925 """
926 return yac_cget_grid_size ( Location.CELL.value, self.grid_id )
927
928 @property
929 def nbr_corners(self):
930 """
931 @see yac_cget_grid_size (`int`, read-only)
932 """
933 return yac_cget_grid_size ( Location.CORNER.value, self.grid_id )
934
935 @property
936 def nbr_edges(self):
937 """
938 @see yac_cget_grid_size (`int`, read-only)
939 """
940 return yac_cget_grid_size ( Location.EDGE.value, self.grid_id )
941
942 def set_core_mask(self, is_core, location : Location):
943 """
944 @see yac_cset_core_mask
945 """
946 cdef size_t len_is_core = len(is_core)
947 assert(len_is_core == yac_cget_grid_size( location.value, self.grid_id ) )
948 cdef int[::1] np_mask = _np.ascontiguousarray(is_core, dtype=_np.intc)
949 _logger.debug(f"set_core_mask grid_id={self.grid_id}")
950 yac_cset_core_mask ( &np_mask[0], location.value, self.grid_id)
951
952 def def_mask(self, location : Location,
953 is_valid, name = None):
954 cdef int len_is_valid = len(is_valid)
955 cdef int[::1] np_mask = _np.ascontiguousarray(is_valid, dtype=_np.int32)
956 cdef int mask_id
957 cdef char* c_name = NULL
958 if name is not None:
959 name_enc = name.encode()
960 c_name = name_enc
961 _logger.debug(f"def_mask_named grid_id={self.grid_id}, name={name}")
962 yac_cdef_mask_named ( self.grid_id,
963 len_is_valid,
964 location.value,
965 &np_mask[0],
966 c_name,
967 &mask_id )
968 return Mask(mask_id)
969
970class Points:
971 """
972 Stores the points_id and provides further functionality
973 """
974 def __init__(self, points_id):
975 self.points_id = points_id
976
977 @property
978 def size(self):
979 """
980 @see yac_cget_points_size (`int`, read-only)
981 """
982 return yac_cget_points_size ( self.points_id )
983
984 def set_mask(self, is_valid):
985 """
986 @see yac_cset_mask
987 """
988 cdef size_t len_is_valid = len(is_valid)
989 assert len_is_valid==self.size
990 cdef int[::1] np_mask = _np.ascontiguousarray(is_valid, dtype=_np.intc)
991 _logger.debug(f"set_mask points_id={self.points_id}")
992 yac_cset_mask ( &np_mask[0],
993 self.points_id )
994
996 """
997 A stuctured 2d Grid
998 """
999 def __init__(self, grid_name : str, x_vertices, y_vertices,
1000 cyclic = [False, False]):
1001 """
1002 @see yac_cdef_grid_reg2d
1003 """
1004 cdef int grid_id
1005 cdef double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1006 cdef double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1007 cdef int[2] cyclic_view = cyclic
1008 _logger.debug(f"def_grid_reg2d grid_name={grid_name}")
1009 yac_cdef_grid_reg2d(grid_name.encode(), [len(x),len(y)],
1010 cyclic_view, &x[0], &y[0], &grid_id)
1011 _logger.debug(f"grid_id={grid_id}")
1012 super().__init__(grid_id)
1013
1014 def def_points(self, location : Location,
1015 x_vertices, y_vertices):
1016 """
1017 @see yac_cdef_points_reg2d
1018 """
1019 cdef int points_id
1020 cdef double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1021 cdef double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1022 _logger.debug(f"def_points_reg2d grid_id={self.grid_id}")
1024 location.value, &x[0], &y[0], &points_id)
1025 _logger.debug(f"points_id={points_id}")
1026 return Points(points_id)
1027
1028 def def_points_unstruct(self, location : Location,
1029 x_vertices, y_vertices):
1030 """
1031 @see yac_cdef_points_unstruct
1032 """
1033 assert len(x_vertices) == len(y_vertices)
1034 cdef int points_id
1035 cdef double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1036 cdef double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1037 _logger.debug(f"def_points_unstruct grid_id={self.grid_id}")
1039 location.value, &x[0], &y[0], &points_id)
1040 _logger.debug(f"points_id={points_id}")
1041 return Points(points_id)
1042
1044 """
1045 A curvilinear stuctured 2d Grid
1046 """
1047 def __init__(self, grid_name : str, x_vertices, y_vertices,
1048 cyclic = [False, False]):
1049 """
1050 @see yac_cdef_grid_curve2d
1051 """
1052 cdef int grid_id
1053 cdef double[::1] x = _np.ascontiguousarray(x_vertices.flatten(), dtype=_np.double)
1054 cdef double[::1] y = _np.ascontiguousarray(y_vertices.flatten(), dtype=_np.double)
1055 cdef int[2] cyclic_view = cyclic
1056 _logger.debug(f"def_grid_curve2d grid_name={grid_name}")
1057 yac_cdef_grid_curve2d(grid_name.encode(),
1058 [_np.shape(x_vertices)[1], _np.shape(y_vertices)[0]],
1059 cyclic_view, &x[0], &y[0], &grid_id)
1060 _logger.debug(f"grid_id={grid_id}")
1061 super().__init__(grid_id)
1062
1063 def def_points(self, location : Location,
1064 x_vertices, y_vertices):
1065 """
1066 @see yac_cdef_points_curve2d
1067 """
1068 assert x_vertices.shape == y_vertices.shape
1069 cdef int points_id
1070 cdef double[::1] x = _np.ascontiguousarray(x_vertices.flatten(), dtype=_np.double)
1071 cdef double[::1] y = _np.ascontiguousarray(y_vertices.flatten(), dtype=_np.double)
1072 _logger.debug(f"def_points_curve2d grid_id={self.grid_id}")
1074 [_np.shape(x_vertices)[1], _np.shape(x_vertices)[0]],
1075 location.value, &x[0], &y[0], &points_id)
1076 _logger.debug(f"points_id={points_id}")
1077 return Points(points_id)
1078
1079 def def_points_unstruct(self, location : Location,
1080 x_vertices, y_vertices):
1081 """
1082 @see yac_cdef_points_unstruct
1083 """
1084 assert len(x_vertices) == len(y_vertices)
1085 cdef int points_id
1086 cdef double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1087 cdef double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1088 _logger.debug(f"def_points_unstruct grid_id={self.grid_id}")
1090 location.value, &x[0], &y[0], &points_id)
1091 _logger.debug(f"points_id={points_id}")
1092 return Points(points_id)
1093
1095 """
1096 An unstuctured 2d Grid
1097 """
1098 def __init__(self, grid_name : str, num_vertices_per_cell,
1099 x_vertices, y_vertices, cell_to_vertex, use_ll_edges=False):
1100 """
1101 @see yac_cdef_grid_unstruct and @see yac_cdef_grid_unstruct_ll
1102 """
1103 cdef int grid_id
1104 cdef int[::1] num_vertices_per_cell_view = _np.ascontiguousarray(num_vertices_per_cell, dtype=_np.intc)
1105 cdef double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1106 cdef double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1107 cdef int[::1] cell_to_vertex_view = _np.ascontiguousarray(cell_to_vertex, dtype=_np.intc)
1108 if not use_ll_edges:
1109 _logger.debug(f"def_grid_unstruct grid_name={grid_name}")
1110 yac_cdef_grid_unstruct(grid_name.encode(), len(x_vertices_view),
1111 len(num_vertices_per_cell_view),
1112 &num_vertices_per_cell_view[0],
1113 &x_vertices_view[0], &y_vertices_view[0],
1114 &cell_to_vertex_view[0], &grid_id)
1115 else:
1116 _logger.debug(f"def_grid_unstruct_ll grid_name={grid_name}")
1117 yac_cdef_grid_unstruct_ll(grid_name.encode(), len(x_vertices_view),
1118 len(num_vertices_per_cell_view),
1119 &num_vertices_per_cell_view[0],
1120 &x_vertices_view[0], &y_vertices_view[0],
1121 &cell_to_vertex_view[0], &grid_id)
1122 _logger.debug(f"grid_id={grid_id}")
1123 super().__init__(grid_id)
1124
1125 def def_points(self, location : Location,
1126 x_points, y_points):
1127 """
1128 @see yac_cdef_points_unstruct
1129 """
1130 cdef int points_id
1131 cdef double[::1] x_points_view = _np.ascontiguousarray(x_points, dtype=_np.double)
1132 cdef double[::1] y_points_view = _np.ascontiguousarray(y_points, dtype=_np.double)
1133 _logger.debug(f"yac_cdef_points_unstruct grid_id={self.grid_id}")
1134 yac_cdef_points_unstruct(self.grid_idgrid_id, len(x_points_view), location.value,
1135 &x_points_view[0], &y_points_view[0], &points_id)
1136 _logger.debug(f"points_id={points_id}")
1137 return Points(points_id)
1138
1139class Field:
1140 """
1141 Stored the field_id
1142 """
1143 def __init__(self, field_id, size=None):
1144 self.field_id = field_id
1145 self._size = size
1146
1147 @classmethod
1148 def create(cls, field_name : str, comp : Component, points, collection_size,
1149 timestep : str, timeunit : TimeUnit, masks = None):
1150 """
1151 @see yac_cdef_field
1152 """
1153 from collections.abc import Iterable
1154 cdef int field_id
1155 if not isinstance(points, Iterable):
1156 points = [points]
1157 cdef int[:] point_ids_array = _np.array([p.points_id for p in points], dtype=_np.intc)
1158 size = sum(p.size for p in points)
1159 cdef int[:] mask_ids_array
1160 if masks is None:
1161 _logger.debug(f"def_field field_name={field_name}, comp_id={comp.comp_id}, point_ids={[p.points_id for p in points]}")
1162 yac_cdef_field(field_name.encode(), comp.comp_id,
1163 &point_ids_array[0], len(point_ids_array),
1164 collection_size, timestep.encode(), TimeUnit(timeunit).value, &field_id)
1165 else:
1166 if not isinstance(masks, Iterable):
1167 masks = [masks]
1168 mask_ids_array = _np.array([m.mask_id for m in masks], dtype=_np.intc)
1169 _logger.debug(f"def_field_mask field_name={field_name}, comp_id={comp.comp_id}, point_ids={[p.points_id for p in points]}")
1170 yac_cdef_field_mask(field_name.encode(), comp.comp_id,
1171 &point_ids_array[0], &mask_ids_array[0],
1172 len(point_ids_array),
1173 collection_size, timestep.encode(), TimeUnit(timeunit).value, &field_id)
1174 _logger.debug(f"field_id={field_id}")
1175 return Field(field_id, size)
1176
1177 def test(self):
1178 """
1179 @see yac_ctest
1180
1181 """
1182 cdef int flag
1183 _logger.debug(f"test field_id={self.field_id}")
1184 yac_ctest ( self.field_id, &flag )
1185 _logger.debug(f"flag={flag}")
1186 return flag
1187
1188 def wait(self):
1189 """
1190 @see yac_cwait
1191
1192 """
1193 cdef int field_id = self.field_id
1194 _logger.debug(f"wait field_id={field_id}")
1195 with cython.nogil:
1196 yac_cwait ( field_id )
1197
1198 @coroutine
1199 def wait_coro(self):
1200 """
1201 Coroutine. Blocks until the communication is completed.
1202 """
1203 while self.test() == 0:
1204 yield
1205
1206 @cython.boundscheck(False)
1207 def get(self, buf=None, asyn=False):
1208 """
1209 @see yac_cget_
1210
1211 @param[out] buf receive buffer, if `None` a numpy array of correct size is allocated
1212 @param[in] asyn if True the call returns immidiatly and must be completed
1213 with `test` or `wait`
1214 """
1215 cdef int info
1216 cdef int ierror
1217 buf_in = buf
1218 if buf is None:
1219 buf = _np.empty((self.collection_sizecollection_size, self.sizesize), dtype=_np.double)
1220 buf = _np.ascontiguousarray(buf.reshape(self.collection_sizecollection_size, self.sizesize), dtype=_np.double)
1221 if buf_in is not None and buf.base is None:
1222 _logger.warning("get: non-contiguous buffer passed to get. Reallocated memory.")
1223 cdef double[:,::1] buf_view = buf
1224 cdef int field_id = self.field_id
1225 cdef int collection_size = self.collection_sizecollection_size
1226 if asyn:
1227 _logger.debug(f"get_async_ field_id={self.field_id}")
1228 yac_cget_async_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1229 else:
1230 _logger.debug(f"get_ field_id={self.field_id}")
1231 with cython.nogil:
1232 yac_cget_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1233 if ierror != 0:
1234 raise RuntimeError("yac_cget returned error number " + str(ierror))
1235 _logger.debug(f"info={info}")
1236 return buf, Action(info)
1237
1238 async def get_coro(self, buf=None):
1239 """
1240 Coroutine. Executes a get operation.
1241
1242 @see yac_cget_async_
1243
1244 @param[out] buf receive buffer, if `None` a numpy array of correct size is allocated
1245 """
1246 buf, info = self.get(buf, asyn=True)
1247 await self.wait_coro()
1248 return buf, info
1249
1250 @cython.boundscheck(False)
1251 def put(self, buf, frac_mask = None):
1252 """
1253 @see yac_cput_
1254 """
1255 cdef int info
1256 cdef int ierror
1257 cdef double[:,:,::1] buf_view = _np.ascontiguousarray(buf.reshape(-1,self.collection_sizecollection_size,self.sizesize), dtype=_np.double)
1258 cdef double[:,:,::1] frac_mask_view
1259 cdef int field_id = self.field_id
1260 cdef int collection_size = self.collection_sizecollection_size
1261 if frac_mask is not None:
1262 frac_mask_view = _np.ascontiguousarray(
1263 frac_mask.reshape(-1,self.collection_sizecollection_size,self.sizesize), dtype=_np.double)
1264 _logger.debug(f"put_frac_ field_id={self.field_id}")
1265 with cython.nogil:
1266 yac_cput_frac_(field_id, collection_size, &buf_view[0,0,0],
1267 &frac_mask_view[0,0,0], &info, &ierror)
1268 else:
1269 _logger.debug(f"put_ field_id={self.field_id}")
1270 with cython.nogil:
1271 yac_cput_(field_id, collection_size, &buf_view[0,0,0], &info, &ierror)
1272 if ierror != 0:
1273 raise RuntimeError("yac_cput returned error number " + str(ierror))
1274 _logger.debug(f"info={info}")
1275 return Action(info)
1276
1277 async def put_coro(self, buf, frac_mask = None):
1278 """
1279 Coroutine. Executes a put operation.
1280
1281 @see yac_cput_
1282 """
1283 await self.wait_coro()
1284 return self.put(buf, frac_mask)
1285
1286 def update(self):
1287 """
1288 @see yac_cupdate
1289 """
1290 _logger.debug(f"update field_id={self.field_id}")
1291 yac_cupdate(self.field_id)
1292
1293 @property
1294 def name(self):
1295 """
1296 @see yac_cget_field_name_from_field_id
1297 """
1298 return bytes.decode(yac_cget_field_name_from_field_id ( self.field_id ))
1299
1300 @property
1301 def role(self):
1302 """
1303 @see yac_cget_role_from_field_id
1304 """
1305 return ExchangeType(yac_cget_role_from_field_id ( self.field_id ))
1306
1307 @property
1308 def timestep(self):
1309 """
1310 @see yac_cget_timestep_from_field_id
1311 """
1312 return bytes.decode(yac_cget_timestep_from_field_id ( self.field_id ))
1313
1314 @property
1316 """
1317 @see yac_cget_collection_size_from_field_id
1318 """
1320
1321 @property
1322 def size(self):
1323 """
1324 The size of the corresponding points object
1325 """
1326 return self._size
1327
1328 @property
1329 def datetime(self):
1330 """
1331 @see yac_cget_field_datetime
1332 """
1333 return bytes.decode(yac_cget_field_datetime(self.field_id))
1334
1335 @property
1336 def action(self):
1337 """
1338 @see yac_cget_action
1339 """
1340 cdef int action
1341 yac_cget_action(self.field_id, &action)
1342 return Action(action)
1343
1345 def __init__(self):
1346 """
1347 @see yac_cget_interp_stack_config
1348 """
1349 cdef int interp_stack_config_id
1350 _logger.debug(f"get_interp_stack_config")
1351 yac_cget_interp_stack_config(&interp_stack_config_id)
1352 _logger.debug(f"interp_stack_config_id={interp_stack_config_id}")
1353 self.interp_stack_id = interp_stack_config_id
1354
1355 def add_average(self, reduction_type : AverageReductionType, partial_coverage):
1356 """
1357 @see yac_cadd_interp_stack_config_average
1358 """
1359 _logger.debug(f"add_interp_stack_config_average interp_stack_id={self.interp_stack_id}")
1361 AverageReductionType(reduction_type).value,
1362 partial_coverage)
1363
1364 def add_ncc(self, reduction_type : NCCReductionType, partial_coverage):
1365 """
1366 @see yac_cadd_interp_stack_config_ncc
1367 """
1368 _logger.debug(f"add_interp_stack_config_ncc interp_stack_id={self.interp_stack_id}")
1370 NCCReductionType(reduction_type).value,
1371 partial_coverage)
1372
1373 def add_nnn(self, reduction_type : NNNReductionType, n : int, scale : _np.float64):
1374 """
1375 @see yac_cadd_interp_stack_config_nnn
1376 """
1377 _logger.debug(f"add_interp_stack_config_nnn interp_stack_id={self.interp_stack_id}")
1379 NNNReductionType(reduction_type).value,
1380 n, scale)
1381
1382 def add_conservative(self, order : int, enforced_conserv : int,
1383 partial_coverage : int, normalisation : ConservNormalizationType):
1384 """
1385 @see yac_cadd_interp_stack_config_conservative
1386 """
1387 _logger.debug(f"add_interp_stack_config_conservative interp_stack_id={self.interp_stack_id}")
1389 order, enforced_conserv,
1390 partial_coverage,
1391 ConservNormalizationType(normalisation).value)
1392
1393 def add_spmap(self, spread_distance : _np.float64, max_search_distance : _np.float64,
1394 weight_type : SPMAPWeightType, scale_type : SPMAPScaleType,
1395 src_sphere_radius : _np.float64, tgt_sphere_radius : _np.float64):
1396 """
1397 @see yac_cadd_interp_stack_config_spmap
1398 """
1399 _logger.debug(f"add_interp_stack_config_spmap interp_stack_id={self.interp_stack_id}")
1401 spread_distance, max_search_distance,
1402 SPMAPWeightType(weight_type).value,
1403 SPMAPScaleType(scale_type).value,
1404 src_sphere_radius, tgt_sphere_radius)
1405
1406 def add_hcsbb(self):
1407 """
1408 @see yac_cadd_interp_stack_config_hcsbb
1409 """
1410 _logger.debug(f"add_interp_stack_config_hcsbb interp_stack_id={self.interp_stack_id}")
1412
1413 def add_user_file(self, filename : str, src_grid_name : str,
1414 tgt_grid_name : str):
1415 """
1416 @see yac_cadd_interp_stack_config_user_file
1417 """
1418 _logger.debug(f"add_interp_stack_config_user_file interp_stack_id={self.interp_stack_id}")
1420 filename.encode(), src_grid_name.encode(),
1421 tgt_grid_name.encode())
1422
1423 def add_fixed(self, value : _np.float64):
1424 """
1425 @see yac_cadd_interp_stack_config_fixed
1426 """
1427 _logger.debug(f"add_interp_stack_config_fixed interp_stack_id={self.interp_stack_id}")
1429
1430 def add_check(self, constructor_key : str, do_search_key : str):
1431 """
1432 @see yac_cadd_interp_stack_config_check
1433 """
1434 _logger.debug(f"add_interp_stack_config_check interp_stack_id={self.interp_stack_id}")
1436 constructor_key.encode(), do_search_key.encode())
1437
1438 def add_creep(self, creep_distance : int):
1439 """
1440 @see yac_cadd_interp_stack_config_creep
1441 """
1442 _logger.debug(f"add_interp_stack_config_creep interp_stack_id={self.interp_stack_id}")
1444 creep_distance)
1445
1446 def __del__(self):
1447 """
1448 @see yac_cfree_interp_stack_config
1449 """
1450 _logger.debug(f"free_interp_stack_config interp_stack_id={self.interp_stack_id}")
1452
1454 """
1455 @see yac_cget_version
1456 """
1457 return bytes.decode(yac_cget_version())
1458
1459
1460if Py_AtExit(yac_cfinalize) < 0:
1461 print(
1462 b"WARNING: %s\n",
1463 b"could not register yac_cfinalize with Py_AtExit()",
1464 )
1465
1466cdef yac_abort_func _prev_abort_func = yac_get_abort_handler()
1467
1468cdef void yac_python_abort(MPI_Comm comm, const char* msg,
1469 const char* source, int line) except *:
1470 import traceback
1471 traceback.print_stack()
1472 _prev_abort_func(comm, msg, source, line)
1473 #raise Exception(msg)
1474
1475yac_set_abort_handler(yac_python_abort)
Refers to YAC_ACTION_NONE, YAC_ACTION_REDUCTION etc.
Definition yac.pyx:361
Reduction type for average interpolation.
Definition yac.pyx:415
Calendar type for use in def_calendar.
Definition yac.pyx:384
Stores the component_id and provides further functionality.
Definition yac.pyx:861
__init__(self, comp_id)
Definition yac.pyx:865
size(self)
number of processes in this component
Definition yac.pyx:880
comp_comm(self)
Definition yac.pyx:869
rank(self)
process index in the component
Definition yac.pyx:889
Normalization type for conservative interpolation.
Definition yac.pyx:445
A curvilinear stuctured 2d Grid.
Definition yac.pyx:1043
def_points_unstruct(self, Location location, x_vertices, y_vertices)
Definition yac.pyx:1080
def_points(self, Location location, x_vertices, y_vertices)
Definition yac.pyx:1064
__init__(self, str grid_name, x_vertices, y_vertices, cyclic=[False, False])
Definition yac.pyx:1048
Exchange type of a field.
Definition yac.pyx:351
Stored the field_id.
Definition yac.pyx:1139
wait(self)
Definition yac.pyx:1188
test(self)
Definition yac.pyx:1177
put_coro(self, buf, frac_mask=None)
Coroutine.
Definition yac.pyx:1277
get_coro(self, buf=None)
Coroutine.
Definition yac.pyx:1238
size(self)
The size of the corresponding points object.
Definition yac.pyx:1322
wait_coro(self)
Coroutine.
Definition yac.pyx:1199
update(self)
Definition yac.pyx:1286
action(self)
Definition yac.pyx:1336
get(self, buf=None, asyn=False)
Definition yac.pyx:1207
collection_size(self)
Definition yac.pyx:1315
create(cls, str field_name, Component comp, points, collection_size, str timestep, TimeUnit timeunit, masks=None)
Definition yac.pyx:1149
collection_size
Definition yac.pyx:1263
role(self)
Definition yac.pyx:1301
__init__(self, field_id, size=None)
Definition yac.pyx:1143
timestep(self)
Definition yac.pyx:1308
put(self, buf, frac_mask=None)
Definition yac.pyx:1251
name(self)
Definition yac.pyx:1294
Stores the grid_id and provides further functionality.
Definition yac.pyx:904
nbr_corners(self)
Definition yac.pyx:929
set_core_mask(self, is_core, Location location)
Definition yac.pyx:942
nbr_cells(self)
Definition yac.pyx:922
grid_id
Definition yac.pyx:911
__init__(self, grid_id)
Definition yac.pyx:910
set_global_index(self, global_index, Location location)
Definition yac.pyx:913
nbr_edges(self)
Definition yac.pyx:936
def_mask(self, Location location, is_valid, name=None)
Definition yac.pyx:953
add_user_file(self, str filename, str src_grid_name, str tgt_grid_name)
Definition yac.pyx:1414
add_check(self, str constructor_key, str do_search_key)
Definition yac.pyx:1430
add_average(self, AverageReductionType reduction_type, partial_coverage)
Definition yac.pyx:1355
add_spmap(self, _np.float64 spread_distance, _np.float64 max_search_distance, SPMAPWeightType weight_type, SPMAPScaleType scale_type, _np.float64 src_sphere_radius, _np.float64 tgt_sphere_radius)
Definition yac.pyx:1395
add_conservative(self, int order, int enforced_conserv, int partial_coverage, ConservNormalizationType normalisation)
Definition yac.pyx:1383
add_creep(self, int creep_distance)
Definition yac.pyx:1438
add_nnn(self, NNNReductionType reduction_type, int n, _np.float64 scale)
Definition yac.pyx:1373
add_fixed(self, _np.float64 value)
Definition yac.pyx:1423
add_ncc(self, NCCReductionType reduction_type, partial_coverage)
Definition yac.pyx:1364
Location for points.
Definition yac.pyx:341
Stores the mask_id.
Definition yac.pyx:897
__init__(self, mask_id)
Definition yac.pyx:901
mask_id
Definition yac.pyx:902
Reduction type for ncc interpolation.
Definition yac.pyx:425
Reduction type for nnn interpolation.
Definition yac.pyx:434
Stores the points_id and provides further functionality.
Definition yac.pyx:970
set_mask(self, is_valid)
Definition yac.pyx:984
__init__(self, points_id)
Definition yac.pyx:974
size(self)
Definition yac.pyx:978
Reduction type for the definition of interpolations.
Definition yac.pyx:372
A stuctured 2d Grid.
Definition yac.pyx:995
__init__(self, str grid_name, x_vertices, y_vertices, cyclic=[False, False])
Definition yac.pyx:1000
def_points(self, Location location, x_vertices, y_vertices)
Definition yac.pyx:1015
def_points_unstruct(self, Location location, x_vertices, y_vertices)
Definition yac.pyx:1029
Refers to YAC_SPMAP_NONE, YAC_SPMAP_SRCAREA YAC_SPMAP_INVTGTAREA, and YAC_SPMAP_FRACAREA.
Definition yac.pyx:461
Refers to YAC_SPMAP_AVG and YAC_SPMAP_DIST.
Definition yac.pyx:454
Refers to YAC_TIME_UNIT_MILLISECOND, YAC_TIME_UNIT_SECOND etc.
Definition yac.pyx:402
An unstuctured 2d Grid.
Definition yac.pyx:1094
def_points(self, Location location, x_points, y_points)
Definition yac.pyx:1126
__init__(self, str grid_name, num_vertices_per_cell, x_vertices, y_vertices, cell_to_vertex, use_ll_edges=False)
Definition yac.pyx:1099
Initializies a YAC instance and provides further functionality.
Definition yac.pyx:471
read_config_yaml(self, str yaml_file)
Definition yac.pyx:854
enddef(self)
Definition yac.pyx:673
def_comp(self, str comp_name)
Definition yac.pyx:526
predef_comp(self, str comp_name)
Definition yac.pyx:554
grid_names(self)
Definition yac.pyx:693
get_grid_metadata(self, str grid_name)
Definition yac.pyx:821
instance_id
Definition yac.pyx:503
def_component_metadata(self, str comp_name, bytes metadata)
Definition yac.pyx:786
sync_def(self)
Definition yac.pyx:610
def_field_metadata(self, str comp_name, str grid_name, str field_name, bytes metadata)
Definition yac.pyx:803
def_grid_metadata(self, str grid_name, bytes metadata)
Definition yac.pyx:794
start_datetime(self)
Definition yac.pyx:595
get_field_metadata(self, str comp_name, str grid_name, str field_name)
Definition yac.pyx:829
get_comps_comm(self, comp_names)
Definition yac.pyx:839
cleanup(self)
Definition yac.pyx:517
get_field_names(self, str comp_name, str grid_name)
Definition yac.pyx:715
get_field_id(self, str comp_name, str grid_name, str field_name)
Definition yac.pyx:729
def_comps(self, comp_names=[])
Definition yac.pyx:536
initialized
Definition yac.pyx:504
get_component_metadata(self, str comp_name)
Definition yac.pyx:813
def_datetime(self, start_datetime, end_datetime)
Definition yac.pyx:564
get_field_role(self, str comp_name, str grid_name, str field_name)
Definition yac.pyx:747
enable_field_frac_mask(self, str comp_name, str grid_name, str field_name, _np.float64 frac_mask_fallback_value)
Definition yac.pyx:775
get_comp_grid_names(self, comp_name)
Definition yac.pyx:704
def_couple(self, str src_comp, str src_grid, src_field, str tgt_comp, str tgt_grid, tgt_field, str coupling_timestep, TimeUnit timeunit, Reduction time_reduction, interp_stack, src_lag=0, tgt_lag=0, weight_file=None, mapping_on_source=1, scale_factor=1.0, scale_summand=0.0, src_masks_names=None, tgt_mask_name=None)
Definition yac.pyx:625
get_field_timestep(self, str comp_name, str grid_name, str field_name)
Definition yac.pyx:738
get_field_frac_mask_fallback_value(self, str comp_name, str grid_name, str field_name)
Definition yac.pyx:765
end_datetime(self)
Definition yac.pyx:603
__del__(self)
Definition yac.pyx:514
__init__(self, comm=None, default_instance=False)
Definition yac.pyx:477
component_names(self)
Definition yac.pyx:681
get_field_collection_size(self, str comp_name, str grid_name, str field_name)
Definition yac.pyx:756
default_instance(cls)
Definition yac.pyx:508
enum callback_type type
version()
Definition yac.pyx:1453
_prev_abort_func
Definition yac.pyx:1466
def_calendar(Calendar calendar)
Definition yac.pyx:395
void yac_cadd_interp_stack_config_ncc(int interp_stack_config_id, int weight_type, int partial_coverage)
Definition yac.c:3401
const char * yac_cget_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
Definition yac.c:1206
void yac_cadd_interp_stack_config_spmap(int interp_stack_config_id, double spread_distance, double max_search_distance, int weight_type, int scale_type, double src_sphere_radius, double tgt_sphere_radius)
Definition yac.c:3458
void yac_cpredef_comp_instance(int yac_instance_id, char const *name, int *comp_id)
Definition yac.c:718
char * yac_cget_start_datetime_instance(int yac_instance_id)
Definition yac.c:581
void yac_cdef_field_mask(char const *name, int const comp_id, int const *point_ids, int const *mask_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
Definition yac.c:1012
void yac_cset_global_index(int const *global_index, int location, int grid_id)
Definition yac.c:3244
void yac_cget_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
Definition yac.c:1832
int yac_cget_nbr_grids_instance(int yac_instance_id)
Definition yac.c:2900
void yac_cfree_ext_couple_config(int ext_couple_config_id)
Definition yac.c:1241
const char * yac_cget_grid_metadata_instance(int yac_instance_id, const char *grid_name)
Definition yac.c:1193
char * yac_cget_end_datetime_instance(int yac_instance_id)
Definition yac.c:596
void yac_cset_ext_couple_config_tgt_mask_name(int ext_couple_config_id, char const *tgt_mask_name)
Definition yac.c:1387
void yac_cdef_grid_curve2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
Definition yac.c:3190
void yac_cget_grid_names_instance(int yac_instance_id, int nbr_grids, const char **grid_names)
Definition yac.c:2978
void yac_cset_ext_couple_config_scale_factor(int ext_couple_config_id, double scale_factor)
Definition yac.c:1309
void yac_cadd_interp_stack_config_creep(int interp_stack_config_id, int creep_distance)
Definition yac.c:3532
void yac_cput_frac_(int const field_id, int const collection_size, double *send_field, double *send_frac_mask, int *info, int *ierr)
Definition yac.c:1938
void yac_cget_comp_rank_c2py(int comp_id, int *rank)
Definition yac.c:667
void yac_cget_comp_size_c2py(int comp_id, int *size)
Definition yac.c:660
int yac_cget_comp_nbr_grids_instance(int yac_instance_id, const char *comp_name)
Definition yac.c:2913
void yac_cdef_grid_unstruct_ll(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
Definition yac.c:3226
void yac_csync_def_instance(int yac_instance_id)
Definition yac.c:2821
static void cleanup()
Definition yac.c:514
void yac_cinit(void)
Definition yac.c:402
void yac_cfinalize()
Definition yac.c:533
void yac_cadd_interp_stack_config_check(int interp_stack_config_id, char const *constructor_key, char const *do_search_key)
Definition yac.c:3520
void yac_cenddef_instance(int yac_instance_id)
Definition yac.c:2834
void yac_cset_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t num_src_mask_names, char const *const *src_mask_names)
Definition yac.c:1362
int yac_cget_nbr_comps_instance(int yac_instance_id)
Definition yac.c:2887
int yac_cget_nbr_fields_instance(int yac_instance_id, const char *comp_name, const char *grid_name)
Definition yac.c:2936
void yac_cget_ext_couple_config(int *ext_couple_config_id)
Definition yac.c:1233
void yac_cdef_grid_metadata_instance(int yac_instance_id, const char *grid_name, const char *metadata)
Definition yac.c:1150
void yac_cset_ext_couple_config_weight_file(int ext_couple_config_id, char const *weight_file)
Definition yac.c:1260
const char * yac_cget_component_metadata_instance(int yac_instance_id, const char *comp_name)
Definition yac.c:1180
void yac_cread_config_yaml_instance(int yac_instance_id, const char *yaml_filename)
Definition yac.c:448
const char * yac_cget_field_timestep_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
Definition yac.c:3097
void yac_cset_ext_couple_config_scale_summand(int ext_couple_config_id, double scale_summand)
Definition yac.c:1332
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
Definition yac.c:638
const char * yac_cget_field_datetime(int field_id)
Definition yac.c:1654
void yac_cdef_comp_instance(int yac_instance_id, char const *comp_name, int *comp_id)
Definition yac.c:789
void yac_cupdate(int field_id)
Definition yac.c:1674
void yac_cget_action(int field_id, int *action)
Definition yac.c:1611
int yac_cget_collection_size_from_field_id(int field_id)
Definition yac.c:3081
void yac_cdef_grid_reg2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
Definition yac.c:3172
void yac_cdef_couple_custom_instance(int yac_instance_id, 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_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, int ext_couple_config_id)
Definition yac.c:1429
void yac_cdef_points_reg2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
Definition yac.c:845
void yac_cinit_comm_instance(MPI_Comm comm, int *yac_instance_id)
Definition yac.c:364
void yac_cadd_interp_stack_config_nnn(int interp_stack_config_id, int type, size_t n, double scale)
Definition yac.c:3419
void yac_cenable_field_frac_mask_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, double frac_mask_fallback_value)
Definition yac.c:1116
void yac_cadd_interp_stack_config_conservative(int interp_stack_config_id, int order, int enforced_conserv, int partial_coverage, int normalisation)
Definition yac.c:3439
void yac_cdef_grid_unstruct(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
Definition yac.c:3208
void yac_cdef_points_unstruct(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
Definition yac.c:919
char * yac_cget_version(void)
Definition yac.c:614
int yac_cget_default_instance_id()
Definition yac.c:359
void yac_cdef_component_metadata_instance(int yac_instance_id, const char *comp_name, const char *metadata)
Definition yac.c:1137
void yac_cdef_calendar(int calendar)
Definition yac.c:562
void yac_cput_(int const field_id, int const collection_size, double *send_field, int *info, int *ierr)
Definition yac.c:1917
void yac_cget_comp_grid_names_instance(int yac_instance_id, const char *comp_name, int nbr_grids, const char **grid_names)
Definition yac.c:2994
void yac_cget_async_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
Definition yac.c:1841
void yac_cadd_interp_stack_config_hcsbb(int interp_stack_config_id)
Definition yac.c:3488
void yac_cget_comps_comm_instance(int yac_instance_id, char const **comp_names, int num_comps, MPI_Comm *comps_comm)
Definition yac.c:678
void yac_cadd_interp_stack_config_fixed(int interp_stack_config_id, double value)
Definition yac.c:3510
double yac_cget_field_frac_mask_fallback_value_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
Definition yac.c:3116
void yac_cdef_points_curve2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
Definition yac.c:881
void yac_cset_ext_couple_config_mapping_side(int ext_couple_config_id, int mapping_side)
Definition yac.c:1286
void yac_ccleanup_instance(int yac_instance_id)
Definition yac.c:497
int yac_cget_field_collection_size_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
Definition yac.c:3127
void yac_cfree_interp_stack_config(int interp_stack_config_id)
Definition yac.c:3362
void yac_cadd_interp_stack_config_user_file(int interp_stack_config_id, char const *filename, char const *src_grid_name, char const *tgt_grid_name)
Definition yac.c:3497
size_t yac_cget_grid_size(int located, int grid_id)
Definition yac.c:3325
void yac_cinit_instance(int *yac_instance_id)
Definition yac.c:390
void yac_cget_interp_stack_config(int *interp_stack_config_id)
Definition yac.c:3348
void yac_cadd_interp_stack_config_average(int interp_stack_config_id, int reduction_type, int partial_coverage)
Definition yac.c:3382
void yac_cdef_field(char const *name, int const comp_id, int const *point_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
Definition yac.c:1085
void yac_cdef_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
Definition yac.c:1164
void yac_cget_field_names_instance(int yac_instance_id, const char *comp_name, const char *grid_name, int nbr_fields, const char **field_names)
Definition yac.c:3019
void yac_cdef_comps_instance(int yac_instance_id, char const **comp_names, int num_comps, int *comp_ids)
Definition yac.c:756
void yac_cget_comp_names_instance(int yac_instance_id, int nbr_comps, const char **comp_names)
Definition yac.c:2961
void yac_cinit_comm(MPI_Comm comm)
Definition yac.c:376
yac_abort_func yac_get_abort_handler(void)
void yac_set_abort_handler(yac_abort_func custom_abort)