[219] | 1 | #include "domain.hpp" |
---|
| 2 | |
---|
[352] | 3 | #include "attribute_template.hpp" |
---|
| 4 | #include "object_template.hpp" |
---|
| 5 | #include "group_template.hpp" |
---|
[219] | 6 | |
---|
[300] | 7 | #include "xmlioserver_spl.hpp" |
---|
| 8 | #include "event_client.hpp" |
---|
| 9 | #include "event_server.hpp" |
---|
| 10 | #include "buffer_in.hpp" |
---|
[352] | 11 | #include "message.hpp" |
---|
| 12 | #include "type.hpp" |
---|
| 13 | #include "context.hpp" |
---|
| 14 | #include "context_client.hpp" |
---|
[369] | 15 | #include "array_new.hpp" |
---|
[553] | 16 | #include "server_distribution_description.hpp" |
---|
[569] | 17 | #include "client_server_mapping_distributed.hpp" |
---|
[274] | 18 | |
---|
[335] | 19 | namespace xios { |
---|
[509] | 20 | |
---|
[219] | 21 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 22 | |
---|
| 23 | CDomain::CDomain(void) |
---|
| 24 | : CObjectTemplate<CDomain>(), CDomainAttributes() |
---|
[584] | 25 | , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() |
---|
[219] | 26 | { /* Ne rien faire de plus */ } |
---|
| 27 | |
---|
| 28 | CDomain::CDomain(const StdString & id) |
---|
| 29 | : CObjectTemplate<CDomain>(id), CDomainAttributes() |
---|
[584] | 30 | , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() |
---|
[449] | 31 | { /* Ne rien faire de plus */ } |
---|
[219] | 32 | |
---|
| 33 | CDomain::~CDomain(void) |
---|
[509] | 34 | { |
---|
[219] | 35 | } |
---|
| 36 | |
---|
| 37 | ///--------------------------------------------------------------- |
---|
| 38 | |
---|
| 39 | const std::set<StdString> & CDomain::getRelFiles(void) const |
---|
| 40 | { |
---|
[509] | 41 | return (this->relFiles); |
---|
[219] | 42 | } |
---|
| 43 | |
---|
| 44 | //---------------------------------------------------------------- |
---|
[509] | 45 | |
---|
[219] | 46 | bool CDomain::hasZoom(void) const |
---|
| 47 | { |
---|
[509] | 48 | return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && |
---|
[219] | 49 | (this->zoom_nj.getValue() != this->nj_glo.getValue())); |
---|
| 50 | } |
---|
[509] | 51 | |
---|
[219] | 52 | //---------------------------------------------------------------- |
---|
[509] | 53 | |
---|
[219] | 54 | bool CDomain::isEmpty(void) const |
---|
| 55 | { |
---|
[509] | 56 | return ((this->zoom_ni_srv == 0) || |
---|
[300] | 57 | (this->zoom_nj_srv == 0)); |
---|
[219] | 58 | } |
---|
| 59 | |
---|
| 60 | //---------------------------------------------------------------- |
---|
| 61 | |
---|
| 62 | bool CDomain::IsWritten(const StdString & filename) const |
---|
| 63 | { |
---|
| 64 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | //---------------------------------------------------------------- |
---|
| 68 | |
---|
| 69 | void CDomain::addRelFile(const StdString & filename) |
---|
| 70 | { |
---|
| 71 | this->relFiles.insert(filename); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | StdString CDomain::GetName(void) { return (StdString("domain")); } |
---|
| 76 | StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } |
---|
| 77 | ENodeType CDomain::GetType(void) { return (eDomain); } |
---|
| 78 | |
---|
| 79 | //---------------------------------------------------------------- |
---|
| 80 | |
---|
[467] | 81 | void CDomain::checkDomain(void) |
---|
[219] | 82 | { |
---|
[449] | 83 | if (!type.isEmpty() && type==type_attr::unstructured) |
---|
| 84 | { |
---|
| 85 | if (ni_glo.isEmpty() || ni_glo <= 0 ) |
---|
| 86 | { |
---|
| 87 | ERROR("CDomain::checkAttributes(void)", |
---|
| 88 | << "[ Id = " << this->getId() << " ] " |
---|
| 89 | << "The global domain is badly defined," |
---|
[509] | 90 | << " check the \'ni_glo\' value !") |
---|
[449] | 91 | } |
---|
| 92 | nj_glo=ni_glo ; |
---|
| 93 | ni_glo=1 ; |
---|
| 94 | if (!ni.isEmpty()) nj=ni ; |
---|
| 95 | if (!ibegin.isEmpty()) jbegin=ibegin ; |
---|
| 96 | if (!iend.isEmpty()) jend=iend ; |
---|
[467] | 97 | if (!i_index.isEmpty()) |
---|
| 98 | { |
---|
| 99 | j_index.resize(1,nj) ; |
---|
| 100 | for(int i=0;i<ni;i++) j_index(0,i)=i_index(i,0) ; |
---|
| 101 | i_index.resize(1,nj) ; |
---|
| 102 | for(int j=0;j<nj;j++) i_index(0,j)=0 ; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | if (!mask.isEmpty()) |
---|
| 106 | { |
---|
| 107 | CArray<int,2> mask_tmp(nj,1) ; |
---|
| 108 | mask_tmp = mask ; |
---|
| 109 | mask.resize(1,nj) ; |
---|
| 110 | for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; |
---|
| 111 | } |
---|
[449] | 112 | ni=1 ; |
---|
[551] | 113 | ibegin=0 ; |
---|
| 114 | iend=0 ; |
---|
[509] | 115 | |
---|
[449] | 116 | } |
---|
| 117 | else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || |
---|
[274] | 118 | (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) |
---|
| 119 | { |
---|
[219] | 120 | ERROR("CDomain::checkAttributes(void)", |
---|
| 121 | << "[ Id = " << this->getId() << " ] " |
---|
[421] | 122 | << "The global domain is badly defined," |
---|
[509] | 123 | << " check the \'ni_glo\' et \'nj_glo\' values !") |
---|
[274] | 124 | } |
---|
[467] | 125 | checkLocalIDomain() ; |
---|
| 126 | checkLocalJDomain() ; |
---|
[509] | 127 | |
---|
[467] | 128 | if (i_index.isEmpty()) |
---|
| 129 | { |
---|
| 130 | i_index.resize(ni,nj) ; |
---|
| 131 | for(int j=0;j<nj;j++) |
---|
[509] | 132 | for(int i=0;i<ni;i++) i_index(i,j)=i ; |
---|
[467] | 133 | } |
---|
[509] | 134 | |
---|
[467] | 135 | if (j_index.isEmpty()) |
---|
| 136 | { |
---|
| 137 | j_index.resize(ni,nj) ; |
---|
| 138 | for(int j=0;j<nj;j++) |
---|
[509] | 139 | for(int i=0;i<ni;i++) j_index(i,j)=j ; |
---|
[467] | 140 | } |
---|
[509] | 141 | |
---|
[219] | 142 | } |
---|
| 143 | |
---|
| 144 | //---------------------------------------------------------------- |
---|
| 145 | |
---|
| 146 | void CDomain::checkLocalIDomain(void) |
---|
| 147 | { |
---|
| 148 | if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty()) |
---|
| 149 | iend.setValue(ibegin.getValue() + ni.getValue() - 1) ; |
---|
| 150 | |
---|
| 151 | else if (!ni.isEmpty() && !iend.isEmpty() && ibegin.isEmpty()) |
---|
| 152 | ibegin.setValue( - ni.getValue() + iend.getValue() + 1) ; |
---|
| 153 | |
---|
| 154 | else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty()) |
---|
| 155 | ni.setValue(iend.getValue() - ibegin.getValue() + 1) ; |
---|
| 156 | |
---|
[449] | 157 | else if (!ibegin.isEmpty() && !iend.isEmpty() && !ni.isEmpty() ) |
---|
[219] | 158 | { |
---|
[449] | 159 | if (iend.getValue() != ibegin.getValue() + ni.getValue() - 1) |
---|
| 160 | ERROR("CDomain::checkAttributes(void)", |
---|
| 161 | << "The domain si wrong defined," |
---|
| 162 | << " iend is different of (ibegin + ni - 1) !") ; |
---|
[219] | 163 | } |
---|
| 164 | else |
---|
| 165 | { |
---|
| 166 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 167 | << "The domain is wrong defined," |
---|
| 168 | << " 2 value from \'iend\', \'ibegin\', \'ni\' must be defined !") ; |
---|
[219] | 169 | } |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || |
---|
[551] | 173 | ibegin.getValue() < 0 || iend.getValue() > (ni_glo.getValue()-1)) |
---|
[449] | 174 | { |
---|
| 175 | |
---|
[219] | 176 | ERROR("CDomain::checkAttributes(void)", |
---|
| 177 | << "[ Id = " << this->getId() << " ] " |
---|
[421] | 178 | << "Local domain is wrong defined," |
---|
| 179 | << " Check the value : ni, ni_glo, ibegin, iend") ; |
---|
[449] | 180 | } |
---|
[219] | 181 | } |
---|
| 182 | |
---|
| 183 | //---------------------------------------------------------------- |
---|
| 184 | |
---|
| 185 | void CDomain::checkLocalJDomain(void) |
---|
| 186 | { |
---|
| 187 | if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty()) |
---|
| 188 | jend.setValue(jbegin.getValue() + nj.getValue() - 1) ; |
---|
| 189 | |
---|
| 190 | else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty()) |
---|
| 191 | jbegin.setValue( - nj.getValue() + jend.getValue() + 1) ; |
---|
| 192 | |
---|
| 193 | else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty()) |
---|
| 194 | nj.setValue(jend.getValue() - jbegin.getValue() + 1) ; |
---|
| 195 | |
---|
[449] | 196 | else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty() ) |
---|
[219] | 197 | { |
---|
[449] | 198 | if (jend.getValue() != jbegin.getValue() + nj.getValue() - 1) |
---|
| 199 | ERROR("CDomain::checkAttributes(void)", |
---|
| 200 | << "The domain is wrong defined," |
---|
| 201 | << " iend is different of (jbegin + nj - 1) !") ; |
---|
[219] | 202 | } |
---|
| 203 | else |
---|
| 204 | { |
---|
| 205 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 206 | << "The domain is wrong defined," |
---|
| 207 | << " 2 values from jend, jbegin, nj must be defined !") ; |
---|
[219] | 208 | } |
---|
| 209 | |
---|
| 210 | if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() || |
---|
[551] | 211 | jbegin.getValue() < 0 || jend.getValue() > (nj_glo.getValue()-1)) |
---|
[219] | 212 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 213 | << "Domain is wrong defined," |
---|
| 214 | << " Check the values : nj, nj_glo, jbegin, jend") ; |
---|
[509] | 215 | |
---|
[449] | 216 | ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; |
---|
| 217 | jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; |
---|
[219] | 218 | } |
---|
| 219 | |
---|
| 220 | //---------------------------------------------------------------- |
---|
| 221 | |
---|
| 222 | void CDomain::checkMask(void) |
---|
| 223 | { |
---|
| 224 | using namespace std; |
---|
[509] | 225 | |
---|
[219] | 226 | int ibegin_mask = 0, |
---|
| 227 | jbegin_mask = 0, |
---|
| 228 | iend_mask = iend.getValue() - ibegin.getValue(), |
---|
| 229 | jend_mask = jend.getValue() - jbegin.getValue(); |
---|
[509] | 230 | |
---|
[219] | 231 | if (!zoom_ibegin.isEmpty()) |
---|
| 232 | { |
---|
| 233 | int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; |
---|
| 234 | int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; |
---|
[509] | 235 | |
---|
[219] | 236 | ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); |
---|
| 237 | jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); |
---|
| 238 | iend_mask = min (iend.getValue(), zoom_iend); |
---|
| 239 | jend_mask = min (jend.getValue(), zoom_jend); |
---|
[509] | 240 | |
---|
[219] | 241 | ibegin_mask -= ibegin.getValue(); |
---|
| 242 | jbegin_mask -= jbegin.getValue(); |
---|
| 243 | iend_mask -= ibegin.getValue(); |
---|
| 244 | jend_mask -= jbegin.getValue(); |
---|
| 245 | } |
---|
| 246 | |
---|
[509] | 247 | |
---|
[219] | 248 | if (!mask.isEmpty()) |
---|
| 249 | { |
---|
[467] | 250 | if ((mask.extent(0) != ni) || |
---|
| 251 | (mask.extent(1) != nj)) |
---|
[219] | 252 | ERROR("CDomain::checkAttributes(void)", |
---|
[435] | 253 | <<"the mask has not the same size than the local domain"<<endl |
---|
[467] | 254 | <<"Local size is "<<ni<<"x"<<nj<<endl |
---|
[509] | 255 | <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); |
---|
[467] | 256 | for (int i = 0; i < ni; i++) |
---|
[219] | 257 | { |
---|
[467] | 258 | for (int j = 0; j < nj; j++) |
---|
[219] | 259 | { |
---|
| 260 | if (i < ibegin_mask && i > iend_mask && |
---|
| 261 | j < jbegin_mask && j > jend_mask ) |
---|
[369] | 262 | mask(i,j) = false; |
---|
[219] | 263 | } |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | else // (!mask.hasValue()) |
---|
| 267 | { // Si aucun masque n'est défini, |
---|
| 268 | // on en crée un nouveau qui valide l'intégralité du domaine. |
---|
[369] | 269 | mask.resize(ni,nj) ; |
---|
[219] | 270 | for (int i = 0; i < ni.getValue(); i++) |
---|
| 271 | { |
---|
| 272 | for (int j = 0; j < nj.getValue(); j++) |
---|
| 273 | { |
---|
| 274 | if (i >= ibegin_mask && i <= iend_mask && |
---|
| 275 | j >= jbegin_mask && j <= jend_mask ) |
---|
[369] | 276 | mask(i,j) = true; |
---|
| 277 | else mask(i,j) = false; |
---|
[219] | 278 | } |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | //---------------------------------------------------------------- |
---|
| 285 | |
---|
| 286 | void CDomain::checkDomainData(void) |
---|
[509] | 287 | { |
---|
[219] | 288 | if (!data_dim.isEmpty() && |
---|
| 289 | !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) |
---|
| 290 | { |
---|
| 291 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 292 | << "Data dimension incompatible (must be 1 or 2) !") ; |
---|
[219] | 293 | } |
---|
| 294 | else if (data_dim.isEmpty()) |
---|
| 295 | { |
---|
| 296 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 297 | << "Data dimension undefined !") ; |
---|
[219] | 298 | } |
---|
| 299 | |
---|
| 300 | if (data_ibegin.isEmpty()) |
---|
| 301 | data_ibegin.setValue(0) ; |
---|
| 302 | if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) |
---|
| 303 | data_jbegin.setValue(0) ; |
---|
| 304 | |
---|
| 305 | if (!data_ni.isEmpty() && (data_ni.getValue() <= 0)) |
---|
| 306 | { |
---|
| 307 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 308 | << "Data dimension is negative (data_ni).") ; |
---|
[219] | 309 | } |
---|
| 310 | else if (data_ni.isEmpty()) |
---|
| 311 | { |
---|
| 312 | data_ni.setValue((data_dim.getValue() == 1) |
---|
| 313 | ? (ni.getValue() * nj.getValue()) |
---|
| 314 | : ni.getValue()); |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | if (data_dim.getValue() == 2) |
---|
| 318 | { |
---|
| 319 | if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) |
---|
| 320 | { |
---|
| 321 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 322 | << "Data dimension is negative (data_nj).") ; |
---|
[219] | 323 | } |
---|
| 324 | else if (data_nj.isEmpty()) |
---|
| 325 | data_nj.setValue(nj.getValue()) ; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | //---------------------------------------------------------------- |
---|
| 331 | |
---|
| 332 | void CDomain::checkCompression(void) |
---|
| 333 | { |
---|
| 334 | if (!data_i_index.isEmpty()) |
---|
| 335 | { |
---|
[369] | 336 | int ssize = data_i_index.numElements(); |
---|
[219] | 337 | if (!data_n_index.isEmpty() && |
---|
| 338 | (data_n_index.getValue() != ssize)) |
---|
| 339 | { |
---|
| 340 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 341 | <<"Dimension data_i_index incompatible with data_n_index.") ; |
---|
[219] | 342 | } |
---|
| 343 | else if (data_n_index.isEmpty()) |
---|
| 344 | data_n_index.setValue(ssize) ; |
---|
| 345 | |
---|
| 346 | if (data_dim.getValue() == 2) |
---|
| 347 | { |
---|
| 348 | if (!data_j_index.isEmpty() && |
---|
[369] | 349 | (data_j_index.numElements() != data_i_index.numElements())) |
---|
[219] | 350 | { |
---|
| 351 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 352 | <<"Dimension data_j_index incompatible with data_i_index.") ; |
---|
[219] | 353 | } |
---|
| 354 | else if (data_j_index.isEmpty()) |
---|
| 355 | { |
---|
| 356 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 357 | <<"data_j_index must be defined !") ; |
---|
[219] | 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | else |
---|
| 362 | { |
---|
| 363 | if (!data_n_index.isEmpty() || |
---|
| 364 | ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) |
---|
[421] | 365 | ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; |
---|
[219] | 366 | } |
---|
| 367 | |
---|
| 368 | if (data_n_index.isEmpty()) |
---|
| 369 | { // -> bloc re-vérifié OK |
---|
| 370 | if (data_dim.getValue() == 1) |
---|
| 371 | { |
---|
| 372 | const int dni = data_ni.getValue(); |
---|
[369] | 373 | data_i_index.resize(dni) ; |
---|
[219] | 374 | data_n_index.setValue(dni); |
---|
[369] | 375 | for (int i = 0; i < dni; i++) data_i_index(i) = i+1 ; |
---|
[219] | 376 | } |
---|
| 377 | else // (data_dim == 2) |
---|
| 378 | { |
---|
| 379 | const int dni = data_ni.getValue() * data_nj.getValue(); |
---|
[369] | 380 | data_i_index.resize(dni) ; |
---|
| 381 | data_j_index.resize(dni) ; |
---|
[509] | 382 | |
---|
[219] | 383 | data_n_index.setValue(dni); |
---|
[509] | 384 | |
---|
[266] | 385 | for(int count = 0, j = 0; j < data_nj.getValue(); j++) |
---|
[219] | 386 | { |
---|
[266] | 387 | for(int i = 0; i < data_ni.getValue(); i++, count++) |
---|
[219] | 388 | { |
---|
[369] | 389 | data_i_index(count) = i+1 ; |
---|
| 390 | data_j_index(count) = j+1 ; |
---|
[219] | 391 | } |
---|
| 392 | } |
---|
| 393 | } |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | //---------------------------------------------------------------- |
---|
[509] | 398 | |
---|
[266] | 399 | void CDomain::completeLonLatClient(void) |
---|
[219] | 400 | { |
---|
[384] | 401 | int i,j,k ; |
---|
| 402 | CArray<double,1> lonvalue_temp(ni*nj) ; |
---|
| 403 | CArray<double,1> latvalue_temp(ni*nj) ; |
---|
[449] | 404 | CArray<double,2> bounds_lon_temp(nvertex,ni*nj) ; |
---|
| 405 | CArray<double,2> bounds_lat_temp(nvertex,ni*nj) ; |
---|
[509] | 406 | |
---|
[449] | 407 | if (type.isEmpty()) |
---|
[384] | 408 | { |
---|
[509] | 409 | if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) |
---|
[449] | 410 | { |
---|
| 411 | type.setValue(type_attr::curvilinear) ; |
---|
| 412 | isCurvilinear=true ; |
---|
| 413 | } |
---|
[509] | 414 | else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) |
---|
[449] | 415 | { |
---|
| 416 | type.setValue(type_attr::regular) ; |
---|
| 417 | isCurvilinear=false ; |
---|
| 418 | } |
---|
| 419 | else ERROR("void CDomain::completeLonLatClient(void)",<<"the grid is nor curvilinear, nor cartesian, because the size of longitude and latitude array is not coherent with the domain size"<<endl |
---|
| 420 | <<"lonvalue size = " << lonvalue.numElements() << "different of ni or ni*nj"<<endl |
---|
| 421 | <<"latvalue size = " << latvalue.numElements() << "different of nj or ni*nj" ) ; |
---|
| 422 | } |
---|
| 423 | if (type==type_attr::curvilinear || type==type_attr::unstructured) |
---|
| 424 | { |
---|
[384] | 425 | lonvalue_temp=lonvalue ; |
---|
| 426 | latvalue_temp=latvalue ; |
---|
[449] | 427 | if (hasBounds) bounds_lon_temp=bounds_lon ; |
---|
| 428 | if (hasBounds) bounds_lat_temp=bounds_lat ; |
---|
[384] | 429 | } |
---|
| 430 | else |
---|
| 431 | { |
---|
| 432 | for(j=0;j<nj;j++) |
---|
[509] | 433 | for(i=0;i<ni;i++) |
---|
[384] | 434 | { |
---|
| 435 | k=j*ni+i ; |
---|
| 436 | lonvalue_temp(k)=lonvalue(i) ; |
---|
| 437 | latvalue_temp(k)=latvalue(j) ; |
---|
[449] | 438 | if (hasBounds) |
---|
| 439 | { |
---|
[509] | 440 | for(int n=0;n<nvertex;n++) |
---|
[449] | 441 | { |
---|
| 442 | bounds_lon_temp(n,k)=bounds_lon(n,i) ; |
---|
| 443 | bounds_lat_temp(n,k)=bounds_lat(n,j) ; |
---|
| 444 | } |
---|
| 445 | } |
---|
[384] | 446 | } |
---|
| 447 | } |
---|
[509] | 448 | |
---|
[384] | 449 | StdSize dm = zoom_ni_client * zoom_nj_client; |
---|
[266] | 450 | |
---|
[584] | 451 | // Make sure that this attribute is non-empty for every client. |
---|
| 452 | if (0 != dm) |
---|
| 453 | { |
---|
| 454 | lonvalue.resize(dm); |
---|
| 455 | latvalue.resize(dm); |
---|
| 456 | } |
---|
[509] | 457 | |
---|
[584] | 458 | |
---|
[384] | 459 | for (int i = 0; i < zoom_ni_client; i++) |
---|
| 460 | { |
---|
| 461 | for (int j = 0; j < zoom_nj_client; j++) |
---|
| 462 | { |
---|
[509] | 463 | lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); |
---|
[449] | 464 | latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); |
---|
| 465 | if (hasBounds) |
---|
| 466 | { |
---|
[509] | 467 | for(int n=0;n<nvertex;n++) |
---|
[449] | 468 | { |
---|
[509] | 469 | bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni ); |
---|
[449] | 470 | bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); |
---|
| 471 | } |
---|
| 472 | } |
---|
[384] | 473 | } |
---|
[266] | 474 | } |
---|
[449] | 475 | } |
---|
[219] | 476 | |
---|
[509] | 477 | |
---|
[219] | 478 | //---------------------------------------------------------------- |
---|
| 479 | |
---|
| 480 | void CDomain::checkZoom(void) |
---|
| 481 | { |
---|
| 482 | // Résolution et vérification des données globales de zoom. |
---|
| 483 | if (!this->zoom_ni.isEmpty() || !this->zoom_nj.isEmpty() || |
---|
| 484 | !this->zoom_ibegin.isEmpty() || !this->zoom_jbegin.isEmpty()) |
---|
| 485 | { |
---|
[384] | 486 | if (this->zoom_ni.isEmpty() || this->zoom_nj.isEmpty() || |
---|
| 487 | this->zoom_ibegin.isEmpty() || this->zoom_jbegin.isEmpty()) |
---|
[219] | 488 | { |
---|
| 489 | ERROR("CDomain::checkZoom(void)", |
---|
[384] | 490 | <<"if one of zoom attributes is defined then all zoom attributes must be defined") ; |
---|
[219] | 491 | } |
---|
| 492 | else |
---|
| 493 | { |
---|
[449] | 494 | int zoom_iend = zoom_ibegin + zoom_ni - 1; |
---|
| 495 | int zoom_jend = zoom_jbegin + zoom_nj - 1; |
---|
[509] | 496 | |
---|
[551] | 497 | if (zoom_ibegin < 0 || zoom_jbegin < 0 || zoom_iend > (ni_glo-1) || zoom_jend > (nj_glo-1)) |
---|
[219] | 498 | ERROR("CDomain::checkZoom(void)", |
---|
[421] | 499 | << "Zoom is wrong defined," |
---|
[479] | 500 | << " Check the values : zoom_ni, zoom_nj, zoom_ibegin, zoom_jbegin") ; |
---|
[219] | 501 | } |
---|
| 502 | } |
---|
| 503 | else |
---|
| 504 | { |
---|
[509] | 505 | zoom_ni = ni_glo; |
---|
[449] | 506 | zoom_nj = nj_glo; |
---|
[551] | 507 | zoom_ibegin = 0; |
---|
| 508 | zoom_jbegin = 0; |
---|
[219] | 509 | } |
---|
[509] | 510 | |
---|
[449] | 511 | // compute client zoom indices |
---|
| 512 | |
---|
| 513 | int zoom_iend=zoom_ibegin+zoom_ni-1 ; |
---|
| 514 | zoom_ibegin_client = ibegin_client > zoom_ibegin ? ibegin_client : zoom_ibegin ; |
---|
| 515 | zoom_iend_client = iend_client < zoom_iend ? iend_client : zoom_iend ; |
---|
| 516 | zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ; |
---|
| 517 | if (zoom_ni_client<0) zoom_ni_client=0 ; |
---|
| 518 | |
---|
[509] | 519 | |
---|
[449] | 520 | int zoom_jend=zoom_jbegin+zoom_nj-1 ; |
---|
| 521 | zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ; |
---|
| 522 | zoom_jend_client = jend_client < zoom_jend ? jend_client : zoom_jend ; |
---|
| 523 | zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; |
---|
| 524 | if (zoom_nj_client<0) zoom_nj_client=0 ; |
---|
[467] | 525 | |
---|
[219] | 526 | } |
---|
[509] | 527 | |
---|
[449] | 528 | void CDomain::checkBounds(void) |
---|
| 529 | { |
---|
| 530 | if (!nvertex.isEmpty() && !bounds_lon.isEmpty() && !bounds_lat.isEmpty()) |
---|
| 531 | { |
---|
| 532 | hasBounds=true ; |
---|
[509] | 533 | |
---|
[449] | 534 | } |
---|
[509] | 535 | else |
---|
[449] | 536 | { |
---|
| 537 | hasBounds=false; |
---|
| 538 | nvertex=0 ; |
---|
| 539 | } |
---|
| 540 | } |
---|
[509] | 541 | |
---|
[219] | 542 | //---------------------------------------------------------------- |
---|
[509] | 543 | // Divide function checkAttributes into 2 seperate ones |
---|
| 544 | // This function only checks all attributes of current domain |
---|
| 545 | void CDomain::checkAttributesOnClient() |
---|
| 546 | { |
---|
| 547 | if (this->isClientChecked) return; |
---|
| 548 | CContext* context=CContext::getCurrent(); |
---|
[219] | 549 | |
---|
[509] | 550 | this->checkDomain(); |
---|
| 551 | this->checkZoom(); |
---|
| 552 | this->checkBounds(); |
---|
| 553 | |
---|
| 554 | if (context->hasClient) |
---|
| 555 | { // CÎté client uniquement |
---|
| 556 | this->checkMask(); |
---|
| 557 | this->checkDomainData(); |
---|
| 558 | this->checkCompression(); |
---|
| 559 | this->completeLonLatClient(); |
---|
| 560 | this->computeConnectedServer() ; |
---|
| 561 | } |
---|
| 562 | else |
---|
| 563 | { // CÎté serveur uniquement |
---|
| 564 | // if (!this->isEmpty()) |
---|
| 565 | // ne sert plus // this->completeLonLatServer(); |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | this->isClientChecked = true; |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | // Send all checked attributes to server |
---|
| 572 | void CDomain::sendCheckedAttributes() |
---|
| 573 | { |
---|
| 574 | if (!this->isClientChecked) checkAttributesOnClient(); |
---|
| 575 | CContext* context=CContext::getCurrent() ; |
---|
| 576 | |
---|
| 577 | if (this->isChecked) return; |
---|
| 578 | if (context->hasClient) |
---|
| 579 | { |
---|
| 580 | sendServerAttribut() ; |
---|
| 581 | sendLonLat() ; |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | this->isChecked = true; |
---|
| 585 | } |
---|
| 586 | |
---|
[219] | 587 | void CDomain::checkAttributes(void) |
---|
| 588 | { |
---|
| 589 | if (this->isChecked) return; |
---|
[347] | 590 | CContext* context=CContext::getCurrent() ; |
---|
[219] | 591 | |
---|
[467] | 592 | this->checkDomain(); |
---|
[219] | 593 | this->checkZoom(); |
---|
[449] | 594 | this->checkBounds(); |
---|
[509] | 595 | |
---|
[300] | 596 | if (context->hasClient) |
---|
[219] | 597 | { // CÎté client uniquement |
---|
| 598 | this->checkMask(); |
---|
| 599 | this->checkDomainData(); |
---|
| 600 | this->checkCompression(); |
---|
[449] | 601 | this->completeLonLatClient(); |
---|
[219] | 602 | } |
---|
| 603 | else |
---|
| 604 | { // CÎté serveur uniquement |
---|
[286] | 605 | // if (!this->isEmpty()) |
---|
[300] | 606 | // ne sert plus // this->completeLonLatServer(); |
---|
[219] | 607 | } |
---|
[509] | 608 | |
---|
[300] | 609 | if (context->hasClient) |
---|
| 610 | { |
---|
| 611 | computeConnectedServer() ; |
---|
| 612 | sendServerAttribut() ; |
---|
| 613 | sendLonLat() ; |
---|
| 614 | } |
---|
[509] | 615 | |
---|
[219] | 616 | this->isChecked = true; |
---|
| 617 | } |
---|
[509] | 618 | |
---|
[300] | 619 | void CDomain::sendServerAttribut(void) |
---|
| 620 | { |
---|
[553] | 621 | std::vector<int> nGlobDomain(2); |
---|
| 622 | nGlobDomain[0] = ni_glo.getValue(); |
---|
| 623 | nGlobDomain[1] = nj_glo.getValue(); |
---|
| 624 | CServerDistributionDescription serverDescription(nGlobDomain); |
---|
| 625 | |
---|
[300] | 626 | int ni_srv=ni_glo.getValue() ; |
---|
[551] | 627 | int ibegin_srv=0 ; |
---|
[300] | 628 | int iend_srv=ni_glo.getValue() ; |
---|
[509] | 629 | |
---|
[300] | 630 | int nj_srv ; |
---|
| 631 | int jbegin_srv ; |
---|
| 632 | int jend_srv ; |
---|
[509] | 633 | |
---|
[347] | 634 | CContext* context=CContext::getCurrent() ; |
---|
[300] | 635 | CContextClient* client=context->client ; |
---|
| 636 | int nbServer=client->serverSize ; |
---|
| 637 | int serverRank=client->getServerLeader() ; |
---|
[509] | 638 | |
---|
[553] | 639 | serverDescription.computeServerDistribution(nbServer); |
---|
| 640 | std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); |
---|
| 641 | std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); |
---|
| 642 | ibegin_srv = (serverIndexBegin[serverRank])[0]; |
---|
| 643 | jbegin_srv = serverIndexBegin[serverRank][1]; |
---|
| 644 | ni_srv = serverDimensionSizes[serverRank][0]; |
---|
| 645 | nj_srv = serverDimensionSizes[serverRank][1]; |
---|
| 646 | iend_srv = ibegin_srv+ni_srv-1; |
---|
| 647 | jend_srv = jbegin_srv+nj_srv-1; |
---|
[509] | 648 | |
---|
| 649 | CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; |
---|
[300] | 650 | if (client->isServerLeader()) |
---|
| 651 | { |
---|
| 652 | CMessage msg ; |
---|
| 653 | msg<<this->getId() ; |
---|
| 654 | msg<<ni_srv<<ibegin_srv<<iend_srv<<nj_srv<<jbegin_srv<<jend_srv; |
---|
| 655 | event.push(client->getServerLeader(),1,msg) ; |
---|
| 656 | client->sendEvent(event) ; |
---|
| 657 | } |
---|
| 658 | else client->sendEvent(event) ; |
---|
| 659 | } |
---|
[467] | 660 | |
---|
[300] | 661 | void CDomain::computeConnectedServer(void) |
---|
| 662 | { |
---|
[467] | 663 | ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; |
---|
| 664 | jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; |
---|
[509] | 665 | |
---|
[553] | 666 | CContext* context=CContext::getCurrent() ; |
---|
[300] | 667 | CContextClient* client=context->client ; |
---|
[553] | 668 | int nbServer=client->serverSize; |
---|
| 669 | bool doComputeGlobalIndexServer = true; |
---|
[449] | 670 | |
---|
[553] | 671 | int i,j,i_ind,j_ind ; |
---|
[449] | 672 | int zoom_iend=zoom_ibegin+zoom_ni-1 ; |
---|
| 673 | int zoom_jend=zoom_jbegin+zoom_nj-1 ; |
---|
[509] | 674 | |
---|
[553] | 675 | // Precompute number of index |
---|
[584] | 676 | int globalIndexCountZoom = 0; |
---|
[467] | 677 | for(j=0;j<nj;j++) |
---|
| 678 | for(i=0;i<ni;i++) |
---|
| 679 | { |
---|
[551] | 680 | i_ind=ibegin+i_index(i,j) ; |
---|
| 681 | j_ind=jbegin+j_index(i,j) ; |
---|
[509] | 682 | |
---|
[551] | 683 | if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend) |
---|
[300] | 684 | { |
---|
[584] | 685 | ++globalIndexCountZoom; |
---|
[300] | 686 | } |
---|
[467] | 687 | } |
---|
| 688 | |
---|
[553] | 689 | // Fill in index |
---|
[584] | 690 | CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); |
---|
| 691 | CArray<size_t,1> globalIndexDomain(ni*nj); |
---|
[553] | 692 | size_t globalIndex; |
---|
[584] | 693 | int globalIndexCount = 0; |
---|
| 694 | globalIndexCountZoom = 0; |
---|
[467] | 695 | |
---|
[553] | 696 | for(j=0;j<nj;j++) |
---|
| 697 | for(i=0;i<ni;i++) |
---|
[467] | 698 | { |
---|
[553] | 699 | i_ind=ibegin+i_index(i,j) ; |
---|
| 700 | j_ind=jbegin+j_index(i,j) ; |
---|
[509] | 701 | |
---|
[584] | 702 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 703 | globalIndexDomain(globalIndexCount) = globalIndex; |
---|
| 704 | ++globalIndexCount; |
---|
[553] | 705 | if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend) |
---|
[300] | 706 | { |
---|
[584] | 707 | globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 708 | ++globalIndexCountZoom; |
---|
[300] | 709 | } |
---|
| 710 | } |
---|
[509] | 711 | |
---|
[569] | 712 | std::vector<int> nGlobDomain(2); |
---|
| 713 | nGlobDomain[0] = ni_glo.getValue(); |
---|
| 714 | nGlobDomain[1] = nj_glo.getValue(); |
---|
| 715 | size_t globalSizeIndex = 1, indexBegin, indexEnd; |
---|
| 716 | int range, clientSize = client->clientSize; |
---|
| 717 | for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; |
---|
| 718 | indexBegin = 0; |
---|
| 719 | for (int i = 0; i < clientSize; ++i) |
---|
| 720 | { |
---|
| 721 | range = globalSizeIndex / clientSize; |
---|
| 722 | if (i < (globalSizeIndex%clientSize)) ++range; |
---|
| 723 | if (i == client->clientRank) break; |
---|
| 724 | indexBegin += range; |
---|
| 725 | } |
---|
| 726 | indexEnd = indexBegin + range - 1; |
---|
| 727 | |
---|
| 728 | CServerDistributionDescription serverDescription(nGlobDomain); |
---|
| 729 | serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd)); |
---|
| 730 | CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), |
---|
| 731 | client->intraComm); |
---|
| 732 | clientServerMap->computeServerIndexMapping(globalIndexDomain); |
---|
| 733 | const std::map<int, std::vector<size_t> >& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); |
---|
[584] | 734 | |
---|
| 735 | std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(), |
---|
| 736 | ite = globalIndexDomainOnServer.end(); |
---|
| 737 | indSrv_.clear(); |
---|
| 738 | for (; it != ite; ++it) |
---|
| 739 | { |
---|
| 740 | int rank = it->first; |
---|
| 741 | std::vector<size_t>::const_iterator itbVec = (it->second).begin(), |
---|
| 742 | iteVec = (it->second).end(); |
---|
| 743 | int nb = globalIndexDomainZoom.numElements(); |
---|
| 744 | for (int i = 0; i < nb; ++i) |
---|
| 745 | { |
---|
[585] | 746 | if (iteVec != std::find(itbVec, iteVec, globalIndexDomainZoom(i))) |
---|
[584] | 747 | { |
---|
| 748 | indSrv_[rank].push_back(globalIndexDomainZoom(i)); |
---|
| 749 | } |
---|
| 750 | } |
---|
[553] | 751 | } |
---|
[569] | 752 | |
---|
[584] | 753 | connectedServerRank_.clear(); |
---|
| 754 | for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { |
---|
| 755 | connectedServerRank_.push_back(it->first); |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | if (!indSrv_.empty()) |
---|
| 759 | { |
---|
| 760 | connectedServerRank_.clear(); |
---|
| 761 | for (it = indSrv_.begin(); it != indSrv_.end(); ++it) |
---|
| 762 | connectedServerRank_.push_back(it->first); |
---|
| 763 | } |
---|
| 764 | nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); |
---|
| 765 | |
---|
[569] | 766 | delete clientServerMap; |
---|
[300] | 767 | } |
---|
[467] | 768 | |
---|
[300] | 769 | void CDomain::sendLonLat(void) |
---|
| 770 | { |
---|
[553] | 771 | int ns,n,i,j,ind,nv, idx; |
---|
[347] | 772 | CContext* context = CContext::getCurrent() ; |
---|
[300] | 773 | CContextClient* client=context->client ; |
---|
| 774 | // send lon lat for each connected server |
---|
[509] | 775 | |
---|
[518] | 776 | CEventClient eventLon(getType(),EVENT_ID_LON) ; |
---|
| 777 | CEventClient eventLat(getType(),EVENT_ID_LAT) ; |
---|
| 778 | |
---|
| 779 | list<shared_ptr<CMessage> > list_msgLon ; |
---|
| 780 | list<shared_ptr<CMessage> > list_msgLat ; |
---|
[449] | 781 | list< CArray<int,1>* > list_indi,list_indj ; |
---|
| 782 | list< CArray<double,1>* >list_lon,list_lat ; |
---|
| 783 | list< CArray<double,2>* >list_boundslon,list_boundslat ; |
---|
[300] | 784 | |
---|
[553] | 785 | std::map<int, std::vector<size_t> >::const_iterator it, itbMap, iteMap; |
---|
| 786 | itbMap = indSrv_.begin(); |
---|
| 787 | iteMap = indSrv_.end(); |
---|
[584] | 788 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
[300] | 789 | { |
---|
[584] | 790 | int nbData = 0; |
---|
| 791 | int rank = connectedServerRank_[k]; |
---|
| 792 | it = indSrv_.find(rank); |
---|
| 793 | if (iteMap != it) |
---|
| 794 | nbData = (it->second).size(); |
---|
| 795 | |
---|
[467] | 796 | CArray<int,1> indi(nbData) ; |
---|
| 797 | CArray<int,1> indj(nbData) ; |
---|
| 798 | CArray<double,1> lon(nbData) ; |
---|
| 799 | CArray<double,1> lat(nbData) ; |
---|
[553] | 800 | CArray<double,2> boundslon(nvertex,nbData); |
---|
| 801 | CArray<double,2> boundslat(nvertex,nbData); |
---|
[509] | 802 | |
---|
[553] | 803 | for (n = 0; n < nbData; ++n) |
---|
[467] | 804 | { |
---|
[553] | 805 | idx = static_cast<int>((it->second)[n]); |
---|
| 806 | i = idx%ni_glo; |
---|
| 807 | j = idx/ni_glo; |
---|
[551] | 808 | ind=(i-(zoom_ibegin_client))+(j-(zoom_jbegin_client))*zoom_ni_client ; |
---|
[509] | 809 | |
---|
[467] | 810 | lon(n)=lonvalue(ind) ; |
---|
| 811 | lat(n)=latvalue(ind) ; |
---|
| 812 | if (hasBounds) |
---|
[300] | 813 | { |
---|
[467] | 814 | for(nv=0;nv<nvertex;nv++) |
---|
[449] | 815 | { |
---|
[467] | 816 | boundslon(nv,n)=bounds_lon(nv,ind); |
---|
| 817 | boundslat(nv,n)=bounds_lat(nv,ind); |
---|
[449] | 818 | } |
---|
[300] | 819 | } |
---|
[551] | 820 | indi(n)=ibegin+i_index(i-ibegin,j-jbegin) ; |
---|
| 821 | indj(n)=jbegin+j_index(i-ibegin,j-jbegin) ; |
---|
[467] | 822 | } |
---|
[509] | 823 | |
---|
[449] | 824 | list_indi.push_back(new CArray<int,1>(indi.copy())) ; |
---|
| 825 | list_indj.push_back(new CArray<int,1>(indj.copy())) ; |
---|
[369] | 826 | list_lon.push_back(new CArray<double,1>(lon.copy())) ; |
---|
| 827 | list_lat.push_back(new CArray<double,1>(lat.copy())) ; |
---|
[449] | 828 | if (hasBounds) list_boundslon.push_back(new CArray<double,2>(boundslon.copy())) ; |
---|
| 829 | if (hasBounds) list_boundslat.push_back(new CArray<double,2>(boundslat.copy())) ; |
---|
[369] | 830 | |
---|
[518] | 831 | list_msgLon.push_back(shared_ptr<CMessage>(new CMessage)) ; |
---|
| 832 | list_msgLat.push_back(shared_ptr<CMessage>(new CMessage)) ; |
---|
[300] | 833 | |
---|
[518] | 834 | *list_msgLon.back()<<this->getId()<<(int)type ; // enum ne fonctionne pour les message => ToFix |
---|
| 835 | *list_msgLat.back()<<this->getId()<<(int)type ; |
---|
| 836 | *list_msgLon.back()<<isCurvilinear ; |
---|
| 837 | *list_msgLat.back()<<isCurvilinear ; |
---|
| 838 | *list_msgLon.back()<<*list_indi.back()<<*list_indj.back()<<*list_lon.back() ; |
---|
| 839 | *list_msgLat.back()<<*list_indi.back()<<*list_indj.back()<<*list_lat.back() ; |
---|
| 840 | |
---|
| 841 | if (hasBounds) |
---|
| 842 | { |
---|
| 843 | *list_msgLon.back()<<*list_boundslon.back(); |
---|
| 844 | *list_msgLat.back()<<*list_boundslat.back(); |
---|
| 845 | } |
---|
[584] | 846 | |
---|
[553] | 847 | eventLon.push(rank,nbConnectedClients_[rank],*list_msgLon.back()) ; |
---|
| 848 | eventLat.push(rank,nbConnectedClients_[rank],*list_msgLat.back()) ; |
---|
[300] | 849 | } |
---|
| 850 | |
---|
[518] | 851 | client->sendEvent(eventLon) ; |
---|
| 852 | client->sendEvent(eventLat) ; |
---|
[509] | 853 | |
---|
| 854 | |
---|
[449] | 855 | for(list<CArray<int,1>* >::iterator it=list_indi.begin();it!=list_indi.end();it++) delete *it; |
---|
| 856 | for(list<CArray<int,1>* >::iterator it=list_indj.begin();it!=list_indj.end();it++) delete *it; |
---|
| 857 | for(list<CArray<double,1>* >::iterator it=list_lon.begin();it!=list_lon.end();it++) delete *it; |
---|
| 858 | for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++) delete *it; |
---|
| 859 | if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++) delete *it; |
---|
[509] | 860 | if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++) delete *it; |
---|
[300] | 861 | } |
---|
[509] | 862 | |
---|
[300] | 863 | bool CDomain::dispatchEvent(CEventServer& event) |
---|
| 864 | { |
---|
[509] | 865 | |
---|
[300] | 866 | if (SuperClass::dispatchEvent(event)) return true ; |
---|
| 867 | else |
---|
| 868 | { |
---|
| 869 | switch(event.type) |
---|
| 870 | { |
---|
| 871 | case EVENT_ID_SERVER_ATTRIBUT : |
---|
| 872 | recvServerAttribut(event) ; |
---|
| 873 | return true ; |
---|
| 874 | break ; |
---|
[518] | 875 | case EVENT_ID_LON : |
---|
| 876 | recvLon(event) ; |
---|
[300] | 877 | return true ; |
---|
| 878 | break ; |
---|
[518] | 879 | case EVENT_ID_LAT : |
---|
| 880 | recvLat(event) ; |
---|
| 881 | return true ; |
---|
| 882 | break ; |
---|
[300] | 883 | default : |
---|
| 884 | ERROR("bool CContext::dispatchEvent(CEventServer& event)", |
---|
| 885 | <<"Unknown Event") ; |
---|
| 886 | return false ; |
---|
| 887 | } |
---|
| 888 | } |
---|
| 889 | } |
---|
[509] | 890 | |
---|
[300] | 891 | void CDomain::recvServerAttribut(CEventServer& event) |
---|
| 892 | { |
---|
| 893 | CBufferIn* buffer=event.subEvents.begin()->buffer; |
---|
| 894 | string domainId ; |
---|
| 895 | *buffer>>domainId ; |
---|
| 896 | get(domainId)->recvServerAttribut(*buffer) ; |
---|
| 897 | } |
---|
[509] | 898 | |
---|
[300] | 899 | void CDomain::recvServerAttribut(CBufferIn& buffer) |
---|
| 900 | { |
---|
| 901 | int zoom_iend=zoom_ibegin.getValue()+zoom_ni.getValue()-1 ; |
---|
| 902 | int zoom_jend=zoom_jbegin.getValue()+zoom_nj.getValue()-1 ; |
---|
| 903 | |
---|
| 904 | buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; |
---|
[509] | 905 | |
---|
| 906 | |
---|
[300] | 907 | zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; |
---|
| 908 | zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; |
---|
| 909 | zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; |
---|
[509] | 910 | |
---|
[300] | 911 | zoom_jbegin_srv = zoom_jbegin.getValue() > jbegin_srv ? zoom_jbegin.getValue() : jbegin_srv ; |
---|
| 912 | zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; |
---|
| 913 | zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; |
---|
| 914 | |
---|
[509] | 915 | if (zoom_ni_srv<=0 || zoom_nj_srv<=0) |
---|
[300] | 916 | { |
---|
[551] | 917 | zoom_ibegin_srv=0 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; |
---|
| 918 | zoom_jbegin_srv=0 ; zoom_jend_srv=0 ; zoom_nj_srv=0 ; |
---|
[300] | 919 | } |
---|
[369] | 920 | lonvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; |
---|
[456] | 921 | lonvalue_srv = 0. ; |
---|
[369] | 922 | latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; |
---|
[456] | 923 | latvalue_srv = 0. ; |
---|
[509] | 924 | if (hasBounds) |
---|
[456] | 925 | { |
---|
| 926 | bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; |
---|
| 927 | bounds_lon_srv = 0. ; |
---|
| 928 | bounds_lat_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; |
---|
| 929 | bounds_lat_srv = 0. ; |
---|
| 930 | } |
---|
[300] | 931 | } |
---|
[509] | 932 | |
---|
[518] | 933 | void CDomain::recvLon(CEventServer& event) |
---|
[300] | 934 | { |
---|
| 935 | list<CEventServer::SSubEvent>::iterator it ; |
---|
| 936 | for (it=event.subEvents.begin();it!=event.subEvents.end();++it) |
---|
| 937 | { |
---|
| 938 | CBufferIn* buffer=it->buffer; |
---|
| 939 | string domainId ; |
---|
| 940 | *buffer>>domainId ; |
---|
[518] | 941 | get(domainId)->recvLon(*buffer) ; |
---|
[300] | 942 | } |
---|
| 943 | } |
---|
[509] | 944 | |
---|
[518] | 945 | void CDomain::recvLon(CBufferIn& buffer) |
---|
[300] | 946 | { |
---|
[449] | 947 | CArray<int,1> indi ; |
---|
| 948 | CArray<int,1> indj ; |
---|
[369] | 949 | CArray<double,1> lon ; |
---|
[518] | 950 | CArray<double,2> boundslon ; |
---|
| 951 | |
---|
| 952 | int type_int ; |
---|
| 953 | buffer>>type_int>>isCurvilinear>>indi>>indj>>lon ; |
---|
| 954 | if (hasBounds) buffer>>boundslon ; |
---|
| 955 | type.setValue((type_attr::t_enum)type_int) ; // probleme des type enum avec les buffers : ToFix |
---|
| 956 | |
---|
| 957 | int i,j,ind_srv ; |
---|
| 958 | for(int ind=0;ind<indi.numElements();ind++) |
---|
| 959 | { |
---|
| 960 | i=indi(ind) ; j=indj(ind) ; |
---|
[551] | 961 | ind_srv=(i-(zoom_ibegin_srv))+(j-(zoom_jbegin_srv))*zoom_ni_srv ; |
---|
[518] | 962 | lonvalue_srv(ind_srv)=lon(ind) ; |
---|
| 963 | if (hasBounds) |
---|
| 964 | { |
---|
| 965 | for(int nv=0;nv<nvertex;nv++) |
---|
| 966 | { |
---|
| 967 | bounds_lon_srv(nv,ind_srv)=boundslon(nv,ind) ; |
---|
| 968 | } |
---|
| 969 | } |
---|
| 970 | } |
---|
| 971 | } |
---|
| 972 | |
---|
| 973 | void CDomain::recvLat(CEventServer& event) |
---|
| 974 | { |
---|
| 975 | list<CEventServer::SSubEvent>::iterator it ; |
---|
| 976 | for (it=event.subEvents.begin();it!=event.subEvents.end();++it) |
---|
| 977 | { |
---|
| 978 | CBufferIn* buffer=it->buffer; |
---|
| 979 | string domainId ; |
---|
| 980 | *buffer>>domainId ; |
---|
| 981 | get(domainId)->recvLat(*buffer) ; |
---|
| 982 | } |
---|
| 983 | } |
---|
| 984 | |
---|
| 985 | void CDomain::recvLat(CBufferIn& buffer) |
---|
| 986 | { |
---|
| 987 | CArray<int,1> indi ; |
---|
| 988 | CArray<int,1> indj ; |
---|
[369] | 989 | CArray<double,1> lat ; |
---|
[449] | 990 | CArray<double,2> boundslat ; |
---|
[509] | 991 | |
---|
[449] | 992 | int type_int ; |
---|
[518] | 993 | buffer>>type_int>>isCurvilinear>>indi>>indj>>lat ; |
---|
| 994 | if (hasBounds) buffer>>boundslat ; |
---|
[449] | 995 | type.setValue((type_attr::t_enum)type_int) ; // probleme des type enum avec les buffers : ToFix |
---|
[300] | 996 | int i,j,ind_srv ; |
---|
[369] | 997 | for(int ind=0;ind<indi.numElements();ind++) |
---|
[300] | 998 | { |
---|
[369] | 999 | i=indi(ind) ; j=indj(ind) ; |
---|
[551] | 1000 | ind_srv=(i-(zoom_ibegin_srv))+(j-(zoom_jbegin_srv))*zoom_ni_srv ; |
---|
[369] | 1001 | latvalue_srv(ind_srv)=lat(ind) ; |
---|
[509] | 1002 | if (hasBounds) |
---|
[449] | 1003 | { |
---|
[509] | 1004 | for(int nv=0;nv<nvertex;nv++) |
---|
[449] | 1005 | { |
---|
[467] | 1006 | bounds_lat_srv(nv,ind_srv)=boundslat(nv,ind) ; |
---|
[449] | 1007 | } |
---|
| 1008 | } |
---|
[300] | 1009 | } |
---|
| 1010 | } |
---|
[553] | 1011 | |
---|
[219] | 1012 | //---------------------------------------------------------------- |
---|
[509] | 1013 | |
---|
[540] | 1014 | DEFINE_REF_FUNC(Domain,domain) |
---|
[509] | 1015 | |
---|
[219] | 1016 | ///--------------------------------------------------------------- |
---|
| 1017 | |
---|
[335] | 1018 | } // namespace xios |
---|