YetAnotherCoupler 3.4.0
|
With Version 2.3.0 (Aug 2021) the concept of YAC instances was introduced. This new feature allows the user to instantiate YAC multiple times in the same application. Additionally, each instance can be initialised with a different MPI communicator and a different coupling configuration (via interface and/or configuration file).
In case an application uses YAC for different purposes, individual YAC instances can be used for each of them without interfering with each other. A potential use case may a model setup consisting of an global atmosphere and ocean model, which are coupled to each other. If in this setup the atmosphere has some dedicated processes that are responsible for writing out a regional part of the data using a different grid, YAC could be used to provide the respective data to these output processes. Using a dedicated YAC instance for the coupling between the atmosphere and its output processes could use its own configuration file, which might simplify the setup of the model run. Both YAC instances could be initialised using dedicated MPI communicators, which reduces complexity even further.
YAC provides a default instance, which is used in case the user does not explicitly provide an instance.
YAC instances are referenced by ID's that are returned by either yac_cinit_instance or yac_cinit_comm_instance. Various routines required the user to explicitly provide this ID as an argument. These routines can be identified by an "_instance" at the end of their names. Some routines like yac_cdef_field do not require an explicit YAC instance ID, because it is implicitly given by another argument (component_id in this case).
An example on how to use YAC instances can be found here.
Here the usage of YAC instances is shown for the C interface; equivalent Fortran interfaces are also available.
A YAC instance is initialised by a call to yac_cinit_instance or yac_cinit_comm_instance.
The definition of components, grid, and start- and endtime require the user to explicitly provide the YAC instance ID.
For all other definition routines the YAC instance ID is provided implicitly.
The definition phase is finalized and the search started with a call to yac_cenddef_instance.
A call to yac_cenddef will do this only for the default instance.
For the data exchange not specific interfaces are required.
A YAC instance needs to be explicitly finalized:
In case any other YAC instance is still active while yac_cfinalize_instance is called, MPI will not by finalized by this call.
If for any other instance yac_cfinalize_instance or yac_cfinalize is called at a later point in time, a call to yac_ccleanup_instance is sufficiant to clean up the memory of a YAC instance.
The default instance can be restarted. To do this its memory needs to be freed by a call to yac_ccleanup. Afterwards yac_cinit can be called again.
It is not possible to restart the other YAC instances. However, at any point in time a new instance can be initialised with a call to yac_cinit_instance yac_cinit_comm_instance even with the same arguments as for a previous call. This new instance can be viewed as a restart of another instance. In any case all initialised instances have to be cleaned up or finalized.