1 | /* ************************************************************************** * |
---|
2 | * Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011 * |
---|
3 | * ************************************************************************** */ |
---|
4 | |
---|
5 | #include <boost/multi_array.hpp> |
---|
6 | #include <boost/shared_ptr.hpp> |
---|
7 | #include <string> |
---|
8 | #include <cstring> |
---|
9 | #include <iostream> |
---|
10 | |
---|
11 | |
---|
12 | #include "xios.hpp" |
---|
13 | #include "oasis_cinterface.hpp" |
---|
14 | |
---|
15 | #include "attribute_template.hpp" |
---|
16 | #include "object_template.hpp" |
---|
17 | #include "group_template.hpp" |
---|
18 | |
---|
19 | #include "icutil.hpp" |
---|
20 | #include "cxios.hpp" |
---|
21 | #include "client.hpp" |
---|
22 | #include "field.hpp" |
---|
23 | #include "context.hpp" |
---|
24 | #include "context_client.hpp" |
---|
25 | #include "mpi.hpp" |
---|
26 | #include "timer.hpp" |
---|
27 | #include "array_new.hpp" |
---|
28 | |
---|
29 | |
---|
30 | extern "C" |
---|
31 | { |
---|
32 | // /////////////////////////////// Définitions ////////////////////////////// // |
---|
33 | |
---|
34 | // ----------------------- Redéfinition de types ---------------------------- |
---|
35 | |
---|
36 | typedef enum { NETCDF4 = 0 } XFileType; |
---|
37 | |
---|
38 | typedef xios::CContext* XContextPtr; |
---|
39 | |
---|
40 | // -------------------- Traitement des données ------------------------------ |
---|
41 | |
---|
42 | // This function is not exported to the public Fortran interface, |
---|
43 | // it is only used from the parse_xml.exe standalone test tool. |
---|
44 | void cxios_init(void) |
---|
45 | { |
---|
46 | CXios::initialize(); |
---|
47 | } |
---|
48 | |
---|
49 | void cxios_init_server(void) |
---|
50 | { |
---|
51 | CXios::initServerSide(); |
---|
52 | } |
---|
53 | |
---|
54 | void cxios_init_client(const char* client_id , int len_client_id, MPI_Fint* f_local_comm, MPI_Fint* f_return_comm ) |
---|
55 | { |
---|
56 | std::string str; |
---|
57 | MPI_Comm local_comm; |
---|
58 | MPI_Comm return_comm; |
---|
59 | |
---|
60 | if (!cstr2string(client_id, len_client_id, str)) return; |
---|
61 | |
---|
62 | int initialized; |
---|
63 | MPI_Initialized(&initialized); |
---|
64 | if (initialized) local_comm=MPI_Comm_f2c(*f_local_comm); |
---|
65 | else local_comm=MPI_COMM_NULL; |
---|
66 | CXios::initClientSide(str, local_comm, return_comm); |
---|
67 | *f_return_comm=MPI_Comm_c2f(return_comm); |
---|
68 | CTimer::get("XIOS init").suspend(); |
---|
69 | CTimer::get("XIOS").suspend(); |
---|
70 | } |
---|
71 | |
---|
72 | void cxios_context_initialize(const char* context_id , int len_context_id, MPI_Fint* f_comm) |
---|
73 | { |
---|
74 | std::string str; |
---|
75 | MPI_Comm comm; |
---|
76 | |
---|
77 | if (!cstr2string(context_id, len_context_id, str)) return; |
---|
78 | CTimer::get("XIOS").resume(); |
---|
79 | CTimer::get("XIOS init context").resume(); |
---|
80 | comm=MPI_Comm_f2c(*f_comm); |
---|
81 | CClient::registerContext(str, comm); |
---|
82 | CTimer::get("XIOS init context").suspend(); |
---|
83 | CTimer::get("XIOS").suspend(); |
---|
84 | } |
---|
85 | |
---|
86 | void cxios_context_is_initialized(const char* context_id , int len_context_id, bool* initialized) |
---|
87 | { |
---|
88 | std::string str; |
---|
89 | |
---|
90 | if (!cstr2string(context_id, len_context_id, str)) return; |
---|
91 | CTimer::get("XIOS").resume(); |
---|
92 | CContext* context = CContext::get(str, str); |
---|
93 | *initialized=context->isInitialized(); |
---|
94 | CTimer::get("XIOS").suspend(); |
---|
95 | } |
---|
96 | |
---|
97 | void cxios_context_close_definition() |
---|
98 | { |
---|
99 | CTimer::get("XIOS").resume(); |
---|
100 | CTimer::get("XIOS close definition").resume(); |
---|
101 | CContext* context = CContext::getCurrent(); |
---|
102 | context->closeDefinition(); |
---|
103 | CTimer::get("XIOS close definition").suspend(); |
---|
104 | CTimer::get("XIOS").suspend(); |
---|
105 | } |
---|
106 | |
---|
107 | void cxios_context_finalize() |
---|
108 | { |
---|
109 | CTimer::get("XIOS").resume(); |
---|
110 | CTimer::get("XIOS context finalize").resume(); |
---|
111 | CContext* context = CContext::getCurrent(); |
---|
112 | context->finalize(); |
---|
113 | CTimer::get("XIOS context finalize").suspend(); |
---|
114 | CTimer::get("XIOS").suspend(); |
---|
115 | } |
---|
116 | |
---|
117 | void cxios_finalize() |
---|
118 | { |
---|
119 | CTimer::get("XIOS").resume(); |
---|
120 | CTimer::get("XIOS finalize").resume(); |
---|
121 | CXios::clientFinalize(); |
---|
122 | } |
---|
123 | |
---|
124 | void cxios_solve_inheritance() |
---|
125 | { |
---|
126 | CTimer::get("XIOS").resume(); |
---|
127 | CContext* context = CContext::getCurrent(); |
---|
128 | context->solveAllInheritance(false); |
---|
129 | CTimer::get("XIOS").suspend(); |
---|
130 | } |
---|
131 | |
---|
132 | /*! \brief This group of functions retrieve variable information from the configuration file (.xml) |
---|
133 | * |
---|
134 | * These functions provide intermediate C interfaces to get variable information of the configuration file (e.x iodef.xml), |
---|
135 | * from a Fortran one, for example the value of a variable with id = "using_server". |
---|
136 | * Each function corresponds to each basic type. |
---|
137 | * \param varId [in] id of the variable that we'd like to get |
---|
138 | * \param varIdSize [in] size of the variable type (integer, float, double, string) |
---|
139 | * \param dataInt [in/out] the retrieved data |
---|
140 | * \param isVarExisted [in/out] Verify whether variable with varId exists |
---|
141 | */ |
---|
142 | void cxios_get_variable_data_k8(const char* varId, int varIdSize, double* data, bool* isVarExisted) |
---|
143 | { |
---|
144 | std::string varIdStr; |
---|
145 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
146 | |
---|
147 | CTimer::get("XIOS").resume(); |
---|
148 | CTimer::get("XIOS get variable data").resume(); |
---|
149 | |
---|
150 | CContext* context = CContext::getCurrent(); |
---|
151 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
152 | |
---|
153 | if (*isVarExisted) |
---|
154 | { |
---|
155 | *data = CVariable::get(context->getId(), varIdStr)->getData<double>(); |
---|
156 | } |
---|
157 | |
---|
158 | CTimer::get("XIOS get variable data").suspend(); |
---|
159 | CTimer::get("XIOS").suspend(); |
---|
160 | } |
---|
161 | |
---|
162 | void cxios_get_variable_data_k4(const char* varId, int varIdSize, float* data, bool* isVarExisted) |
---|
163 | { |
---|
164 | std::string varIdStr; |
---|
165 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
166 | |
---|
167 | CTimer::get("XIOS").resume(); |
---|
168 | CTimer::get("XIOS get variable data").resume(); |
---|
169 | |
---|
170 | CContext* context = CContext::getCurrent(); |
---|
171 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
172 | |
---|
173 | if (*isVarExisted) |
---|
174 | { |
---|
175 | *data = CVariable::get(context->getId(), varIdStr)->getData<float>(); |
---|
176 | } |
---|
177 | |
---|
178 | CTimer::get("XIOS get variable data").suspend(); |
---|
179 | CTimer::get("XIOS").suspend(); |
---|
180 | } |
---|
181 | |
---|
182 | void cxios_get_variable_data_int(const char* varId, int varIdSize, int* data, bool* isVarExisted) |
---|
183 | { |
---|
184 | std::string varIdStr; |
---|
185 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
186 | |
---|
187 | CTimer::get("XIOS").resume(); |
---|
188 | CTimer::get("XIOS get variable data").resume(); |
---|
189 | |
---|
190 | CContext* context = CContext::getCurrent(); |
---|
191 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
192 | |
---|
193 | if (*isVarExisted) |
---|
194 | { |
---|
195 | *data = CVariable::get(context->getId(), varIdStr)->getData<int>(); |
---|
196 | } |
---|
197 | |
---|
198 | CTimer::get("XIOS get variable data").suspend(); |
---|
199 | CTimer::get("XIOS").suspend(); |
---|
200 | } |
---|
201 | |
---|
202 | void cxios_get_variable_data_logic(const char* varId, int varIdSize, bool* data, bool* isVarExisted) |
---|
203 | { |
---|
204 | std::string varIdStr; |
---|
205 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
206 | |
---|
207 | CTimer::get("XIOS").resume(); |
---|
208 | CTimer::get("XIOS get variable data").resume(); |
---|
209 | |
---|
210 | CContext* context = CContext::getCurrent(); |
---|
211 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
212 | |
---|
213 | if (*isVarExisted) |
---|
214 | { |
---|
215 | *data = CVariable::get(context->getId(), varIdStr)->getData<bool>(); |
---|
216 | } |
---|
217 | |
---|
218 | CTimer::get("XIOS get variable data").suspend(); |
---|
219 | CTimer::get("XIOS").suspend(); |
---|
220 | } |
---|
221 | |
---|
222 | void cxios_get_variable_data_char(const char* varId, int varIdSize, char* data, int dataSizeIn, bool* isVarExisted) |
---|
223 | { |
---|
224 | std::string varIdStr; |
---|
225 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
226 | |
---|
227 | CTimer::get("XIOS").resume(); |
---|
228 | CTimer::get("XIOS get variable data").resume(); |
---|
229 | |
---|
230 | CContext* context = CContext::getCurrent(); |
---|
231 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
232 | |
---|
233 | if (*isVarExisted) |
---|
234 | { |
---|
235 | int dataSizeOut = CVariable::get(context->getId(), varIdStr)->getData<string>().length(); |
---|
236 | strncpy(data, CVariable::get(context->getId(), varIdStr)->getData<string>().c_str(), std::min(dataSizeIn, dataSizeOut)); |
---|
237 | } |
---|
238 | |
---|
239 | CTimer::get("XIOS get variable data").suspend(); |
---|
240 | CTimer::get("XIOS").suspend(); |
---|
241 | } |
---|
242 | |
---|
243 | /*! \brief This group of functions write information into existing variable in the configuration file (.xml) |
---|
244 | * |
---|
245 | * These functions provide intermediate C interfaces to get variable information of the configuration file (e.x iodef.xml), |
---|
246 | * from a Fortran one, for example the value of a variable with id = "using_server". |
---|
247 | * Each function corresponds to each basic type. |
---|
248 | * \param varId [in] id of the variable that we'd like to get |
---|
249 | * \param varIdSize [in] size of the variable type (integer, float, double, string) |
---|
250 | * \param data [in] the input data |
---|
251 | * \param isVarExisted [in/out] Verify whether variable with varId exists |
---|
252 | */ |
---|
253 | void cxios_set_variable_data_k8(const char* varId, int varIdSize, double data, bool* isVarExisted) |
---|
254 | { |
---|
255 | std::string varIdStr; |
---|
256 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
257 | |
---|
258 | CTimer::get("XIOS").resume(); |
---|
259 | CTimer::get("XIOS set variable data").resume(); |
---|
260 | |
---|
261 | CContext* context = CContext::getCurrent(); |
---|
262 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
263 | |
---|
264 | if (*isVarExisted) |
---|
265 | { |
---|
266 | CVariable::get(context->getId(), varIdStr)->setData<double>(data); |
---|
267 | //CVariable::get(context->getId(), varIdStr)->sendValue(); |
---|
268 | } |
---|
269 | |
---|
270 | CTimer::get("XIOS set variable data").suspend(); |
---|
271 | CTimer::get("XIOS").suspend(); |
---|
272 | } |
---|
273 | |
---|
274 | void cxios_set_variable_data_k4(const char* varId, int varIdSize, float data, bool* isVarExisted) |
---|
275 | { |
---|
276 | std::string varIdStr; |
---|
277 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
278 | |
---|
279 | CTimer::get("XIOS").resume(); |
---|
280 | CTimer::get("XIOS set variable data").resume(); |
---|
281 | |
---|
282 | CContext* context = CContext::getCurrent(); |
---|
283 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
284 | |
---|
285 | if (*isVarExisted) |
---|
286 | { |
---|
287 | CVariable::get(context->getId(), varIdStr)->setData<float>(data); |
---|
288 | //CVariable::get(context->getId(), varIdStr)->sendValue(); |
---|
289 | } |
---|
290 | |
---|
291 | CTimer::get("XIOS set variable data").suspend(); |
---|
292 | CTimer::get("XIOS").suspend(); |
---|
293 | } |
---|
294 | |
---|
295 | void cxios_set_variable_data_int(const char* varId, int varIdSize, int data, bool* isVarExisted) |
---|
296 | { |
---|
297 | std::string varIdStr; |
---|
298 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
299 | |
---|
300 | CTimer::get("XIOS").resume(); |
---|
301 | CTimer::get("XIOS set variable data").resume(); |
---|
302 | |
---|
303 | CContext* context = CContext::getCurrent(); |
---|
304 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
305 | |
---|
306 | if (*isVarExisted) |
---|
307 | { |
---|
308 | CVariable::get(context->getId(), varIdStr)->setData<int>(data); |
---|
309 | //CVariable::get(context->getId(), varIdStr)->sendValue(); |
---|
310 | } |
---|
311 | |
---|
312 | |
---|
313 | CTimer::get("XIOS set variable data").suspend(); |
---|
314 | CTimer::get("XIOS").suspend(); |
---|
315 | } |
---|
316 | |
---|
317 | void cxios_set_variable_data_logic(const char* varId, int varIdSize, bool data, bool* isVarExisted) |
---|
318 | { |
---|
319 | std::string varIdStr; |
---|
320 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
321 | |
---|
322 | CTimer::get("XIOS").resume(); |
---|
323 | CTimer::get("XIOS set variable data").resume(); |
---|
324 | |
---|
325 | CContext* context = CContext::getCurrent(); |
---|
326 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
327 | |
---|
328 | if (*isVarExisted) |
---|
329 | { |
---|
330 | CVariable::get(context->getId(), varIdStr)->setData<bool>(data); |
---|
331 | //CVariable::get(context->getId(), varIdStr)->sendValue(); |
---|
332 | } |
---|
333 | |
---|
334 | CTimer::get("XIOS set variable data").suspend(); |
---|
335 | CTimer::get("XIOS").suspend(); |
---|
336 | } |
---|
337 | |
---|
338 | void cxios_set_variable_data_char(const char* varId, int varIdSize, const char* data, int dataSizeIn, bool* isVarExisted) |
---|
339 | { |
---|
340 | std::string varIdStr, dataStr; |
---|
341 | if (!cstr2string(varId, varIdSize, varIdStr)) return; |
---|
342 | if (!cstr2string(data, dataSizeIn, dataStr)) |
---|
343 | { |
---|
344 | *isVarExisted = false; |
---|
345 | return; |
---|
346 | } |
---|
347 | |
---|
348 | CTimer::get("XIOS").resume(); |
---|
349 | CTimer::get("XIOS set variable data").resume(); |
---|
350 | |
---|
351 | CContext* context = CContext::getCurrent(); |
---|
352 | *isVarExisted = CVariable::has(context->getId(), varIdStr); |
---|
353 | |
---|
354 | if (*isVarExisted) |
---|
355 | { |
---|
356 | CVariable::get(context->getId(), varIdStr)->setData<string>(dataStr); |
---|
357 | //CVariable::get(context->getId(), varIdStr)->sendValue(); |
---|
358 | } |
---|
359 | |
---|
360 | CTimer::get("XIOS set variable data").suspend(); |
---|
361 | CTimer::get("XIOS").suspend(); |
---|
362 | } |
---|
363 | |
---|
364 | |
---|
365 | // ---------------------- Ecriture des données ------------------------------ |
---|
366 | |
---|
367 | void cxios_write_data_k80(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize) |
---|
368 | { |
---|
369 | std::string fieldid_str; |
---|
370 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
371 | |
---|
372 | CTimer::get("XIOS").resume(); |
---|
373 | CTimer::get("XIOS send field").resume(); |
---|
374 | CContext* context = CContext::getCurrent(); |
---|
375 | if (!context->hasServer) context->client->checkBuffers(); |
---|
376 | CArray<double, 1> data(data_k8, shape(data_Xsize), neverDeleteData); |
---|
377 | CField::get(fieldid_str)->setData(data); |
---|
378 | CTimer::get("XIOS send field").suspend(); |
---|
379 | CTimer::get("XIOS").suspend(); |
---|
380 | } |
---|
381 | |
---|
382 | void cxios_write_data_k81(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize) |
---|
383 | { |
---|
384 | std::string fieldid_str; |
---|
385 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
386 | |
---|
387 | CTimer::get("XIOS").resume(); |
---|
388 | CTimer::get("XIOS send field").resume(); |
---|
389 | |
---|
390 | CContext* context = CContext::getCurrent(); |
---|
391 | if (!context->hasServer) context->client->checkBuffers(); |
---|
392 | |
---|
393 | CArray<double, 1> data(data_k8, shape(data_Xsize), neverDeleteData); |
---|
394 | CField::get(fieldid_str)->setData(data); |
---|
395 | |
---|
396 | CTimer::get("XIOS send field").suspend(); |
---|
397 | CTimer::get("XIOS").suspend(); |
---|
398 | } |
---|
399 | |
---|
400 | void cxios_write_data_k82(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize, int data_Ysize) |
---|
401 | { |
---|
402 | std::string fieldid_str; |
---|
403 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
404 | |
---|
405 | CTimer::get("XIOS").resume(); |
---|
406 | CTimer::get("XIOS send field").resume(); |
---|
407 | |
---|
408 | CContext* context = CContext::getCurrent(); |
---|
409 | if (!context->hasServer) context->client->checkBuffers(); |
---|
410 | |
---|
411 | CArray<double, 2>data(data_k8, shape(data_Xsize, data_Ysize), neverDeleteData); |
---|
412 | CField::get(fieldid_str)->setData(data); |
---|
413 | |
---|
414 | CTimer::get("XIOS send field").suspend(); |
---|
415 | CTimer::get("XIOS").suspend(); |
---|
416 | } |
---|
417 | |
---|
418 | void cxios_write_data_k83(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize, int data_Ysize, int data_Zsize) |
---|
419 | { |
---|
420 | std::string fieldid_str; |
---|
421 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
422 | |
---|
423 | CTimer::get("XIOS").resume(); |
---|
424 | CTimer::get("XIOS send field").resume(); |
---|
425 | |
---|
426 | CContext* context = CContext::getCurrent(); |
---|
427 | if (!context->hasServer) context->client->checkBuffers(); |
---|
428 | |
---|
429 | CArray<double, 3>data(data_k8, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); |
---|
430 | CField::get(fieldid_str)->setData(data); |
---|
431 | |
---|
432 | CTimer::get("XIOS send field").suspend(); |
---|
433 | CTimer::get("XIOS").suspend(); |
---|
434 | } |
---|
435 | |
---|
436 | void cxios_write_data_k40(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize) |
---|
437 | { |
---|
438 | std::string fieldid_str; |
---|
439 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
440 | |
---|
441 | CTimer::get("XIOS").resume(); |
---|
442 | CTimer::get("XIOS send field").resume(); |
---|
443 | CContext* context = CContext::getCurrent(); |
---|
444 | if (!context->hasServer) context->client->checkBuffers(); |
---|
445 | |
---|
446 | CArray<float, 1> data_tmp(data_k4, shape(data_Xsize), neverDeleteData); |
---|
447 | CArray<double, 1> data(data_Xsize) ; |
---|
448 | data = data_tmp; |
---|
449 | CField::get(fieldid_str)->setData(data); |
---|
450 | CTimer::get("XIOS send field").suspend(); |
---|
451 | CTimer::get("XIOS").suspend(); |
---|
452 | } |
---|
453 | |
---|
454 | void cxios_write_data_k41(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize) |
---|
455 | { |
---|
456 | std::string fieldid_str; |
---|
457 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
458 | |
---|
459 | CTimer::get("XIOS").resume(); |
---|
460 | CTimer::get("XIOS send field").resume(); |
---|
461 | |
---|
462 | CContext* context = CContext::getCurrent(); |
---|
463 | if (!context->hasServer) context->client->checkBuffers(); |
---|
464 | |
---|
465 | CArray<float, 1> data_tmp(data_k4, shape(data_Xsize), neverDeleteData); |
---|
466 | CArray<double, 1> data(data_Xsize); |
---|
467 | data = data_tmp; |
---|
468 | CField::get(fieldid_str)->setData(data); |
---|
469 | |
---|
470 | CTimer::get("XIOS send field").suspend(); |
---|
471 | CTimer::get("XIOS").suspend(); |
---|
472 | } |
---|
473 | |
---|
474 | void cxios_write_data_k42(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize, int data_Ysize) |
---|
475 | { |
---|
476 | std::string fieldid_str; |
---|
477 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
478 | |
---|
479 | CTimer::get("XIOS").resume(); |
---|
480 | CTimer::get("XIOS send field").resume(); |
---|
481 | |
---|
482 | CContext* context = CContext::getCurrent(); |
---|
483 | if (!context->hasServer) context->client->checkBuffers(); |
---|
484 | |
---|
485 | CArray<float, 2> data_tmp(data_k4, shape(data_Xsize, data_Ysize), neverDeleteData); |
---|
486 | CArray<double, 2> data(data_Xsize, data_Ysize); |
---|
487 | data = data_tmp; |
---|
488 | CField::get(fieldid_str)->setData(data); |
---|
489 | |
---|
490 | CTimer::get("XIOS send field").suspend(); |
---|
491 | CTimer::get("XIOS").suspend(); |
---|
492 | } |
---|
493 | |
---|
494 | void cxios_write_data_k43(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize, int data_Ysize, int data_Zsize) |
---|
495 | { |
---|
496 | std::string fieldid_str; |
---|
497 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
498 | |
---|
499 | CTimer::get("XIOS").resume(); |
---|
500 | CTimer::get("XIOS send field").resume(); |
---|
501 | |
---|
502 | CContext* context = CContext::getCurrent(); |
---|
503 | if (!context->hasServer) context->client->checkBuffers(); |
---|
504 | |
---|
505 | CArray<float, 3> data_tmp(data_k4, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); |
---|
506 | CArray<double, 3> data(data_Xsize, data_Ysize, data_Zsize); |
---|
507 | data = data_tmp; |
---|
508 | CField::get(fieldid_str)->setData(data); |
---|
509 | |
---|
510 | CTimer::get("XIOS send field").suspend(); |
---|
511 | CTimer::get("XIOS").suspend(); |
---|
512 | } |
---|
513 | |
---|
514 | // ---------------------- Lecture des données ------------------------------ |
---|
515 | |
---|
516 | void cxios_read_data_k81(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize) |
---|
517 | { |
---|
518 | std::string fieldid_str; |
---|
519 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
520 | |
---|
521 | CTimer::get("XIOS").resume(); |
---|
522 | CTimer::get("XIOS recv field").resume(); |
---|
523 | |
---|
524 | CContext* context = CContext::getCurrent(); |
---|
525 | if (!context->hasServer) context->client->checkBuffers(); |
---|
526 | |
---|
527 | CArray<double, 1> data(data_k8, shape(data_Xsize), neverDeleteData); |
---|
528 | CField::get(fieldid_str)->getData(data); |
---|
529 | |
---|
530 | CTimer::get("XIOS recv field").suspend(); |
---|
531 | CTimer::get("XIOS").suspend(); |
---|
532 | } |
---|
533 | |
---|
534 | void cxios_read_data_k82(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize, int data_Ysize) |
---|
535 | { |
---|
536 | std::string fieldid_str; |
---|
537 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
538 | |
---|
539 | CTimer::get("XIOS").resume(); |
---|
540 | CTimer::get("XIOS recv field").resume(); |
---|
541 | |
---|
542 | CContext* context = CContext::getCurrent(); |
---|
543 | if (!context->hasServer) context->client->checkBuffers(); |
---|
544 | |
---|
545 | CArray<double, 2>data(data_k8, shape(data_Xsize, data_Ysize), neverDeleteData); |
---|
546 | CField::get(fieldid_str)->getData(data); |
---|
547 | |
---|
548 | CTimer::get("XIOS recv field").suspend(); |
---|
549 | CTimer::get("XIOS").suspend(); |
---|
550 | } |
---|
551 | |
---|
552 | void cxios_read_data_k83(const char* fieldid, int fieldid_size, double* data_k8, int data_Xsize, int data_Ysize, int data_Zsize) |
---|
553 | { |
---|
554 | std::string fieldid_str; |
---|
555 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
556 | |
---|
557 | CTimer::get("XIOS").resume(); |
---|
558 | CTimer::get("XIOS recv field").resume(); |
---|
559 | |
---|
560 | CContext* context = CContext::getCurrent(); |
---|
561 | if (!context->hasServer) context->client->checkBuffers(); |
---|
562 | |
---|
563 | CArray<double, 3>data(data_k8, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); |
---|
564 | CField::get(fieldid_str)->getData(data); |
---|
565 | |
---|
566 | CTimer::get("XIOS recv field").suspend(); |
---|
567 | CTimer::get("XIOS").suspend(); |
---|
568 | } |
---|
569 | |
---|
570 | void cxios_read_data_k41(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize) |
---|
571 | { |
---|
572 | std::string fieldid_str; |
---|
573 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
574 | |
---|
575 | CTimer::get("XIOS").resume(); |
---|
576 | CTimer::get("XIOS recv field").resume(); |
---|
577 | |
---|
578 | CContext* context = CContext::getCurrent(); |
---|
579 | if (!context->hasServer) context->client->checkBuffers(); |
---|
580 | |
---|
581 | CArray<double, 1> data(data_Xsize); |
---|
582 | CField::get(fieldid_str)->getData(data); |
---|
583 | CArray<float, 1> data_tmp(data_k4, shape(data_Xsize), neverDeleteData); |
---|
584 | data_tmp = data; |
---|
585 | |
---|
586 | CTimer::get("XIOS recv field").suspend(); |
---|
587 | CTimer::get("XIOS").suspend(); |
---|
588 | } |
---|
589 | |
---|
590 | void cxios_read_data_k42(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize, int data_Ysize) |
---|
591 | { |
---|
592 | std::string fieldid_str; |
---|
593 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
594 | |
---|
595 | CTimer::get("XIOS").resume(); |
---|
596 | CTimer::get("XIOS recv field").resume(); |
---|
597 | |
---|
598 | CContext* context = CContext::getCurrent(); |
---|
599 | if (!context->hasServer) context->client->checkBuffers(); |
---|
600 | |
---|
601 | CArray<double, 2> data(data_Xsize, data_Ysize); |
---|
602 | CField::get(fieldid_str)->getData(data); |
---|
603 | CArray<float, 2> data_tmp(data_k4, shape(data_Xsize, data_Ysize), neverDeleteData); |
---|
604 | data_tmp = data; |
---|
605 | |
---|
606 | CTimer::get("XIOS recv field").suspend(); |
---|
607 | CTimer::get("XIOS").suspend(); |
---|
608 | } |
---|
609 | |
---|
610 | void cxios_read_data_k43(const char* fieldid, int fieldid_size, float* data_k4, int data_Xsize, int data_Ysize, int data_Zsize) |
---|
611 | { |
---|
612 | std::string fieldid_str; |
---|
613 | if (!cstr2string(fieldid, fieldid_size, fieldid_str)) return; |
---|
614 | |
---|
615 | CTimer::get("XIOS").resume(); |
---|
616 | CTimer::get("XIOS recv field").resume(); |
---|
617 | |
---|
618 | CContext* context = CContext::getCurrent(); |
---|
619 | if (!context->hasServer) context->client->checkBuffers(); |
---|
620 | |
---|
621 | CArray<double, 3> data(data_Xsize, data_Ysize, data_Zsize); |
---|
622 | CField::get(fieldid_str)->getData(data); |
---|
623 | CArray<float, 3> data_tmp(data_k4, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); |
---|
624 | data_tmp = data; |
---|
625 | |
---|
626 | CTimer::get("XIOS recv field").suspend(); |
---|
627 | CTimer::get("XIOS").suspend(); |
---|
628 | } |
---|
629 | } // extern "C" |
---|