YetAnotherCoupler  2.4.2
YAC instances

Introduction

With Version 2.3.0 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 different XML 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 XML 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.

Usage

Here the usage of YAC instances is shown for the C interface; equivalent Fortran interfaces are also available.

Initialisation Phase

A YAC instance is initialised by a call to yac_cinit_instance or yac_cinit_comm_instance.

char * xml_filename = "coupling_aquaplanet.xml";
char * xsd_filename = "coupling.xsd";
int yac_instance_id;
yac_cinit_instance ( xml_filename, xsd_filename, &yac_instance_id );
void yac_cinit_instance(const char *xml_filename, const char *schema_filename, int *yac_instance_id)
char * xml_filename = "coupling_aquaplanet.xml";
char * xsd_filename = "coupling.xsd";
MPI_Comm comm = MPI_COMM_WORLD;
int yac_instance_id;
yac_cinit_comm_instance ( xml_filename, xsd_filename, comm, &yac_instance_id );
void yac_cinit_comm_instance(const char *xml_filename, const char *schema_filename, MPI_Comm comm, int *yac_instance_id)

Definition Phase

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.

End of definition and search

The definition phase is finalized and the search started with a call to yac_csearch_instance.

int ierror;
yac_csearch_instance ( yac_instance_id, &ierror );
void yac_csearch_instance(int yac_instance_id, int *ierror)

A call to yac_csearch will do this only for the default instance.

Data Exchange

For the data exchange not specific interfaces are required.

Ending Phase

A YAC instance needs to be explicitly finalized:

yac_cfinalize_instance ( yac_instance_id );
void yac_cfinalize_instance(int yac_instance_id)

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.

Restart Phase

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.