[219] | 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 | |
---|
[274] | 9 | #include "tree_manager.hpp" |
---|
| 10 | |
---|
[219] | 11 | #include <algorithm> |
---|
| 12 | |
---|
| 13 | namespace xmlioserver { |
---|
| 14 | namespace tree { |
---|
| 15 | |
---|
| 16 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 17 | |
---|
| 18 | CDomain::CDomain(void) |
---|
| 19 | : CObjectTemplate<CDomain>(), CDomainAttributes() |
---|
| 20 | , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles() |
---|
| 21 | , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub() |
---|
[278] | 22 | , ibegin_zoom_sub(), jbegin_zoom_sub(), ni_zoom_sub(), nj_zoom_sub() |
---|
[219] | 23 | , lonvalue_sub(), latvalue_sub() |
---|
| 24 | { /* Ne rien faire de plus */ } |
---|
| 25 | |
---|
| 26 | CDomain::CDomain(const StdString & id) |
---|
| 27 | : CObjectTemplate<CDomain>(id), CDomainAttributes() |
---|
| 28 | , isChecked(false), local_mask(new CArray<int, 2>(boost::extents[0][0])), relFiles() |
---|
| 29 | , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub() |
---|
[278] | 30 | , ibegin_zoom_sub(), jbegin_zoom_sub(),ni_zoom_sub(), nj_zoom_sub() |
---|
[219] | 31 | , lonvalue_sub(), latvalue_sub() |
---|
| 32 | { /* Ne rien faire de plus */ } |
---|
| 33 | |
---|
| 34 | CDomain::~CDomain(void) |
---|
| 35 | { |
---|
| 36 | this->local_mask.reset(); |
---|
| 37 | for (StdSize i = 0; i < this->lonvalue_sub.size(); i++) |
---|
| 38 | { |
---|
| 39 | this->lonvalue_sub[i].reset(); |
---|
| 40 | this->latvalue_sub[i].reset(); |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | ///--------------------------------------------------------------- |
---|
| 45 | |
---|
| 46 | const std::set<StdString> & CDomain::getRelFiles(void) const |
---|
| 47 | { |
---|
| 48 | return (this->relFiles); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | //---------------------------------------------------------------- |
---|
| 52 | |
---|
| 53 | bool CDomain::hasZoom(void) const |
---|
| 54 | { |
---|
| 55 | return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && |
---|
| 56 | (this->zoom_nj.getValue() != this->nj_glo.getValue())); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | //---------------------------------------------------------------- |
---|
| 60 | |
---|
| 61 | bool CDomain::isEmpty(void) const |
---|
| 62 | { |
---|
| 63 | return ((this->zoom_ni_loc.getValue() == 0) || |
---|
| 64 | (this->zoom_nj_loc.getValue() == 0)); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | //---------------------------------------------------------------- |
---|
| 68 | |
---|
| 69 | bool CDomain::IsWritten(const StdString & filename) const |
---|
| 70 | { |
---|
| 71 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | //---------------------------------------------------------------- |
---|
| 75 | |
---|
| 76 | void CDomain::addRelFile(const StdString & filename) |
---|
| 77 | { |
---|
| 78 | this->relFiles.insert(filename); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | //---------------------------------------------------------------- |
---|
| 82 | |
---|
| 83 | void CDomain::fromBinary(StdIStream & is) |
---|
| 84 | { |
---|
| 85 | SuperClass::fromBinary(is); |
---|
| 86 | |
---|
[274] | 87 | if ( !this->ibegin.isEmpty() && |
---|
| 88 | !this->jbegin.isEmpty() && |
---|
| 89 | !this->iend.isEmpty() && |
---|
| 90 | !this->jend.isEmpty() && |
---|
| 91 | !this->latvalue.isEmpty() && |
---|
| 92 | !this->lonvalue.isEmpty()) |
---|
| 93 | { |
---|
[219] | 94 | |
---|
[274] | 95 | this->ibegin_sub.push_back(this->ibegin.getValue()); |
---|
| 96 | this->jbegin_sub.push_back(this->jbegin.getValue()); |
---|
| 97 | this->iend_sub.push_back(this->iend.getValue()); |
---|
| 98 | this->jend_sub.push_back(this->jend.getValue()); |
---|
| 99 | |
---|
| 100 | this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue()); |
---|
| 101 | this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue()); |
---|
[278] | 102 | this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue()); |
---|
| 103 | this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue()); |
---|
[219] | 104 | |
---|
[274] | 105 | this->latvalue_sub.push_back(this->latvalue.getValue()); |
---|
| 106 | this->lonvalue_sub.push_back(this->lonvalue.getValue()); |
---|
| 107 | } |
---|
| 108 | |
---|
[219] | 109 | #define CLEAR_ATT(name_)\ |
---|
| 110 | SuperClassAttribute::operator[](#name_)->clear() |
---|
| 111 | |
---|
| 112 | CLEAR_ATT(mask); |
---|
| 113 | CLEAR_ATT(data_n_index); |
---|
| 114 | CLEAR_ATT(data_i_index); |
---|
| 115 | CLEAR_ATT(data_j_index); |
---|
| 116 | |
---|
| 117 | CLEAR_ATT(data_ni); |
---|
| 118 | CLEAR_ATT(data_nj); |
---|
| 119 | CLEAR_ATT(data_ibegin); |
---|
| 120 | CLEAR_ATT(data_jbegin); |
---|
| 121 | |
---|
| 122 | CLEAR_ATT(ni); |
---|
| 123 | CLEAR_ATT(nj); |
---|
| 124 | |
---|
| 125 | #undef CLEAR_ATT |
---|
| 126 | |
---|
[274] | 127 | if ( !this->ibegin.isEmpty() && |
---|
| 128 | !this->jbegin.isEmpty() && |
---|
| 129 | !this->iend.isEmpty() && |
---|
| 130 | !this->jend.isEmpty() && |
---|
| 131 | !this->latvalue.isEmpty() && |
---|
| 132 | !this->lonvalue.isEmpty()) |
---|
| 133 | { |
---|
| 134 | |
---|
| 135 | this->ibegin.setValue(*std::min_element(this->ibegin_sub.begin(),this->ibegin_sub.end())); |
---|
| 136 | this->jbegin.setValue(*std::min_element(this->jbegin_sub.begin(),this->jbegin_sub.end())); |
---|
| 137 | this->iend.setValue(*std::max_element(this->iend_sub.begin(),this->iend_sub.end())); |
---|
| 138 | this->jend.setValue(*std::max_element(this->jend_sub.begin(),this->jend_sub.end())); |
---|
| 139 | } |
---|
[219] | 140 | } |
---|
| 141 | |
---|
| 142 | //---------------------------------------------------------------- |
---|
| 143 | |
---|
| 144 | StdString CDomain::GetName(void) { return (StdString("domain")); } |
---|
| 145 | StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } |
---|
| 146 | ENodeType CDomain::GetType(void) { return (eDomain); } |
---|
| 147 | |
---|
| 148 | //---------------------------------------------------------------- |
---|
| 149 | |
---|
| 150 | void CDomain::checkGlobalDomain(void) |
---|
| 151 | { |
---|
| 152 | if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || |
---|
[274] | 153 | (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) |
---|
| 154 | { |
---|
[219] | 155 | ERROR("CDomain::checkAttributes(void)", |
---|
| 156 | << "[ Id = " << this->getId() << " ] " |
---|
| 157 | << "Le domaine global est mal défini," |
---|
[274] | 158 | << " vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") |
---|
| 159 | } |
---|
[219] | 160 | } |
---|
| 161 | |
---|
| 162 | //---------------------------------------------------------------- |
---|
| 163 | |
---|
| 164 | void CDomain::checkLocalIDomain(void) |
---|
| 165 | { |
---|
| 166 | if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty()) |
---|
| 167 | iend.setValue(ibegin.getValue() + ni.getValue() - 1) ; |
---|
| 168 | |
---|
| 169 | else if (!ni.isEmpty() && !iend.isEmpty() && ibegin.isEmpty()) |
---|
| 170 | ibegin.setValue( - ni.getValue() + iend.getValue() + 1) ; |
---|
| 171 | |
---|
| 172 | else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty()) |
---|
| 173 | ni.setValue(iend.getValue() - ibegin.getValue() + 1) ; |
---|
| 174 | |
---|
| 175 | else if (!ibegin.isEmpty() && !iend.isEmpty() && |
---|
| 176 | !ni.isEmpty() && (iend.getValue() != ibegin.getValue() + ni.getValue() - 1)) |
---|
| 177 | { |
---|
| 178 | ERROR("CDomain::checkAttributes(void)", |
---|
| 179 | << "Le domaine est mal défini," |
---|
| 180 | << " iend est différent de (ibegin + ni - 1) !") ; |
---|
| 181 | } |
---|
| 182 | else |
---|
| 183 | { |
---|
| 184 | ERROR("CDomain::checkAttributes(void)", |
---|
| 185 | << "Le domaine est mal défini," |
---|
| 186 | << " deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || |
---|
| 191 | ibegin.getValue() < 1 || iend.getValue() > ni_glo.getValue()) |
---|
| 192 | ERROR("CDomain::checkAttributes(void)", |
---|
| 193 | << "[ Id = " << this->getId() << " ] " |
---|
| 194 | << "Domaine local mal défini," |
---|
| 195 | << " vérifiez les valeurs ni, ni_glo, ibegin, iend") ; |
---|
| 196 | |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | //---------------------------------------------------------------- |
---|
| 200 | |
---|
| 201 | void CDomain::checkLocalJDomain(void) |
---|
| 202 | { |
---|
| 203 | if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty()) |
---|
| 204 | jend.setValue(jbegin.getValue() + nj.getValue() - 1) ; |
---|
| 205 | |
---|
| 206 | else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty()) |
---|
| 207 | jbegin.setValue( - nj.getValue() + jend.getValue() + 1) ; |
---|
| 208 | |
---|
| 209 | else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty()) |
---|
| 210 | nj.setValue(jend.getValue() - jbegin.getValue() + 1) ; |
---|
| 211 | |
---|
| 212 | else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty() && |
---|
| 213 | (jend.getValue() != jbegin.getValue() + nj.getValue() - 1)) |
---|
| 214 | { |
---|
| 215 | ERROR("CDomain::checkAttributes(void)", |
---|
| 216 | << "Le domaine est mal défini," |
---|
| 217 | << " iend est différent de (jbegin + nj - 1) !") ; |
---|
| 218 | } |
---|
| 219 | else |
---|
| 220 | { |
---|
| 221 | ERROR("CDomain::checkAttributes(void)", |
---|
| 222 | << "Le domaine est mal défini," |
---|
| 223 | << " deux valeurs au moins parmis jend, jbegin, nj doivent être définies !") ; |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() || |
---|
| 227 | jbegin.getValue() < 1 || jend.getValue() > nj_glo.getValue()) |
---|
| 228 | ERROR("CDomain::checkAttributes(void)", |
---|
| 229 | << "Domaine local mal défini," |
---|
| 230 | << " vérifiez les valeurs nj, nj_glo, jbegin, jend") ; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | //---------------------------------------------------------------- |
---|
| 234 | |
---|
| 235 | void CDomain::checkMask(void) |
---|
| 236 | { |
---|
| 237 | using namespace std; |
---|
| 238 | |
---|
| 239 | int ibegin_mask = 0, |
---|
| 240 | jbegin_mask = 0, |
---|
| 241 | iend_mask = iend.getValue() - ibegin.getValue(), |
---|
| 242 | jend_mask = jend.getValue() - jbegin.getValue(); |
---|
| 243 | |
---|
| 244 | if (!zoom_ibegin.isEmpty()) |
---|
| 245 | { |
---|
| 246 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
| 247 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
| 248 | |
---|
| 249 | ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); |
---|
| 250 | jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); |
---|
| 251 | iend_mask = min (iend.getValue(), zoom_iend); |
---|
| 252 | jend_mask = min (jend.getValue(), zoom_jend); |
---|
| 253 | |
---|
| 254 | ibegin_mask -= ibegin.getValue(); |
---|
| 255 | jbegin_mask -= jbegin.getValue(); |
---|
| 256 | iend_mask -= ibegin.getValue(); |
---|
| 257 | jend_mask -= jbegin.getValue(); |
---|
| 258 | } |
---|
| 259 | |
---|
| 260 | //~ std::cout << "-------------------" << std::endl |
---|
| 261 | //~ << "zoom : " << std::boolalpha << this->hasZoom() << std::endl |
---|
| 262 | //~ << "size : " << ni.getValue() << " X " << nj.getValue() << std::endl |
---|
| 263 | //~ << "it : " << ibegin.getValue() << ", " << iend.getValue() << std::endl |
---|
| 264 | //~ << "jt : " << jbegin.getValue() << ", " << jend.getValue() << std::endl |
---|
| 265 | //~ << "im : " << ibegin_mask << ", " << iend_mask << std::endl |
---|
| 266 | //~ << "jm : " << jbegin_mask << ", " << jend_mask << std::endl |
---|
| 267 | //~ << "-------------------" << std::endl; |
---|
| 268 | |
---|
| 269 | if (!mask.isEmpty()) |
---|
| 270 | { |
---|
| 271 | ARRAY(bool, 2) mask_ = mask.getValue(); |
---|
| 272 | unsigned int niu = ni.getValue(), nju = nj.getValue(); |
---|
| 273 | if ((mask_->shape()[0] != niu) || |
---|
| 274 | (mask_->shape()[1] != nju)) |
---|
| 275 | ERROR("CDomain::checkAttributes(void)", |
---|
| 276 | <<"Le masque n'a pas la même taille que le domaine local") ; |
---|
| 277 | |
---|
| 278 | for (int i = 0; i < ni.getValue(); i++) |
---|
| 279 | { |
---|
| 280 | for (int j = 0; j < nj.getValue(); j++) |
---|
| 281 | { |
---|
| 282 | if (i < ibegin_mask && i > iend_mask && |
---|
| 283 | j < jbegin_mask && j > jend_mask ) |
---|
| 284 | (*mask_)[i][j] = false; |
---|
| 285 | } |
---|
| 286 | } |
---|
| 287 | } |
---|
| 288 | else // (!mask.hasValue()) |
---|
| 289 | { // Si aucun masque n'est défini, |
---|
| 290 | // on en crée un nouveau qui valide l'intégralité du domaine. |
---|
| 291 | ARRAY_CREATE(__arr, bool, 2, [ni.getValue()][nj.getValue()]); |
---|
| 292 | for (int i = 0; i < ni.getValue(); i++) |
---|
| 293 | { |
---|
| 294 | for (int j = 0; j < nj.getValue(); j++) |
---|
| 295 | { |
---|
| 296 | if (i >= ibegin_mask && i <= iend_mask && |
---|
| 297 | j >= jbegin_mask && j <= jend_mask ) |
---|
| 298 | (*__arr)[i][j] = true; |
---|
| 299 | else (*__arr)[i][j] = false; |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | mask.setValue(__arr); |
---|
| 304 | __arr.reset(); |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | |
---|
| 309 | //---------------------------------------------------------------- |
---|
| 310 | |
---|
| 311 | void CDomain::checkDomainData(void) |
---|
| 312 | { |
---|
| 313 | if (!data_dim.isEmpty() && |
---|
| 314 | !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) |
---|
| 315 | { |
---|
| 316 | ERROR("CDomain::checkAttributes(void)", |
---|
| 317 | << "Dimension des données non comptatible (doit être 1 ou 2) !") ; |
---|
| 318 | } |
---|
| 319 | else if (data_dim.isEmpty()) |
---|
| 320 | { |
---|
| 321 | ERROR("CDomain::checkAttributes(void)", |
---|
| 322 | << "Dimension des données non définie !") ; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | if (data_ibegin.isEmpty()) |
---|
| 326 | data_ibegin.setValue(0) ; |
---|
| 327 | if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) |
---|
| 328 | data_jbegin.setValue(0) ; |
---|
| 329 | |
---|
| 330 | if (!data_ni.isEmpty() && (data_ni.getValue() <= 0)) |
---|
| 331 | { |
---|
| 332 | ERROR("CDomain::checkAttributes(void)", |
---|
| 333 | << "Dimension des données négative (data_ni).") ; |
---|
| 334 | } |
---|
| 335 | else if (data_ni.isEmpty()) |
---|
| 336 | { |
---|
| 337 | data_ni.setValue((data_dim.getValue() == 1) |
---|
| 338 | ? (ni.getValue() * nj.getValue()) |
---|
| 339 | : ni.getValue()); |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | if (data_dim.getValue() == 2) |
---|
| 343 | { |
---|
| 344 | if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) |
---|
| 345 | { |
---|
| 346 | ERROR("CDomain::checkAttributes(void)", |
---|
| 347 | << "Dimension des données négative (data_nj).") ; |
---|
| 348 | } |
---|
| 349 | else if (data_nj.isEmpty()) |
---|
| 350 | data_nj.setValue(nj.getValue()) ; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | } |
---|
| 354 | |
---|
| 355 | //---------------------------------------------------------------- |
---|
| 356 | |
---|
| 357 | void CDomain::checkCompression(void) |
---|
| 358 | { |
---|
| 359 | if (!data_i_index.isEmpty()) |
---|
| 360 | { |
---|
| 361 | int ssize = data_i_index.getValue()->size(); |
---|
| 362 | if (!data_n_index.isEmpty() && |
---|
| 363 | (data_n_index.getValue() != ssize)) |
---|
| 364 | { |
---|
| 365 | ERROR("CDomain::checkAttributes(void)", |
---|
| 366 | <<"Dimension data_i_index incompatible avec data_n_index.") ; |
---|
| 367 | } |
---|
| 368 | else if (data_n_index.isEmpty()) |
---|
| 369 | data_n_index.setValue(ssize) ; |
---|
| 370 | |
---|
| 371 | if (data_dim.getValue() == 2) |
---|
| 372 | { |
---|
| 373 | if (!data_j_index.isEmpty() && |
---|
| 374 | (data_j_index.getValue()->size() != data_i_index.getValue()->size())) |
---|
| 375 | { |
---|
| 376 | ERROR("CDomain::checkAttributes(void)", |
---|
| 377 | <<"Dimension data_j_index incompatible avec data_i_index.") ; |
---|
| 378 | } |
---|
| 379 | else if (data_j_index.isEmpty()) |
---|
| 380 | { |
---|
| 381 | ERROR("CDomain::checkAttributes(void)", |
---|
| 382 | <<"La donnée data_j_index doit être renseignée !") ; |
---|
| 383 | } |
---|
| 384 | } |
---|
| 385 | } |
---|
| 386 | else |
---|
| 387 | { |
---|
| 388 | if (!data_n_index.isEmpty() || |
---|
| 389 | ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) |
---|
| 390 | ERROR("CDomain::checkAttributes(void)", << "data_i_index non défini") ; |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | if (data_n_index.isEmpty()) |
---|
| 394 | { // -> bloc re-vérifié OK |
---|
| 395 | if (data_dim.getValue() == 1) |
---|
| 396 | { |
---|
| 397 | const int dni = data_ni.getValue(); |
---|
| 398 | ARRAY_CREATE(__arri, int, 1, [dni]); |
---|
| 399 | data_n_index.setValue(dni); |
---|
| 400 | for (int i = 0; i < dni; i++) |
---|
| 401 | (*__arri)[i] = i+1 ; |
---|
| 402 | data_i_index.setValue(__arri) ; |
---|
| 403 | } |
---|
| 404 | else // (data_dim == 2) |
---|
| 405 | { |
---|
| 406 | const int dni = data_ni.getValue() * data_nj.getValue(); |
---|
| 407 | |
---|
| 408 | ARRAY_CREATE(__arri, int, 1, [dni]); |
---|
| 409 | ARRAY_CREATE(__arrj, int, 1, [dni]); |
---|
| 410 | data_n_index.setValue(dni); |
---|
| 411 | |
---|
[266] | 412 | //for(int count = 0, i = 0; i < data_ni.getValue(); i++) |
---|
| 413 | //for(int j = 0; j < data_nj.getValue(); j++, count++) |
---|
| 414 | |
---|
| 415 | for(int count = 0, j = 0; j < data_nj.getValue(); j++) |
---|
[219] | 416 | { |
---|
[266] | 417 | for(int i = 0; i < data_ni.getValue(); i++, count++) |
---|
[219] | 418 | { |
---|
| 419 | (*__arri)[count] = i+1 ; |
---|
| 420 | (*__arrj)[count] = j+1 ; |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | data_i_index.setValue(__arri) ; |
---|
| 424 | data_j_index.setValue(__arrj) ; |
---|
| 425 | __arri.reset(); |
---|
| 426 | __arrj.reset(); |
---|
| 427 | } |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | //---------------------------------------------------------------- |
---|
| 432 | |
---|
[266] | 433 | void CDomain::completeLonLatClient(void) |
---|
[219] | 434 | { |
---|
| 435 | ARRAY_CREATE(lonvalue_temp, double, 1, [0]); |
---|
| 436 | ARRAY_CREATE(latvalue_temp, double, 1, [0]); |
---|
| 437 | |
---|
[266] | 438 | const int zoom_ibegin_client = zoom_ibegin_loc.getValue(), |
---|
| 439 | zoom_jbegin_client = zoom_jbegin_loc.getValue(), |
---|
| 440 | zoom_ni_client = zoom_ni_loc.getValue(), |
---|
| 441 | zoom_nj_client = zoom_nj_loc.getValue(); |
---|
| 442 | |
---|
| 443 | ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(), |
---|
| 444 | latvalue_ = this->latvalue.getValue(); |
---|
| 445 | |
---|
| 446 | if (this->data_dim.getValue() == 2) |
---|
| 447 | { |
---|
| 448 | StdSize dm = zoom_ni_client * zoom_nj_client; |
---|
| 449 | |
---|
| 450 | lonvalue_temp->resize(boost::extents[dm]); |
---|
| 451 | latvalue_temp->resize(boost::extents[dm]); |
---|
| 452 | |
---|
| 453 | for (int i = 0; i < zoom_ni_client; i++) |
---|
| 454 | { |
---|
| 455 | for (int j = 0; j < zoom_nj_client; j++) |
---|
| 456 | { |
---|
[278] | 457 | (*lonvalue_temp)[i + j * zoom_ni_client] = |
---|
| 458 | (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; |
---|
| 459 | (*latvalue_temp)[i + j * zoom_ni_client] = |
---|
| 460 | (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; |
---|
[266] | 461 | } |
---|
| 462 | } |
---|
| 463 | this->lonvalue.setValue(lonvalue_temp); |
---|
| 464 | this->latvalue.setValue(latvalue_temp); |
---|
| 465 | } |
---|
| 466 | else |
---|
| 467 | { |
---|
| 468 | lonvalue_temp->resize(boost::extents[zoom_ni_client]); |
---|
| 469 | latvalue_temp->resize(boost::extents[zoom_nj_client]); |
---|
| 470 | |
---|
| 471 | for (int i = zoom_ibegin_client - 1; i < (zoom_ni_client - zoom_ibegin_client + 1); i++) |
---|
| 472 | { |
---|
| 473 | (*lonvalue_temp)[i] = (*lonvalue_)[i]; |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | for (int j = zoom_ibegin_client - 1; j < (zoom_nj_client - zoom_jbegin_client + 1); j++) |
---|
| 477 | { |
---|
| 478 | (*latvalue_temp)[j] = (*latvalue_)[j]; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | this->lonvalue.setValue(lonvalue_temp); |
---|
| 482 | this->latvalue.setValue(latvalue_temp); |
---|
| 483 | } |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | //---------------------------------------------------------------- |
---|
| 487 | |
---|
| 488 | void CDomain::completeLonLatServer(void) |
---|
| 489 | { |
---|
| 490 | ARRAY_CREATE(lonvalue_temp, double, 1, [0]); |
---|
| 491 | ARRAY_CREATE(latvalue_temp, double, 1, [0]); |
---|
| 492 | |
---|
[278] | 493 | const int ibegin_serv = ibegin.getValue(), |
---|
| 494 | jbegin_serv = jbegin.getValue(), |
---|
| 495 | zoom_ni_serv = zoom_ni_loc.getValue(), |
---|
| 496 | zoom_nj_serv = zoom_nj_loc.getValue(), |
---|
| 497 | ibegin_zoom_srv = zoom_ibegin_loc.getValue(), |
---|
| 498 | jbegin_zoom_srv = zoom_jbegin_loc.getValue(); |
---|
[219] | 499 | |
---|
| 500 | /*std::cout << "Rang du serveur :" << comm::CMPIManager::GetCommRank() << std::endl |
---|
| 501 | << "Begin serv : " << ibegin_serv << ", " << jbegin_serv << std::endl |
---|
| 502 | << "End serv : " << iend_serv << ", " << jend_serv << std::endl |
---|
| 503 | << "Zoom_loc begin : " << zoom_ibegin_loc << ", " << zoom_jbegin_loc << std::endl |
---|
| 504 | << "Zoom_loc size : " << zoom_ni_loc << ", " << zoom_nj_loc << std::endl;*/ |
---|
| 505 | |
---|
| 506 | if (this->data_dim.getValue() == 2) |
---|
| 507 | { |
---|
[278] | 508 | StdSize dm = zoom_ni_serv * zoom_nj_serv; |
---|
[219] | 509 | |
---|
| 510 | lonvalue_temp->resize(boost::extents[dm]); |
---|
| 511 | latvalue_temp->resize(boost::extents[dm]); |
---|
| 512 | |
---|
| 513 | for (StdSize k = 0; k < lonvalue_sub.size(); k++) |
---|
| 514 | { |
---|
| 515 | ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k], |
---|
| 516 | latvalue_loc = this->latvalue_sub[k]; |
---|
[278] | 517 | const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k], |
---|
| 518 | zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k], |
---|
[286] | 519 | ibegin_cl = ibegin_sub[k] , |
---|
| 520 | jbegin_cl = jbegin_sub[k] , |
---|
[278] | 521 | ni_cl = iend_sub[k] - ibegin_sub[k] + 1; |
---|
[219] | 522 | |
---|
[278] | 523 | for (int i = 0; i < zoom_ni_cl; i++) |
---|
[219] | 524 | { |
---|
[278] | 525 | for (int j = 0; j < zoom_nj_cl; j++) |
---|
[219] | 526 | { |
---|
[286] | 527 | int ii = i + (ibegin_cl-1) - (ibegin_serv - 1) + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1); |
---|
| 528 | int jj = j + (jbegin_cl-1) - (jbegin_serv - 1) + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1); |
---|
[278] | 529 | (*lonvalue_temp)[ii + jj * zoom_ni_serv] = |
---|
| 530 | (*lonvalue_loc)[i + j * zoom_ni_cl]; |
---|
| 531 | (*latvalue_temp)[ii + jj * zoom_ni_serv] = |
---|
| 532 | (*latvalue_loc)[i + j * zoom_ni_cl]; |
---|
[219] | 533 | } |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | this->lonvalue.setValue(lonvalue_temp); |
---|
| 537 | this->latvalue.setValue(latvalue_temp); |
---|
| 538 | } |
---|
| 539 | else |
---|
| 540 | { |
---|
| 541 | lonvalue_temp->resize(boost::extents[zoom_ni_serv]); |
---|
| 542 | latvalue_temp->resize(boost::extents[zoom_nj_serv]); |
---|
| 543 | |
---|
| 544 | for (StdSize k = 0; k < lonvalue_sub.size(); k++) |
---|
| 545 | { |
---|
| 546 | ARRAY(double, 1) lonvalue_loc = this->lonvalue_sub[k], |
---|
| 547 | latvalue_loc = this->latvalue_sub[k]; |
---|
[278] | 548 | const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k], |
---|
| 549 | zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k]; |
---|
[219] | 550 | |
---|
[278] | 551 | for (int i = 0; i < zoom_ni_cl; i++) |
---|
| 552 | (*lonvalue_temp)[i /*- (ibegin_serv - 1)*/ + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1)] = |
---|
| 553 | (*lonvalue_loc)[i]; |
---|
[219] | 554 | |
---|
[278] | 555 | for (int j = 0; j < zoom_nj_cl; j++) |
---|
| 556 | (*latvalue_temp)[j /*- (jbegin_serv - 1)*/ + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1)] = |
---|
| 557 | (*latvalue_loc)[j]; |
---|
[219] | 558 | } |
---|
| 559 | this->lonvalue.setValue(lonvalue_temp); |
---|
| 560 | this->latvalue.setValue(latvalue_temp); |
---|
| 561 | } |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | //---------------------------------------------------------------- |
---|
| 565 | |
---|
| 566 | void CDomain::checkZoom(void) |
---|
| 567 | { |
---|
| 568 | // Résolution et vérification des données globales de zoom. |
---|
| 569 | if (!this->zoom_ni.isEmpty() || !this->zoom_nj.isEmpty() || |
---|
| 570 | !this->zoom_ibegin.isEmpty() || !this->zoom_jbegin.isEmpty()) |
---|
| 571 | { |
---|
| 572 | if (this->zoom_ni.isEmpty() && this->zoom_nj.isEmpty() && |
---|
| 573 | this->zoom_ibegin.isEmpty() && this->zoom_jbegin.isEmpty()) |
---|
| 574 | { |
---|
| 575 | ERROR("CDomain::checkZoom(void)", |
---|
| 576 | <<"Les attributs définissant un zoom doivent tous être définis") ; |
---|
| 577 | } |
---|
| 578 | else |
---|
| 579 | { |
---|
| 580 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
| 581 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
| 582 | |
---|
| 583 | if (zoom_ibegin.getValue() < 1 || zoom_jbegin.getValue() < 1 || |
---|
| 584 | zoom_iend > ni_glo.getValue() || zoom_jend > nj_glo.getValue()) |
---|
| 585 | ERROR("CDomain::checkZoom(void)", |
---|
| 586 | << "Zoom mal défini," |
---|
| 587 | << " vérifiez les valeurs zoom_ni, zoom_nj, zoom_ibegin, zoom_ibegin") ; |
---|
| 588 | } |
---|
| 589 | } |
---|
| 590 | else |
---|
| 591 | { |
---|
| 592 | this->zoom_ni.setValue(this->ni_glo.getValue()); |
---|
| 593 | this->zoom_nj.setValue(this->nj_glo.getValue()); |
---|
| 594 | this->zoom_ibegin.setValue(1); |
---|
| 595 | this->zoom_jbegin.setValue(1); |
---|
| 596 | } |
---|
| 597 | // Résolution des données locales de zoom. |
---|
| 598 | { |
---|
| 599 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
| 600 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
| 601 | |
---|
| 602 | if ((zoom_ibegin.getValue() > iend.getValue()) || |
---|
| 603 | (zoom_iend < ibegin.getValue())) |
---|
| 604 | { |
---|
| 605 | zoom_ni_loc.setValue(0); |
---|
[286] | 606 | zoom_ibegin_loc.setValue(zoom_ibegin.getValue()); |
---|
[219] | 607 | } |
---|
| 608 | else |
---|
| 609 | { |
---|
| 610 | int zoom_ibegin_loc_ = (zoom_ibegin.getValue() > ibegin.getValue()) |
---|
| 611 | ? zoom_ibegin.getValue() |
---|
| 612 | : ibegin.getValue(); |
---|
| 613 | int zoom_iend_loc_ = (zoom_iend < iend.getValue()) |
---|
| 614 | ? zoom_iend |
---|
| 615 | : iend.getValue(); |
---|
| 616 | int zoom_ni_loc_ = zoom_iend_loc_ - zoom_ibegin_loc_ + 1; |
---|
| 617 | |
---|
| 618 | zoom_ni_loc.setValue(zoom_ni_loc_); |
---|
| 619 | zoom_ibegin_loc.setValue(zoom_ibegin_loc_-ibegin.getValue()+1); |
---|
| 620 | } |
---|
| 621 | |
---|
| 622 | if ((zoom_jbegin.getValue() > jend.getValue()) || |
---|
| 623 | (zoom_jend < jbegin.getValue())) |
---|
| 624 | { |
---|
| 625 | zoom_nj_loc.setValue(0); |
---|
[286] | 626 | zoom_jbegin_loc.setValue(zoom_jbegin.getValue()); |
---|
[219] | 627 | } |
---|
| 628 | else |
---|
| 629 | { |
---|
| 630 | int zoom_jbegin_loc_ = (zoom_jbegin.getValue() > jbegin.getValue()) |
---|
| 631 | ? zoom_jbegin.getValue() |
---|
| 632 | : jbegin.getValue(); |
---|
| 633 | int zoom_jend_loc_ = (zoom_jend < jend.getValue()) |
---|
| 634 | ? zoom_jend |
---|
| 635 | : jend.getValue(); |
---|
| 636 | int zoom_nj_loc_ = zoom_jend_loc_ - zoom_jbegin_loc_ + 1; |
---|
| 637 | |
---|
| 638 | zoom_nj_loc.setValue(zoom_nj_loc_); |
---|
| 639 | zoom_jbegin_loc.setValue(zoom_jbegin_loc_-jbegin.getValue()+1); |
---|
| 640 | } |
---|
| 641 | } |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | //---------------------------------------------------------------- |
---|
| 645 | |
---|
| 646 | void CDomain::checkAttributes(void) |
---|
| 647 | { |
---|
| 648 | if (this->isChecked) return; |
---|
| 649 | |
---|
| 650 | this->checkGlobalDomain(); |
---|
| 651 | this->checkLocalIDomain(); |
---|
| 652 | this->checkLocalJDomain(); |
---|
| 653 | |
---|
| 654 | this->checkZoom(); |
---|
| 655 | |
---|
| 656 | if (this->latvalue_sub.size() == 0) |
---|
| 657 | { // CÎté client uniquement |
---|
| 658 | this->checkMask(); |
---|
| 659 | this->checkDomainData(); |
---|
| 660 | this->checkCompression(); |
---|
[266] | 661 | |
---|
| 662 | this->ibegin_sub.push_back(this->ibegin.getValue()); |
---|
| 663 | this->jbegin_sub.push_back(this->jbegin.getValue()); |
---|
| 664 | this->iend_sub.push_back(this->iend.getValue()); |
---|
| 665 | this->jend_sub.push_back(this->jend.getValue()); |
---|
[286] | 666 | |
---|
| 667 | this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue()); |
---|
| 668 | this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue()); |
---|
| 669 | this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue()); |
---|
| 670 | this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue()); |
---|
[266] | 671 | |
---|
| 672 | this->latvalue_sub.push_back(this->latvalue.getValue()); |
---|
| 673 | this->lonvalue_sub.push_back(this->lonvalue.getValue()); |
---|
[286] | 674 | |
---|
| 675 | |
---|
| 676 | // if (!this->isEmpty()) |
---|
| 677 | // { |
---|
[266] | 678 | this->completeLonLatClient(); |
---|
[286] | 679 | // } |
---|
[219] | 680 | } |
---|
| 681 | else |
---|
| 682 | { // CÎté serveur uniquement |
---|
[286] | 683 | // if (!this->isEmpty()) |
---|
[266] | 684 | this->completeLonLatServer(); |
---|
[219] | 685 | } |
---|
| 686 | this->completeMask(); |
---|
| 687 | |
---|
| 688 | this->isChecked = true; |
---|
| 689 | } |
---|
| 690 | |
---|
| 691 | //---------------------------------------------------------------- |
---|
| 692 | |
---|
| 693 | void CDomain::completeMask(void) |
---|
| 694 | { |
---|
| 695 | this->local_mask->resize(boost::extents[zoom_ni_loc.getValue()][zoom_nj_loc.getValue()]); |
---|
| 696 | } |
---|
| 697 | |
---|
| 698 | //---------------------------------------------------------------- |
---|
| 699 | |
---|
| 700 | ARRAY(int, 2) CDomain::getLocalMask(void) const |
---|
| 701 | { |
---|
| 702 | return (this->local_mask); |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | //---------------------------------------------------------------- |
---|
| 706 | |
---|
| 707 | const std::vector<int> & CDomain::getIBeginSub(void) const |
---|
| 708 | { |
---|
| 709 | return (this->ibegin_sub); |
---|
| 710 | } |
---|
| 711 | |
---|
| 712 | //---------------------------------------------------------------- |
---|
| 713 | |
---|
[274] | 714 | const std::vector<int> & CDomain::getIBeginZoomSub(void) const |
---|
| 715 | { |
---|
| 716 | return (this->ibegin_zoom_sub); |
---|
| 717 | } |
---|
[286] | 718 | |
---|
| 719 | const std::vector<int> & CDomain::getNiZoomSub(void) const |
---|
| 720 | { |
---|
| 721 | return (this->ni_zoom_sub); |
---|
| 722 | } |
---|
[274] | 723 | |
---|
| 724 | //---------------------------------------------------------------- |
---|
| 725 | |
---|
[219] | 726 | const std::vector<int> & CDomain::getIEndSub(void) const |
---|
| 727 | { |
---|
| 728 | return (this->iend_sub); |
---|
| 729 | } |
---|
| 730 | |
---|
| 731 | //---------------------------------------------------------------- |
---|
| 732 | |
---|
| 733 | const std::vector<int> & CDomain::getJBeginSub(void) const |
---|
| 734 | { |
---|
| 735 | return (this->jbegin_sub); |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | //---------------------------------------------------------------- |
---|
[274] | 739 | |
---|
| 740 | const std::vector<int> & CDomain::getJBeginZoomSub(void) const |
---|
| 741 | { |
---|
| 742 | return (this->jbegin_zoom_sub); |
---|
| 743 | } |
---|
[286] | 744 | |
---|
| 745 | const std::vector<int> & CDomain::getNjZoomSub(void) const |
---|
| 746 | { |
---|
| 747 | return (this->nj_zoom_sub); |
---|
| 748 | } |
---|
[274] | 749 | |
---|
[219] | 750 | |
---|
[274] | 751 | //---------------------------------------------------------------- |
---|
| 752 | |
---|
[219] | 753 | const std::vector<int> & CDomain::getJEndSub(void) const |
---|
| 754 | { |
---|
[286] | 755 | return (this->jend_sub); |
---|
[219] | 756 | } |
---|
| 757 | |
---|
| 758 | //---------------------------------------------------------------- |
---|
| 759 | |
---|
| 760 | const std::vector<ARRAY(double, 1)> & CDomain::getLonValueSub(void) const |
---|
| 761 | { |
---|
| 762 | return (this->lonvalue_sub); |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | //---------------------------------------------------------------- |
---|
| 766 | |
---|
| 767 | const std::vector<ARRAY(double, 1)> & CDomain::getLatValueSub(void) const |
---|
| 768 | { |
---|
| 769 | return (this->latvalue_sub); |
---|
| 770 | } |
---|
| 771 | |
---|
| 772 | ///--------------------------------------------------------------- |
---|
| 773 | |
---|
| 774 | } // namespace tree |
---|
| 775 | } // namespace xmlioserver |
---|