% $Id$
%

\label{DataDepInit}

For multi-model applications it is not uncommon that during start-up one or more components depends on data from one or more other components. These types of data-dependencies during initialize can become very complex very quickly. Finding the "correct" sequence to initialize all components for a complex dependency graph is not trivial. The NUOPC Layer deals with this issue by repeatedly looping over all components that indicate that their initialization has data dependencies on other components. The loop is finally exited when either all components have indicated completion of their initialization, or a dead-lock situation is being detected by the NUOPC Layer.

The data-dependency resolution loop considers all components that have specialized {\tt label\_DataInitialize}. Participating components communicate their current status to the NUOPC Layer via Field and Component metadata. Every time a component's {\tt label\_DataInitialize} specialization routine is called, it is responsible for checking the Fields in the importState and for initializing any internal data structures and Fields in the exportState. Fields that are fully initialized in the exportState must be indicated by setting their {\tt Updated} Attribute to "true". This is used by the NUOPC Layer to ensure that there is continued progress during the resolution loop iterations. Once the component is fully initialized it must further set its {\tt InitializeDataComplete} Attribute to "true" before returning.

During the execution of the data-dependency resolution loop the NUOPC Layer calls all of the Connectors {\em to} a Model/Mediator component before calling the component's {\tt label\_DataInitialize}. Doing so ensures that all the currently available Fields are passed to the component before it tries to access them. Once a component has set its {\tt InitializeDataComplete} Attribute to "true", it, and the Connectors to it, will no longer be called during the remainder of the resolution loop. 

When {\em all} of the components that participate in the data-dependency resolution loop have set their {\tt InitializeDataComplete} Attribute to "true", the NUOPC Layer successfully exits the data-dependency resolution loop. The loop is also interrupted before all {\tt InitializeDataComplete} Attributes are set to "true" if a full cycle completes without any indicated progress. The NUOPC Layer flags this situation as a potential dead-lock and returns with error.
