source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/util/oasisgui/library/oasis3-mct/XML/oasis3-mct/seqlag/seqlag.xml @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 5 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

  • Property svn:executable set to *
File size: 12.5 KB
Line 
1<model name="defineseqlag" title="LAGSEQ" layout="flat">
2    <desc>
3Please enter the LAG and the sequence (SEQ), if any, for
4the different coupling fields, selecting the different rows available.
5The LAG is useless for INPUT and OUTPUT fields.
6The "load" button is useless for the OASIS3-MCT application.[]
7A blue (?), located at the right bottom of this window, gives more information on the data to fill up.
8    </desc>
9</model>
10<model name="defseqlag" title="LAG-SEQ" layout="flat">
11    <multiple name="seqlag" title="Definition the LAG and the Sequence" require="field_names_list" custom_label="Fields">
12      <xor name="lag" title="LAG" default="lag_off">
13            <model name="lag_off" title="NO LAG">
14             <desc> No LAG is defined.
15             </desc>
16            </model>
17            <model name="lag_on" title="LAG">
18              <param name="lag_fld" title="Lag (integer)" type="double" />
19            </model>
20      </xor>
21      <xor name="seq" title="SEQUENCE" default="seq_off">
22            <model name="seq_off" title="NO SEQ">
23             <desc> No sequence is defined.
24             </desc>
25            </model>
26            <model name="seq_on" title="SEQ">
27              <param name="seq_fld" title="Sequence (integer)" type="integer" />
28            </model>
29      </xor>
30    </multiple> 
31    <docu> 
32
33[section=LAG]
34With LAG>0 for coupling fields in the namcouple (LAG must be equal to the time step of the source model),
35models read their data at t=0 in their restart files
36and write a restart file at the end of the simulation for the next run. This configuration is the one that is
37usually used in the real coupled models.
38
39Defining LAG=dt (time step of the model) implies that there will be a shift in time between the oasis_put and the oasis_get.
40If tCPL is the coupling time, the oasis_put done at tCPL + LAG will match the oasis_get done at tCPL.
41
42More information is available section 2.10.1 in the User Guide.
43
44[section=SEQ]
45The order of coupling operations in the system is determined solely by the order of calls to send (put) and
46receive (get) data in the models in conjunction with the setting of the lag in the namcouple.
47Data that is received (get) is always blocking while data that is sent (put) is non-blocking with respect to the model
48making that call. It is possible to deadlock the system if the relative orders of puts and gets in different
49models are not compatible. The SEQ option can be used to avoid such deadlock.
50
51More information is available section 2.10.2 in the User Guide.
52<docuold>
53[section=Generalities]
54Using the OASIS3-MCT coupling library, the user has full flexibility to reproduce different coupling algorithms. In
55the components, the sending and receiving routines, respectively oasis_put and oasis_get, can be called at each model timestep,
56with the appropriate date argument giving the actual time (at the beginning of the timestep), expressed in number of
57seconds since the start of the run or in any other time units, as long as the same are used in all models and
58in the configuration file. This date argument is automatically analysed by the coupling library and depending on the coupling
59period and the lag (LAG) chosen by the user for each coupling field in the configuration file, different
60coupling algorithms can be reproduced without modifying the component model codes themselves. []
61
62With OASIS3-MCT, the SEQ index is no longer needed in the configuration file to specify the sequencing order of different
63coupling fields. The sequence (SEQ) index now provides the coupling layer with an ability to detect
64a deadlock before it happens and exit. []
65
66[section=The LAG concept]
67The lag (LAG) value tells the coupler to modify the time at which that data is sent (put) by the amount of the lag. The lag
68must be expressed in the time unit used (that must be the same in the models and in the configuration file and can be positive or negative
69but should never be larger (in absolute magnitude) than the coupling period of any field due to problems with restartability
70and dead-locking. When a component model calls a oasis_put, the value of the lag is automatically added to the value of the
71date argument and the ``put'' is actually performed when the sum date+lag is a coupling time; in the target component, this
72``put'' will match a oasis_get for which the date argument is the same coupling time. The lag only shifts the time data is sent.
73It cannot be used to shift the time data is received yet. []
74
75When the lag is positive, a restart file must be available to initiate the coupling and in those cases, the restart file is
76then updated at the end of the run. A positive lag acts like a send occurred before the model started. In fact, for a field
77with positive lag, the source component model automatically reads the field in the restart file during the coupling initialization
78phase (below the oasis_enddef) and send the data to match the oasis_get performed at time=0 in the target component model.
79The final coupling data on the source side will then be automatically written to the restart file for use in the next run. []
80
81When there is a lag, the first and last instance of the source field in the debug netCDF file (EXPOUT fields) always correspond
82respectively to the field read from and written to the restart file.
83
84On the figures below, short black arrows correspond to oasis_put or oasis_get called in the component model that
85do not lead to any ``put'' or receiving action; long black arrows correspond to oasis_put or oasis_get called in the component
86models that do actually lead to a ``put'' or ``get'' action; long red arrows correspond to oasis_put or oasis_get called in
87the component models that lead to a reading or writing of the coupling field from or to a coupling restart file.
88
89
90[item=LAG concept first example:]
91
92
93A first coupling algorithm, exploiting the LAG concept, is illustrated on figure 1. []
94
95[image=fig_lag_concept_1.gif;caption=Figure 1: LAG concept first example] []
96
97During a coupling timestep, model A receives F_2 and then sends F_1; its timestep length is 4. During a coupling timestep, model B receives F_1
98and then sends F_2; its timestep length is 6. F_1 and F_2 coupling periods are respectively 12 and 24. If F_1/F_2 ``put" action by model A/B
99was used at a coupling timestep to match the model B/A ``get" action, a deadlock would occur as both models would be initially
100waiting on a ``get" action. To prevent this, F_1 and F_2 produced at the timestep before have to be used to match respectively the model
101B and model A ``get" actions. []
102
103This implies that a lag of respectively 4 and 6 seconds must be defined for F_1 and F_2. For F_1, the oasis_put performed at time 8
104and 20 by model A will then lead to ``put" actions (as 8 + 4 = 12 and 20 + 4 = 24 which are coupling periods) that match the
105``get" actions performed at times 12 and 24 below the oasis_get called by model B. For F_2, the oasis_put performed at time 18
106by model B then leads to a ``put" action (as 18 + 6 = 24 which is a coupling period) that matches the ``get" action performed i
107at time 24 below the oasis_get called by model A. []
108
109At the beginning of the run, as their LAG index is greater than 0, the first oasis_get of F_1 and F_2 will automatically be fulfilled
110with fields read from their respective coupling restart files. The user therefore has to create those coupling restart files before
111the first run in the experiment. At the end of the run, F_1 having a lag greater than 0, is automatically written to its coupling
112restart file below the last F_1 oasis_put as the date+lag equals the total run time. The analogue is true for F_2. These values
113will automatically be read in at the beginning of the next run below the respective oasis_get. []
114
115
116[item=LAG concept second example:]
117
118A second coupling algorithm exploiting the LAG concept is illustrated on figure 2. During its timestep, model A receives F_2, sends
119F_3 and then F_1; its timestep length is 6. During its timestep, model B receives F_1, receives F_3 and then sends F_2; its timestep
120length is also 6. F_1, F_2 and F_3 coupling periods are both supposed to be equal to 12. []
121
122
123[image=fig_lag_concept_2.gif;caption=Figure 2: LAG concept second example] []
124
125
126For F_1 and F_2 the situation is similar to the first example. If F_1/F_2 ``put" action by model A/B was used at a coupling timestep
127to match the model B/A ``get" action, a deadlock would occur as both models would be waiting on a ``get" action. To prevent this, F_1 and
128F_2 produced at the timestep before have to be used to match the model A and model B ``get" actions, which means that a lag of 6 must
129be defined for both F_1 and F_2. For both coupling fields, the oasis_put performed at times 6 and 18 by the source model then
130lead to ``put" actions (as 6 + 6 = 12 and 18 + 6 = 24 which are coupling periods) that match the ``get" action performed at time
13112 and 24 below the oasis_get called by the target model. []
132
133For F_3, sent by model A and received by model B, no lag needs to be defined: the coupling field produced by model A at the
134coupling timestep can be ``consumed'' by model B without causing a deadlock situation. []
135
136As in the first example, the oasis_get performed at the beginning of the run for F_1 and F_2, will automatically receive data
137read from their coupling restart files, and the last oasis_put performed at the end of the run automatically write them to
138their coupling restart file. For F_3, no coupling restart file is needed nor used as at each coupling period the coupling
139field produced by model A can be directly ``consumed'' by model B. []
140
141We see here how the introduction of appropriate LAG indices results in receiving in the target model the coupling fields
142produced by the source model the timestep before; this is, in some coupling configurations, essential to avoid deadlock situations. []
143
144
145[section=The sequence concept]
146The order of coupling operations in the system is determined solely by the order of calls to send (put) and receive (get)
147data in the models in conjunction with the setting of the lag in the configuration file. Data that is received (get) is always
148blocking while data that is sent (put) is non-blocking with respect to the model making that call. It is possible to
149deadlock the system if the relative orders of puts and gets in different models are not compatible. []
150
151With OASIS3-MCT, the sequence (SEQ) index in the configuration file now provides the coupling layer with an ability to detect
152a deadlock before it happens and exit. It does this by tracking the order of get and put calls in models compared to the SEQ
153specified in the configuration file. If there are any inconsistencies, the model will abort gracefully with a useable error message
154before the system deadlocks. If there are any coupling dependencies in the system, use of the SEQ index is recommended for
155diagnosis but has no impact on the ultimate solution and is NOT required. []
156
157Take the following two examples. In both examples, there are two models, each ``put'' a field to the other at every coupling
158period without any lags. In the first case, there is no dependency and each model sends (puts) the data first and then
159receives the data second at each timestep. []
160
161
162[image=fig_seq_1.gif;caption=Figure 3: SEQ concept first example] []
163
164
165The put from model1 for fld1 is received by the get in model2 and the put from model2 for fld2 is received by the get in
166model1. In this case, there is no sequencing dependency and the value of SEQ must be identical (or unset) in the configuration file
167description of the fld1 and fld2 coupling. If SEQ is set to 1 for fld1 and 2 for fld2 in this case, then the model will
168abort because at runtime, the coupling will detect, in model 2, that fld2 was sent before fld1 was received which is out
169of sequence as defined by the SEQ settings.[]
170
171In the next example, there is a dependency in the sequencing. []
172
173
174[image=fig_seq_2.gif;caption=Figure 4: SEQ concept second example] []
175
176
177In model2, fld2 depends on fld1. If this dependency is known, then there is a benefit in using SEQ=1 for fld1 and SEQ=2
178for fld2. At runtime, if the sequencings of both model1 and model2 do not match the above diagram, the model will abort
179gracefully. For instance, if model2 has the dependency shown above but model1 does not have consistent ordering of the
180put and get as required by model2, then if SEQ is unused, the model will deadlock and hang. If SEQ is set properly,
181the coupling layer will detect that the required sequence has not been followed and will exit gracefully with an error message. []
182
183Again, the SEQ namecouple setting is only diagnostic and is not required.
184</docuold>
185    </docu>
186</model>
Note: See TracBrowser for help on using the repository browser.