1 | #include "domain.hpp" |
---|
2 | |
---|
3 | #include "attribute_template_impl.hpp" |
---|
4 | #include "object_template_impl.hpp" |
---|
5 | #include "group_template_impl.hpp" |
---|
6 | |
---|
7 | #include "mpi_manager.hpp" |
---|
8 | |
---|
9 | #include "tree_manager.hpp" |
---|
10 | #include "xmlioserver_spl.hpp" |
---|
11 | #include "event_client.hpp" |
---|
12 | #include "event_server.hpp" |
---|
13 | #include "buffer_in.hpp" |
---|
14 | |
---|
15 | namespace xmlioserver { |
---|
16 | namespace tree { |
---|
17 | |
---|
18 | /// ////////////////////// Définitions ////////////////////// /// |
---|
19 | |
---|
20 | CDomain::CDomain(void) |
---|
21 | : CObjectTemplate<CDomain>(), CDomainAttributes() |
---|
22 | , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles() |
---|
23 | , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub() |
---|
24 | , ibegin_zoom_sub(), jbegin_zoom_sub(), ni_zoom_sub(), nj_zoom_sub() |
---|
25 | , lonvalue_sub(), latvalue_sub(),lonvalue_srv(new CArray<double,1>()) |
---|
26 | , latvalue_srv(new CArray<double,1>()) |
---|
27 | { /* Ne rien faire de plus */ } |
---|
28 | |
---|
29 | CDomain::CDomain(const StdString & id) |
---|
30 | : CObjectTemplate<CDomain>(id), CDomainAttributes() |
---|
31 | , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles() |
---|
32 | , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub() |
---|
33 | , ibegin_zoom_sub(), jbegin_zoom_sub(),ni_zoom_sub(), nj_zoom_sub() |
---|
34 | , lonvalue_sub(), latvalue_sub(),lonvalue_srv(new CArray<double,1>()) |
---|
35 | , latvalue_srv(new CArray<double,1>()) |
---|
36 | { /* Ne rien faire de plus */ } |
---|
37 | |
---|
38 | CDomain::~CDomain(void) |
---|
39 | { |
---|
40 | this->local_mask.reset(); |
---|
41 | for (StdSize i = 0; i < this->lonvalue_sub.size(); i++) |
---|
42 | { |
---|
43 | this->lonvalue_sub[i].reset(); |
---|
44 | this->latvalue_sub[i].reset(); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | ///--------------------------------------------------------------- |
---|
49 | |
---|
50 | const std::set<StdString> & CDomain::getRelFiles(void) const |
---|
51 | { |
---|
52 | return (this->relFiles); |
---|
53 | } |
---|
54 | |
---|
55 | //---------------------------------------------------------------- |
---|
56 | |
---|
57 | bool CDomain::hasZoom(void) const |
---|
58 | { |
---|
59 | return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && |
---|
60 | (this->zoom_nj.getValue() != this->nj_glo.getValue())); |
---|
61 | } |
---|
62 | |
---|
63 | //---------------------------------------------------------------- |
---|
64 | |
---|
65 | bool CDomain::isEmpty(void) const |
---|
66 | { |
---|
67 | return ((this->zoom_ni_srv == 0) || |
---|
68 | (this->zoom_nj_srv == 0)); |
---|
69 | } |
---|
70 | |
---|
71 | //---------------------------------------------------------------- |
---|
72 | |
---|
73 | bool CDomain::IsWritten(const StdString & filename) const |
---|
74 | { |
---|
75 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
76 | } |
---|
77 | |
---|
78 | //---------------------------------------------------------------- |
---|
79 | |
---|
80 | void CDomain::addRelFile(const StdString & filename) |
---|
81 | { |
---|
82 | this->relFiles.insert(filename); |
---|
83 | } |
---|
84 | |
---|
85 | //---------------------------------------------------------------- |
---|
86 | |
---|
87 | void CDomain::fromBinary(StdIStream & is) |
---|
88 | { |
---|
89 | SuperClass::fromBinary(is); |
---|
90 | |
---|
91 | if ( !this->ibegin.isEmpty() && |
---|
92 | !this->jbegin.isEmpty() && |
---|
93 | !this->iend.isEmpty() && |
---|
94 | !this->jend.isEmpty() && |
---|
95 | !this->latvalue.isEmpty() && |
---|
96 | !this->lonvalue.isEmpty()) |
---|
97 | { |
---|
98 | |
---|
99 | this->ibegin_sub.push_back(this->ibegin.getValue()); |
---|
100 | this->jbegin_sub.push_back(this->jbegin.getValue()); |
---|
101 | this->iend_sub.push_back(this->iend.getValue()); |
---|
102 | this->jend_sub.push_back(this->jend.getValue()); |
---|
103 | |
---|
104 | this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue()); |
---|
105 | this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue()); |
---|
106 | this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue()); |
---|
107 | this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue()); |
---|
108 | |
---|
109 | this->latvalue_sub.push_back(this->latvalue.getValue()); |
---|
110 | this->lonvalue_sub.push_back(this->lonvalue.getValue()); |
---|
111 | } |
---|
112 | |
---|
113 | #define CLEAR_ATT(name_)\ |
---|
114 | SuperClassAttribute::operator[](#name_)->clear() |
---|
115 | |
---|
116 | CLEAR_ATT(mask); |
---|
117 | CLEAR_ATT(data_n_index); |
---|
118 | CLEAR_ATT(data_i_index); |
---|
119 | CLEAR_ATT(data_j_index); |
---|
120 | |
---|
121 | CLEAR_ATT(data_ni); |
---|
122 | CLEAR_ATT(data_nj); |
---|
123 | CLEAR_ATT(data_ibegin); |
---|
124 | CLEAR_ATT(data_jbegin); |
---|
125 | |
---|
126 | CLEAR_ATT(ni); |
---|
127 | CLEAR_ATT(nj); |
---|
128 | |
---|
129 | #undef CLEAR_ATT |
---|
130 | |
---|
131 | if ( !this->ibegin.isEmpty() && |
---|
132 | !this->jbegin.isEmpty() && |
---|
133 | !this->iend.isEmpty() && |
---|
134 | !this->jend.isEmpty() && |
---|
135 | !this->latvalue.isEmpty() && |
---|
136 | !this->lonvalue.isEmpty()) |
---|
137 | { |
---|
138 | |
---|
139 | this->ibegin.setValue(*std::min_element(this->ibegin_sub.begin(),this->ibegin_sub.end())); |
---|
140 | this->jbegin.setValue(*std::min_element(this->jbegin_sub.begin(),this->jbegin_sub.end())); |
---|
141 | this->iend.setValue(*std::max_element(this->iend_sub.begin(),this->iend_sub.end())); |
---|
142 | this->jend.setValue(*std::max_element(this->jend_sub.begin(),this->jend_sub.end())); |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | //---------------------------------------------------------------- |
---|
147 | |
---|
148 | StdString CDomain::GetName(void) { return (StdString("domain")); } |
---|
149 | StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } |
---|
150 | ENodeType CDomain::GetType(void) { return (eDomain); } |
---|
151 | |
---|
152 | //---------------------------------------------------------------- |
---|
153 | |
---|
154 | void CDomain::checkGlobalDomain(void) |
---|
155 | { |
---|
156 | if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || |
---|
157 | (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) |
---|
158 | { |
---|
159 | ERROR("CDomain::checkAttributes(void)", |
---|
160 | << "[ Id = " << this->getId() << " ] " |
---|
161 | << "Le domaine global est mal défini," |
---|
162 | << " vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") |
---|
163 | } |
---|
164 | } |
---|
165 | |
---|
166 | //---------------------------------------------------------------- |
---|
167 | |
---|
168 | void CDomain::checkLocalIDomain(void) |
---|
169 | { |
---|
170 | if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty()) |
---|
171 | iend.setValue(ibegin.getValue() + ni.getValue() - 1) ; |
---|
172 | |
---|
173 | else if (!ni.isEmpty() && !iend.isEmpty() && ibegin.isEmpty()) |
---|
174 | ibegin.setValue( - ni.getValue() + iend.getValue() + 1) ; |
---|
175 | |
---|
176 | else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty()) |
---|
177 | ni.setValue(iend.getValue() - ibegin.getValue() + 1) ; |
---|
178 | |
---|
179 | else if (!ibegin.isEmpty() && !iend.isEmpty() && |
---|
180 | !ni.isEmpty() && (iend.getValue() != ibegin.getValue() + ni.getValue() - 1)) |
---|
181 | { |
---|
182 | ERROR("CDomain::checkAttributes(void)", |
---|
183 | << "Le domaine est mal défini," |
---|
184 | << " iend est différent de (ibegin + ni - 1) !") ; |
---|
185 | } |
---|
186 | else |
---|
187 | { |
---|
188 | ERROR("CDomain::checkAttributes(void)", |
---|
189 | << "Le domaine est mal défini," |
---|
190 | << " deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ; |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || |
---|
195 | ibegin.getValue() < 1 || iend.getValue() > ni_glo.getValue()) |
---|
196 | ERROR("CDomain::checkAttributes(void)", |
---|
197 | << "[ Id = " << this->getId() << " ] " |
---|
198 | << "Domaine local mal défini," |
---|
199 | << " vérifiez les valeurs ni, ni_glo, ibegin, iend") ; |
---|
200 | |
---|
201 | } |
---|
202 | |
---|
203 | //---------------------------------------------------------------- |
---|
204 | |
---|
205 | void CDomain::checkLocalJDomain(void) |
---|
206 | { |
---|
207 | if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty()) |
---|
208 | jend.setValue(jbegin.getValue() + nj.getValue() - 1) ; |
---|
209 | |
---|
210 | else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty()) |
---|
211 | jbegin.setValue( - nj.getValue() + jend.getValue() + 1) ; |
---|
212 | |
---|
213 | else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty()) |
---|
214 | nj.setValue(jend.getValue() - jbegin.getValue() + 1) ; |
---|
215 | |
---|
216 | else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty() && |
---|
217 | (jend.getValue() != jbegin.getValue() + nj.getValue() - 1)) |
---|
218 | { |
---|
219 | ERROR("CDomain::checkAttributes(void)", |
---|
220 | << "Le domaine est mal défini," |
---|
221 | << " iend est différent de (jbegin + nj - 1) !") ; |
---|
222 | } |
---|
223 | else |
---|
224 | { |
---|
225 | ERROR("CDomain::checkAttributes(void)", |
---|
226 | << "Le domaine est mal défini," |
---|
227 | << " deux valeurs au moins parmis jend, jbegin, nj doivent être définies !") ; |
---|
228 | } |
---|
229 | |
---|
230 | if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() || |
---|
231 | jbegin.getValue() < 1 || jend.getValue() > nj_glo.getValue()) |
---|
232 | ERROR("CDomain::checkAttributes(void)", |
---|
233 | << "Domaine local mal défini," |
---|
234 | << " vérifiez les valeurs nj, nj_glo, jbegin, jend") ; |
---|
235 | } |
---|
236 | |
---|
237 | //---------------------------------------------------------------- |
---|
238 | |
---|
239 | void CDomain::checkMask(void) |
---|
240 | { |
---|
241 | using namespace std; |
---|
242 | |
---|
243 | int ibegin_mask = 0, |
---|
244 | jbegin_mask = 0, |
---|
245 | iend_mask = iend.getValue() - ibegin.getValue(), |
---|
246 | jend_mask = jend.getValue() - jbegin.getValue(); |
---|
247 | |
---|
248 | if (!zoom_ibegin.isEmpty()) |
---|
249 | { |
---|
250 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
251 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
252 | |
---|
253 | ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); |
---|
254 | jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); |
---|
255 | iend_mask = min (iend.getValue(), zoom_iend); |
---|
256 | jend_mask = min (jend.getValue(), zoom_jend); |
---|
257 | |
---|
258 | ibegin_mask -= ibegin.getValue(); |
---|
259 | jbegin_mask -= jbegin.getValue(); |
---|
260 | iend_mask -= ibegin.getValue(); |
---|
261 | jend_mask -= jbegin.getValue(); |
---|
262 | } |
---|
263 | |
---|
264 | |
---|
265 | if (!mask.isEmpty()) |
---|
266 | { |
---|
267 | ARRAY(bool, 2) mask_ = mask.getValue(); |
---|
268 | unsigned int niu = ni.getValue(), nju = nj.getValue(); |
---|
269 | if ((mask_->shape()[0] != niu) || |
---|
270 | (mask_->shape()[1] != nju)) |
---|
271 | ERROR("CDomain::checkAttributes(void)", |
---|
272 | <<"Le masque n'a pas la même taille que le domaine local") ; |
---|
273 | |
---|
274 | for (int i = 0; i < ni.getValue(); i++) |
---|
275 | { |
---|
276 | for (int j = 0; j < nj.getValue(); j++) |
---|
277 | { |
---|
278 | if (i < ibegin_mask && i > iend_mask && |
---|
279 | j < jbegin_mask && j > jend_mask ) |
---|
280 | (*mask_)[i][j] = false; |
---|
281 | } |
---|
282 | } |
---|
283 | } |
---|
284 | else // (!mask.hasValue()) |
---|
285 | { // Si aucun masque n'est défini, |
---|
286 | // on en crée un nouveau qui valide l'intégralité du domaine. |
---|
287 | ARRAY_CREATE(__arr, bool, 2, [ni.getValue()][nj.getValue()]); |
---|
288 | for (int i = 0; i < ni.getValue(); i++) |
---|
289 | { |
---|
290 | for (int j = 0; j < nj.getValue(); j++) |
---|
291 | { |
---|
292 | if (i >= ibegin_mask && i <= iend_mask && |
---|
293 | j >= jbegin_mask && j <= jend_mask ) |
---|
294 | (*__arr)[i][j] = true; |
---|
295 | else (*__arr)[i][j] = false; |
---|
296 | } |
---|
297 | } |
---|
298 | |
---|
299 | mask.setValue(__arr); |
---|
300 | __arr.reset(); |
---|
301 | } |
---|
302 | } |
---|
303 | |
---|
304 | |
---|
305 | //---------------------------------------------------------------- |
---|
306 | |
---|
307 | void CDomain::checkDomainData(void) |
---|
308 | { |
---|
309 | if (!data_dim.isEmpty() && |
---|
310 | !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) |
---|
311 | { |
---|
312 | ERROR("CDomain::checkAttributes(void)", |
---|
313 | << "Dimension des données non comptatible (doit être 1 ou 2) !") ; |
---|
314 | } |
---|
315 | else if (data_dim.isEmpty()) |
---|
316 | { |
---|
317 | ERROR("CDomain::checkAttributes(void)", |
---|
318 | << "Dimension des données non définie !") ; |
---|
319 | } |
---|
320 | |
---|
321 | if (data_ibegin.isEmpty()) |
---|
322 | data_ibegin.setValue(0) ; |
---|
323 | if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) |
---|
324 | data_jbegin.setValue(0) ; |
---|
325 | |
---|
326 | if (!data_ni.isEmpty() && (data_ni.getValue() <= 0)) |
---|
327 | { |
---|
328 | ERROR("CDomain::checkAttributes(void)", |
---|
329 | << "Dimension des données négative (data_ni).") ; |
---|
330 | } |
---|
331 | else if (data_ni.isEmpty()) |
---|
332 | { |
---|
333 | data_ni.setValue((data_dim.getValue() == 1) |
---|
334 | ? (ni.getValue() * nj.getValue()) |
---|
335 | : ni.getValue()); |
---|
336 | } |
---|
337 | |
---|
338 | if (data_dim.getValue() == 2) |
---|
339 | { |
---|
340 | if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) |
---|
341 | { |
---|
342 | ERROR("CDomain::checkAttributes(void)", |
---|
343 | << "Dimension des données négative (data_nj).") ; |
---|
344 | } |
---|
345 | else if (data_nj.isEmpty()) |
---|
346 | data_nj.setValue(nj.getValue()) ; |
---|
347 | } |
---|
348 | |
---|
349 | } |
---|
350 | |
---|
351 | //---------------------------------------------------------------- |
---|
352 | |
---|
353 | void CDomain::checkCompression(void) |
---|
354 | { |
---|
355 | if (!data_i_index.isEmpty()) |
---|
356 | { |
---|
357 | int ssize = data_i_index.getValue()->size(); |
---|
358 | if (!data_n_index.isEmpty() && |
---|
359 | (data_n_index.getValue() != ssize)) |
---|
360 | { |
---|
361 | ERROR("CDomain::checkAttributes(void)", |
---|
362 | <<"Dimension data_i_index incompatible avec data_n_index.") ; |
---|
363 | } |
---|
364 | else if (data_n_index.isEmpty()) |
---|
365 | data_n_index.setValue(ssize) ; |
---|
366 | |
---|
367 | if (data_dim.getValue() == 2) |
---|
368 | { |
---|
369 | if (!data_j_index.isEmpty() && |
---|
370 | (data_j_index.getValue()->size() != data_i_index.getValue()->size())) |
---|
371 | { |
---|
372 | ERROR("CDomain::checkAttributes(void)", |
---|
373 | <<"Dimension data_j_index incompatible avec data_i_index.") ; |
---|
374 | } |
---|
375 | else if (data_j_index.isEmpty()) |
---|
376 | { |
---|
377 | ERROR("CDomain::checkAttributes(void)", |
---|
378 | <<"La donnée data_j_index doit être renseignée !") ; |
---|
379 | } |
---|
380 | } |
---|
381 | } |
---|
382 | else |
---|
383 | { |
---|
384 | if (!data_n_index.isEmpty() || |
---|
385 | ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) |
---|
386 | ERROR("CDomain::checkAttributes(void)", << "data_i_index non défini") ; |
---|
387 | } |
---|
388 | |
---|
389 | if (data_n_index.isEmpty()) |
---|
390 | { // -> bloc re-vérifié OK |
---|
391 | if (data_dim.getValue() == 1) |
---|
392 | { |
---|
393 | const int dni = data_ni.getValue(); |
---|
394 | ARRAY_CREATE(__arri, int, 1, [dni]); |
---|
395 | data_n_index.setValue(dni); |
---|
396 | for (int i = 0; i < dni; i++) |
---|
397 | (*__arri)[i] = i+1 ; |
---|
398 | data_i_index.setValue(__arri) ; |
---|
399 | } |
---|
400 | else // (data_dim == 2) |
---|
401 | { |
---|
402 | const int dni = data_ni.getValue() * data_nj.getValue(); |
---|
403 | |
---|
404 | ARRAY_CREATE(__arri, int, 1, [dni]); |
---|
405 | ARRAY_CREATE(__arrj, int, 1, [dni]); |
---|
406 | data_n_index.setValue(dni); |
---|
407 | |
---|
408 | //for(int count = 0, i = 0; i < data_ni.getValue(); i++) |
---|
409 | //for(int j = 0; j < data_nj.getValue(); j++, count++) |
---|
410 | |
---|
411 | for(int count = 0, j = 0; j < data_nj.getValue(); j++) |
---|
412 | { |
---|
413 | for(int i = 0; i < data_ni.getValue(); i++, count++) |
---|
414 | { |
---|
415 | (*__arri)[count] = i+1 ; |
---|
416 | (*__arrj)[count] = j+1 ; |
---|
417 | } |
---|
418 | } |
---|
419 | data_i_index.setValue(__arri) ; |
---|
420 | data_j_index.setValue(__arrj) ; |
---|
421 | __arri.reset(); |
---|
422 | __arrj.reset(); |
---|
423 | } |
---|
424 | } |
---|
425 | } |
---|
426 | |
---|
427 | //---------------------------------------------------------------- |
---|
428 | |
---|
429 | void CDomain::completeLonLatClient(void) |
---|
430 | { |
---|
431 | ARRAY_CREATE(lonvalue_temp, double, 1, [0]); |
---|
432 | ARRAY_CREATE(latvalue_temp, double, 1, [0]); |
---|
433 | |
---|
434 | const int zoom_ibegin_client = zoom_ibegin_loc.getValue(), |
---|
435 | zoom_jbegin_client = zoom_jbegin_loc.getValue(), |
---|
436 | zoom_ni_client = zoom_ni_loc.getValue(), |
---|
437 | zoom_nj_client = zoom_nj_loc.getValue(); |
---|
438 | |
---|
439 | ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(), |
---|
440 | latvalue_ = this->latvalue.getValue(); |
---|
441 | |
---|
442 | if (this->data_dim.getValue() == 2) |
---|
443 | { |
---|
444 | StdSize dm = zoom_ni_client * zoom_nj_client; |
---|
445 | |
---|
446 | lonvalue_temp->resize(boost::extents[dm]); |
---|
447 | latvalue_temp->resize(boost::extents[dm]); |
---|
448 | |
---|
449 | for (int i = 0; i < zoom_ni_client; i++) |
---|
450 | { |
---|
451 | for (int j = 0; j < zoom_nj_client; j++) |
---|
452 | { |
---|
453 | (*lonvalue_temp)[i + j * zoom_ni_client] = |
---|
454 | (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; |
---|
455 | (*latvalue_temp)[i + j * zoom_ni_client] = |
---|
456 | (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; |
---|
457 | } |
---|
458 | } |
---|
459 | this->lonvalue.setValue(lonvalue_temp); |
---|
460 | this->latvalue.setValue(latvalue_temp); |
---|
461 | } |
---|
462 | else |
---|
463 | { |
---|
464 | lonvalue_temp->resize(boost::extents[zoom_ni_client]); |
---|
465 | latvalue_temp->resize(boost::extents[zoom_nj_client]); |
---|
466 | |
---|
467 | for (int i = zoom_ibegin_client - 1; i < (zoom_ni_client - zoom_ibegin_client + 1); i++) |
---|
468 | { |
---|
469 | (*lonvalue_temp)[i] = (*lonvalue_)[i]; |
---|
470 | } |
---|
471 | |
---|
472 | for (int j = zoom_ibegin_client - 1; j < (zoom_nj_client - zoom_jbegin_client + 1); j++) |
---|
473 | { |
---|
474 | (*latvalue_temp)[j] = (*latvalue_)[j]; |
---|
475 | } |
---|
476 | |
---|
477 | this->lonvalue.setValue(lonvalue_temp); |
---|
478 | this->latvalue.setValue(latvalue_temp); |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | //---------------------------------------------------------------- |
---|
483 | |
---|
484 | void CDomain::completeLonLatServer(void) |
---|
485 | { |
---|
486 | ARRAY_CREATE(lonvalue_temp, double, 1, [0]); |
---|
487 | ARRAY_CREATE(latvalue_temp, double, 1, [0]); |
---|
488 | |
---|
489 | const int ibegin_serv = ibegin.getValue(), |
---|
490 | jbegin_serv = jbegin.getValue(), |
---|
491 | zoom_ni_serv = zoom_ni_loc.getValue(), |
---|
492 | zoom_nj_serv = zoom_nj_loc.getValue(), |
---|
493 | ibegin_zoom_srv = zoom_ibegin_loc.getValue(), |
---|
494 | jbegin_zoom_srv = zoom_jbegin_loc.getValue(); |
---|
495 | |
---|
496 | |
---|
497 | if (this->data_dim.getValue() == 2) |
---|
498 | { |
---|
499 | StdSize dm = zoom_ni_serv * zoom_nj_serv; |
---|
500 | |
---|
501 | lonvalue_temp->resize(boost::extents[dm]); |
---|
502 | latvalue_temp->resize(boost::extents[dm]); |
---|
503 | |
---|
504 | for (StdSize k = 0; k < lonvalue_sub.size(); k++) |
---|
505 | { |
---|
506 | ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k], |
---|
507 | latvalue_loc = this->latvalue_sub[k]; |
---|
508 | const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k], |
---|
509 | zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k], |
---|
510 | ibegin_cl = ibegin_sub[k] , |
---|
511 | jbegin_cl = jbegin_sub[k] , |
---|
512 | ni_cl = iend_sub[k] - ibegin_sub[k] + 1; |
---|
513 | |
---|
514 | for (int i = 0; i < zoom_ni_cl; i++) |
---|
515 | { |
---|
516 | for (int j = 0; j < zoom_nj_cl; j++) |
---|
517 | { |
---|
518 | int ii = i + (ibegin_cl-1) - (ibegin_serv - 1) + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1); |
---|
519 | int jj = j + (jbegin_cl-1) - (jbegin_serv - 1) + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1); |
---|
520 | (*lonvalue_temp)[ii + jj * zoom_ni_serv] = |
---|
521 | (*lonvalue_loc)[i + j * zoom_ni_cl]; |
---|
522 | (*latvalue_temp)[ii + jj * zoom_ni_serv] = |
---|
523 | (*latvalue_loc)[i + j * zoom_ni_cl]; |
---|
524 | } |
---|
525 | } |
---|
526 | } |
---|
527 | this->lonvalue.setValue(lonvalue_temp); |
---|
528 | this->latvalue.setValue(latvalue_temp); |
---|
529 | } |
---|
530 | else |
---|
531 | { |
---|
532 | lonvalue_temp->resize(boost::extents[zoom_ni_serv]); |
---|
533 | latvalue_temp->resize(boost::extents[zoom_nj_serv]); |
---|
534 | |
---|
535 | for (StdSize k = 0; k < lonvalue_sub.size(); k++) |
---|
536 | { |
---|
537 | ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k], |
---|
538 | latvalue_loc = this->latvalue_sub[k]; |
---|
539 | const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k], |
---|
540 | zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k]; |
---|
541 | |
---|
542 | for (int i = 0; i < zoom_ni_cl; i++) |
---|
543 | (*lonvalue_temp)[i /*- (ibegin_serv - 1)*/ + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1)] = |
---|
544 | (*lonvalue_loc)[i]; |
---|
545 | |
---|
546 | for (int j = 0; j < zoom_nj_cl; j++) |
---|
547 | (*latvalue_temp)[j /*- (jbegin_serv - 1)*/ + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1)] = |
---|
548 | (*latvalue_loc)[j]; |
---|
549 | } |
---|
550 | this->lonvalue.setValue(lonvalue_temp); |
---|
551 | this->latvalue.setValue(latvalue_temp); |
---|
552 | } |
---|
553 | } |
---|
554 | |
---|
555 | //---------------------------------------------------------------- |
---|
556 | |
---|
557 | void CDomain::checkZoom(void) |
---|
558 | { |
---|
559 | // Résolution et vérification des données globales de zoom. |
---|
560 | if (!this->zoom_ni.isEmpty() || !this->zoom_nj.isEmpty() || |
---|
561 | !this->zoom_ibegin.isEmpty() || !this->zoom_jbegin.isEmpty()) |
---|
562 | { |
---|
563 | if (this->zoom_ni.isEmpty() && this->zoom_nj.isEmpty() && |
---|
564 | this->zoom_ibegin.isEmpty() && this->zoom_jbegin.isEmpty()) |
---|
565 | { |
---|
566 | ERROR("CDomain::checkZoom(void)", |
---|
567 | <<"Les attributs définissant un zoom doivent tous être définis") ; |
---|
568 | } |
---|
569 | else |
---|
570 | { |
---|
571 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
572 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
573 | |
---|
574 | if (zoom_ibegin.getValue() < 1 || zoom_jbegin.getValue() < 1 || |
---|
575 | zoom_iend > ni_glo.getValue() || zoom_jend > nj_glo.getValue()) |
---|
576 | ERROR("CDomain::checkZoom(void)", |
---|
577 | << "Zoom mal défini," |
---|
578 | << " vérifiez les valeurs zoom_ni, zoom_nj, zoom_ibegin, zoom_ibegin") ; |
---|
579 | } |
---|
580 | } |
---|
581 | else |
---|
582 | { |
---|
583 | this->zoom_ni.setValue(this->ni_glo.getValue()); |
---|
584 | this->zoom_nj.setValue(this->nj_glo.getValue()); |
---|
585 | this->zoom_ibegin.setValue(1); |
---|
586 | this->zoom_jbegin.setValue(1); |
---|
587 | } |
---|
588 | // Résolution des données locales de zoom. |
---|
589 | { |
---|
590 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
591 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
592 | |
---|
593 | if ((zoom_ibegin.getValue() > iend.getValue()) || |
---|
594 | (zoom_iend < ibegin.getValue())) |
---|
595 | { |
---|
596 | zoom_ni_loc.setValue(0); |
---|
597 | zoom_ibegin_loc.setValue(zoom_ibegin.getValue()); |
---|
598 | } |
---|
599 | else |
---|
600 | { |
---|
601 | int zoom_ibegin_loc_ = (zoom_ibegin.getValue() > ibegin.getValue()) |
---|
602 | ? zoom_ibegin.getValue() |
---|
603 | : ibegin.getValue(); |
---|
604 | int zoom_iend_loc_ = (zoom_iend < iend.getValue()) |
---|
605 | ? zoom_iend |
---|
606 | : iend.getValue(); |
---|
607 | int zoom_ni_loc_ = zoom_iend_loc_ - zoom_ibegin_loc_ + 1; |
---|
608 | |
---|
609 | zoom_ni_loc.setValue(zoom_ni_loc_); |
---|
610 | zoom_ibegin_loc.setValue(zoom_ibegin_loc_-ibegin.getValue()+1); |
---|
611 | } |
---|
612 | |
---|
613 | if ((zoom_jbegin.getValue() > jend.getValue()) || |
---|
614 | (zoom_jend < jbegin.getValue())) |
---|
615 | { |
---|
616 | zoom_nj_loc.setValue(0); |
---|
617 | zoom_jbegin_loc.setValue(zoom_jbegin.getValue()); |
---|
618 | } |
---|
619 | else |
---|
620 | { |
---|
621 | int zoom_jbegin_loc_ = (zoom_jbegin.getValue() > jbegin.getValue()) |
---|
622 | ? zoom_jbegin.getValue() |
---|
623 | : jbegin.getValue(); |
---|
624 | int zoom_jend_loc_ = (zoom_jend < jend.getValue()) |
---|
625 | ? zoom_jend |
---|
626 | : jend.getValue(); |
---|
627 | int zoom_nj_loc_ = zoom_jend_loc_ - zoom_jbegin_loc_ + 1; |
---|
628 | |
---|
629 | zoom_nj_loc.setValue(zoom_nj_loc_); |
---|
630 | zoom_jbegin_loc.setValue(zoom_jbegin_loc_-jbegin.getValue()+1); |
---|
631 | } |
---|
632 | } |
---|
633 | } |
---|
634 | |
---|
635 | //---------------------------------------------------------------- |
---|
636 | |
---|
637 | void CDomain::checkAttributes(void) |
---|
638 | { |
---|
639 | if (this->isChecked) return; |
---|
640 | shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; |
---|
641 | |
---|
642 | this->checkGlobalDomain(); |
---|
643 | this->checkLocalIDomain(); |
---|
644 | this->checkLocalJDomain(); |
---|
645 | |
---|
646 | this->checkZoom(); |
---|
647 | |
---|
648 | if (context->hasClient) |
---|
649 | { // CÎté client uniquement |
---|
650 | this->checkMask(); |
---|
651 | this->checkDomainData(); |
---|
652 | this->checkCompression(); |
---|
653 | |
---|
654 | this->ibegin_sub.push_back(this->ibegin.getValue()); |
---|
655 | this->jbegin_sub.push_back(this->jbegin.getValue()); |
---|
656 | this->iend_sub.push_back(this->iend.getValue()); |
---|
657 | this->jend_sub.push_back(this->jend.getValue()); |
---|
658 | |
---|
659 | this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue()); |
---|
660 | this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue()); |
---|
661 | this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue()); |
---|
662 | this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue()); |
---|
663 | |
---|
664 | this->latvalue_sub.push_back(this->latvalue.getValue()); |
---|
665 | this->lonvalue_sub.push_back(this->lonvalue.getValue()); |
---|
666 | |
---|
667 | |
---|
668 | // if (!this->isEmpty()) |
---|
669 | // { |
---|
670 | this->completeLonLatClient(); |
---|
671 | // } |
---|
672 | this->completeMask(); |
---|
673 | |
---|
674 | } |
---|
675 | else |
---|
676 | { // CÎté serveur uniquement |
---|
677 | // if (!this->isEmpty()) |
---|
678 | // ne sert plus // this->completeLonLatServer(); |
---|
679 | } |
---|
680 | |
---|
681 | if (context->hasClient) |
---|
682 | { |
---|
683 | computeConnectedServer() ; |
---|
684 | sendServerAttribut() ; |
---|
685 | sendLonLat() ; |
---|
686 | } |
---|
687 | |
---|
688 | this->isChecked = true; |
---|
689 | } |
---|
690 | |
---|
691 | void CDomain::sendServerAttribut(void) |
---|
692 | { |
---|
693 | int ni_srv=ni_glo.getValue() ; |
---|
694 | int ibegin_srv=1 ; |
---|
695 | int iend_srv=ni_glo.getValue() ; |
---|
696 | |
---|
697 | int nj_srv ; |
---|
698 | int jbegin_srv ; |
---|
699 | int jend_srv ; |
---|
700 | |
---|
701 | shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; |
---|
702 | CContextClient* client=context->client ; |
---|
703 | int nbServer=client->serverSize ; |
---|
704 | int serverRank=client->getServerLeader() ; |
---|
705 | |
---|
706 | jend_srv=0 ; |
---|
707 | for(int i=0;i<=serverRank;i++) |
---|
708 | { |
---|
709 | jbegin_srv=jend_srv+1 ; |
---|
710 | nj_srv=nj_glo.getValue()/nbServer ; |
---|
711 | if (i<nj_glo.getValue()%nbServer) nj_srv++ ; |
---|
712 | jend_srv=jbegin_srv+nj_srv-1 ; |
---|
713 | } |
---|
714 | |
---|
715 | CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; |
---|
716 | if (client->isServerLeader()) |
---|
717 | { |
---|
718 | CMessage msg ; |
---|
719 | msg<<this->getId() ; |
---|
720 | msg<<ni_srv<<ibegin_srv<<iend_srv<<nj_srv<<jbegin_srv<<jend_srv; |
---|
721 | event.push(client->getServerLeader(),1,msg) ; |
---|
722 | client->sendEvent(event) ; |
---|
723 | } |
---|
724 | else client->sendEvent(event) ; |
---|
725 | } |
---|
726 | |
---|
727 | void CDomain::computeConnectedServer(void) |
---|
728 | { |
---|
729 | int ib,ie,in; |
---|
730 | int jb,je,jn ; |
---|
731 | |
---|
732 | int ni_srv=ni_glo.getValue() ; |
---|
733 | int ibegin_srv=1 ; |
---|
734 | int iend_srv=ni_glo.getValue() ; |
---|
735 | |
---|
736 | int nj_serv,jbegin_srv, jend_srv ; |
---|
737 | int zoom_ibegin_srv,zoom_iend_srv,zoom_ni_srv ; |
---|
738 | int zoom_jbegin_srv,zoom_jend_srv,zoom_nj_srv ; |
---|
739 | |
---|
740 | ibegin_client=ibegin.getValue() ; iend_client=iend.getValue() ; ni_client=ni.getValue() ; |
---|
741 | jbegin_client=jbegin.getValue() ; jend_client=jend.getValue() ; nj_client=nj.getValue() ; |
---|
742 | |
---|
743 | shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; |
---|
744 | CContextClient* client=context->client ; |
---|
745 | int nbServer=client->serverSize ; |
---|
746 | |
---|
747 | // compute client zoom indices |
---|
748 | int zoom_iend=zoom_ibegin.getValue()+zoom_ni.getValue()-1 ; |
---|
749 | zoom_ibegin_client = ibegin_client > zoom_ibegin.getValue() ? ibegin_client : zoom_ibegin.getValue() ; |
---|
750 | zoom_iend_client = iend_client < zoom_iend ? iend_client : zoom_iend ; |
---|
751 | zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ; |
---|
752 | if (zoom_ni_client<0) zoom_ni_client=0 ; |
---|
753 | |
---|
754 | int zoom_jend=zoom_jbegin.getValue()+zoom_nj.getValue()-1 ; |
---|
755 | zoom_jbegin_client = jbegin_client > zoom_jbegin.getValue() ? jbegin_client : zoom_jbegin.getValue() ; |
---|
756 | zoom_jend_client = jend_client < zoom_jend ? jend_client : zoom_jend ; |
---|
757 | zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; |
---|
758 | if (zoom_nj_client<0) zoom_nj_client=0 ; |
---|
759 | |
---|
760 | // find how much client are connected to a server |
---|
761 | jend_srv=0 ; |
---|
762 | for(int ns=0;ns<nbServer;ns++) |
---|
763 | { |
---|
764 | jbegin_srv=jend_srv+1 ; |
---|
765 | nj_srv=nj_glo.getValue()/nbServer ; |
---|
766 | if (ns<nj_glo.getValue()%nbServer) nj_srv++ ; |
---|
767 | jend_srv=jbegin_srv+nj_srv-1 ; |
---|
768 | |
---|
769 | ib = ibegin_client>ibegin_srv ? ibegin_client : ibegin_srv ; |
---|
770 | ie= iend_client< iend_srv? iend_client : iend_srv ; |
---|
771 | in=ie-ib+1 ; |
---|
772 | if (in<0) in=0 ; |
---|
773 | |
---|
774 | jb= jbegin_client>jbegin_srv ? jbegin_client : jbegin_srv ; |
---|
775 | je= jend_client<jend_srv ? jend_client : jend_srv ; |
---|
776 | jn=je-jb+1 ; |
---|
777 | if (jn<0) jn=0 ; |
---|
778 | |
---|
779 | if (in>0 && jn>0) |
---|
780 | { |
---|
781 | zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; |
---|
782 | zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; |
---|
783 | zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; |
---|
784 | if (zoom_ni_srv<0) zoom_ni_srv=0 ; |
---|
785 | |
---|
786 | zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; |
---|
787 | zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; |
---|
788 | zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; |
---|
789 | if (zoom_nj_srv<0) zoom_nj_srv=0 ; |
---|
790 | |
---|
791 | if (zoom_ni_srv>0 && zoom_nj_srv>0 && zoom_ni_client>0 && zoom_nj_client>0) |
---|
792 | { |
---|
793 | ib = zoom_ibegin_client>zoom_ibegin_srv ? zoom_ibegin_client : zoom_ibegin_srv ; |
---|
794 | ie=zoom_iend_client<zoom_iend_srv?zoom_iend_client:zoom_iend_srv ; |
---|
795 | in=ie-ib+1 ; |
---|
796 | if (in<0) in=0 ; |
---|
797 | |
---|
798 | jb=zoom_jbegin_client>zoom_jbegin_srv?zoom_jbegin_client:zoom_jbegin_srv ; |
---|
799 | je=zoom_jend_client<zoom_jend_srv?zoom_jend_client:zoom_jend_srv ; |
---|
800 | jn=je-jb+1 ; |
---|
801 | if (jn<0) jn=0 ; |
---|
802 | } |
---|
803 | else |
---|
804 | { |
---|
805 | ib=1 ; ie=0 ; in=0 ; |
---|
806 | jb=1 ; je=0 ; jn=0 ; |
---|
807 | } |
---|
808 | |
---|
809 | // if (in>0 && jn>0) |
---|
810 | // { |
---|
811 | connectedServer.push_back(ns) ; |
---|
812 | ib_srv.push_back(ib) ; |
---|
813 | ie_srv.push_back(ie) ; |
---|
814 | in_srv.push_back(in) ; |
---|
815 | jb_srv.push_back(jb) ; |
---|
816 | je_srv.push_back(je) ; |
---|
817 | jn_srv.push_back(jn) ; |
---|
818 | // } |
---|
819 | |
---|
820 | } |
---|
821 | } |
---|
822 | int nbConnectedServer=connectedServer.size() ; |
---|
823 | int* recvCount=new int[client->clientSize] ; |
---|
824 | int* displ=new int[client->clientSize] ; |
---|
825 | int* sendBuff=new int[nbConnectedServer] ; |
---|
826 | valarray<int> nbClient(0,client->serverSize) ; |
---|
827 | |
---|
828 | for(int n=0;n<nbConnectedServer;n++) sendBuff[n]=connectedServer[n] ; |
---|
829 | |
---|
830 | // get connected server for everybody |
---|
831 | MPI_Allgather(&nbConnectedServer,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm) ; |
---|
832 | |
---|
833 | displ[0]=0 ; |
---|
834 | for(int n=1;n<client->clientSize;n++) displ[n]=displ[n-1]+recvCount[n-1] ; |
---|
835 | int recvSize=displ[client->clientSize-1]+recvCount[client->clientSize-1] ; |
---|
836 | int* recvBuff=new int[recvSize] ; |
---|
837 | |
---|
838 | |
---|
839 | MPI_Allgatherv(sendBuff,nbConnectedServer,MPI_INT,recvBuff,recvCount,displ,MPI_INT,client->intraComm) ; |
---|
840 | for(int n=0;n<recvSize;n++) nbClient[recvBuff[n]]++ ; |
---|
841 | |
---|
842 | for(int n=0;n<nbConnectedServer;n++) nbSenders.push_back(nbClient[connectedServer[n]]) ; |
---|
843 | |
---|
844 | delete [] recvCount ; |
---|
845 | delete [] displ ; |
---|
846 | delete [] sendBuff ; |
---|
847 | delete [] recvBuff ; |
---|
848 | } |
---|
849 | |
---|
850 | void CDomain::sendLonLat(void) |
---|
851 | { |
---|
852 | shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; |
---|
853 | CContextClient* client=context->client ; |
---|
854 | // send lon lat for each connected server |
---|
855 | CEventClient event(getType(),EVENT_ID_LON_LAT) ; |
---|
856 | |
---|
857 | ARRAY(double, 1) lonvalue_client = lonvalue.getValue(), |
---|
858 | latvalue_client = latvalue.getValue(); |
---|
859 | |
---|
860 | int ib,ie,in ; |
---|
861 | int jb,je,jn ; |
---|
862 | |
---|
863 | list<shared_ptr<CMessage> > list_msg ; |
---|
864 | list<ARRAY(double,1)> list_indi,list_indj,list_lon,list_lat ; |
---|
865 | |
---|
866 | for(int ns=0;ns<connectedServer.size();ns++) |
---|
867 | { |
---|
868 | ib=ib_srv[ns] ; ie=ie_srv[ns] ; in=in_srv[ns] ; |
---|
869 | jb=jb_srv[ns] ; je=je_srv[ns] ; jn=jn_srv[ns] ; |
---|
870 | |
---|
871 | ARRAY_CREATE(indi,double,1,[in*jn]) ; |
---|
872 | ARRAY_CREATE(indj,double,1,[in*jn]) ; |
---|
873 | ARRAY_CREATE(lon,double,1,[in*jn]) ; |
---|
874 | ARRAY_CREATE(lat,double,1,[in*jn]) ; |
---|
875 | |
---|
876 | |
---|
877 | int ind_client,ind_loc ; |
---|
878 | |
---|
879 | for(int j=jb;j<=je;j++) |
---|
880 | for(int i=ib;i<=ie;i++) |
---|
881 | { |
---|
882 | ind_client=(i-zoom_ibegin_client)+(j-zoom_jbegin_client)*zoom_ni_client ; |
---|
883 | ind_loc=(i-ib)+(j-jb)*in ; |
---|
884 | (*lon)[ind_loc]=(*lonvalue_client)[ind_client] ; |
---|
885 | (*lat)[ind_loc]=(*latvalue_client)[ind_client] ; |
---|
886 | (*indi)[ind_loc]=i ; |
---|
887 | (*indj)[ind_loc]=j ; |
---|
888 | } |
---|
889 | |
---|
890 | list_indi.push_back(indi) ; list_indj.push_back(indj) ; |
---|
891 | list_lon.push_back(lon) ; list_lat.push_back(lat) ; |
---|
892 | list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; |
---|
893 | |
---|
894 | *list_msg.back()<<this->getId() ; |
---|
895 | *list_msg.back()<<list_indi.back()<<list_indj.back()<<list_lon.back()<<list_lat.back() ; |
---|
896 | event.push(connectedServer[ns],nbSenders[ns],*list_msg.back()) ; |
---|
897 | } |
---|
898 | |
---|
899 | client->sendEvent(event) ; |
---|
900 | } |
---|
901 | |
---|
902 | bool CDomain::dispatchEvent(CEventServer& event) |
---|
903 | { |
---|
904 | |
---|
905 | if (SuperClass::dispatchEvent(event)) return true ; |
---|
906 | else |
---|
907 | { |
---|
908 | switch(event.type) |
---|
909 | { |
---|
910 | case EVENT_ID_SERVER_ATTRIBUT : |
---|
911 | recvServerAttribut(event) ; |
---|
912 | return true ; |
---|
913 | break ; |
---|
914 | case EVENT_ID_LON_LAT : |
---|
915 | recvLonLat(event) ; |
---|
916 | return true ; |
---|
917 | break ; |
---|
918 | default : |
---|
919 | ERROR("bool CContext::dispatchEvent(CEventServer& event)", |
---|
920 | <<"Unknown Event") ; |
---|
921 | return false ; |
---|
922 | } |
---|
923 | } |
---|
924 | } |
---|
925 | |
---|
926 | void CDomain::recvServerAttribut(CEventServer& event) |
---|
927 | { |
---|
928 | CBufferIn* buffer=event.subEvents.begin()->buffer; |
---|
929 | string domainId ; |
---|
930 | *buffer>>domainId ; |
---|
931 | get(domainId)->recvServerAttribut(*buffer) ; |
---|
932 | } |
---|
933 | |
---|
934 | void CDomain::recvServerAttribut(CBufferIn& buffer) |
---|
935 | { |
---|
936 | int zoom_iend=zoom_ibegin.getValue()+zoom_ni.getValue()-1 ; |
---|
937 | int zoom_jend=zoom_jbegin.getValue()+zoom_nj.getValue()-1 ; |
---|
938 | |
---|
939 | buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; |
---|
940 | |
---|
941 | zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; |
---|
942 | zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; |
---|
943 | zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; |
---|
944 | |
---|
945 | zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; |
---|
946 | zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; |
---|
947 | zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; |
---|
948 | |
---|
949 | if (zoom_ni_srv<=0 || zoom_nj_srv<=0) |
---|
950 | { |
---|
951 | zoom_ibegin_srv=1 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; |
---|
952 | zoom_jbegin_srv=1 ; zoom_jend_srv=0 ; zoom_nj_srv=0 ; |
---|
953 | } |
---|
954 | |
---|
955 | lonvalue_srv->resize(extents[zoom_ni_srv*zoom_nj_srv]) ; |
---|
956 | latvalue_srv->resize(extents[zoom_ni_srv*zoom_nj_srv]) ; |
---|
957 | } |
---|
958 | |
---|
959 | void CDomain::recvLonLat(CEventServer& event) |
---|
960 | { |
---|
961 | list<CEventServer::SSubEvent>::iterator it ; |
---|
962 | for (it=event.subEvents.begin();it!=event.subEvents.end();++it) |
---|
963 | { |
---|
964 | CBufferIn* buffer=it->buffer; |
---|
965 | string domainId ; |
---|
966 | *buffer>>domainId ; |
---|
967 | get(domainId)->recvLonLat(*buffer) ; |
---|
968 | } |
---|
969 | } |
---|
970 | |
---|
971 | void CDomain::recvLonLat(CBufferIn& buffer) |
---|
972 | { |
---|
973 | ARRAY_CREATE(indi,double,1,[0]) ; |
---|
974 | ARRAY_CREATE(indj,double,1,[0]) ; |
---|
975 | ARRAY_CREATE(lon,double,1,[0]) ; |
---|
976 | ARRAY_CREATE(lat,double,1,[0]) ; |
---|
977 | |
---|
978 | buffer>>indi>>indj>>lon>>lat ; |
---|
979 | int i,j,ind_srv ; |
---|
980 | |
---|
981 | for(int ind=0;ind<indi->num_elements();ind++) |
---|
982 | { |
---|
983 | i=(*indi)[ind] ; j=(*indj)[ind] ; |
---|
984 | ind_srv=(i-zoom_ibegin_srv)+(j-zoom_jbegin_srv)*zoom_ni_srv ; |
---|
985 | (*lonvalue_srv)[ind_srv]=(*lon)[ind] ; |
---|
986 | (*latvalue_srv)[ind_srv]=(*lat)[ind] ; |
---|
987 | } |
---|
988 | } |
---|
989 | //---------------------------------------------------------------- |
---|
990 | |
---|
991 | void CDomain::completeMask(void) |
---|
992 | { |
---|
993 | this->local_mask->resize(boost::extents[zoom_ni_loc.getValue()][zoom_nj_loc.getValue()]); |
---|
994 | } |
---|
995 | |
---|
996 | //---------------------------------------------------------------- |
---|
997 | |
---|
998 | ARRAY(int, 2) CDomain::getLocalMask(void) const |
---|
999 | { |
---|
1000 | return (this->local_mask); |
---|
1001 | } |
---|
1002 | |
---|
1003 | //---------------------------------------------------------------- |
---|
1004 | |
---|
1005 | const std::vector<int> & CDomain::getIBeginSub(void) const |
---|
1006 | { |
---|
1007 | return (this->ibegin_sub); |
---|
1008 | } |
---|
1009 | |
---|
1010 | //---------------------------------------------------------------- |
---|
1011 | |
---|
1012 | const std::vector<int> & CDomain::getIBeginZoomSub(void) const |
---|
1013 | { |
---|
1014 | return (this->ibegin_zoom_sub); |
---|
1015 | } |
---|
1016 | |
---|
1017 | const std::vector<int> & CDomain::getNiZoomSub(void) const |
---|
1018 | { |
---|
1019 | return (this->ni_zoom_sub); |
---|
1020 | } |
---|
1021 | |
---|
1022 | //---------------------------------------------------------------- |
---|
1023 | |
---|
1024 | const std::vector<int> & CDomain::getIEndSub(void) const |
---|
1025 | { |
---|
1026 | return (this->iend_sub); |
---|
1027 | } |
---|
1028 | |
---|
1029 | //---------------------------------------------------------------- |
---|
1030 | |
---|
1031 | const std::vector<int> & CDomain::getJBeginSub(void) const |
---|
1032 | { |
---|
1033 | return (this->jbegin_sub); |
---|
1034 | } |
---|
1035 | |
---|
1036 | //---------------------------------------------------------------- |
---|
1037 | |
---|
1038 | const std::vector<int> & CDomain::getJBeginZoomSub(void) const |
---|
1039 | { |
---|
1040 | return (this->jbegin_zoom_sub); |
---|
1041 | } |
---|
1042 | |
---|
1043 | const std::vector<int> & CDomain::getNjZoomSub(void) const |
---|
1044 | { |
---|
1045 | return (this->nj_zoom_sub); |
---|
1046 | } |
---|
1047 | |
---|
1048 | |
---|
1049 | //---------------------------------------------------------------- |
---|
1050 | |
---|
1051 | const std::vector<int> & CDomain::getJEndSub(void) const |
---|
1052 | { |
---|
1053 | return (this->jend_sub); |
---|
1054 | } |
---|
1055 | |
---|
1056 | //---------------------------------------------------------------- |
---|
1057 | |
---|
1058 | const std::vector<ARRAY(double, 1)> & CDomain::getLonValueSub(void) const |
---|
1059 | { |
---|
1060 | return (this->lonvalue_sub); |
---|
1061 | } |
---|
1062 | |
---|
1063 | //---------------------------------------------------------------- |
---|
1064 | |
---|
1065 | const std::vector<ARRAY(double, 1)> & CDomain::getLatValueSub(void) const |
---|
1066 | { |
---|
1067 | return (this->latvalue_sub); |
---|
1068 | } |
---|
1069 | |
---|
1070 | ///--------------------------------------------------------------- |
---|
1071 | |
---|
1072 | } // namespace tree |
---|
1073 | } // namespace xmlioserver |
---|