Changeset 265 for XMLIO_V2/dev/dev_rv/src/xmlio/node
- Timestamp:
- 09/06/11 11:57:45 (13 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/xmlio/node
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/node/axis.cpp
r237 r265 55 55 if (size != true_size) 56 56 ERROR("CAxis::checkAttributes(void)", 57 << "Le tableau \'zvalue\' a une taille différente" 58 << " de celle indiquée dans l'attribut \'size\'") 57 << "Le tableau \'zvalue\' a une taille différente de celle indiquée dans l'attribut \'size\'") 59 58 60 59 this->isChecked = true; -
XMLIO_V2/dev/dev_rv/src/xmlio/node/domain.cpp
r196 r265 381 381 data_n_index.setValue(dni); 382 382 383 for(int count = 0, i = 0; i < data_ni.getValue(); i++) 383 //for(int count = 0, i = 0; i < data_ni.getValue(); i++) 384 //for(int j = 0; j < data_nj.getValue(); j++, count++) 385 386 for(int count = 0, j = 0; j < data_nj.getValue(); j++) 384 387 { 385 for(int j = 0; j < data_nj.getValue(); j++, count++)388 for(int i = 0; i < data_ni.getValue(); i++, count++) 386 389 { 387 390 (*__arri)[count] = i+1 ; … … 399 402 //---------------------------------------------------------------- 400 403 401 void CDomain::completeLonLat(void) 404 void CDomain::completeLonLatClient(void) 405 { 406 ARRAY_CREATE(lonvalue_temp, double, 1, [0]); 407 ARRAY_CREATE(latvalue_temp, double, 1, [0]); 408 409 const int zoom_ibegin_client = zoom_ibegin_loc.getValue(), 410 zoom_jbegin_client = zoom_jbegin_loc.getValue(), 411 zoom_ni_client = zoom_ni_loc.getValue(), 412 zoom_nj_client = zoom_nj_loc.getValue(); 413 414 ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(), 415 latvalue_ = this->latvalue.getValue(); 416 417 if (this->data_dim.getValue() == 2) 418 { 419 StdSize dm = zoom_ni_client * zoom_nj_client; 420 421 lonvalue_temp->resize(boost::extents[dm]); 422 latvalue_temp->resize(boost::extents[dm]); 423 424 for (int i = 0; i < zoom_ni_client; i++) 425 { 426 for (int j = 0; j < zoom_nj_client; j++) 427 { 428 (*lonvalue_temp)[i + j * zoom_ni_client] = (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; 429 (*latvalue_temp)[i + j * zoom_ni_client] = (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; 430 } 431 } 432 this->lonvalue.setValue(lonvalue_temp); 433 this->latvalue.setValue(latvalue_temp); 434 } 435 else 436 { 437 lonvalue_temp->resize(boost::extents[zoom_ni_client]); 438 latvalue_temp->resize(boost::extents[zoom_nj_client]); 439 440 for (int i = zoom_ibegin_client - 1; i < (zoom_ni_client - zoom_ibegin_client + 1); i++) 441 { 442 (*lonvalue_temp)[i] = (*lonvalue_)[i]; 443 } 444 445 for (int j = zoom_ibegin_client - 1; j < (zoom_nj_client - zoom_jbegin_client + 1); j++) 446 { 447 (*latvalue_temp)[j] = (*latvalue_)[j]; 448 } 449 450 this->lonvalue.setValue(lonvalue_temp); 451 this->latvalue.setValue(latvalue_temp); 452 } 453 } 454 455 //---------------------------------------------------------------- 456 457 void CDomain::completeLonLatServer(void) 402 458 { 403 459 ARRAY_CREATE(lonvalue_temp, double, 1, [0]); … … 441 497 for (int j = jbegin_loc - jbegin_serv; j < (jend_loc - jbegin_serv + 1); j++) 442 498 { 443 (*lonvalue_)[i + j * this->ni.getValue()] = (*lonvalue_loc)[l]; 444 (*latvalue_)[i + j * this->ni.getValue()] = (*latvalue_loc)[l++]; 499 (*lonvalue_)[i + j * this->ni.getValue()] = (*lonvalue_loc)[l]; // erreur 500 (*latvalue_)[i + j * this->ni.getValue()] = (*latvalue_loc)[l++]; // erreur 445 501 } 446 502 } … … 572 628 this->checkDomainData(); 573 629 this->checkCompression(); 630 631 this->ibegin_sub.push_back(this->ibegin.getValue()); 632 this->jbegin_sub.push_back(this->jbegin.getValue()); 633 this->iend_sub.push_back(this->iend.getValue()); 634 this->jend_sub.push_back(this->jend.getValue()); 635 636 this->latvalue_sub.push_back(this->latvalue.getValue()); 637 this->lonvalue_sub.push_back(this->lonvalue.getValue()); 638 639 if (!this->isEmpty()) 640 { 641 this->completeLonLatClient(); 642 } 574 643 } 575 644 else 576 645 { // CÃŽté serveur uniquement 577 646 if (!this->isEmpty()) 578 this->completeLonLat ();647 this->completeLonLatServer(); 579 648 } 580 649 this->completeMask(); -
XMLIO_V2/dev/dev_rv/src/xmlio/node/domain.hpp
r184 r265 90 90 /// Mutateur /// 91 91 void addRelFile(const StdString & filename); 92 void completeLonLat(void); 92 void completeLonLatServer(void); 93 void completeLonLatClient(void); 93 94 94 95 /// Destructeur /// -
XMLIO_V2/dev/dev_rv/src/xmlio/node/field.cpp
r206 r265 19 19 , grid(), file() 20 20 , freq_operation(), freq_write() 21 , nstep(0) 21 22 , last_Write(), last_operation() 22 23 , foperation() 23 , data( )24 , data(new CArray<double, 1>(boost::extents[0])) 24 25 { /* Ne rien faire de plus */ } 25 26 … … 29 30 , grid(), file() 30 31 , freq_operation(), freq_write() 32 , nstep(0) 31 33 , last_Write(), last_operation() 32 34 , foperation() 33 , data( )35 , data(new CArray<double, 1>(boost::extents[0])) 34 36 { /* Ne rien faire de plus */ } 35 37 … … 88 90 { 89 91 return (this->file); 92 } 93 94 StdSize CField::getNStep(void) const 95 { 96 return (this->nstep); 97 } 98 99 void CField::incrementNStep(void) 100 { 101 this->nstep++; 90 102 } 91 103 … … 236 248 else 237 249 { 250 CDuration freq_offset_ = NoneDu; 251 if (!freq_offset.isEmpty()) 252 { 253 freq_offset_ = CDuration::FromString(freq_offset.getValue()); 254 } 255 else 256 { 257 freq_offset.setValue(NoneDu.toString()); 258 } 259 238 260 this->freq_operation = CDuration::FromString(freq_op.getValue()); 239 261 this->freq_write = CDuration::FromString(this->file->output_freq.getValue()); … … 242 264 this->last_operation = boost::shared_ptr<xmlioserver::date::CDate> 243 265 (new date::CDate(_context->getCalendar()->getInitDate())); 266 const CDuration toffset = this->freq_operation - freq_offset_ - _context->getCalendar()->getTimeStep(); 267 *this->last_operation = *this->last_operation - toffset; 244 268 245 269 #define DECLARE_FUNCTOR(MType, mtype) \ -
XMLIO_V2/dev/dev_rv/src/xmlio/node/field.hpp
r229 r265 64 64 public : 65 65 66 StdSize getNStep(void) const; 67 66 68 const date::CDuration & getFreqOperation(void) const; 67 69 const date::CDuration & getFreqWrite(void) const; … … 78 80 /// Mutateur /// 79 81 void setRelFile(const boost::shared_ptr<CFile> _file); 82 void incrementNStep(void); 80 83 81 84 template <StdSize N> 82 85 inline bool updateData 83 (const date::CDate & currDate, const ARRAY(double, N) data);86 (const date::CDate & currDate, const date::CDuration & timestep, const ARRAY(double, N) data); 84 87 85 88 bool updateDataServer … … 118 121 date::CDuration freq_operation, freq_write; 119 122 123 StdSize nstep; 120 124 boost::shared_ptr<date::CDate> last_Write, last_operation; 121 125 boost::shared_ptr<func::CFunctor> foperation; … … 146 150 147 151 template <StdSize N> 148 bool CField::updateData(const date::CDate & currDate, const ARRAY(double, N) data) 149 { 150 if ((*last_operation + freq_operation) >= currDate) 152 bool CField::updateData(const date::CDate & currDate, const date::CDuration & timestep, const ARRAY(double, N) _data) 153 { 154 const date::CDate opeDate = *last_operation + freq_operation; 155 const date::CDate writeDate = *last_Write + freq_write; 156 157 // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 158 // std::cout << "Champ : " << this->getBaseFieldId() << std::endl; 159 // std::cout << "CurrDate : " << currDate << std::endl; 160 // std::cout << "opeDate : " << opeDate << " = " << *last_operation << " + " << freq_operation << std::endl; 161 // std::cout << "writeDate : " << writeDate << " = " << *last_Write << " + " << freq_write << std::endl; 162 // std::cout << "(opeDate <= currDate) = " << std::boolalpha << (opeDate <= currDate) << std::endl; 163 // std::cout << "(writeDate <= currDate) = " << std::boolalpha << (writeDate <= currDate) << std::endl; 164 165 //std::cout << ">> " << currDate << " : Envoi de données " << this->getBaseFieldId() << std::endl; 166 if (opeDate <= currDate) 151 167 { 152 ARRAY_CREATE(input, double, 1, [0]); 153 input->resize(boost::extents[data->size()]); 154 this->grid->inputField(data, input); 168 //std::cout << "> " << currDate << ": Operation du champs" << this->getBaseFieldId() << std::endl; 169 170 if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements()) 171 { 172 this->data->resize(boost::extents[this->grid->storeIndex[0] ->num_elements()]); 173 } 174 175 ARRAY_CREATE(input, double, 1, [this->data->num_elements()]); 176 this->grid->inputField(_data, input); 155 177 (*this->foperation)(input); 178 156 179 *last_operation = currDate; 180 // std::cout << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 157 181 } 158 182 159 if ( (*last_Write + freq_write) >= currDate)183 if (writeDate < (currDate + freq_operation)) 160 184 { 161 *last_Write = currDate; 162 return (true); 185 this->foperation->final(); 186 this->incrementNStep(); 187 *last_Write = writeDate; 188 // std::cout << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 189 return (true); 163 190 } 191 // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 164 192 return (false); 165 193 }; -
XMLIO_V2/dev/dev_rv/src/xmlio/node/file.cpp
r214 r265 106 106 { 107 107 this->setVirtualFieldGroup 108 (CObjectFactory::CreateObject<CFieldGroup>( newVFieldGroupId));108 (CObjectFactory::CreateObject<CFieldGroup>(/*newVFieldGroupId*/)); 109 109 } 110 110 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/file.hpp
r257 r265 53 53 std::vector<boost::shared_ptr<CField> > 54 54 getEnabledFields(int default_outputlevel = 5, 55 int default_level 56 bool default_enabled 55 int default_level = 1, 56 bool default_enabled = true); 57 57 58 58 public : -
XMLIO_V2/dev/dev_rv/src/xmlio/node/grid.cpp
r205 r265 1 1 2 #include "grid.hpp" 2 3 … … 100 101 //--------------------------------------------------------------- 101 102 102 std::vector<StdSize> CGrid::get Shape(void) const103 std::vector<StdSize> CGrid::getLocalShape(void) const 103 104 { 104 105 std::vector<StdSize> retvalue; 105 retvalue.push_back( this->domain->ni.getValue());106 retvalue.push_back( this->domain->nj.getValue());106 retvalue.push_back(domain->zoom_ni_loc.getValue()); 107 retvalue.push_back(domain->zoom_nj_loc.getValue()); 107 108 if (this->withAxis) 108 109 retvalue.push_back(this->axis->size.getValue()); … … 111 112 //--------------------------------------------------------------- 112 113 113 StdSize CGrid::get Size(void) const114 StdSize CGrid::getLocalSize(void) const 114 115 { 115 116 StdSize retvalue = 1; 116 std::vector<StdSize> shape_ = this->getShape(); 117 std::vector<StdSize> shape_ = this->getLocalShape(); 118 for (StdSize s = 0; s < shape_.size(); s++) 119 retvalue *= shape_[s]; 120 return (retvalue); 121 } 122 123 //--------------------------------------------------------------- 124 125 std::vector<StdSize> CGrid::getGlobalShape(void) const 126 { 127 std::vector<StdSize> retvalue; 128 retvalue.push_back(domain->ni.getValue()); 129 retvalue.push_back(domain->nj.getValue()); 130 if (this->withAxis) 131 retvalue.push_back(this->axis->size.getValue()); 132 return (retvalue); 133 } 134 //--------------------------------------------------------------- 135 136 StdSize CGrid::getGlobalSize(void) const 137 { 138 StdSize retvalue = 1; 139 std::vector<StdSize> shape_ = this->getGlobalShape(); 117 140 for (StdSize s = 0; s < shape_.size(); s++) 118 141 retvalue *= shape_[s]; … … 129 152 if (this->storeIndex.size() == 1) 130 153 { 154 131 155 this->computeIndex() ; 132 } 133 else 134 { 135 this->computeIndexServer(); 136 } 156 ARRAY_CREATE(storeIndex_ , int, 1, [0]); 157 ARRAY_CREATE(out_l_index_, int, 1, [0]); 158 ARRAY_CREATE(out_i_index_, int, 1, [0]); 159 ARRAY_CREATE(out_j_index_, int, 1, [0]); 160 161 this->storeIndex .push_front(storeIndex_); 162 this->out_i_index.push_front(out_i_index_); 163 this->out_j_index.push_front(out_j_index_); 164 this->out_l_index.push_front(out_l_index_); 165 } 166 this->computeIndexServer(); 137 167 this->isChecked = true; 138 168 } … … 177 207 178 208 void CGrid::computeIndex(void) 179 { 209 { 210 180 211 const int ni = domain->ni.getValue() , 181 212 nj = domain->nj.getValue() , … … 200 231 201 232 ARRAY(bool, 2) mask = domain->mask.getValue() ; 233 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 202 234 203 235 int indexCount = 0; … … 210 242 temp_j = (data_dim == 1) ? -1 211 243 : (*data_j_index)[n] + data_jbegin; 212 i = (data_dim == 1) ? (temp_i - 2) % ni244 i = (data_dim == 1) ? (temp_i - 1) % ni 213 245 : (temp_i - 1) ; 214 j = (data_dim == 1) ? (temp_i - 2) / ni246 j = (data_dim == 1) ? (temp_i - 1) / ni 215 247 : (temp_j - 1) ; 216 248 … … 226 258 ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]); 227 259 ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]); 228 260 261 // for(int count = 0, indexCount = 0, l = 0; l < size; l++) 262 // for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 263 264 //for(int n = 0, i = 0, j = 0, count = 0, indexCount = 0; n < data_n_index; n++) 265 //for(int l = 0; l < size; l++, count++) 266 229 267 for(int count = 0, indexCount = 0, l = 0; l < size; l++) 230 268 { … … 234 272 temp_j = (data_dim == 1) ? -1 235 273 : (*data_j_index)[n] + data_jbegin; 236 i = (data_dim == 1) ? (temp_i - 2) % ni274 i = (data_dim == 1) ? (temp_i - 1) % ni 237 275 : (temp_i - 1) ; 238 j = (data_dim == 1) ? (temp_i - 2) / ni276 j = (data_dim == 1) ? (temp_i - 1) / ni 239 277 : (temp_j - 1) ; 240 278 … … 250 288 } 251 289 } 290 291 292 // if (this->storeIndex[0]->size() != 0) 293 // for (StdSize u = 0; u < this->storeIndex[0]->size(); u++) 294 // (*local_mask)[(*out_i_index[0])[u]][(*out_j_index[0])[u]] = 1; 295 296 // std::cout << "indexCount" << indexCount << std::endl; 297 // std::cout << this->getId() << " : " << (*this->storeIndex[0]).num_elements() << std::endl; 298 // StdOFStream ofs2(("log_client_"+this->getId()).c_str()); 299 // for (StdSize h = 0; h < storeIndex[0]->size(); h++) 300 // { 301 // ofs2 << "(" << (*storeIndex[0])[h] << ";" 302 // << (*out_i_index[0])[h] << "," 303 // << (*out_j_index[0])[h] << "," 304 // << (*out_l_index[0])[h] << ")" << std::endl; 305 // } 306 // ofs2.close(); 252 307 } 253 308 … … 282 337 (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const 283 338 { 339 //std::cout <<"champ : " ; 284 340 for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) 341 { 285 342 (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] = (*stored)[n] ; 343 /*if (storeIndex[0]->num_elements() == 31) 344 { 345 std::cout << "( " << (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] << ", " 346 << (*out_i_index[0])[n] << ", " 347 << (*out_j_index[0])[n] << ", " 348 << (*out_l_index[0])[n] << ")"; 349 }*/ 350 } 351 //std::cout << std::endl; 352 286 353 } 287 354 … … 311 378 (const double * const data, ARRAY(double, 1) stored) const 312 379 { 313 const StdSize size = storeIndex[0]->num_elements() ; 380 const StdSize size = (this->storeIndex[0])->num_elements() ; 381 // std::cout << this->getId() << "> size : " << size << std::endl; 314 382 stored->resize(boost::extents[size]) ; 315 383 for(StdSize i = 0; i < size; i++) … … 365 433 void CGrid::computeIndexServer(void) 366 434 { 367 ARRAY(int, 1) storeIndex_srv = this->storeIndex[0];368 ARRAY(int, 1) out_i_index_srv = this->out_i_index[0];369 ARRAY(int, 1) out_j_index_srv = this->out_j_index[0];370 ARRAY(int, 1) out_l_index_srv = this->out_l_index[0];371 372 435 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 373 436 … … 375 438 const std::vector<int> & jbegin = this->domain->getJBeginSub(); 376 439 377 const int ibegin_srv = this->domain->ibegin.getValue();378 const int jbegin_srv = this->domain->jbegin.getValue();379 const int zoom_ni_srv 380 const int zoom_nj_srv 440 const int ibegin_srv = this->domain->ibegin.getValue(); 441 const int jbegin_srv = this->domain->jbegin.getValue(); 442 const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue(); 443 const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue(); 381 444 382 445 const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue(); … … 387 450 dn += this->out_i_index[j]->size(); 388 451 389 ARRAY_ ASSIGN(storeIndex_srv , int, 1, [dn]);390 ARRAY_ ASSIGN(out_i_index_srv, int, 1, [dn]);391 ARRAY_ ASSIGN(out_j_index_srv, int, 1, [dn]);392 ARRAY_ ASSIGN(out_l_index_srv, int, 1, [dn]);452 ARRAY_CREATE(storeIndex_srv , int, 1, [dn]); 453 ARRAY_CREATE(out_i_index_srv, int, 1, [dn]); 454 ARRAY_CREATE(out_j_index_srv, int, 1, [dn]); 455 ARRAY_CREATE(out_l_index_srv, int, 1, [dn]); 393 456 394 457 for (StdSize i = 0, dn = 0; i < ibegin.size(); i++) … … 404 467 for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 405 468 { 406 (*storeIndex_srv)[n] = (*storeIndex_cl)[m] + dn; // Faux mais inutile dans tous les cas.469 (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 407 470 (*out_i_index_srv)[n] = (*out_i_index_cl)[m] 408 471 + (ibegin_cl - 1) - (ibegin_srv - 1) - (ibegin_zoom_srv - 1); … … 438 501 (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1; 439 502 440 //~ StdOFStream ofs(this->getId().c_str()); 441 //~ for (StdSize h = 0; h < storeIndex_srv->size(); h++) 442 //~ { 443 //~ ofs << "(" << (*storeIndex_srv)[h] << ";" 444 //~ << (*out_i_index_srv)[h] << "," 445 //~ << (*out_j_index_srv)[h] << "," 446 //~ << (*out_l_index_srv)[h] << ")" << std::endl; 447 //~ } 448 //~ ofs.close(); 503 // StdOFStream ofs(("log_server_"+this->getId()).c_str()); 504 // for (StdSize h = 0; h < storeIndex_srv->size(); h++) 505 // { 506 // ofs << "(" << (*storeIndex_srv)[h] << ";" 507 // << (*out_i_index_srv)[h] << "," 508 // << (*out_j_index_srv)[h] << "," 509 // << (*out_l_index_srv)[h] << ")" << std::endl; 510 // } 511 // ofs.close(); 512 513 this->storeIndex [0] = storeIndex_srv ; 514 this->out_i_index[0] = out_i_index_srv; 515 this->out_j_index[0] = out_j_index_srv; 516 this->out_l_index[0] = out_l_index_srv; 517 449 518 this->storeIndex.resize(1); 450 519 this->out_i_index.resize(1); … … 454 523 } 455 524 456 //----------------------------------------------------------------457 525 458 526 void CGrid::inputFieldServer -
XMLIO_V2/dev/dev_rv/src/xmlio/node/grid.hpp
r205 r265 68 68 69 69 StdSize getDimension(void) const; 70 StdSize getSize(void) const; 71 std::vector<StdSize> getShape(void) const; 70 71 StdSize getLocalSize(void) const; 72 StdSize getGlobalSize(void) const; 73 std::vector<StdSize> getLocalShape(void) const; 74 std::vector<StdSize> getGlobalShape(void) const; 72 75 73 76 /// Entrées-sorties de champs /// … … 130 133 void CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const 131 134 { 132 if (this->get Size() != field->num_elements())135 if (this->getGlobalSize() != field->num_elements()) 133 136 ERROR("CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored)", 134 << "[ Taille des données attendue = " << this->get Size() << ", "137 << "[ Taille des données attendue = " << this->getGlobalSize() << ", " 135 138 << "Taille des données reçue = " << field->num_elements() << " ] " 136 139 << "Le tableau de données n'a pas la bonne taille !") ; 137 this->storeField_arr(field .data(), stored) ;140 this->storeField_arr(field->data(), stored) ; 138 141 } 139 142
Note: See TracChangeset
for help on using the changeset viewer.