1 | \newpage |
---|
2 | \chapter{Interfacing a model with the PSMILe library} |
---|
3 | \label{sec_modelinterfacing} |
---|
4 | |
---|
5 | At run-time, OASIS3 acts as a separate mono process executable which |
---|
6 | drives the coupled run, interpolates and transforms the coupling |
---|
7 | fields. To communicate with OASIS3 or directly between the component |
---|
8 | models, different communication techniques have been historically |
---|
9 | developed. The technique used for one particular run is defined by the |
---|
10 | user in the configuration file {\it namcouple} (see section |
---|
11 | \ref{sec_namcouple}). In OASIS3, the CLIM communication technique |
---|
12 | based on MPI1 or MPI2 message passing and the associated model |
---|
13 | interface library PSMILe, should be used\footnote{The SIPC technique, |
---|
14 | based on UNIX shared-memory segments, was also maintained; for a |
---|
15 | practical toy model example using SIPC, see the sources in {\tt |
---|
16 | /prism/src/mod/sipcatmos, /sipcocean} and some explanations in {\tt |
---|
17 | /prism/util/running/toysvipc} (from CERFACS CVS only).}. For a practical toy model |
---|
18 | using the PSMILe library, see the sources in {\tt /prism/src/mod/toyatm, |
---|
19 | /toyche, /toyoce} and more details in \cite{val04b} . |
---|
20 | |
---|
21 | |
---|
22 | %\vspace*{0.5cm} |
---|
23 | |
---|
24 | To communicate with OASIS3 or directly with another component model |
---|
25 | using the CLIM/MPI communication technique, |
---|
26 | or to perform I/O actions, a component model needs to be interfaced |
---|
27 | with the PRISM System Model Interface library, PSMILe, which sources |
---|
28 | can be found in {\tt prism/src/lib/psmile} directory. PSMILe supports: |
---|
29 | |
---|
30 | \begin{itemize} |
---|
31 | \item parallel communication between a parallel component |
---|
32 | model and OASIS3 main process, |
---|
33 | \item direct communication between two parallel component models when no |
---|
34 | transformations and no repartitioning are required, |
---|
35 | \item automatic sending and receiving actions at appropriate times |
---|
36 | following user's choice indicated in the {\it namcouple}, |
---|
37 | \item time integration or accumulation of the coupling fields, |
---|
38 | \item I/O actions from/to files. |
---|
39 | \end{itemize} |
---|
40 | |
---|
41 | To adapt a component model to PSMILe, specific calls of |
---|
42 | the following classes have to be implemented in the code: |
---|
43 | |
---|
44 | \begin{enumerate} |
---|
45 | \item Initialisation (section \ref{subsubsec_Initialisation}) |
---|
46 | \item Grid data file definition (section \ref{subsubsec_griddef}) |
---|
47 | \item Partition definition (section \ref{subsubsec_Partition}) |
---|
48 | \item I/O-coupling field declaration (section \ref{subsubsec_Declaration}) |
---|
49 | \item End of definition phase (section \ref{subsubsec_Endofdefinition}) |
---|
50 | \item I/O-coupling field sending and receiving (section |
---|
51 | \ref{subsubsec_sendingreceiving}) |
---|
52 | \item Termination (section \ref{subsubsec_Termination}) |
---|
53 | \end{enumerate} |
---|
54 | |
---|
55 | Finally, in section \ref{subsubsec_Algoritms}, different coupling |
---|
56 | algorithms are illustrated, and explanations are given on how to |
---|
57 | reproduce them with PSMILe by defining the appropriate indices of |
---|
58 | lag and sequence for each coupling field. |
---|
59 | |
---|
60 | \section{Initialisation} |
---|
61 | \label{subsubsec_Initialisation} |
---|
62 | %{Initialisation} |
---|
63 | |
---|
64 | All processes initialise the coupling and, if required, retrieve a |
---|
65 | local communicator for the component model internal parallelisation. |
---|
66 | |
---|
67 | \begin{itemize} |
---|
68 | |
---|
69 | \item {\tt USE mod\_prism\_proto} |
---|
70 | |
---|
71 | Module to be used by the component models. |
---|
72 | |
---|
73 | \item {\tt CALL prism\_init\_comp\_proto (compid, model\_name, ierror)} |
---|
74 | |
---|
75 | \begin{itemize} |
---|
76 | \item {\tt compid [INTEGER; OUT]}: component model ID |
---|
77 | \item {\tt model\_name [CHARACTER*6; IN]}: name of calling model (as in |
---|
78 | {\em namcouple}) |
---|
79 | \item {\tt ierror [INTEGER; OUT]}: returned error code. |
---|
80 | \end{itemize} |
---|
81 | |
---|
82 | Routine called by all component model processes, which initialises the |
---|
83 | coupling.\footnote{The model may call MPI\_Init explicitly, but if so, has to |
---|
84 | call it before calling {\tt prism\_init\_comp\_proto}; in this case, the |
---|
85 | model also has to call MPI\_Finalize explicitly, but only after calling |
---|
86 | {\tt prism\_terminate\_proto}.} |
---|
87 | |
---|
88 | \item {\tt CALL prism\_get\_localcomm\_proto (local\_comm, ierror )} |
---|
89 | |
---|
90 | \begin{itemize} |
---|
91 | \item {\tt local\_comm [INTEGER; OUT]}: value of local communicator |
---|
92 | \item {\tt ierror [INTEGER; OUT]}: returned error code. |
---|
93 | \end{itemize} |
---|
94 | |
---|
95 | For MPI1: routine called by all model processes to get the value of a local |
---|
96 | communicator to be used by the model for its internal |
---|
97 | parallelisation. |
---|
98 | |
---|
99 | In fact, with MPI1, all component models started in a pseudo-MPMD mode |
---|
100 | share automatically the same MPI\_COMM\_WORLD communicator. Another |
---|
101 | communicator has to be used for the internal parallelisation of each |
---|
102 | model. OASIS3 creates this model local communicator following a |
---|
103 | ``coloring scheme"; its value is returned as the first argument of |
---|
104 | prism\_get\_localcomm\_proto routine. |
---|
105 | |
---|
106 | With MPI2, the communicator |
---|
107 | MPI\_COMM\_WORLD will be returned as local communicator. |
---|
108 | |
---|
109 | Besides that, the differences between using PSMILe with MPI1 or MPI2 message passing are |
---|
110 | \begin{itemize} |
---|
111 | \item The \$CHANNEL in the namcouple; see section \ref{subsec_namcouplefirst}. |
---|
112 | \item The way the models |
---|
113 | are started. With MPI2, only OASIS3 needs to be started at the command line; |
---|
114 | it will then spawn the component models at the beginning of the run. |
---|
115 | With MPI1, models have to be started by the user in a pseudo-MPMD |
---|
116 | mode; the way to do this depends on the computing platform. For more details, see section \ref{subsec_running}. |
---|
117 | \end{itemize} |
---|
118 | \end{itemize} |
---|
119 | |
---|
120 | \section{Grid data file definition} |
---|
121 | \label{subsubsec_griddef} |
---|
122 | |
---|
123 | The grid data files {\em grids.nc, masks.nc} and {\em areas.nc} must |
---|
124 | be created by the user before the run, or can be written directly |
---|
125 | at run time by the component models. |
---|
126 | |
---|
127 | If written by the component models, the writing of those grid files is |
---|
128 | driven by OASIS3 main process. It first checks whether the binary file |
---|
129 | {\em grids} or the netCDF file {\em grids.nc} exists (in that case, it |
---|
130 | is assumed that {\em areas} or {\em areas.nc} and {\em masks} or {\em |
---|
131 | masks.nc} files exist too), or if writing is needed. If {\em grids} or |
---|
132 | {\em grids.nc} exists, it must contain all grid information from all |
---|
133 | models; if it does not exist, each model must write its grid |
---|
134 | definition in the grid data files. |
---|
135 | |
---|
136 | The coupler sends the information on whether or not writing is needed |
---|
137 | to the mo\-dels following an OASIS internal order (below |
---|
138 | prism\_start\_grids\_writing). If no writing is needed, nothing |
---|
139 | happens when calling the following prism\_write\_xxxx routines. If |
---|
140 | writing is needed, the first model creates the files, writes the data |
---|
141 | arrays (with {\tt prism\_write\_grid}, {\tt prism\_write\_corner}, |
---|
142 | {\tt prism\_write\_mask}, {\tt prism\_write\_area} calls), |
---|
143 | and then sends a termination flag to the coupler (below \break {\tt |
---|
144 | prism\_terminate\_grids\_writing} call). The coupler will send the |
---|
145 | starting flag to the next model; this ensures that only one model |
---|
146 | accesses the files at a time. |
---|
147 | |
---|
148 | This section describes the PSMILe routines that may be called by the |
---|
149 | master process of each component model to write, at run time, the whole |
---|
150 | grid information to the grid data files. These routines have to |
---|
151 | be called just after {\tt prism\_init\_comp\_proto}. |
---|
152 | |
---|
153 | The TOYCLIM coupled model (see the sources of the toy |
---|
154 | component models in {\tt prism/\-src/mod/toyatm, /toyoce, and /toyche}) |
---|
155 | uses those routines to write its grid data |
---|
156 | files if \texttt{gridswr=1} in the running script |
---|
157 | \texttt{RUN\_toyclim\_$<$expid$>$} (see section \ref{subsec_running}). |
---|
158 | |
---|
159 | %To run a toy experiment |
---|
160 | %into which the component models write those files, execute the |
---|
161 | %script prism/util/running/toyclim/sc\_run\_toyclim\_grid. |
---|
162 | |
---|
163 | \begin{itemize} |
---|
164 | \item {\tt USE mod\_prism\_grids\_writing} |
---|
165 | |
---|
166 | Module to be used by the component model to call grid writing routines. |
---|
167 | |
---|
168 | \item {\tt CALL prism\_start\_grids\_writing (flag)} |
---|
169 | |
---|
170 | \begin{itemize} |
---|
171 | \item {\tt flag [INTEGER; OUT]}: returns 1/0 if grids writing is |
---|
172 | needed/not needed |
---|
173 | \end{itemize} |
---|
174 | Initialisation of grids writing. |
---|
175 | |
---|
176 | \item {\tt CALL prism\_write\_grid (cgrid, nx, ny, lon, lat)} |
---|
177 | |
---|
178 | \begin{itemize} |
---|
179 | \item {\tt cgrid [CHARACTER*4; IN]}: grid name prefix (see |
---|
180 | \ref{subsec_namcouplesecond} |
---|
181 | \item {\tt nx [INTEGER; IN]} : grid dimension in x-direction |
---|
182 | \item {\tt ny [INTEGER; IN]} : grid dimension in y-direction |
---|
183 | \item {\tt lon [REAL, DIMENSION(nx,ny); IN)} : array of longitudes |
---|
184 | (degrees East) |
---|
185 | \item {\tt lat [REAL, DIMENSION(nx,ny); IN)} : array of latitudes |
---|
186 | (degrees North) |
---|
187 | \end{itemize} |
---|
188 | Writing of the model grid longitudes and latitudes. Note that OASIS |
---|
189 | automatically detects overlapping grid points (which is essential to |
---|
190 | have a correct conservative remapping \texttt{SCRIPR/CONSERV}, see |
---|
191 | section \ref{subsec_interp}) only if their longitude is given with the |
---|
192 | same number (e.g. 360.0 for both, not 450.0 for one and 90.0 for the |
---|
193 | other). |
---|
194 | |
---|
195 | |
---|
196 | \item {\tt CALL prism\_write\_corner (cgrid, nx, ny, nc, clon, clat)} |
---|
197 | |
---|
198 | \begin{itemize} |
---|
199 | \item {\tt cgrid [CHARACTER*4; IN]}: grid name prefix |
---|
200 | \item {\tt nx [INTEGER; IN]} : grid dimension in x-direction |
---|
201 | \item {\tt ny [INTEGER; IN]} : grid dimension in y-direction |
---|
202 | \item {\tt nc [INTEGER; IN]} : number of corners per grid cell (4) |
---|
203 | \item {\tt lon [REAL, DIMENSION (nx,ny,nc);IN]} : array of corner |
---|
204 | longitudes (in degrees\_East) |
---|
205 | \item {\tt lat [REAL, DIMENSION (nx,ny,nc);IN]} : array of corner |
---|
206 | latitudes (in degrees\_North) |
---|
207 | \end{itemize} |
---|
208 | Writing of the grid cell corner longitudes and latitudes |
---|
209 | (counterclockwise sense). Writing of corners is optional as corner |
---|
210 | information is needed only for some transformations (see section |
---|
211 | \ref{subsec_griddata}). If called, prism\_write\_corners needs to be |
---|
212 | called after prism\_write\_grids. |
---|
213 | |
---|
214 | \item {\tt CALL prism\_write\_mask (cgrid, nx, ny, mask)} |
---|
215 | \begin{itemize} |
---|
216 | \item {\tt cgrid [CHARACTER*4; IN]}: grid name prefix |
---|
217 | \item {\tt nx [INTEGER; IN]} : grid dimension in x-direction |
---|
218 | \item {\tt ny [INTEGER; IN]} : grid dimension in y-direction |
---|
219 | \item {\tt mask [INTEGER, DIMENSION(nx,ny) ;IN]} : mask array (0 - not masked, 1 - masked) |
---|
220 | \end{itemize} |
---|
221 | Writing of the model grid mask. |
---|
222 | |
---|
223 | \item {\tt CALL prism\_write\_area (cgrid, nx, ny, area)} |
---|
224 | \begin{itemize} |
---|
225 | \item {\tt cgrid [CHARACTER*4; IN]}: grid name prefix |
---|
226 | \item {\tt nx [INTEGER; IN]} : grid dimension in x-direction |
---|
227 | \item {\tt ny [INTEGER; IN]} : grid dimension in y-direction |
---|
228 | \item {\tt area [REAL, DIMENSION(nx,ny); IN]} : array of grid cell areas |
---|
229 | \end{itemize} |
---|
230 | Writing of the model grid cell areas. Writing of areas is optional as |
---|
231 | area information is needed only for some transformations (see section |
---|
232 | \ref{subsec_griddata}). |
---|
233 | |
---|
234 | \item {\tt CALL prism\_terminate\_grids\_writing()} |
---|
235 | |
---|
236 | Termination of grids writing. A flag stating that all needed grid |
---|
237 | information was written will be sent to OASIS3 main process. |
---|
238 | |
---|
239 | \end{itemize} |
---|
240 | |
---|
241 | \section{Partition definition} |
---|
242 | \label{subsubsec_Partition} |
---|
243 | |
---|
244 | When a component of the coupled system is a parallel code, each |
---|
245 | coupling field is usually scattered among the different |
---|
246 | processes. With the PSMILe library, each process sends |
---|
247 | directly its partition to OASIS3 main process or directly to the |
---|
248 | other component model if no transformation nor repartition is |
---|
249 | required. To do so, each process implied in the coupling has to |
---|
250 | define its local partition in the global index space. |
---|
251 | |
---|
252 | \begin{itemize} |
---|
253 | |
---|
254 | \item {\tt USE mod\_prism\_def\_partition\_proto} |
---|
255 | |
---|
256 | Module to be used by the component model to call {\tt |
---|
257 | prism\_def\_partition\_proto}. |
---|
258 | |
---|
259 | \item {\tt CALL prism\_def\_partition\_proto (il\_part\_id, |
---|
260 | ig\_paral, ierror)} |
---|
261 | \begin{itemize} |
---|
262 | \item {\tt il\_part\_id [INTEGER; OUT]}: partition ID |
---|
263 | \item {\tt ig\_paral [INTEGER, DIMENSION(:), IN]}: vector of |
---|
264 | integers describing the local partition in the global index space |
---|
265 | \item {\tt ierror [INTEGER; OUT]}: returned error code. |
---|
266 | \end{itemize} |
---|
267 | \end{itemize} |
---|
268 | |
---|
269 | The vector of integers describing the process local partition, {\tt |
---|
270 | ig\_paral}, has a different expression depending on the type of the |
---|
271 | partition. In OASIS3, 4 types of partition are supported: Serial (no |
---|
272 | partition), Apple, Box, and Orange. |
---|
273 | |
---|
274 | \subsection{Serial (no partition)} |
---|
275 | |
---|
276 | This is the choice for a monoprocess model. In this case, we have |
---|
277 | {\tt ig\_paral(1:3)}: |
---|
278 | \begin{itemize} |
---|
279 | \item {\tt ig\_paral(1)} = 0 (indicates a Serial ``partition'') |
---|
280 | \item {\tt ig\_paral(2)} = 0 |
---|
281 | \item {\tt ig\_paral(3)} = the total grid size. |
---|
282 | \end{itemize} |
---|
283 | |
---|
284 | \subsection{Apple partition} |
---|
285 | |
---|
286 | Each partition is a segment of the global domain, described by its |
---|
287 | global offset and its local size. In this case, we have {\tt |
---|
288 | ig\_paral(1:3)}: |
---|
289 | \begin{itemize} |
---|
290 | \item {\tt ig\_paral(1)} = 1 (indicates an Apple partition) |
---|
291 | \item {\tt ig\_paral(2)} = the segment global offset |
---|
292 | \item {\tt ig\_paral(3)} = the segment local size |
---|
293 | \end{itemize} |
---|
294 | |
---|
295 | Figure \ref{apple_partition} illustrates an Apple partition over 3 |
---|
296 | processes. |
---|
297 | \begin{figure} |
---|
298 | \includegraphics[scale=.6]{apple_new.eps} |
---|
299 | \caption{Apple partition} |
---|
300 | \label{apple_partition} |
---|
301 | \end{figure} |
---|
302 | |
---|
303 | |
---|
304 | \subsection{Box partition} |
---|
305 | |
---|
306 | Each partition is a rectangular region of the global domain, described |
---|
307 | by the global offset of its upper left corner, and its local extents in the |
---|
308 | X and Y dimensions. The global extent in the X dimension must also be |
---|
309 | given. In this case, we have {\tt ig\_paral(1:5)}: |
---|
310 | \begin{itemize} |
---|
311 | \item {\tt ig\_paral(1)} = 2 (indicates a Box partition) |
---|
312 | \item {\tt ig\_paral(2)} = the upper left corner global offset |
---|
313 | \item {\tt ig\_paral(3)} = the local extent in X |
---|
314 | \item {\tt ig\_paral(4)} = the local extent in Y\footnote{The maximum |
---|
315 | value of the local extent in Y is presently 338; it can be increased |
---|
316 | by modifying the value of {\tt Clim\_MaxSegments} in {\tt |
---|
317 | prism/src/lib/clim/src/mod\_clim.F90} and in {\tt |
---|
318 | prism/src/lib/psmile/src/mod\_prism\_proto.F90} and by recompiling |
---|
319 | Oasis3 and the PSMILe library.} |
---|
320 | \item {\tt ig\_paral(5)} = the global extent in X. |
---|
321 | \end{itemize} |
---|
322 | |
---|
323 | Figure \ref{box_partition} illustrates a Box partition over 3 |
---|
324 | processes. |
---|
325 | |
---|
326 | \begin{figure} |
---|
327 | \includegraphics[scale=.6]{box_new.eps} |
---|
328 | \caption{Box partition} |
---|
329 | \label{box_partition} |
---|
330 | \end{figure} |
---|
331 | |
---|
332 | \subsection{Orange partition} |
---|
333 | |
---|
334 | Each partition is an ensemble of segments of the global domain. Each |
---|
335 | segment is described by its global offset and its local extent. In |
---|
336 | this case, we have {\tt ig\_paral(1:N)} where {\tt N = 2 + 2*number of |
---|
337 | segments}\footnote{As for the Box partition, the maximum number of |
---|
338 | segments is presently 338; it can be increased by modifying the value |
---|
339 | of {\tt Clim\_MaxSegments}}. |
---|
340 | |
---|
341 | \begin{itemize} |
---|
342 | \item {\tt ig\_paral(1)} = 3 (indicates a Orange partition) |
---|
343 | \item {\tt ig\_paral(2)} = the total number of segments for the partition (limited to 200 presently, see note for ig\_paral(4) for Box partition above) |
---|
344 | \item {\tt ig\_paral(3)} = the first segment global offset |
---|
345 | \item {\tt ig\_paral(4)} = the first segment local extent |
---|
346 | \item {\tt ig\_paral(5)} = the second segment global offset |
---|
347 | \item {\tt ig\_paral(6)} = the second segment local extent |
---|
348 | \item ... |
---|
349 | \item {\tt ig\_paral(N-1)} = the last segment global offset |
---|
350 | \item {\tt ig\_paral(N)} = the last segment local extent |
---|
351 | \end{itemize} |
---|
352 | |
---|
353 | Figure \ref{orange_partition} illustrates an Orange partition with 3 segments |
---|
354 | for one process. The other process partitions are not illustrated. |
---|
355 | |
---|
356 | \begin{figure} |
---|
357 | \includegraphics[scale=.6]{orange_new.eps} |
---|
358 | \caption{Orange partition for one process} |
---|
359 | \label{orange_partition} |
---|
360 | \end{figure} |
---|
361 | |
---|
362 | %{Partition definition} |
---|
363 | |
---|
364 | \section{I/O-coupling field declaration} |
---|
365 | \label{subsubsec_Declaration} |
---|
366 | |
---|
367 | Each process implied in the coupling declares each field it will send |
---|
368 | or receive during the simulation. |
---|
369 | |
---|
370 | \begin{itemize} |
---|
371 | |
---|
372 | \item {\tt CALL prism\_def\_var\_proto(var\_id, name, il\_part\_id, |
---|
373 | var\_nodims, kinout, var\_actual\_shape, var\_type, ierror)} |
---|
374 | |
---|
375 | \begin{itemize} |
---|
376 | \item {\tt var\_id [INTEGER; OUT]}: coupling field ID |
---|
377 | \item {\tt name [CHARACTER*8; IN]}: field symbolic name (as in the |
---|
378 | {\it namcouple}) |
---|
379 | \item {\tt il\_part\_id [INTEGER; IN]}: partition ID (returned by |
---|
380 | {\tt prism\_def\_partition\-\_proto}) |
---|
381 | \item {\tt var\_nodims [INTEGER, DIMENSION(2); IN]}: var\_nodims(1) is |
---|
382 | the rank of field array (1 or 2); var\_nodims(2) is the number of |
---|
383 | bundles (always 1 for OASIS3). |
---|
384 | \item {\tt kinout [INTEGER; IN]}: {\tt PRISM\_In} for fields received by |
---|
385 | the model, or {\tt PRISM\_Out} for fields sent by the model |
---|
386 | \item {\tt var\_actual\_shape [INTEGER, DIMENSION(2*var\_nodims(1)); IN]}: |
---|
387 | vector of integers giving the minimum and maximum index for each |
---|
388 | dimension of the coupling field array; for OASIS3, the minimum |
---|
389 | index has to be 1 and the maximum index has to be the extent of the |
---|
390 | dimension. |
---|
391 | \item {\tt var\_type [INTEGER; IN]}: type of coupling field array; |
---|
392 | put {\tt PRISM\_Real} for single or double precision real |
---|
393 | arrays\footnote{PRISM standard is to exchange coupling fields |
---|
394 | declared {\tt REAL(kind=SELECTED\_REAL\_KIND(12,307))}. By default, |
---|
395 | all real variables are declared as such in OASIS3. To exchange |
---|
396 | single precision coupling fields, OASIS3 has to be compiled with |
---|
397 | the pre-compiling key use\_realtype\_single, the coupling fields |
---|
398 | must be declared {\tt REAL(kind=SELECTED\_REAL\_KIND(6,37))} in the |
---|
399 | component models}. No automatic conversion is implemented; |
---|
400 | therefore, all coupling fields exchanged through OASIS3 main |
---|
401 | process must be of same type\footnote{Coupling fields exchanged |
---|
402 | directly between two component models can have a type different |
---|
403 | from the ones exchanged through OASIS3 main process, as long as |
---|
404 | they are single or double precision real arrays in both models.}. |
---|
405 | \item {\tt ierror [INTEGER; OUT]}: returned error code. |
---|
406 | \end{itemize} |
---|
407 | \end{itemize} |
---|
408 | %{I/O-coupling field declaration} |
---|
409 | |
---|
410 | \section{End of definition phase} |
---|
411 | \label{subsubsec_Endofdefinition} |
---|
412 | Each process implied in the coupling closes the definition phase. |
---|
413 | \begin{itemize} |
---|
414 | \item {\tt CALL prism\_enddef\_proto(ierror)} |
---|
415 | \begin{itemize} |
---|
416 | \item ierror [INTEGER; OUT]: returned error code. |
---|
417 | \end{itemize} |
---|
418 | \end{itemize} |
---|
419 | |
---|
420 | %{End of definition phase} |
---|
421 | |
---|
422 | \section{Sending and receiving actions} |
---|
423 | \label{subsubsec_sendingreceiving} |
---|
424 | |
---|
425 | \subsection{Sending a coupling field} |
---|
426 | \label{prismput} |
---|
427 | |
---|
428 | In the model time stepping loop, each process implied in the coupling |
---|
429 | sends its part of the I/O or coupling field. |
---|
430 | |
---|
431 | \begin{itemize} |
---|
432 | \item {\tt USE mod\_prism\_put\_proto} |
---|
433 | |
---|
434 | Module to be used by the component model to call {\tt |
---|
435 | prism\_put\_proto}. |
---|
436 | |
---|
437 | \item {\tt CALL prism\_put\_proto(var\_id, date, field\_array, info)} |
---|
438 | \begin{itemize} |
---|
439 | \item {\tt var\_id [INTEGER; IN]}: field ID (from |
---|
440 | corresponding prism\_def\_var\_proto) |
---|
441 | \item {\tt date [INTEGER; IN]}: number of seconds in the run at the |
---|
442 | beginning of the timestep |
---|
443 | \item {\tt field\_array [REAL, IN]}: I/O or coupling field array |
---|
444 | \item {\tt info [INTEGER; OUT]}: returned info code i.e. |
---|
445 | \begin{itemize} |
---|
446 | \item PRISM\_Sent(=4) if the field was sent to another model |
---|
447 | (directly or via OASIS3 main process) |
---|
448 | \item PRISM\_LocTrans (=5) if the field was only used in a time |
---|
449 | transformation (not sent, not output) |
---|
450 | \item PRISM\_ToRest (=6) if the field was written to a restart file only |
---|
451 | \item PRISM\_Output (=7) if the field was written to an output file only |
---|
452 | \item PRISM\_SentOut (=8) if the field was both written to an output file |
---|
453 | and sent to another model (directly or via OASIS3 main process) |
---|
454 | \item PRISM\_ToRestOut (=9) if the field was written both to a |
---|
455 | restart file and to an output file. |
---|
456 | \item PRISM\_Ok (=0) otherwise and no error occurred. |
---|
457 | \end{itemize} |
---|
458 | \end{itemize} |
---|
459 | \end{itemize} |
---|
460 | |
---|
461 | This routine may be called by the model at each timestep. The sending |
---|
462 | is actually performed only if the time obtained by adding the field |
---|
463 | lag (see \ref{subsubsec_Algoritms}) to the argument {\tt date} |
---|
464 | corresponds to a time at which it should be activated, given the |
---|
465 | coupling or I/O period indicated by the user in the namcouple (see |
---|
466 | section \ref{sec_namcouple}). A field will not be sent at all if its |
---|
467 | coupling or I/O period indicated in the {\it namcouple} is greater |
---|
468 | than the total run time. |
---|
469 | |
---|
470 | If a local time transformation is indicated for the field by |
---|
471 | the user in the namcouple (INSTANT, AVERAGE, ACCUMUL, T\_MIN or T\_MAX, |
---|
472 | see section \ref{sec_transformations}), it is automatically performed |
---|
473 | and the resulting field is finally sent at the coupling or I/O |
---|
474 | frequency. |
---|
475 | |
---|
476 | For a coupling field with a positive lag (see |
---|
477 | \ref{subsubsec_Algoritms}), the OASIS3 restart file (see section |
---|
478 | \ref{subsec_restartdata}) is automatically written by the |
---|
479 | last {\tt prism\_put\_proto} call of the run, if its argument {\tt date} |
---|
480 | + the field lag corresponds to a coupling or I/O period. To |
---|
481 | force the writing of the field in its coupling restart file, one can |
---|
482 | use {\tt prism\_put\_restart\_proto} (see below). |
---|
483 | |
---|
484 | This routine can use the buffered MPI\_BSend (by default) or the |
---|
485 | standard blocking send MPI\_Send (if {\tt NOBSEND} is specified in the |
---|
486 | namcouple -see {\tt \$CHANNEL} section |
---|
487 | \ref{subsec_namcouplefirst}) to send the coupling fields. |
---|
488 | |
---|
489 | \vspace*{0.5cm} |
---|
490 | |
---|
491 | \subsection{Receiving a coupling field} |
---|
492 | |
---|
493 | \vspace*{0.5cm} |
---|
494 | |
---|
495 | In the model time stepping loop, each process implied in the coupling |
---|
496 | receives its part of the I/O-coupling field. |
---|
497 | |
---|
498 | \begin{itemize} |
---|
499 | \item {\tt USE mod\_prism\_get\_proto} |
---|
500 | |
---|
501 | Module to be used by the component model to call {\tt |
---|
502 | prism\_get\_proto}. |
---|
503 | \item {\tt CALL prism\_get\_proto(var\_id, date, field\_array, ierror)} |
---|
504 | \begin{itemize} |
---|
505 | \item {\tt var\_id [INTEGER; IN]}: field ID (from |
---|
506 | corresponding prism\_def\_var\_proto) |
---|
507 | \item {\tt date [INTEGER; IN]}: number of seconds in the run at the |
---|
508 | beginning of the timestep |
---|
509 | \item {\tt field\_array [REAL, OUT]}: I/O or coupling field array |
---|
510 | \item {\tt info [INTEGER; OUT]}: returned info code |
---|
511 | \begin{itemize} |
---|
512 | \item PRISM\_Recvd(=3) if the field was received from another model |
---|
513 | (directly or via OASIS3 main process) |
---|
514 | \item PRISM\_FromRest (=10) if the field was read from a restart |
---|
515 | file only (directly or via OASIS3 main process) |
---|
516 | \item PRISM\_Input (=11) if the field was read from an input |
---|
517 | file only |
---|
518 | \item PRISM\_RecvOut (=12) if the field was both received from |
---|
519 | another model (directly or via OASIS3 main process) and written to |
---|
520 | an output file |
---|
521 | \item PRISM\_FromRestOut (=13) if the field was both read from a |
---|
522 | restart file (directly or via OASIS3 main process) and written to an |
---|
523 | output file |
---|
524 | \item PRISM\_Ok (=0) otherwise and no error occurred. |
---|
525 | \end{itemize} |
---|
526 | \end{itemize} |
---|
527 | \end{itemize} |
---|
528 | |
---|
529 | This routine may be called by the model at each timestep. The {\tt date} |
---|
530 | argument is automatically analysed and the receiving action is actually |
---|
531 | performed only if {\tt date} corresponds to a time for which it should |
---|
532 | be activated, given the period indicated by the user in the |
---|
533 | namcouple. A field will not be received at all if its |
---|
534 | coupling or I/O period indicated in the {\it namcouple} is greater |
---|
535 | than the total run time. |
---|
536 | |
---|
537 | \subsection{Auxiliary routines} |
---|
538 | \label{subsec:auxiliary} |
---|
539 | \begin{itemize} |
---|
540 | \item {\tt CALL prism\_put\_inquire(var\_id, date, info)} |
---|
541 | \begin{itemize} |
---|
542 | \item {\tt var\_id [INTEGER; IN]}: field ID (from |
---|
543 | corresponding prism\_def\_var\_proto) |
---|
544 | \item {\tt date [INTEGER; IN]}: number of seconds in the run at the |
---|
545 | beginning of the timestep |
---|
546 | \item {\tt info [INTEGER; OUT]}: returned info code. |
---|
547 | \end{itemize} |
---|
548 | \end{itemize} |
---|
549 | |
---|
550 | This routine may be called at any time to |
---|
551 | inquire what would happen to the corresponding field (i.e. with same |
---|
552 | {\tt var\_id} and at same {\tt date}) below the corresponding {\tt |
---|
553 | prism\_put\_proto}. The possible value of the returned info code are |
---|
554 | as for {\tt prism\_put\_proto}: |
---|
555 | \begin{itemize} |
---|
556 | \item PRISM\_Sent(=4) if the field would be sent to another model |
---|
557 | (directly or via OASIS3 main process) |
---|
558 | \item PRISM\_LocTrans (=5) if the field would be only used in a time |
---|
559 | transformation (not sent, not output) |
---|
560 | \item PRISM\_ToRest (=6) if the field would be written to a restart file only |
---|
561 | \item PRISM\_Output (=7) if the field would be written to an output file only |
---|
562 | \item PRISM\_SentOut (=8) if the field would be both written to an output file |
---|
563 | and sent to another model (directly or via OASIS3 main process) |
---|
564 | \item PRISM\_ToRestOut (=9) if the field would be written both to a |
---|
565 | restart file and to an output file. |
---|
566 | \item PRISM\_Ok (=0) otherwise and no error occurred. |
---|
567 | \end{itemize} |
---|
568 | This is useful when the |
---|
569 | calculation of the corresponding {\tt field\_array} is CPU consuming |
---|
570 | and should be avoided if the field is not effectively used below the {\tt |
---|
571 | prism\_put\_proto}. |
---|
572 | |
---|
573 | \begin{itemize} |
---|
574 | \item {\tt CALL prism\_put\_restart\_proto(var\_id, date, ierror)} |
---|
575 | \begin{itemize} |
---|
576 | \item {\tt var\_id [INTEGER; IN]}: field ID (from |
---|
577 | corresponding prism\_def\_var\_proto) |
---|
578 | \item {\tt date [INTEGER; IN]}: number of seconds in the run at the |
---|
579 | beginning of the timestep |
---|
580 | \item {\tt info [INTEGER; OUT]}: returned error code (should be |
---|
581 | PRISM\_ToRest=6 if the restart writing was successful) |
---|
582 | \end{itemize} |
---|
583 | \end{itemize} |
---|
584 | |
---|
585 | This routine forces the writing of the field with corresponding {\tt |
---|
586 | var\_id} in its coupling restart file (see section |
---|
587 | \ref{subsec_restartdata}). If a time operation is specified for this |
---|
588 | field, the value of the field as calculated below the last {\tt |
---|
589 | prism\_put\_proto} is written. If no time operation is specified, the |
---|
590 | value of the field transferred to the last {\tt prism\_put\_proto} is |
---|
591 | written. |
---|
592 | |
---|
593 | %{sending and receiving actions} |
---|
594 | |
---|
595 | \section{Termination} |
---|
596 | \label{subsubsec_Termination} |
---|
597 | |
---|
598 | \begin{itemize} |
---|
599 | |
---|
600 | \item {\tt CALL prism\_terminate\_proto(ierror)} |
---|
601 | \begin{itemize} |
---|
602 | \item {\tt ierror [INTEGER; OUT]}: returned error code. |
---|
603 | \end{itemize} |
---|
604 | Each process must terminate the coupling by calling {\tt |
---|
605 | prism\_terminate\_proto}\footnote{If the process called {\tt |
---|
606 | MPI\_Init} (before calling {\tt prism\_init\_comp\_proto}), it must |
---|
607 | also call {\tt MPI\_Finalize} explicitly, but only after calling |
---|
608 | {\tt prism\_terminate\_proto}.} (normal termination). Oasis will |
---|
609 | terminate after all processes implied in the coupling call |
---|
610 | prism\_terminate\_proto. With MPI2, the run may be considered |
---|
611 | finished when Oasis terminates; to avoid problem, place the call |
---|
612 | to prism\_terminate\_proto at the very end in the component model code. |
---|
613 | |
---|
614 | \item {\tt CALL prism\_abort\_proto(compid, routine\_name, abort\_message)} |
---|
615 | \begin{itemize} |
---|
616 | \item {\tt compid [INTEGER; IN]}: component model ID (from |
---|
617 | prism\_init\_comp\_proto) |
---|
618 | \item {\tt routine\_name; IN]}: name of calling routine |
---|
619 | \item {\tt abort\_message; IN]}: message to be written out. |
---|
620 | \end{itemize} |
---|
621 | |
---|
622 | If a process needs to abort (abnormal termination), it must do so by |
---|
623 | calling {\tt prism\_abort\_proto}. This will ensure a proper |
---|
624 | termination of all processes in the coupled model communicator. This |
---|
625 | routine writes the name of the calling model, the name of the |
---|
626 | calling routine, and the message to the job standard output (stdout). |
---|
627 | |
---|
628 | \end{itemize} |
---|
629 | |
---|
630 | %{Termination} |
---|
631 | |
---|
632 | \section{Coupling algorithms - SEQ and LAG concepts} |
---|
633 | \label{subsubsec_Algoritms} |
---|
634 | |
---|
635 | Using PSMILe library, the user has full flexibility to reproduce |
---|
636 | different coupling algorithms, without modifying the component model |
---|
637 | codes themselves. In the component codes, the sending and receiving |
---|
638 | routines, respectively {\tt prism\_put\_proto} and {\tt |
---|
639 | prism\_get\_proto}, can be called at each model timestep, with the |
---|
640 | appropriate {\tt date} argument giving the actual time (at the |
---|
641 | beginning of the timestep), expressed in ``number of seconds since the |
---|
642 | start of the run''. This {\tt date} argument is automatically analysed |
---|
643 | by the PSMILe\footnote{With the PIPE, SIPC, GMEM and previously with |
---|
644 | the CLIM communication techniques, no such analysis was performed. For |
---|
645 | PIPE, SIPC, and GMEM, the sending actions on the source side would |
---|
646 | automatically match the receiving actions on the target side on a FIFO |
---|
647 | (First In First Out) basis.} and depending on the coupling period, the |
---|
648 | lag and sequencing indices (LAG and SEQ), chosen by the user for each |
---|
649 | coupling field in the configuration file {\it namcouple}, different |
---|
650 | coupling algorithms can be reproduced {\bf without modifying anything in the |
---|
651 | component model codes themselves.} The lag and sequence concepts and |
---|
652 | indices are explained in more details here below. These mechanisms |
---|
653 | are valid for fields exchanged through OASIS3 main |
---|
654 | process and for fields exchanged directly between the component |
---|
655 | models. |
---|
656 | |
---|
657 | \subsection{The lag concept} |
---|
658 | \label{subsub_lag} |
---|
659 | |
---|
660 | If no lag index or if a lag index equal to 0 is given by the user in |
---|
661 | the {\it namcouple} for a particular coupling field, the sending or |
---|
662 | receiving actions will actually be performed, below the {\tt |
---|
663 | prism\_put\_proto} called in the source model or below the {\tt |
---|
664 | prism\_get\_proto} called in the target model respectively, each time the |
---|
665 | {\tt date} arguments on both sides match an integer number of |
---|
666 | coupling periods. |
---|
667 | |
---|
668 | \vspace*{0.5cm} |
---|
669 | |
---|
670 | To match a {\tt prism\_put\_proto} called by the source model at a |
---|
671 | particular date with a {\tt prism\_get\_proto} called by the target |
---|
672 | model at a different date, the user has to define in the {\it |
---|
673 | namcouple} an appropriate lag index, LAG, for the coupling field(see |
---|
674 | section \ref{sec_namcouple}). The value of the LAG index must be |
---|
675 | expressed in ``number of seconds''; its value is automatically added |
---|
676 | to the {\tt prism\_put\_proto} date value and the sending action is |
---|
677 | effectively performed when the sum of the date and the lag matches an |
---|
678 | integer number of coupling periods. This sending action is |
---|
679 | automatically matched, on the target side, with the receiving action |
---|
680 | performed when the {\tt prism\_get\_proto} date argument equals the |
---|
681 | same integer number of coupling periods. |
---|
682 | |
---|
683 | \begin{enumerate} |
---|
684 | |
---|
685 | \item LAG concept first example |
---|
686 | |
---|
687 | A first coupling algorithm, exploiting the LAG concept, is |
---|
688 | illustrated on figure \ref{fig:lag_concept_1}. |
---|
689 | |
---|
690 | |
---|
691 | On the 4 figures in this section, short black arrows correspond to {\tt |
---|
692 | prism\_put\_proto} or \break {\tt prism\_get\_proto} called in the component model |
---|
693 | that do not lead to any sending or receiving action; |
---|
694 | long black arrows correspond to {\tt prism\_put\_proto} or {\tt |
---|
695 | prism\_get\_proto} called in the component models that do |
---|
696 | effectively lead to a sending or receiving action; |
---|
697 | long red arrows correspond to {\tt prism\_put\_proto} or {\tt |
---|
698 | prism\_get\_proto} called in the component models that lead to a |
---|
699 | reading or writing of the coupling field from or to a coupling |
---|
700 | restart file (either directly or through OASIS3 main process). |
---|
701 | |
---|
702 | \begin{figure} |
---|
703 | \includegraphics[scale=.6]{fig_lag_concept_1.eps} |
---|
704 | \caption{LAG concept first example} |
---|
705 | \label{fig:lag_concept_1} |
---|
706 | \end{figure} |
---|
707 | |
---|
708 | During a coupling timestep, model A receives $F_2$ and then sends $F_1$; its |
---|
709 | timestep length is 4. During a coupling timestep, model B receives $F_1$ |
---|
710 | and then sends $F_2$; its timestep length is 6. $F_1$ and $F_2$ |
---|
711 | coupling periods are respectively 12 and 24. If $F_1$/$F_2$ sending |
---|
712 | action by model A/B was used at a coupling timestep to match the |
---|
713 | model B/A receiving action, a deadlock would occur as both models |
---|
714 | would be initially waiting on a receiving action. To prevent this, |
---|
715 | $F_1$ and $F_2$ produced at the timestep before have to be used to |
---|
716 | match respectively the model B and model A receiving actions. |
---|
717 | |
---|
718 | This implies that a lag of respectively 4 and 6 seconds must be |
---|
719 | defined for $F_1$ and $F_2$. For $F_1$, the {\tt prism\_put\_proto} |
---|
720 | performed at time 8 and 20 by model A will then lead to sending actions |
---|
721 | (as 8 + 4 = 12 and 20 + 4 = 24 which are coupling periods) that |
---|
722 | match the receiving actions performed at times 12 and 24 below the {\tt |
---|
723 | prism\_get\_proto} called by model B. For $F_2$, the {\tt |
---|
724 | prism\_put\_proto} performed at time 18 by model B then leads to |
---|
725 | a sending action (as 18 + 6 = 24 which is a coupling |
---|
726 | period) that matches the receiving action performed at time 24 |
---|
727 | below the {\tt prism\_get\_proto} called by model A. |
---|
728 | |
---|
729 | At the beginning of the run, as their LAG index is greater than 0, |
---|
730 | the first {\tt prism\_get\_proto} will automatically lead to reading |
---|
731 | $F_1$ and $F_2$ from their coupling restart files. The user |
---|
732 | therefore have to create those coupling restart files for the first |
---|
733 | run in the experiment. At the end of the run, $F_1$ |
---|
734 | having a lag greater than 0, is automatically written to its |
---|
735 | coupling restart file below the last $F_1$ {\tt prism\_put\_proto} if the |
---|
736 | {\tt date} + $F_1$ lag equals a coupling time. The analogue is true |
---|
737 | for $F_2$. These |
---|
738 | values will automatically be read in at the beginning of the next |
---|
739 | run below the respective {\tt prism\_get\_proto}. |
---|
740 | |
---|
741 | \item LAG concept second example |
---|
742 | |
---|
743 | A second coupling algorithm exploiting the LAG concept is |
---|
744 | illustrated on figure \ref{fig:lag_concept_2}. During its timestep, |
---|
745 | model A receives $F_2$, sends $F_3$ and then $F_1$; its timestep |
---|
746 | length is 6. During its timestep, model B receives $F_1$, receives |
---|
747 | $F_3$ and then sends $F_2$; its timestep length is also 6. $F_1$, |
---|
748 | $F_2$ and $F_3$ coupling periods are both supposed to be equal to |
---|
749 | 12. |
---|
750 | |
---|
751 | \begin{figure} |
---|
752 | \includegraphics[scale=.6]{fig_lag_concept_2.eps} |
---|
753 | \caption{LAG concept second example} |
---|
754 | \label{fig:lag_concept_2} |
---|
755 | \end{figure} |
---|
756 | |
---|
757 | For $F_1$ and $F_2$ the situation is similar to the first |
---|
758 | example. If $F_1$/$F_2$ sending action by model A/B was used at a |
---|
759 | coupling timestep to match the model B/A receiving action, a |
---|
760 | deadlock would occur as both models would be waiting on a receiving |
---|
761 | action. To prevent this, $F_1$ and $F_2$ produced at the timestep |
---|
762 | before have to be used to match the model A and model B receiving |
---|
763 | actions, which means that a lag of 6 must be defined for both $F_1$ |
---|
764 | and $F_2$. For both coupling fields, the {\tt prism\_put\_proto} |
---|
765 | performed at times 6 and 18 by the source model then lead to sending |
---|
766 | actions (as 6 + 6 = 12 and 18 + 6 = 24 which are coupling periods) |
---|
767 | that match the receiving action performed at time 12 and 24 below |
---|
768 | the {\tt prism\_get\_proto} called by the target model. |
---|
769 | |
---|
770 | For $F_3$, sent by model A and received by model B, no lag |
---|
771 | needs to be defined: the coupling field produced by model A at the |
---|
772 | coupling timestep can be ``consumed'' by model B without causing a |
---|
773 | deadlock situation. |
---|
774 | |
---|
775 | As in the first example, the {\tt prism\_get\_proto} performed at |
---|
776 | the beginning of the run for $F_1$ and $F_2$, automatically read |
---|
777 | them from their coupling restart files, and the last {\tt |
---|
778 | prism\_put\_proto} performed at the end of the run automatically |
---|
779 | write them to their coupling restart file. For $F_3$, no coupling |
---|
780 | restart file is needed nor used as at each coupling period the |
---|
781 | coupling field produced by model A can be directly ``consumed'' by |
---|
782 | model B. |
---|
783 | |
---|
784 | We see here how the introduction of appropriate LAG indices results in |
---|
785 | receiving, below the \break {\tt prism\_get\_proto} in the target model, |
---|
786 | coupling fields produced, below the {\tt prism\_put\_proto} by the |
---|
787 | source model, the timestep before; this is, in some coupling |
---|
788 | configurations, essential to avoid deadlock situations. |
---|
789 | |
---|
790 | \end{enumerate} |
---|
791 | |
---|
792 | \subsection{The sequence concept} |
---|
793 | |
---|
794 | To exchange the coupling fields going through OASIS3 main process |
---|
795 | (i.e. with status EXPORTED, AUXILARY, or EXPOUT, see section |
---|
796 | \ref{sec_namcouple}), in a given order at each coupling timestep, a |
---|
797 | sequence index SEQ must be defined for each of them. This is not |
---|
798 | required for I/O fields or for coupling fields exchanged directly |
---|
799 | between the component models, i.e. with status IGNOUT, INPUT or |
---|
800 | OUTPUT. SEQ gives the position of the coupling field in the |
---|
801 | sequence. |
---|
802 | |
---|
803 | \begin{figure} |
---|
804 | \includegraphics[scale=.6]{fig_seq_concept.eps} |
---|
805 | \caption{The SEQ concept} |
---|
806 | \label{fig:seq_concept} |
---|
807 | \end{figure} |
---|
808 | |
---|
809 | A coupling algorithm, showing the SEQ concept, is illustrated on |
---|
810 | figure \ref{fig:seq_concept}. All coupling field produced by the |
---|
811 | source model at the coupling timestep can be ``consumed'' by the |
---|
812 | target model at the same timestep without causing any |
---|
813 | deadlock situation; therefore, LAG = 0 for all coupling fields. |
---|
814 | However, at each coupling timestep, a particular order |
---|
815 | of exchange must be respected; $F_1$ must be received by |
---|
816 | model A before it can send $F_2$, which in turn must be received by model B |
---|
817 | before it can send $F_3$. Therefore, SEQ = 1, 2, 3 must be defined |
---|
818 | respectively for $F_1$, $F_2$ and $F_3$. |
---|
819 | As all fields can be consumed at the time they are produced (LAG=0 for |
---|
820 | all fields), there no reading/writing from/to coupling restart files. |
---|
821 | |
---|
822 | \subsection{A mix of lag and sequence: the sequential coupled model} |
---|
823 | \label{subsubsec_mix} |
---|
824 | |
---|
825 | One can run the same component models simultaneously or sequentially |
---|
826 | by defining the appropriate LAG and SEQ indices. In the example |
---|
827 | illustrated on figure \ref{fig:mix_seqlag}, the models perform their |
---|
828 | {\tt prism\_put\_proto} and {\tt prism\_get\_proto} calls exactly as |
---|
829 | in the first lag example above: model A receives $F_2$ and then sends |
---|
830 | $F_1$; its timestep length is 4. During a coupling timestep, model B |
---|
831 | receives $F_1$ and then sends $F_2$; its timestep length is 6. $F_1$ |
---|
832 | and $F_2$ coupling periods are both 12. By defining a LAG index of -8 |
---|
833 | for $F_1$, the models will now run sequentially. |
---|
834 | |
---|
835 | \begin{figure} |
---|
836 | \includegraphics[scale=.6]{fig_mix_seqlag.eps} |
---|
837 | \caption{Mix of LAF and SEQ concepts} |
---|
838 | \label{fig:mix_seqlag} |
---|
839 | \end{figure} |
---|
840 | |
---|
841 | As the LAG for $F_2$ is positive (6), a reading of $F_2$ in its |
---|
842 | coupling restart file is automatically performed below the initial |
---|
843 | {\tt prism\_get\_proto}. As the LAG for $F_1$ is negative (-8), no |
---|
844 | reading from file is performed initially and model B waits; at time 8, |
---|
845 | a sending action is effectively performed below model A $F_1$ {\tt |
---|
846 | prism\_put\_proto} (as 8 + LAG (-8) = 0 which is the first coupling |
---|
847 | timestep) and matches the initial model B $F_1$ {\tt |
---|
848 | prism\_get\_proto}. Below the last model A $F_1$ {\tt |
---|
849 | prism\_put\_proto} of the run at time 116, a sending action is |
---|
850 | effectively performed, as $116 + LAG(-8) = 108$ is a coupling period |
---|
851 | (as the LAG is negative, the field is not written to its coupling |
---|
852 | restart file). Below the last model B $F_2$ {\tt prism\_put\_proto} of |
---|
853 | the run at time 114, a writing of $F_2$ to its restart file is |
---|
854 | performed, as $114 + LAG(6) = 120$ is a coupling period and as the LAG |
---|
855 | is positive. |
---|
856 | |
---|
857 | If the coupling fields are transformed through OASIS3 main process, it |
---|
858 | is important to indicate a sequence index. In fact, at each OASIS3 |
---|
859 | main process coupling timestep, $F_1$ is necessarily treated after |
---|
860 | $F_2$. Therefore, $SEQ(F_1) = 2$ and $SEQ(F_2) = 1$. |
---|
861 | |
---|
862 | \subsection{Mixing sequential and parallel |
---|
863 | runs using {\tt prism\_put\_restart\_proto}} |
---|
864 | |
---|
865 | In the example illustrated on figure \ref{restart_ex}, the models |
---|
866 | run sequentially for the first run only and then run |
---|
867 | simultaneously. For the first run, the LAG and SEQ indices must be |
---|
868 | defined as in section \ref{subsubsec_mix}. After the first run, the |
---|
869 | situation is similar to the one of section \ref{subsub_lag}, and |
---|
870 | positive LAG must be defined for $F_1$ and $F_2$. As their lag is |
---|
871 | positive, their corresponding first {\tt prism\_get\_proto} will |
---|
872 | automatically lead to reading $F_1$ and $F_2$ from coupling restart |
---|
873 | files. In this case, model A has to write $F_1$ to its restart file |
---|
874 | explicitly by calling {\tt prism\_put\_restart\_proto} (illustrated |
---|
875 | on the figure by an orange arrow) at the end of the first run; in |
---|
876 | fact, $F_1$ lag being then negative, such writing is not automatically |
---|
877 | done below the last {\tt prism\_put\_proto} of the first run. |
---|
878 | |
---|
879 | |
---|
880 | \begin{figure} |
---|
881 | \includegraphics[scale=.6]{restart_example.eps} |
---|
882 | \caption{An example using prism\_put\_restart\_proto} |
---|
883 | \label{restart_ex} |
---|
884 | \end{figure} |
---|
885 | |
---|
886 | %section{PRISM System Model Interface for the CLIM/MPI2-MPI1 |
---|
887 | %communication technique (PSMILe V.0)} |
---|
888 | %section{Model\_interfacing} |
---|