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