Changeset 1129
- Timestamp:
- 05/11/17 18:25:20 (7 years ago)
- Location:
- XIOS/dev/dev_olga
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/bld.cfg
r1099 r1129 36 36 #bld::target test_regular.exe 37 37 #bld::target test_new_features.exe test_unstruct_complete.exe 38 #bld::target test_client.exe test_complete.exe 38 #bld::target test_client.exe 39 bld::target test_complete.exe 39 40 bld::target test_client.exe 40 41 bld::exe_dep -
XIOS/dev/dev_olga/inputs/COMPLETE/iodef.xml
r718 r1129 8 8 <context id="xios"> 9 9 <variable_definition> 10 <variable_group id="server"> 11 <variable id="using_server2" type="bool">true</variable> 12 <variable id="ratio_server2" type="int">50</variable> 13 </variable_group> 14 10 15 <variable_group id="buffer"> 11 16 <variable id="optimal_buffer_size" type="string">memory</variable> -
XIOS/dev/dev_olga/src/distribution.cpp
r887 r1129 18 18 } 19 19 20 const CArray<size_t,1>& CDistribution:: getGlobalIndex() const 21 { 22 return globalIndex_; 23 } 24 20 25 CDistribution::~CDistribution() 21 26 { /* Nothing to do */ } -
XIOS/dev/dev_olga/src/distribution.hpp
r930 r1129 35 35 int getDims() const; //! Get dimension size 36 36 int getRank() const; //! Get rank of current process 37 37 const CArray<size_t,1>& getGlobalIndex() const; 38 38 39 protected: 39 40 virtual void createGlobalIndex() {}; -
XIOS/dev/dev_olga/src/distribution_client.cpp
r1025 r1129 291 291 nBeginLocal_.at(indexMap_[idx]+1) = 0; 292 292 nBeginGlobal_.at(indexMap_[idx]+1) = domList[domIndex]->jbegin; 293 nZoomBegin_.at((indexMap_[idx]+1)) = domList[domIndex]->global_zoom_jbegin;294 nZoomEnd_.at((indexMap_[idx]+1)) = domList[domIndex]-> global_zoom_jbegin + domList[domIndex]->global_zoom_nj-1;293 nZoomBegin_.at((indexMap_[idx]+1)) = 0; //domList[domIndex]->global_zoom_jbegin; 294 nZoomEnd_.at((indexMap_[idx]+1)) = domList[domIndex]->nj_glo.getValue()- 1; //domList[domIndex]->global_zoom_jbegin + domList[domIndex]->global_zoom_nj-1; 295 295 296 296 dataBegin_.at(indexMap_[idx]+1) = domList[domIndex]->data_jbegin.getValue(); … … 303 303 nBeginLocal_.at(indexMap_[idx]) = 0; 304 304 nBeginGlobal_.at(indexMap_[idx]) = domList[domIndex]->ibegin; 305 nZoomBegin_.at((indexMap_[idx])) = domList[domIndex]->global_zoom_ibegin;306 nZoomEnd_.at((indexMap_[idx])) = domList[domIndex]-> global_zoom_ibegin + domList[domIndex]->global_zoom_ni-1;305 nZoomBegin_.at((indexMap_[idx])) = 0; // domList[domIndex]->global_zoom_ibegin; 306 nZoomEnd_.at((indexMap_[idx])) = domList[domIndex]->ni_glo.getValue() -1; //domList[domIndex]->global_zoom_ibegin + domList[domIndex]->global_zoom_ni-1; 307 307 308 308 dataBegin_.at(indexMap_[idx]) = domList[domIndex]->data_ibegin.getValue(); … … 325 325 nBeginLocal_.at(indexMap_[idx]) = 0; 326 326 nBeginGlobal_.at(indexMap_[idx]) = axisList[axisIndex]->begin.getValue(); 327 nZoomBegin_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin;328 nZoomEnd_.at((indexMap_[idx])) = axisList[axisIndex]-> global_zoom_begin + axisList[axisIndex]->global_zoom_n-1;327 nZoomBegin_.at((indexMap_[idx])) = 0; //axisList[axisIndex]->global_zoom_begin; 328 nZoomEnd_.at((indexMap_[idx])) = axisList[axisIndex]->n_glo.getValue() - 1; //axisList[axisIndex]->global_zoom_begin + axisList[axisIndex]->global_zoom_n-1; 329 329 330 330 dataBegin_.at(indexMap_[idx]) = axisList[axisIndex]->data_begin.getValue(); … … 587 587 localDataIndex_.resize(indexLocalDataOnClientCount); 588 588 localMaskIndex_.resize(indexSend2ServerCount); 589 globalDataIndex_.rehash(std::ceil(indexLocalDataOnClientCount/globalDataIndex_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount); 589 590 globalLocalDataSendToServerMap_.rehash(std::ceil(indexSend2ServerCount/globalLocalDataSendToServerMap_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount); 590 591 … … 652 653 if (gridMask_(gridMaskIndex)) 653 654 { 655 size_t globalIndex = 0; 656 for (int k = 0; k < numElement_; ++k) 657 { 658 globalIndex += (currentGlobalIndex[k])*elementNGlobal_[k]; 659 } 660 globalDataIndex_[globalIndex] = indexLocalDataOnClientCount; 654 661 localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 655 662 bool isIndexOnServer = true; … … 661 668 if (isIndexOnServer) 662 669 { 663 size_t globalIndex = 0;664 for (int k = 0; k < numElement_; ++k)665 {666 globalIndex += (currentGlobalIndex[k])*elementNGlobal_[k];667 }668 670 globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 669 671 localMaskIndex_[indexSend2ServerCount] = gridMaskIndex; … … 736 738 } 737 739 740 CDistributionClient::GlobalLocalDataMap& CDistributionClient::getGlobalDataIndexOnClient() 741 { 742 if (!isComputed_) createGlobalIndexSendToServer(); 743 return globalDataIndex_; 744 } 745 738 746 /*! 739 747 Return local data index of client -
XIOS/dev/dev_olga/src/distribution_client.hpp
r1025 r1129 45 45 virtual const std::vector<int>& getLocalDataIndexOnClient(); 46 46 GlobalLocalDataMap& getGlobalLocalDataSendToServer(); 47 GlobalLocalDataMap& getGlobalDataIndexOnClient(); 47 48 const std::vector<int>& getLocalMaskIndexOnClient(); 48 49 … … 80 81 //!< LocalData index on client 81 82 GlobalLocalDataMap globalLocalDataSendToServerMap_; 83 GlobalLocalDataMap globalDataIndex_; 82 84 std::vector<int> localDataIndex_; 83 85 std::vector<int> localMaskIndex_; -
XIOS/dev/dev_olga/src/distribution_server.cpp
r1099 r1129 37 37 } 38 38 39 CDistributionServer::CDistributionServer(int rank,40 const std::vector<CArray<int,1> >& globalIndexEachDimension,41 const std::vector<int>& nGlobal)42 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(),43 nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_(),44 globalIndexEachDimension_(globalIndexEachDimension)45 {46 createGlobalIndexFromIndex(globalIndexEachDimension, nGlobal);47 }39 // CDistributionServer::CDistributionServer(int rank, 40 // const std::vector<CArray<int,1> >& globalIndexEachDimension, 41 // const std::vector<int>& nGlobal) 42 // : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(), 43 // nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_(), 44 // globalIndexEachDimension_(globalIndexEachDimension) 45 // { 46 // createGlobalIndexFromIndex(globalIndexEachDimension, nGlobal); 47 // } 48 48 49 49 CDistributionServer::~CDistributionServer() … … 101 101 } 102 102 103 void CDistributionServer::createGlobalIndexFromIndex(const std::vector<CArray<int,1> >& globalIndexOnEachDimension,104 const std::vector<int>& nbGlobal)105 {106 size_t idx = 0, ssize = 1;107 for (int i = 0; i < globalIndexOnEachDimension.size(); ++i) ssize *= globalIndexOnEachDimension[i].numElements();108 109 this->globalIndex_.resize(ssize);110 size_t nbDim = nbGlobal.size();111 std::vector<int> idxLoop(nbDim,0);112 std::vector<int> currentIndex(nbDim);113 int innerLoopSize = globalIndexOnEachDimension[0].numElements();114 115 globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor()));116 while (idx<ssize)117 {118 for (int i = 0; i < nbDim-1; ++i)119 {120 if (idxLoop[i] == globalIndexOnEachDimension[i].numElements())121 {122 idxLoop[i] = 0;123 ++idxLoop[i+1];124 }125 }126 127 for (int i = 1; i < nbDim; ++i)128 currentIndex[i] = globalIndexOnEachDimension[i](idxLoop[i]);129 130 size_t mulDim, globalIndex;131 for (int i = 0; i < innerLoopSize; ++i)132 {133 mulDim = 1;134 globalIndex = globalIndexOnEachDimension[0](i);135 136 for (int k = 0; k < nbDim; ++k)137 {138 mulDim *= nbGlobal[k];139 globalIndex += (currentIndex[k])*mulDim;140 }141 globalLocalIndexMap_[globalIndex] = idx;142 this->globalIndex_(idx) = globalIndex;143 144 ++idx;145 }146 idxLoop[0] += innerLoopSize;147 }148 149 }103 // void CDistributionServer::createGlobalIndexFromIndex(const std::vector<CArray<int,1> >& globalIndexOnEachDimension, 104 // const std::vector<int>& nbGlobal) 105 // { 106 // size_t idx = 0, ssize = 1; 107 // for (int i = 0; i < globalIndexOnEachDimension.size(); ++i) ssize *= globalIndexOnEachDimension[i].numElements(); 108 109 // this->globalIndex_.resize(ssize); 110 // size_t nbDim = nbGlobal.size(); 111 // std::vector<int> idxLoop(nbDim,0); 112 // std::vector<int> currentIndex(nbDim); 113 // int innerLoopSize = globalIndexOnEachDimension[0].numElements(); 114 115 // globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor())); 116 // while (idx<ssize) 117 // { 118 // for (int i = 0; i < nbDim-1; ++i) 119 // { 120 // if (idxLoop[i] == globalIndexOnEachDimension[i].numElements()) 121 // { 122 // idxLoop[i] = 0; 123 // ++idxLoop[i+1]; 124 // } 125 // } 126 127 // for (int i = 1; i < nbDim; ++i) 128 // currentIndex[i] = globalIndexOnEachDimension[i](idxLoop[i]); 129 130 // size_t mulDim, globalIndex; 131 // for (int i = 0; i < innerLoopSize; ++i) 132 // { 133 // mulDim = 1; 134 // globalIndex = globalIndexOnEachDimension[0](i); 135 136 // for (int k = 0; k < nbDim; ++k) 137 // { 138 // mulDim *= nbGlobal[k]; 139 // globalIndex += (currentIndex[k])*mulDim; 140 // } 141 // globalLocalIndexMap_[globalIndex] = idx; 142 // this->globalIndex_(idx) = globalIndex; 143 144 // ++idx; 145 // } 146 // idxLoop[0] += innerLoopSize; 147 // } 148 149 // } 150 150 151 151 /*! … … 156 156 CArray<size_t,1> CDistributionServer::computeLocalIndex(const CArray<size_t,1>& globalIndex) 157 157 { 158 int ssize = globalIndex.numElements(); 159 CArray<size_t,1> localIndex(ssize); 158 size_t ssize = globalIndex.numElements(); 159 size_t localIndexSize = std::min(globalIndex_.numElements(), ssize); 160 CArray<size_t,1> localIndex(localIndexSize); 160 161 GlobalLocalMap::const_iterator ite = globalLocalIndexMap_.end(), it; 161 for (int idx = 0 ; idx < ssize; ++idx)162 for (int idx = 0, i = 0; idx < ssize; ++idx) 162 163 { 163 164 it = globalLocalIndexMap_.find(globalIndex(idx)); 164 165 if (ite != it) 166 { 165 167 localIndex(idx) = it->second; 168 ++i; 169 } 166 170 } 167 171 -
XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
r1099 r1129 50 50 void CNc4DataOutput::writeDomain_(CDomain* domain) 51 51 { 52 domain->computeWrittenIndex(); 52 53 if (domain->type == CDomain::type_attr::unstructured) 53 54 { … … 59 60 } 60 61 62 61 63 CContext* context = CContext::getCurrent() ; 62 64 CContextServer* server=context->server ; … … 107 109 : latid; 108 110 */ 111 112 CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer; 113 int nbWritten = indexToWrite.numElements(); 114 CArray<double,1> writtenLat, writtenLon; 115 CArray<double,2> writtenBndsLat, writtenBndsLon; 116 CArray<double,1> writtenArea; 117 118 if (domain->hasLonLat) 119 { 120 writtenLat.resize(nbWritten); 121 writtenLon.resize(nbWritten); 122 for (int idx = 0; idx < nbWritten; ++idx) 123 { 124 writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 125 writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 126 } 127 128 129 if (domain->hasBounds) 130 { 131 int nvertex = domain->nvertex, idx; 132 writtenBndsLat.resize(nvertex, nbWritten); 133 writtenBndsLon.resize(nvertex, nbWritten); 134 CArray<double,2>& boundslat = domain->bounds_latvalue; 135 CArray<double,2>& boundslon = domain->bounds_lonvalue; 136 for (idx = 0; idx < nbWritten; ++idx) 137 for (int nv = 0; nv < nvertex; ++nv) 138 { 139 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 140 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 141 } 142 } 143 } 144 145 if (domain->hasArea) 146 { 147 writtenArea.resize(nbWritten); 148 for (int idx = 0; idx < nbWritten; ++idx) 149 { 150 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 151 } 152 } 109 153 110 154 try … … 225 269 if (domain->hasLonLat) 226 270 { 271 // CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer; 272 // int nbWritten = indexToWrite.numElements(); 273 // CArray<double,1> writtenLat(nbWritten), writtenLon(nbWritten); 274 // for (int idx = 0; idx < nbWritten; ++idx) 275 // { 276 // writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 277 // writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 278 // } 227 279 switch (domain->type) 228 280 { 229 case CDomain::type_attr::curvilinear : 230 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 231 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 281 case CDomain::type_attr::curvilinear : 282 283 // SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 284 // SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 285 SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); 286 SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); 232 287 break; 233 288 case CDomain::type_attr::rectilinear : 234 CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->zoom_ni)) ; 289 // CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->zoom_ni)) ; 290 // SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 291 // CArray<double,1> lon = domain->lonvalue(Range(0,domain->zoom_ni-1)) ; 292 // // CArray<double,1> lon = domain->lonvalue(Range(0,local_size_write[1]-1)) ; 293 // SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 294 295 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)) ; 235 296 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 236 CArray<double,1> lon = domain->lonvalue(Range(0,domain->zoom_ni-1)) ;297 CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)) ; 237 298 // CArray<double,1> lon = domain->lonvalue(Range(0,local_size_write[1]-1)) ; 238 299 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); … … 242 303 if (domain->hasBounds) 243 304 { 244 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 245 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 305 // CArray<double,2> writtenBndsLat(nbWritten,2), writtenBndsLon(nbWritten,2); 306 // for (int idx = 0; idx < nbWritten; ++idx) 307 // for (int nv = 0; nv < domain->nvertex; ++nv) 308 // { 309 // writtenBndsLat(idx) = domain->bounds_latvalue(nv, indexToWrite(idx)); 310 // writtenBndsLon(idx) = domain->bounds_lonvalue(nv, indexToWrite(idx)); 311 // } 312 313 // SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 314 // SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 315 SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); 316 SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); 246 317 } 247 318 } 248 319 249 320 if (domain->hasArea) 250 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 321 { 322 // CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer; 323 // int nbWritten = indexToWrite.numElements(); 324 // CArray<double,1> writtenArea(nbWritten); 325 // for (int idx = 0; idx < nbWritten; ++idx) 326 // { 327 // writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 328 // } 329 330 SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0); 331 // SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 332 } 251 333 252 334 SuperClassWriter::definition_start(); … … 334 416 start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; 335 417 count[1]=domain->zoom_ni ; count[0]=domain->zoom_nj ; 336 // start[1]= start_write[0];337 // start[0]= start_write[1];338 // count[1]= count_write[0];339 // count[0]= count_write[1];340 418 } 341 419 342 420 if (domain->hasLonLat) 343 421 { 344 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 345 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 422 // SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 423 // SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 424 SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); 425 SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 346 426 } 347 427 break; … … 357 437 start[0]=0 ; 358 438 count[0]=0 ; 359 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 360 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 361 439 // SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 440 // SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 441 442 SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); 443 SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); 362 444 } 363 445 else 364 { 365 // start[0]= start_write[1]; 366 // count[0]= count_write[1]; 446 { 367 447 start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; 368 448 count[0]=domain->zoom_nj; 369 CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->zoom_ni)) ; 449 // CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,domain->zoom_ni)); 450 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)); 370 451 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 371 452 372 // start[0]= start_write[0];373 // count[0]= count_write[0];374 453 start[0]=domain->zoom_ibegin-domain->global_zoom_ibegin; 375 454 count[0]=domain->zoom_ni; 376 CArray<double,1> lon=domain->lonvalue(Range(0,domain->zoom_ni-1)) ; 455 // CArray<double,1> lon=domain->lonvalue(Range(0,domain->zoom_ni-1)); 456 CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)); 377 457 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 378 458 } … … 401 481 } 402 482 403 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0, &start, &count); 404 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0, &start, &count); 483 // SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0, &start, &count); 484 // SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0, &start, &count); 485 SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count); 486 SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count); 405 487 } 406 488 … … 421 503 count[1] = domain->zoom_ni; 422 504 count[0] = domain->zoom_nj; 423 424 // start[1]= start_write[0];425 // start[0]= start_write[1];426 // count[1]= count_write[0];427 // count[0]= count_write[1];428 505 } 429 506 430 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 507 // SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 508 SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); 431 509 } 432 510 … … 1056 1134 axis->checkAttributes(); 1057 1135 1058 // int local_size_write = axis->getLocalWriteSize(); 1059 // int global_size_write = axis->getGlobalWriteSize(); 1060 // int start_write = axis->getStartWriteIndex(); 1061 // int count_write = axis->getCountWriteIndex(); 1062 1063 1064 // if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 1065 1136 axis->computeWrittenIndex(); 1137 1066 1138 int zoom_size = (MULTI_FILE == SuperClass::type) ? axis->zoom_n 1067 1139 : axis->global_zoom_n; … … 1114 1186 SuperClassWriter::definition_end(); 1115 1187 1188 CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer; 1189 int nbWritten = indexToWrite.numElements(); 1190 CArray<double,1> axis_value(indexToWrite.numElements()); 1191 for (int i = 0; i < nbWritten; i++) axis_value(i) = axis->value(indexToWrite(i)); 1192 CArray<double,2> axis_bounds; 1193 1116 1194 switch (SuperClass::type) 1117 1195 { 1118 1196 case MULTI_FILE: 1119 1197 { 1120 CArray<double,1> axis_value(axis->zoom_n);1121 for (int i = 0; i < axis->zoom_n; i++) axis_value(i) = axis->value(i);1198 // CArray<double,1> axis_value(axis->zoom_n); 1199 // for (int i = 0; i < axis->zoom_n; i++) axis_value(i) = axis->value(i); 1122 1200 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 1123 1201 … … 1131 1209 case ONE_FILE: 1132 1210 { 1133 CArray<double,1> axis_value(axis->zoom_n);1134 axis_value = axis->value;1211 // CArray<double,1> axis_value(axis->zoom_n); 1212 // axis_value = axis->value; 1135 1213 std::vector<StdSize> start(1), startBounds(2) ; 1136 1214 std::vector<StdSize> count(1), countBounds(2) ; … … 1142 1220 1143 1221 if (!axis->bounds.isEmpty()) 1222 { 1223 axis_bounds.resize(2, indexToWrite.numElements()); 1224 for (int i = 0; i < nbWritten; ++i) 1225 { 1226 axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 1227 axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 1228 } 1144 1229 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 1230 } 1145 1231 1146 1232 SuperClassWriter::definition_start(); … … 2371 2457 msg.append(context->getId()); msg.append("\n"); 2372 2458 msg.append(e.what()); 2373 ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg);2459 ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg); 2374 2460 } 2375 2461 } -
XIOS/dev/dev_olga/src/node/axis.cpp
r1099 r1129 28 28 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 29 29 , transformationMap_(), hasValue(false), doZoomByIndex_(false) 30 , computedWrittenIndex_(false) 30 31 { 31 32 } … … 38 39 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 39 40 , transformationMap_(), hasValue(false), doZoomByIndex_(false) 41 , computedWrittenIndex_(false) 40 42 { 41 43 } … … 129 131 { 130 132 return offsetWrittenIndexes_; 131 }132 133 /*!134 Returns the start of indexes written by each server.135 \return the start of indexes written by each server136 */137 int CAxis::getStartWriteIndex() const138 {139 return start_write_index_;140 }141 142 /*!143 Returns the count of indexes written by each server.144 \return the count of indexes written by each server145 */146 int CAxis::getCountWriteIndex() const147 {148 return count_write_index_;149 }150 151 /*!152 Returns the local data written by each server.153 */154 int CAxis::getLocalWriteSize() const155 {156 return local_write_size_;157 }158 159 /*!160 Returns the global data written by all server.161 */162 int CAxis::getGlobalWriteSize() const163 {164 return global_write_size_;165 133 } 166 134 … … 454 422 else 455 423 { 456 sendDistributedAttributes(); 457 sendDistributionAttribute(globalDim, orderPositionInGrid, distType); 424 sendDistributedAttributes(); 458 425 } 426 sendDistributionAttribute(globalDim, orderPositionInGrid, distType); 459 427 } 460 428 … … 639 607 } 640 608 } 609 610 void CAxis::computeWrittenIndex() 611 { 612 if (computedWrittenIndex_) return; 613 computedWrittenIndex_ = true; 614 615 CContext* context=CContext::getCurrent() ; 616 CContextClient* client = context->client; 617 618 std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 619 nBegin[0] = zoom_begin; 620 nSize[0] = zoom_n; 621 nBeginGlobal[0] = 0; 622 nGlob[0] = n_glo; 623 CDistributionServer srvDist(client->clientSize, nBegin, nSize, nBeginGlobal, nGlob); 624 const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); 625 626 size_t nbWritten = 0, indGlo; 627 boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 628 ite = globalLocalIndexMap_.end(), it; 629 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 630 itSrve = writtenGlobalIndex.end(), itSrv; 631 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 632 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 633 { 634 indGlo = *itSrv; 635 if (ite != globalLocalIndexMap_.find(indGlo)) 636 { 637 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 638 ++nbWritten; 639 } 640 } 641 642 } 643 641 644 642 645 … … 875 878 CMessage& msg = msgs.back(); 876 879 msg << this->getId(); 877 msg << index.getValue() << dataIndex << zoom_index.getValue() << mask.getValue(); 880 msg << index.getValue() << dataIndex << mask.getValue(); 881 882 msg << doZoomByIndex_; 883 if (doZoomByIndex_) msg << zoom_index.getValue(); 878 884 msg << hasValue; 879 885 if (hasValue) msg << value.getValue(); 880 881 886 msg << hasBounds_; 882 887 if (hasBounds_) msg << bounds.getValue(); … … 913 918 buffer >> tmp_data_index; 914 919 data_index.reference(tmp_data_index); 915 buffer >> tmp_zoom_index;916 zoom_index.reference(tmp_zoom_index);917 920 buffer >> tmp_mask; 918 921 mask.reference(tmp_mask); 922 923 buffer >> doZoomByIndex_; 924 if (doZoomByIndex_) 925 { 926 buffer >> tmp_zoom_index; 927 zoom_index.reference(tmp_zoom_index); 928 } 929 919 930 buffer >> hasValue; 920 931 if (hasValue) … … 931 942 } 932 943 933 { 934 count_write_index_ = zoom_index.numElements(); 935 start_write_index_ = 0; 936 local_write_size_ = count_write_index_; 937 global_write_size_ = count_write_index_; 938 } 944 data_begin.setValue(0); 945 globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor())); 946 for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[idx] = index(idx); 939 947 } 940 948 … … 1065 1073 get(axisId)->recvDistributedAttributes(ranks, buffers); 1066 1074 } 1075 1067 1076 1068 1077 void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) … … 1099 1108 nbData += vec_indi[idx].numElements(); 1100 1109 } 1101 1110 1102 1111 index.resize(nbData); 1112 globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor())); 1103 1113 CArray<int,1> nonCompressedData(nbData); 1104 1114 mask.resize(nbData); … … 1118 1128 { 1119 1129 index(nbData) = indi(n); 1130 globalLocalIndexMap_[indi(n)] = nbData; 1120 1131 nonCompressedData(nbData) = (0 <= dataIndi(n)) ? nbData : -1; 1121 1132 mask(nbData) = maskIndi(n); … … 1149 1160 } 1150 1161 } 1162 data_begin.setValue(0); 1151 1163 1152 1164 if (doZoomByIndex_) … … 1170 1182 } 1171 1183 } 1172 1173 1174 // {1175 // CContextServer* server = CContext::getCurrent()->server;1176 // count_write_index_ = zoom_index.numElements();1177 // MPI_Scan(&count_write_index_, &start_write_index_, 1, MPI_INT, MPI_SUM, server->intraComm);1178 // global_write_size_ = start_write_index_;1179 // start_write_index_ -= count_write_index_;1180 // local_write_size_ = count_write_index_;1181 // }1182 1184 } 1183 1185 -
XIOS/dev/dev_olga/src/node/axis.hpp
r1099 r1129 78 78 int getOffsetWrittenIndexes() const; 79 79 80 int getStartWriteIndex() const;81 int getCountWriteIndex() const;82 int getLocalWriteSize() const;83 int getGlobalWriteSize() const;84 85 80 std::map<int, StdSize> getAttributesBufferSize(); 86 81 … … 119 114 void checkEligibilityForCompressedOutput(); 120 115 116 void computeWrittenIndex(); 121 117 bool hasTransformation(); 122 118 void solveInheritanceTransformation(); … … 134 130 CArray<int,1> globalDimGrid; 135 131 int orderPosInGrid; 132 CArray<size_t,1> localIndexToWriteOnServer; 136 133 137 134 private: … … 176 173 bool hasBounds_; 177 174 178 int start_write_index_;179 int count_write_index_;180 int local_write_size_;181 int global_write_size_;182 183 175 bool doZoomByIndex_; 176 bool computedWrittenIndex_; 184 177 185 178 private: -
XIOS/dev/dev_olga/src/node/context.cpp
r1099 r1129 572 572 postProcessingGlobalAttributes(); 573 573 574 if (hasClient) sendPostProcessingGlobalAttributes(); 575 576 // There are some processings that should be done after all of above. For example: check mask or index 574 if (hasClient) sendPostProcessingGlobalAttributes(); 575 577 576 this->buildFilterGraphOfEnabledFields(); 578 577 579 578 if (hasClient && !hasServer) 580 579 { 581 buildFilterGraphOfFieldsWithReadAccess(); 580 buildFilterGraphOfFieldsWithReadAccess(); 582 581 } 583 582 … … 623 622 { 624 623 this->enabledFiles[i]->solveOnlyRefOfEnabledFields(false); 624 // this->enabledFiles[i]->solveAllReferenceEnabledField(false); 625 625 } 626 626 … … 663 663 this->enabledFiles[i]->generateNewTransformationGridDest(); 664 664 } 665 666 for (int i = 0; i < size; ++i) 667 { 668 //this->enabledFiles[i]->checkGridOfEnabledFields(); 669 } 670 } 671 672 void CContext::solveAllRefOfEnabledFields(bool sendToServer) 665 } 666 667 void CContext::solveAllRefOfEnabledFieldsAndTransform(bool sendToServer) 673 668 { 674 669 int size = this->enabledFiles.size(); 675 670 for (int i = 0; i < size; ++i) 676 671 { 677 this->enabledFiles[i]->solveAllRefOfEnabledFields (sendToServer);672 this->enabledFiles[i]->solveAllRefOfEnabledFieldsAndTransform(sendToServer); 678 673 } 679 674 } … … 1168 1163 1169 1164 // Search and rebuild all reference object of enabled fields, and transform 1170 this->solveAllEnabledFields();1171 1165 // this->solveAllEnabledFields 1166 this->solveAllRefOfEnabledFieldsAndTransform(false); 1172 1167 // // Check grid and calculate its distribution 1173 1168 // if (hasClient) checkGridEnabledFields(); -
XIOS/dev/dev_olga/src/node/context.hpp
r1099 r1129 114 114 void checkAxisDomainsGridsEligibilityForCompressedOutput(); 115 115 void prepareTimeseries(void); 116 void solveOnlyRefOfEnabledFields(bool sendToServer); 117 void solveAllRefOfEnabledFields(bool sendToServer); 116 void solveOnlyRefOfEnabledFields(bool sendToServer); 118 117 void buildFilterGraphOfEnabledFields(); 119 118 void startPrefetchingOfEnabledReadModeFiles(); … … 125 124 void postProcessingGlobalAttributes(); 126 125 126 void solveAllRefOfEnabledFieldsAndTransform(bool sendToServer); 127 127 void solveAllEnabledFields(); 128 128 void checkGridEnabledFields(); -
XIOS/dev/dev_olga/src/node/domain.cpp
r1099 r1129 26 26 namespace xios { 27 27 28 /// ////////////////////// D éfinitions ////////////////////// ///28 /// ////////////////////// Dfinitions ////////////////////// /// 29 29 30 30 CDomain::CDomain(void) 31 31 : CObjectTemplate<CDomain>(), CDomainAttributes() 32 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 32 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() 33 33 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 34 34 , isClientAfterTransformationChecked(false), hasLonLat(false) 35 35 , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 36 36 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 37 , globalLocalIndexMap_() 37 , globalLocalIndexMap_(), computedWrittenIndex_(false) 38 38 { 39 39 } … … 41 41 CDomain::CDomain(const StdString & id) 42 42 : CObjectTemplate<CDomain>(id), CDomainAttributes() 43 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 43 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() 44 44 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 45 45 , isClientAfterTransformationChecked(false), hasLonLat(false) 46 46 , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 47 47 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 48 , globalLocalIndexMap_() 48 , globalLocalIndexMap_(), computedWrittenIndex_(false) 49 49 { 50 50 } … … 1082 1082 //---------------------------------------------------------------- 1083 1083 1084 /* 1085 Fill in longitude and latitude value from clients (or models) into internal values lonvalue, latvalue which 1086 will be used by XIOS. 1087 */ 1084 1088 void CDomain::completeLonLatClient(void) 1085 1089 { … … 1181 1185 } 1182 1186 1187 /* 1188 Convert internal longitude latitude value used by XIOS to "lonvalue_*" which can be retrieved with Fortran interface 1189 */ 1190 void CDomain::convertLonLatValue(void) 1191 { 1192 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 1193 if (!lonvalue_2d.isEmpty() && lonlatValueExisted) 1194 { 1195 lonvalue_2d.resize(ni,nj); 1196 latvalue_2d.resize(ni,nj); 1197 if (hasBounds) 1198 { 1199 bounds_lon_2d.resize(nvertex, ni, nj); 1200 bounds_lat_2d.resize(nvertex, ni, nj); 1201 } 1202 1203 for (int j = 0; j < nj; ++j) 1204 { 1205 for (int i = 0; i < ni; ++i) 1206 { 1207 int k = j * ni + i; 1208 1209 lonvalue_2d(i,j) = lonvalue(k); 1210 latvalue_2d(i,j) = latvalue(k); 1211 1212 if (hasBounds) 1213 { 1214 for (int n = 0; n < nvertex; ++n) 1215 { 1216 bounds_lon_2d(n,i,j) = bounds_lonvalue(n,k); 1217 bounds_lat_2d(n,i,j) = bounds_latvalue(n,k); 1218 } 1219 } 1220 } 1221 } 1222 } 1223 else if (!lonvalue_1d.isEmpty() && lonlatValueExisted) 1224 { 1225 if (type_attr::rectilinear == type) 1226 { 1227 if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) 1228 { 1229 lonvalue.resize(ni * nj); 1230 latvalue.resize(ni * nj); 1231 if (hasBounds) 1232 { 1233 bounds_lonvalue.resize(nvertex, ni * nj); 1234 bounds_latvalue.resize(nvertex, ni * nj); 1235 } 1236 1237 for (int j = 0; j < nj; ++j) 1238 { 1239 for (int i = 0; i < ni; ++i) 1240 { 1241 int k = j * ni + i; 1242 1243 lonvalue(k) = lonvalue_1d(i); 1244 latvalue(k) = latvalue_1d(j); 1245 1246 if (hasBounds) 1247 { 1248 for (int n = 0; n < nvertex; ++n) 1249 { 1250 bounds_lonvalue(n,k) = bounds_lon_1d(n,i); 1251 bounds_latvalue(n,k) = bounds_lat_1d(n,j); 1252 } 1253 } 1254 } 1255 } 1256 } 1257 else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) 1258 { 1259 lonvalue.reference(lonvalue_1d); 1260 latvalue.reference(latvalue_1d); 1261 if (hasBounds) 1262 { 1263 bounds_lonvalue.reference(bounds_lon_1d); 1264 bounds_latvalue.reference(bounds_lat_1d); 1265 } 1266 } 1267 else 1268 ERROR("CDomain::completeLonClient(void)", 1269 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1270 << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl 1271 << "'lonvalue_1d' size is " << lonvalue_1d.numElements() 1272 << " and 'latvalue_1d' size is " << latvalue_1d.numElements() << std::endl 1273 << " They should be correspondingly " << ni.getValue() << " and " << nj.getValue() << " or " << std::endl 1274 << i_index.numElements() << " and " << j_index.numElements() << "."); 1275 } 1276 else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) 1277 { 1278 lonvalue.reference(lonvalue_1d); 1279 latvalue.reference(latvalue_1d); 1280 if (hasBounds) 1281 { 1282 bounds_lonvalue.reference(bounds_lon_1d); 1283 bounds_latvalue.reference(bounds_lat_1d); 1284 } 1285 } 1286 } 1287 } 1288 1289 1183 1290 void CDomain::checkBounds(void) 1184 1291 { … … 1395 1502 1396 1503 if (context->hasClient && !context->hasServer) 1397 { // C ÃŽtéclient uniquement1504 { // Ct client uniquement 1398 1505 this->checkMask(); 1399 1506 this->checkDomainData(); … … 1402 1509 } 1403 1510 else 1404 { // C ÃŽtéserveur uniquement1511 { // Ct serveur uniquement 1405 1512 } 1406 1513 … … 1435 1542 1436 1543 if (context->hasClient) 1437 { // C ÃŽtéclient uniquement1544 { // Ct client uniquement 1438 1545 this->checkMask(); 1439 1546 this->checkDomainData(); … … 1443 1550 } 1444 1551 else 1445 { // C ÃŽtéserveur uniquement1552 { // Ct serveur uniquement 1446 1553 } 1447 1554 … … 1549 1656 for (i = 0; i < nbIndex; ++i) 1550 1657 globalLocalIndexMap_[globalIndexDomain(i)] = i; 1551 1552 1658 } 1553 1659 … … 1598 1704 zoom_nj = zoom_jend-zoom_jbegin+1; 1599 1705 } 1706 1707 // if (globalLocalIndexZoomMap_.empty()) 1708 // { 1709 // int nbIndexZoom = globalIndexDomainZoom.numElements(); 1710 // for (i = 0; i < nbIndex; ++i) 1711 // globalLocalIndexZoomMap_[globalIndexDomainZoom(i)] = i; 1712 // } 1600 1713 1601 1714 … … 1690 1803 for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 1691 1804 connectedServerRank_.push_back(it->first); 1692 // std::vector<size_t> vec = it->second;1693 // std::sort(vec.begin(), vec.end());1694 // indSrv_[it->first] = vec;1695 1805 } 1696 1806 … … 1700 1810 clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 1701 1811 CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1702 // indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1703 std::vector<int> connectedServerZoomRank; //(indZoomSrv_.size()); 1704 // for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1705 // connectedServerZoomRank.push_back(it->first); 1706 for (it = globalIndexDomainZoomOnServer.begin(); it != globalIndexDomainZoomOnServer.end(); ++it) 1707 { 1708 connectedServerZoomRank.push_back(it->first); 1709 std::vector<size_t> vec = it->second; 1710 std::sort(vec.begin(), vec.end()); 1711 indZoomSrv_[it->first] = vec; 1712 } 1713 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank); 1812 indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1813 1814 for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1815 connectedServerZoomRank_.push_back(it->first); 1816 1817 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank_); 1714 1818 1715 1819 delete clientServerMap; … … 1721 1825 return indSrv_; 1722 1826 } 1827 1828 void CDomain::computeWrittenIndex() 1829 { 1830 if (computedWrittenIndex_) return; 1831 computedWrittenIndex_ = true; 1832 1833 CContext* context=CContext::getCurrent() ; 1834 CContextClient* client = context->client; 1835 1836 std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); 1837 nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin; 1838 nSize[0] = zoom_ni; nSize[1] = zoom_nj; 1839 nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; 1840 nGlob[0] = ni_glo; nGlob[1] = nj_glo; 1841 CDistributionServer srvDist(client->clientSize, nBegin, nSize, nBeginGlobal, nGlob); 1842 const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); 1843 1844 size_t nbWritten = 0, indGlo; 1845 boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 1846 ite = globalLocalIndexMap_.end(), it; 1847 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 1848 itSrve = writtenGlobalIndex.end(), itSrv; 1849 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 1850 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 1851 { 1852 indGlo = *itSrv; 1853 if (ite != globalLocalIndexMap_.find(indGlo)) 1854 { 1855 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 1856 ++nbWritten; 1857 } 1858 } 1859 } 1723 1860 1724 1861 /*! … … 1729 1866 { 1730 1867 sendDistributionAttributes(); 1731 sendIndex(); 1732 sendIndex();1868 sendIndex(); 1869 // sendIndexZoom(); 1733 1870 sendMask(); 1734 1871 sendLonLat(); … … 1757 1894 list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 1758 1895 1759 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex , itZoom, iteZoom;1760 iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end();1896 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 1897 iteIndex = indSrv_.end(); 1761 1898 for (int k = 0; k < connectedServerRank_.size(); ++k) 1762 1899 { … … 1766 1903 if (iteIndex != itIndex) 1767 1904 nbIndGlob = itIndex->second.size(); 1768 int nbIndZoom = 0; 1769 itZoom = indZoomSrv_.find(rank); 1770 if (iteZoom != itZoom) 1771 nbIndZoom = itZoom->second.size(); 1772 1773 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1774 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1775 1776 CArray<int,1>& indZoom = list_indZoom.back(); 1905 1906 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1907 1777 1908 CArray<int,1>& indGlob = list_indGlob.back(); 1778 1909 for (n = 0; n < nbIndGlob; ++n) 1779 1910 { 1780 1911 indGlob(n) = static_cast<int>(itIndex->second[n]); 1781 }1782 1783 for (n = 0; n < nbIndZoom; ++n)1784 {1785 indZoom(n) = static_cast<int>(itZoom->second[n]);1786 1912 } 1787 1913 … … 1789 1915 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1790 1916 list_msgsIndex.back() << isCurvilinear; 1791 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back(); 1792 if (!doZoomByIndex_) 1793 { 1794 //list_msgsIndex.back() << zoom_ni.getValue() << zoom_ibegin.getValue() << zoom_nj.getValue() << zoom_jbegin.getValue(); 1795 } 1917 list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 1796 1918 1797 1919 // if (isCompressible_) … … 1811 1933 1812 1934 client->sendEvent(eventIndex); 1935 } 1936 } 1937 1938 /*! 1939 Send global index and zoom index from client to connected client(s) 1940 zoom index can be smaller than global index 1941 */ 1942 void CDomain::sendIndexZoom() 1943 { 1944 int ns, n, i, j, ind, nv, idx; 1945 CContext* context = CContext::getCurrent(); 1946 1947 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1948 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 1949 for (int p = 0; p < nbSrvPools; ++p) 1950 { 1951 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; 1952 CEventClient eventIndexZoom(getType(), EVENT_ID_INDEX_ZOOM); 1953 1954 list<CMessage> list_msgsIndex; 1955 list<CArray<int,1> > list_indZoom; 1956 1957 boost::unordered_map<int, vector<size_t> >::const_iterator itZoom, iteZoom; 1958 iteZoom = indZoomSrv_.end(); 1959 for (int k = 0; k < connectedServerZoomRank_.size(); ++k) 1960 { 1961 int nbIndGlob = 0; 1962 int rank = connectedServerZoomRank_[k]; 1963 int nbIndZoom = 0; 1964 itZoom = indZoomSrv_.find(rank); 1965 if (iteZoom != itZoom) 1966 nbIndZoom = itZoom->second.size(); 1967 1968 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1969 CArray<int,1>& indZoom = list_indZoom.back(); 1970 for (n = 0; n < nbIndZoom; ++n) 1971 { 1972 indZoom(n) = static_cast<int>(itZoom->second[n]); 1973 } 1974 1975 list_msgsIndex.push_back(CMessage()); 1976 list_msgsIndex.back() << this->getId(); // enum ne fonctionne pour les message => ToFix 1977 list_msgsIndex.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back 1978 1979 eventIndexZoom.push(rank, nbConnectedClientsZoom_[rank], list_msgsIndex.back()); 1980 } 1981 1982 client->sendEvent(eventIndexZoom); 1813 1983 } 1814 1984 } … … 2036 2206 list_msgsLat.push_back(CMessage()); 2037 2207 2038 list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 2039 list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 2040 2208 list_msgsLon.back() << this->getId() << hasLonLat; 2209 if (hasLonLat) 2210 list_msgsLon.back() << list_lon.back(); 2211 list_msgsLon.back() << hasBounds; 2041 2212 if (hasBounds) 2042 2213 { 2043 2214 list_msgsLon.back() << list_boundslon.back(); 2215 } 2216 2217 list_msgsLat.back() << this->getId() << hasLonLat; 2218 if (hasLonLat) 2219 list_msgsLat.back() << list_lat.back(); 2220 list_msgsLat.back() << hasBounds; 2221 if (hasBounds) 2222 { 2044 2223 list_msgsLat.back() << list_boundslat.back(); 2045 2224 } … … 2076 2255 2077 2256 int nbIndex = i_index.numElements(); 2257 int niByIndex = max(i_index) - min(i_index) + 1; 2258 int njByIndex = max(j_index) - min(j_index) + 1; 2259 int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex; 2260 int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex; 2261 2262 2078 2263 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 2079 dataIIndex = -1; dataJIndex = -1, ind = 0; 2264 dataIIndex = -1; 2265 dataJIndex = -1; 2266 ind = 0; 2267 2080 2268 for (idx = 0; idx < data_i_index.numElements(); ++idx) 2081 2269 { 2082 if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 2083 { 2084 dataIIndex(ind) = data_i_index(idx); 2085 dataJIndex(ind) = data_j_index(idx); 2086 ++ind; 2270 int dataIidx = data_i_index(idx) + data_ibegin; 2271 int dataJidx = data_j_index(idx) + data_jbegin; 2272 if ((0 <= dataIidx) && (dataIidx < dataIindexBound) && 2273 (0 <= dataJidx) && (dataJidx < dataJindexBound)) 2274 { 2275 dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx; 2276 dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);// 2087 2277 } 2088 2278 } … … 2131 2321 case EVENT_ID_INDEX: 2132 2322 recvIndex(event); 2323 return true; 2324 break; 2325 case EVENT_ID_INDEX_ZOOM: 2326 recvIndexZoom(event); 2133 2327 return true; 2134 2328 break; … … 2198 2392 { 2199 2393 int nbReceived = rankBuffers.size(), i, ind, index, type_int; 2200 recvClientRanks_.resize(nbReceived); 2201 vector<CArray<int,1> > recvZoomInd(nbReceived); 2202 int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 2394 recvClientRanks_.resize(nbReceived); 2203 2395 2204 2396 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); … … 2208 2400 recvClientRanks_[ind] = it->first; 2209 2401 CBufferIn& buffer = *(it->second); 2210 buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind] >> doZoomByIndex_; 2211 if (!doZoomByIndex_) 2212 { 2213 //buffer >> ni_zoom_tmp >> ibegin_zoom_tmp >> nj_zoom_tmp >> jbegin_zoom_tmp; 2214 } 2402 buffer >> type_int >> isCurvilinear >> indGlob_[it->first]; 2215 2403 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 2216 2404 } … … 2224 2412 j_index.resize(nbIndGlob); 2225 2413 2414 globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 2226 2415 nbIndGlob = 0; 2227 2416 for (i = 0; i < nbReceived; ++i) … … 2233 2422 i_index(nbIndGlob) = index % ni_glo; 2234 2423 j_index(nbIndGlob) = index / ni_glo; 2424 globalLocalIndexMap_[index] = nbIndGlob; 2235 2425 ++nbIndGlob; 2236 2426 } 2237 } 2238 2239 int nbZoomInd = 0; 2240 for (i = 0; i < nbReceived; ++i) 2241 { 2242 nbZoomInd += recvZoomInd[i].numElements(); 2243 } 2244 2245 if (doZoomByIndex_) 2246 { 2247 zoom_i_index.resize(nbZoomInd); 2248 zoom_j_index.resize(nbZoomInd); 2249 2250 nbZoomInd = 0; 2251 for (i = 0; i < nbReceived; ++i) 2252 { 2253 CArray<int,1>& tmp = recvZoomInd[i]; 2254 for (ind = 0; ind < tmp.numElements(); ++ind) 2255 { 2256 index = tmp(ind); 2257 zoom_i_index(nbZoomInd) = index % ni_glo; 2258 zoom_j_index(nbZoomInd) = index / ni_glo; 2259 ++nbZoomInd; 2260 } 2261 } 2262 } 2263 else 2264 { 2265 // zoom_ni.setValue(ni_zoom_tmp); 2266 // zoom_ibegin.setValue(ibegin_zoom_tmp); 2267 // zoom_nj.setValue(nj_zoom_tmp); 2268 // zoom_jbegin.setValue(jbegin_zoom_tmp); 2269 // int nbZoom = ni_zoom_tmp * nj_zoom_tmp; 2270 // zoom_i_index.resize(nbZoom); 2271 // zoom_j_index.resize(nbZoom); 2272 // nbZoom = 0; 2273 // for (int j = 0; j < nj_zoom_tmp; ++j) 2274 // for (int i = 0; i < ni_zoom_tmp; ++i) 2275 // { 2276 // zoom_i_index(nbZoom) = ibegin_zoom_tmp + i; 2277 // zoom_j_index(nbZoom) = jbegin_zoom_tmp + j; 2278 // ++nbZoom; 2279 // } 2280 } 2281 2282 globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 2283 nbIndGlob = 0; 2284 for (int j = 0; j < nj; ++j) 2285 for (int i = 0; i < ni; ++i) 2286 { 2287 globalLocalIndexMap_[(i + ibegin) + (j + jbegin) * ni_glo] = nbIndGlob; 2288 ++nbIndGlob; 2289 } 2290 2291 2427 } 2292 2428 2293 2429 // { … … 2368 2504 2369 2505 /*! 2506 Receive index event from clients(s) 2507 \param[in] event event contain info about rank and associated index 2508 */ 2509 void CDomain::recvIndexZoom(CEventServer& event) 2510 { 2511 string domainId; 2512 std::map<int, CBufferIn*> rankBuffers; 2513 2514 list<CEventServer::SSubEvent>::iterator it; 2515 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2516 { 2517 CBufferIn* buffer = it->buffer; 2518 *buffer >> domainId; 2519 rankBuffers[it->rank] = buffer; 2520 } 2521 get(domainId)->recvIndexZoom(rankBuffers); 2522 } 2523 2524 /*! 2525 Receive index information from client(s) 2526 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2527 */ 2528 void CDomain::recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers) 2529 { 2530 int nbReceived = rankBuffers.size(), i, ind, index, type_int; 2531 recvClientZoomRanks_.resize(nbReceived); 2532 int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 2533 2534 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 2535 ind = 0; 2536 for (ind = 0; it != ite; ++it, ++ind) 2537 { 2538 recvClientZoomRanks_[ind] = it->first; 2539 CBufferIn& buffer = *(it->second); 2540 buffer >> indGlobZoom_[it->first] >> doZoomByIndex_; 2541 } 2542 2543 int nbZoomInd = 0; 2544 for (i = 0; i < nbReceived; ++i) 2545 { 2546 nbZoomInd += indGlobZoom_[recvClientZoomRanks_[i]].numElements(); 2547 } 2548 2549 if (doZoomByIndex_) 2550 { 2551 zoom_i_index.resize(nbZoomInd); 2552 zoom_j_index.resize(nbZoomInd); 2553 2554 nbZoomInd = 0; 2555 for (i = 0; i < nbReceived; ++i) 2556 { 2557 CArray<int,1>& tmp = indGlobZoom_[recvClientRanks_[i]]; 2558 for (ind = 0; ind < tmp.numElements(); ++ind) 2559 { 2560 index = tmp(ind); 2561 zoom_i_index(nbZoomInd) = index % ni_glo; 2562 zoom_j_index(nbZoomInd) = index / ni_glo; 2563 ++nbZoomInd; 2564 } 2565 } 2566 } 2567 else 2568 { 2569 } 2570 2571 // globalLocalIndexZoomMap_.rehash(std::ceil(nbZoomInd/globalLocalIndexZoomMap_.max_load_factor())); 2572 // nbZoomInd = 0; 2573 // for (int j = 0; j < zoom_nj; ++j) 2574 // for (int i = 0; i < zoom_ni; ++i) 2575 // { 2576 // globalLocalIndexZoomMap_[(i + zoom_ibegin) + (j + zoom_jbegin) * ni_glo] = nbZoomInd; 2577 // ++nbZoomInd; 2578 // } 2579 } 2580 2581 /*! 2370 2582 Receive attributes event from clients(s) 2371 2583 \param[in] event event contain info about rank and associated attributes … … 2506 2718 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 2507 2719 { 2508 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex ;2720 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 2509 2721 if (nbReceived != recvClientRanks_.size()) 2510 2722 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", … … 2519 2731 CBufferIn& buffer = *(rankBuffers[rank]); 2520 2732 buffer >> hasLonLat; 2521 buffer >> recvLonValue[i]; 2733 if (hasLonLat) 2734 buffer >> recvLonValue[i]; 2522 2735 buffer >> hasBounds; 2523 2736 if (hasBounds) … … 2525 2738 } 2526 2739 2527 lonvalue.resize(zoom_ni*zoom_nj); 2528 lonvalue = 0; 2529 2530 if (hasBounds) 2740 if (hasLonLat) 2531 2741 { 2532 bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); 2533 bounds_lonvalue = 0.; 2534 } 2742 int nbLonInd = 0; 2743 for (i = 0; i < nbReceived; ++i) 2744 { 2745 nbLonInd += recvLonValue[i].numElements(); 2746 } 2535 2747 2536 for (i = 0; i < nbReceived; ++i) 2537 { 2538 int rank = recvClientRanks_[i]; 2539 CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2540 for (ind = 0; ind < indi.numElements(); ++ind) 2541 { 2542 iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2543 index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2544 lonvalue(index) = recvLonValue[i](ind); 2545 if (hasBounds) 2546 { 2547 for (int nv = 0; nv < nvertex; ++nv) 2548 bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); 2549 } 2550 } 2551 } 2748 if (nbLonInd != globalLocalIndexMap_.size()) 2749 info (0) << "Something wrong with longitude index "<< std::endl; 2750 2751 lonvalue.resize(nbLonInd); 2752 if (hasBounds) 2753 { 2754 bounds_lonvalue.resize(nvertex,nbLonInd); 2755 bounds_lonvalue = 0.; 2756 } 2757 2758 nbLonInd = 0; 2759 for (i = 0; i < nbReceived; ++i) 2760 { 2761 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2762 CArray<double,1>& tmp = recvLonValue[i]; 2763 for (ind = 0; ind < tmp.numElements(); ++ind) 2764 { 2765 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2766 lonvalue(lInd) = tmp(ind); 2767 if (hasBounds) 2768 { 2769 for (int nv = 0; nv < nvertex; ++nv) 2770 bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); 2771 } 2772 } 2773 } 2774 } 2775 2776 2777 2778 // lonvalue.resize(zoom_ni*zoom_nj); 2779 // lonvalue = 0; 2780 2781 // if (hasBounds) 2782 // { 2783 // bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); 2784 // bounds_lonvalue = 0.; 2785 // } 2786 2787 // if (0 == lonvalue.numElements()) return; 2788 2789 // for (i = 0; i < nbReceived; ++i) 2790 // { 2791 // int rank = recvClientRanks_[i]; 2792 // CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2793 // for (ind = 0; ind < indi.numElements(); ++ind) 2794 // { 2795 // iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2796 // index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2797 // lonvalue(index) = recvLonValue[i](ind); 2798 // if (hasBounds) 2799 // { 2800 // for (int nv = 0; nv < nvertex; ++nv) 2801 // bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); 2802 // } 2803 // } 2804 // } 2552 2805 } 2553 2806 … … 2577 2830 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 2578 2831 { 2579 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex ;2832 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; 2580 2833 if (nbReceived != recvClientRanks_.size()) 2581 2834 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", … … 2590 2843 CBufferIn& buffer = *(rankBuffers[rank]); 2591 2844 buffer >> hasLonLat; 2592 buffer >> recvLatValue[i]; 2845 if (hasLonLat) 2846 buffer >> recvLatValue[i]; 2593 2847 buffer >> hasBounds; 2594 2848 if (hasBounds) … … 2596 2850 } 2597 2851 2598 latvalue.resize(zoom_ni*zoom_nj); 2599 latvalue = 0; 2600 2601 if (hasBounds) 2852 if (hasLonLat) 2602 2853 { 2603 bounds_latvalue.resize(nvertex,zoom_ni*zoom_nj); 2604 bounds_latvalue = 0. ; 2605 } 2854 int nbLatInd = 0; 2855 for (i = 0; i < nbReceived; ++i) 2856 { 2857 nbLatInd += recvLatValue[i].numElements(); 2858 } 2606 2859 2607 for (i = 0; i < nbReceived; ++i) 2608 { 2609 int rank = recvClientRanks_[i]; 2610 CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2611 CArray<double,1>& lat = recvLatValue[i]; 2612 for (ind = 0; ind < indi.numElements(); ++ind) 2613 { 2614 iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2615 index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2616 latvalue(index) = lat(ind); 2617 if (hasBounds) 2618 { 2619 CArray<double,2>& boundslat = recvBoundsLatValue[i]; 2620 for (int nv = 0; nv < nvertex; ++nv) 2621 bounds_latvalue(nv, index) = boundslat(nv, ind); 2622 } 2623 } 2860 if (nbLatInd != globalLocalIndexMap_.size()) 2861 info (0) << "Something wrong with latitude index "<< std::endl; 2862 2863 latvalue.resize(nbLatInd); 2864 if (hasBounds) 2865 { 2866 bounds_latvalue.resize(nvertex,nbLatInd); 2867 bounds_latvalue = 0. ; 2868 } 2869 2870 nbLatInd = 0; 2871 for (i = 0; i < nbReceived; ++i) 2872 { 2873 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2874 CArray<double,1>& tmp = recvLatValue[i]; 2875 for (ind = 0; ind < tmp.numElements(); ++ind) 2876 { 2877 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2878 latvalue(lInd) = tmp(ind); 2879 if (hasBounds) 2880 { 2881 CArray<double,2>& boundslat = recvBoundsLatValue[i]; 2882 for (int nv = 0; nv < nvertex; ++nv) 2883 bounds_latvalue(nv, lInd) = boundslat(nv, ind); 2884 } 2885 ++nbLatInd; 2886 } 2887 } 2624 2888 } 2625 2889 } … … 2651 2915 void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 2652 2916 { 2653 int nbReceived = rankBuffers.size(), i, ind, index ;2917 int nbReceived = rankBuffers.size(), i, ind, index, lInd; 2654 2918 if (nbReceived != recvClientRanks_.size()) 2655 2919 ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", … … 2669 2933 int nbAreaInd = 0; 2670 2934 for (i = 0; i < nbReceived; ++i) 2671 { 2672 if (hasArea) 2673 nbAreaInd += recvAreaValue[i].numElements(); 2935 { 2936 nbAreaInd += recvAreaValue[i].numElements(); 2674 2937 } 2675 2938 2676 areavalue.resize(nbAreaInd); 2677 nbAreaInd = 0; 2939 if (nbAreaInd != globalLocalIndexMap_.size()) 2940 info (0) << "Something wrong with latitude index "<< std::endl; 2941 2678 2942 if (hasArea) 2679 2943 { 2944 areavalue.resize(nbAreaInd); 2945 nbAreaInd = 0; 2680 2946 for (i = 0; i < nbReceived; ++i) 2681 2947 { 2948 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2682 2949 CArray<double,1>& tmp = recvAreaValue[i]; 2683 2950 for (ind = 0; ind < tmp.numElements(); ++ind) 2684 2951 { 2685 area(nbAreaInd) = tmp(ind); 2686 ++nbAreaInd; 2687 } 2688 } 2952 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2953 areavalue(lInd) = tmp(ind); 2954 } 2955 } 2956 2689 2957 } 2690 2958 } … … 2728 2996 void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 2729 2997 { 2730 int nbReceived = rankBuffers.size(), i, ind, index, indexI, type_int;2998 int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; 2731 2999 if (nbReceived != recvClientRanks_.size()) 2732 ERROR("void CDomain::recv Lat(std::map<int, CBufferIn*>& rankBuffers)",3000 ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", 2733 3001 << "The number of sending clients is not correct." 2734 3002 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); … … 2743 3011 } 2744 3012 2745 int nbCompressedData = 0; 3013 int nbIndex = i_index.numElements(); 3014 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 3015 dataIIndex = -1; dataJIndex = -1; 3016 3017 nbIndex = 0; 2746 3018 for (i = 0; i < nbReceived; ++i) 3019 { 3020 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 3021 CArray<int,1>& tmpI = recvDataIIndex[i]; 3022 CArray<int,1>& tmpJ = recvDataJIndex[i]; 3023 if ((tmpI.numElements() != tmpInd.numElements()) || (tmpJ.numElements() != tmpInd.numElements())) 3024 ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", 3025 << "The number of global received index is not coherent with the number of received data index." 3026 << "Expected number of global index: " << tmpI.numElements() << " but received " << tmpInd.numElements()); 3027 3028 for (ind = 0; ind < tmpI.numElements(); ++ind) 3029 { 3030 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 3031 dataIIndex(lInd) = tmpI(ind); 3032 dataJIndex(lInd) = tmpJ(ind); 3033 } 3034 } 3035 3036 int nbCompressedData = 0; 3037 for (ind = 0; ind < dataIIndex.numElements(); ++ind) 2747 3038 { 2748 CArray<int,1>& tmp = recvDataIIndex[i]; 2749 for (ind = 0; ind < tmp.numElements(); ++ind) 2750 { 2751 index = tmp(ind); 2752 if (0 <= index) 2753 ++nbCompressedData; 2754 } 2755 } 2756 3039 indexI = dataIIndex(ind); indexJ = dataJIndex(ind); 3040 if ((0 <= indexI) && (0 <= indexJ)) 3041 ++nbCompressedData; 3042 } 3043 2757 3044 data_i_index.resize(nbCompressedData); 2758 3045 data_j_index.resize(nbCompressedData); 2759 3046 2760 nbCompressedData = 0; 2761 for (i = 0; i < nbReceived; ++i)3047 nbCompressedData = 0; 3048 for (ind = 0; ind < dataIIndex.numElements(); ++ind) 2762 3049 { 2763 CArray<int,1>& tmpI = recvDataIIndex[i]; 2764 CArray<int,1>& tmpIndex = indGlob_[recvClientRanks_[i]]; 2765 for (ind = 0; ind < tmpI.numElements(); ++ind) 2766 { 2767 indexI = tmpI(ind); 2768 index = tmpIndex(ind); 2769 if (0 <= indexI) 2770 { 2771 data_i_index(nbCompressedData) = index % ni_glo - ibegin; 2772 data_j_index(nbCompressedData) = index / ni_glo - jbegin; 2773 ++nbCompressedData; 2774 } 2775 } 2776 } 3050 indexI = dataIIndex(ind); indexJ = dataJIndex(ind); 3051 if ((0 <= indexI) && (0 <= indexJ)) 3052 { 3053 data_i_index(nbCompressedData) = (1 == data_dim) ? ind : i_index(ind) - i_index(0); 3054 data_j_index(nbCompressedData) = (1 == data_dim) ? 0 : j_index(ind) - j_index(0); 3055 ++nbCompressedData; 3056 } 3057 } 3058 3059 // Reset data_ibegin, data_jbegin 3060 data_ibegin.setValue(0); 3061 data_jbegin.setValue(0); 2777 3062 } 2778 3063 -
XIOS/dev/dev_olga/src/node/domain.hpp
r1099 r1129 51 51 EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 52 52 EVENT_ID_AREA, EVENT_ID_MASK, 53 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT 53 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT, 54 EVENT_ID_INDEX_ZOOM 54 55 } ; 55 56 … … 106 107 107 108 std::map<int, StdSize> getAttributesBufferSize(); 109 CArray<size_t,1> localIndexToWriteOnServer; 108 110 109 111 bool isEmpty(void) const; … … 127 129 void completeLonLatClient(void); 128 130 void computeConnectedClients(); 131 void computeWrittenIndex(); 129 132 130 133 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, … … 138 141 static void recvDistributionAttributes(CEventServer& event); 139 142 static void recvIndex(CEventServer& event); 143 static void recvIndexZoom(CEventServer& event); 140 144 static void recvMask(CEventServer& event); 141 145 static void recvZoom(CEventServer& event); … … 144 148 static void recvArea(CEventServer& event); 145 149 static void recvDataIndex(CEventServer& event); 146 void recvDistributionAttributes(CBufferIn& buffer); 147 void recvZoom(std::vector<int>& rank, std::vector<CBufferIn*>& buffers); 150 void recvDistributionAttributes(CBufferIn& buffer); 148 151 void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 152 void recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers); 149 153 void recvMask(std::map<int, CBufferIn*>& rankBuffers); 150 154 void recvLon(std::map<int, CBufferIn*>& rankBuffers); … … 192 196 void sendArea(); 193 197 void sendLonLat(); 194 void send Zoom();198 void sendIndexZoom(); 195 199 void sendDataIndex(); 200 201 void convertLonLatValue(); 196 202 197 203 private: … … 202 208 203 209 bool doZoomByIndex_; 204 bool isChecked ;210 bool isChecked, computedWrittenIndex_; 205 211 std::set<StdString> relFiles, relFilesCompressed; 206 212 bool isClientChecked; // Verify whether all attributes of domain on the client side are good 207 213 bool isClientAfterTransformationChecked; 208 std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_ ;214 std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_, indGlobZoom_; 209 215 std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server 210 216 … … 213 219 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 214 220 std::vector<int> indexesToWrite; 215 std::vector<int> recvClientRanks_ ;221 std::vector<int> recvClientRanks_, recvClientZoomRanks_; 216 222 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 217 std::vector<int> connectedServerRank_ ;223 std::vector<int> connectedServerRank_, connectedServerZoomRank_; 218 224 bool isDistributed_; 219 225 //! True if and only if the data defined on the domain can be outputted in a compressed way … … 222 228 TransMapTypes transformationMap_; 223 229 bool isUnstructed_; 224 boost::unordered_map<size_t,size_t> globalLocalIndexMap_ ;230 boost::unordered_map<size_t,size_t> globalLocalIndexMap_, globalLocalIndexZoomMap_; 225 231 226 232 private: -
XIOS/dev/dev_olga/src/node/field.cpp
r1099 r1129 35 35 , nstep(0), nstepMax(0) 36 36 , hasOutputFile(false) 37 , domAxisScalarIds_(vector<StdString>(3,"")), areAllReferenceSolved(false), isReferenceSolved(false) 37 , domAxisScalarIds_(vector<StdString>(3,"")) 38 , areAllReferenceSolved(false), isReferenceSolved(false), isReferenceSolvedAndTransformed(false) 38 39 , useCompressedOutput(false) 39 40 , wasDataAlreadyReceivedFromServer(false) … … 46 47 , nstep(0), nstepMax(0) 47 48 , hasOutputFile(false) 48 , domAxisScalarIds_(vector<StdString>(3,"")), areAllReferenceSolved(false), isReferenceSolved(false) 49 , domAxisScalarIds_(vector<StdString>(3,"")) 50 , areAllReferenceSolved(false), isReferenceSolved(false), isReferenceSolvedAndTransformed(false) 49 51 , useCompressedOutput(false) 50 52 , wasDataAlreadyReceivedFromServer(false) … … 257 259 size_t sizeData = 0; 258 260 if (0 == recvDataSrv.numElements()) 259 { 260 for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 261 { 262 sizeData += it->second.numElements(); 263 data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 264 } 261 { 262 CArray<int,1>& storeClient = grid->storeIndex_client; 263 // for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 264 // { 265 // // sizeData += it->second.numElements(); 266 // data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 267 // } 268 269 // for (map<int, CArray<size_t, 1> >::iterator it = grid->outLocalIndexStoreOnClient.begin(); it != grid->outLocalIndexStoreOnClient.end(); ++it) 270 // { 271 // // sizeData += it->second.numElements(); 272 // data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements()))); 273 // } 265 274 266 275 // Gather all data from different clients 267 recvDataSrv.resize(sizeData); 276 // recvDataSrv.resize(sizeData); 277 recvDataSrv.resize(storeClient.numElements()); 268 278 recvFoperationSrv = boost::shared_ptr<func::CFunctor>(new func::CInstant(recvDataSrv)); 269 279 } … … 276 286 if (opeDate <= currDate) 277 287 { 278 for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it)279 { 288 for (map<int, CArray<size_t, 1> >::iterator it = grid->outLocalIndexStoreOnClient.begin(); it != grid->outLocalIndexStoreOnClient.end(); ++it) 289 { 280 290 CArray<double,1> tmp; 281 291 CArray<size_t,1>& indexTmp = it->second; … … 288 298 // sizeData += it->second.numElements(); 289 299 } 300 301 // for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 302 // { 303 // CArray<double,1> tmp; 304 // CArray<size_t,1>& indexTmp = it->second; 305 // *(rankBuffers[it->first]) >> tmp; 306 // for (int idx = 0; idx < indexTmp.numElements(); ++idx) 307 // { 308 // recv_data_tmp(indexTmp(idx)) = tmp(idx); 309 // } 310 // // recv_data_tmp(Range(sizeData,sizeData+it->second.numElements()-1)) = tmp; 311 // // sizeData += it->second.numElements(); 312 // } 290 313 } 291 314 … … 316 339 recvFoperationSrv->final(); 317 340 last_Write_srv = writeDate; 341 grid->computeWrittenIndex(); 318 342 writeField(); 319 343 lastlast_Write_srv = last_Write_srv; … … 813 837 } 814 838 815 void CField::solveAllEnabledFields() 839 /*! 840 Solve reference of all enabled fields even the source fields . 841 In this step, we do transformations. 842 */ 843 void CField::solveAllEnabledFieldsAndTransform() 816 844 { 817 845 CContext* context = CContext::getCurrent(); … … 819 847 bool hasServer = context->hasServer; 820 848 821 if (!isReferenceSolved )822 { 823 isReferenceSolved = true;849 if (!isReferenceSolvedAndTransformed) 850 { 851 isReferenceSolvedAndTransformed = true; 824 852 825 853 if (hasClient && !hasServer) 826 854 { 827 855 solveRefInheritance(true); 828 if (hasDirectFieldReference()) getDirectFieldReference()->solveAllEnabledFields ();856 if (hasDirectFieldReference()) getDirectFieldReference()->solveAllEnabledFieldsAndTransform(); 829 857 } 830 858 … … 992 1020 { 993 1021 // if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 994 if (!isReferenceSolved ) solveAllEnabledFields();1022 if (!isReferenceSolvedAndTransformed) solveAllEnabledFieldsAndTransform(); 995 1023 CContext* context = CContext::getCurrent(); 996 1024 bool hasWriterServer = context->hasServer && !context->hasClient; … … 1428 1456 void CField::outputField(CArray<double,1>& fieldOut) 1429 1457 { 1430 map<int, CArray<double,1> >::iterator it; 1431 1432 fieldOut = recvDataSrv; 1433 1458 map<int, CArray<double,1> >::iterator it; 1459 1460 CArray<size_t,1>& outIndexClient = grid->localIndexToWriteOnClient; 1461 CArray<size_t,1>& outIndexServer = grid->localIndexToWriteOnServer; 1462 for (size_t idx = 0; idx < outIndexServer.numElements(); ++idx) 1463 { 1464 fieldOut(outIndexServer(idx)) = recvDataSrv(outIndexClient(idx)); 1465 } 1466 1434 1467 // for (it = data_srv.begin(); it != data_srv.end(); it++) 1435 1468 // { -
XIOS/dev/dev_olga/src/node/field.hpp
r1099 r1129 122 122 void solveGridDomainAxisBaseRef(); 123 123 124 void solveAllEnabledFields ();124 void solveAllEnabledFieldsAndTransform(); 125 125 void checkGridOfEnabledFields(); 126 126 void sendGridOfEnabledFields(); … … 216 216 string content; 217 217 218 bool areAllReferenceSolved;219 bool isReferenceSolved;220 218 std::vector<StdString> domAxisScalarIds_; 221 219 bool useCompressedOutput; … … 225 223 bool hasTimeCentered; 226 224 225 227 226 DECLARE_REF_FUNC(Field,field) 227 228 private: 229 bool areAllReferenceSolved; 230 bool isReferenceSolved; 231 bool isReferenceSolvedAndTransformed; 228 232 229 233 private: -
XIOS/dev/dev_olga/src/node/file.cpp
r1071 r1129 695 695 for (int i = 0; i < size; ++i) 696 696 { 697 //this->enabledFields[i]->solveOnlyReferenceEnabledField(sendToServer);698 this->enabledFields[i]->solveAllEnabledFields();697 this->enabledFields[i]->solveOnlyReferenceEnabledField(sendToServer); 698 // this->enabledFields[i]->solveAllEnabledFields(); 699 699 // this->enabledFields[i]->buildGridTransformationGraph(); 700 700 } … … 736 736 \param [in] sendToServer: Send all info to server (true) or only a part of it (false) 737 737 */ 738 void CFile::solveAllRefOfEnabledFields (bool sendToServer)738 void CFile::solveAllRefOfEnabledFieldsAndTransform(bool sendToServer) 739 739 { 740 740 int size = this->enabledFields.size(); 741 741 for (int i = 0; i < size; ++i) 742 742 { 743 this->enabledFields[i]->solveAllReferenceEnabledField(sendToServer); 743 // this->enabledFields[i]->solveAllReferenceEnabledField(sendToServer); 744 this->enabledFields[i]->solveAllEnabledFieldsAndTransform(); 744 745 } 745 746 } -
XIOS/dev/dev_olga/src/node/file.hpp
r1071 r1129 105 105 void solveOnlyRefOfEnabledFields(bool sendToServer); 106 106 void generateNewTransformationGridDest(); 107 void solveAllRefOfEnabledFields(bool sendToServer);107 108 108 void buildFilterGraphOfEnabledFields(CGarbageCollector& gc); 109 109 void prefetchEnabledReadModeFields(); 110 110 void prefetchEnabledReadModeFieldsIfNeeded(); 111 111 112 void solveAllRefOfEnabledFieldsAndTransform(bool sendToServer); 112 113 void checkGridOfEnabledFields(); 113 114 void sendGridOfEnabledFields(); -
XIOS/dev/dev_olga/src/node/grid.cpp
r1099 r1129 35 35 , axisPositionInGrid_(), positionDimensionDistributed_(1), hasDomainAxisBaseRef_(false) 36 36 , gridSrc_(), hasTransform_(false), isGenerated_(false), order_(), globalIndexOnServer_() 37 , computedWrittenIndex_(false) 37 38 { 38 39 setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); … … 53 54 , axisPositionInGrid_(), positionDimensionDistributed_(1), hasDomainAxisBaseRef_(false) 54 55 , gridSrc_(), hasTransform_(false), isGenerated_(false), order_(), globalIndexOnServer_() 56 , computedWrittenIndex_(false) 55 57 { 56 58 setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); … … 403 405 } 404 406 405 void CGrid::modifyMask(const CArray<int,1>& indexToModify )407 void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue) 406 408 { 407 409 using namespace std; … … 412 414 switch (dim) { 413 415 case 1: 414 modifyGridMask(mask_1d, indexToModify );416 modifyGridMask(mask_1d, indexToModify, modifyValue); 415 417 break; 416 418 case 2: 417 modifyGridMask(mask_2d, indexToModify );419 modifyGridMask(mask_2d, indexToModify, modifyValue); 418 420 break; 419 421 case 3: 420 modifyGridMask(mask_3d, indexToModify );422 modifyGridMask(mask_3d, indexToModify, modifyValue); 421 423 break; 422 424 case 4: 423 modifyGridMask(mask_4d, indexToModify );425 modifyGridMask(mask_4d, indexToModify, modifyValue); 424 426 break; 425 427 case 5: 426 modifyGridMask(mask_5d, indexToModify );428 modifyGridMask(mask_5d, indexToModify, modifyValue); 427 429 break; 428 430 case 6: 429 modifyGridMask(mask_6d, indexToModify );431 modifyGridMask(mask_6d, indexToModify, modifyValue); 430 432 break; 431 433 case 7: 432 modifyGridMask(mask_7d, indexToModify); 434 modifyGridMask(mask_7d, indexToModify, modifyValue); 435 break; 436 default: 437 break; 438 } 439 } 440 441 void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue) 442 { 443 std::vector<CDomain*> domainP = this->getDomains(); 444 std::vector<CAxis*> axisP = this->getAxis(); 445 int dim = domainP.size() * 2 + axisP.size(); 446 447 switch (dim) { 448 case 1: 449 modifyGridMaskSize(mask_1d, newDimensionSize, newValue); 450 break; 451 case 2: 452 modifyGridMaskSize(mask_2d, newDimensionSize, newValue); 453 break; 454 case 3: 455 modifyGridMaskSize(mask_3d, newDimensionSize, newValue); 456 break; 457 case 4: 458 modifyGridMaskSize(mask_4d, newDimensionSize, newValue); 459 break; 460 case 5: 461 modifyGridMaskSize(mask_5d, newDimensionSize, newValue); 462 break; 463 case 6: 464 modifyGridMaskSize(mask_6d, newDimensionSize, newValue); 465 break; 466 case 7: 467 modifyGridMaskSize(mask_7d, newDimensionSize, newValue); 433 468 break; 434 469 default: … … 504 539 { 505 540 return axisPositionInGrid_; 541 } 542 543 void CGrid::computeWrittenIndex() 544 { 545 if (computedWrittenIndex_) return; 546 computedWrittenIndex_ = true; 547 548 size_t nbWritten = 0, indGlo; 549 CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistribution_->getGlobalDataIndexOnClient(); 550 CDistributionClient::GlobalLocalDataMap::const_iterator itb = globalDataIndex.begin(), 551 ite = globalDataIndex.end(), it; 552 const CDistributionServer::GlobalLocalMap& globalLocalIndex = serverDistribution_->getGlobalLocalIndex(); 553 CDistributionServer::GlobalLocalMap::const_iterator itSrvb = globalLocalIndex.begin(), 554 itSrve = globalLocalIndex.end(), itSrv; 555 for (it = itb; it != ite; ++it) 556 { 557 indGlo = it->first; 558 if (globalLocalIndex.end() != globalLocalIndex.find(indGlo)) ++nbWritten; 559 } 560 561 localIndexToWriteOnClient.resize(nbWritten); 562 localIndexToWriteOnServer.resize(nbWritten); 563 564 nbWritten = 0; 565 for (it = itb; it != ite; ++it) 566 { 567 indGlo = it->first; 568 itSrv = globalLocalIndex.find(indGlo); 569 if (itSrve != itSrv) 570 { 571 localIndexToWriteOnServer(nbWritten) = itSrv->second; 572 localIndexToWriteOnClient(nbWritten) = it->second; 573 ++nbWritten; 574 } 575 } 576 506 577 } 507 578 … … 526 597 527 598 // First of all, compute distribution on client side 528 if (0 != serverDistribution_) 529 { 530 clientDistribution_ = new CDistributionClient(rank, this, serverDistribution_->getGlobalLocalIndex()); 531 storeIndex_client.resize(serverDistribution_->getGridSize()); 532 int nbStoreIndex = storeIndex_client.numElements(); 533 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = idx; 534 } 535 else 536 { 599 // if (0 != serverDistribution_) 600 // { 601 // // clientDistribution_ = new CDistributionClient(rank, this, serverDistribution_->getGlobalLocalIndex()); 602 // clientDistribution_ = new CDistributionClient(rank, this); 603 // storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 604 // // storeIndex_client.resize(serverDistribution_->getGridSize()); 605 // int nbStoreIndex = storeIndex_client.numElements(); 606 // for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = idx; 607 // } 608 // else 609 // { 537 610 clientDistribution_ = new CDistributionClient(rank, this); 538 611 // Get local data index on client … … 540 613 int nbStoreIndex = storeIndex_client.numElements(); 541 614 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 542 }615 // } 543 616 544 if (0 == serverDistribution_) 545 isDataDistributed_= clientDistribution_->isDataDistributed(); 617 if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); 618 else 619 { 620 621 // Mapping global index received from clients to the storeIndex_client 622 CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistribution_->getGlobalDataIndexOnClient(); 623 CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 624 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 625 ite = outGlobalIndexFromClient.end(), it; 626 627 for (it = itb; it != ite; ++it) 628 { 629 int rank = it->first; 630 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 631 outLocalIndexStoreOnClient.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 632 CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient[rank]; 633 size_t nbIndex = 0; 634 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 635 { 636 if (itGloe != globalDataIndex.find(globalIndex(idx))) 637 { 638 ++nbIndex; 639 } 640 } 641 642 if (nbIndex != localIndex.numElements()) 643 ERROR("void CGrid::computeClientIndex()", 644 << "Number of local index on client is different from number of received global index" 645 << "Rank of sent client " << rank <<"." 646 << "Number of local index " << nbIndex << ". " 647 << "Number of received global index " << localIndex.numElements() << "."); 648 649 nbIndex = 0; 650 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 651 { 652 if (itGloe != globalDataIndex.find(globalIndex(idx))) 653 { 654 localIndex(idx) = globalDataIndex[globalIndex(idx)]; 655 } 656 } 657 658 659 } 660 } 546 661 } 547 662 } … … 1341 1456 else 1342 1457 { 1343 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap, itbGlobalMap; 1344 itbGlobalMap = globalIndexOnServer_.begin(), itGlobalMap; 1458 // CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap, itbGlobalMap; 1459 // itbGlobalMap = globalIndexOnServer_.begin(), itGlobalMap; 1460 // iteGlobalMap = globalIndexOnServer_.end(); 1461 1462 // std::map<int,int > nbGlobalLocalTmp; 1463 // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1464 // { 1465 // int serverRank = itGlobalMap->first; 1466 // nbGlobalLocalTmp[serverRank] = 0; 1467 // const std::vector<size_t>& indexVec = itGlobalMap->second; 1468 // int indexSize = indexVec.size(); 1469 // for (int idx = 0; idx < indexSize; ++idx) 1470 // { 1471 // itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 1472 // if (iteIndex != itIndex) 1473 // { 1474 // ++nbGlobalLocalTmp[serverRank]; 1475 // } 1476 // } 1477 // } 1478 1479 // std::map<int,std::vector<int> >localIndexTmp; 1480 // std::map<int,std::vector<size_t> > globalIndexTmp; 1481 // for (std::map<int,int>::iterator it = nbGlobalLocalTmp.begin(); it != nbGlobalLocalTmp.end(); ++it) 1482 // { 1483 // localIndexTmp[it->first].resize(it->second); 1484 // globalIndexTmp[it->first].resize(it->second); 1485 // it->second = 0; 1486 // } 1487 1488 // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1489 // { 1490 // int serverRank = itGlobalMap->first; 1491 // const std::vector<size_t>& indexVec = itGlobalMap->second; 1492 // int indexSize = indexVec.size(); 1493 // int ind = 0; 1494 // for (int idx = 0; idx < indexSize; ++idx) 1495 // { 1496 // itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 1497 // if (iteIndex != itIndex) 1498 // { 1499 // ind = nbGlobalLocalTmp[serverRank]; 1500 // globalIndexTmp[serverRank][ind] = itIndex->first; 1501 // localIndexTmp[serverRank][ind] = itIndex->second; 1502 // ++nbGlobalLocalTmp[serverRank]; 1503 // } 1504 // } 1505 // } 1506 1507 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 1508 itGlobalMap = globalIndexOnServer_.begin(); 1345 1509 iteGlobalMap = globalIndexOnServer_.end(); 1346 1347 std::map<int,int > nbGlobalLocalTmp; 1348 for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1510 1511 std::map<int,std::vector<int> >localIndexTmp; 1512 std::map<int,std::vector<size_t> > globalIndexTmp; 1513 for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1349 1514 { 1350 1515 int serverRank = itGlobalMap->first; 1351 nbGlobalLocalTmp[serverRank] = 0;1516 int indexSize = itGlobalMap->second.size(); 1352 1517 const std::vector<size_t>& indexVec = itGlobalMap->second; 1353 int indexSize = indexVec.size();1354 1518 for (int idx = 0; idx < indexSize; ++idx) 1355 1519 { … … 1357 1521 if (iteIndex != itIndex) 1358 1522 { 1359 ++nbGlobalLocalTmp[serverRank]; 1360 } 1361 } 1362 } 1363 1364 std::map<int,std::vector<int> >localIndexTmp; 1365 std::map<int,std::vector<size_t> > globalIndexTmp; 1366 for (std::map<int,int>::iterator it = nbGlobalLocalTmp.begin(); it != nbGlobalLocalTmp.end(); ++it) 1367 { 1368 localIndexTmp[it->first].resize(it->second); 1369 globalIndexTmp[it->first].resize(it->second); 1370 it->second = 0; 1371 } 1372 1373 for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1374 { 1375 int serverRank = itGlobalMap->first; 1376 const std::vector<size_t>& indexVec = itGlobalMap->second; 1377 int indexSize = indexVec.size(); 1378 int ind = 0; 1379 for (int idx = 0; idx < indexSize; ++idx) 1380 { 1381 itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 1382 if (iteIndex != itIndex) 1383 { 1384 ind = nbGlobalLocalTmp[serverRank]; 1385 globalIndexTmp[serverRank][ind] = itIndex->first; 1386 localIndexTmp[serverRank][ind] = itIndex->second; 1387 ++nbGlobalLocalTmp[serverRank]; 1523 globalIndexTmp[serverRank].push_back(itIndex->first); 1524 localIndexTmp[serverRank].push_back(itIndex->second); 1388 1525 } 1389 1526 } … … 1455 1592 //connectedServerRank_[p] = ranks; 1456 1593 1594 int idx = 0, numElement = axis_domain_order.numElements(); 1595 int ssize = numElement; 1596 std::vector<int> indexMap(numElement); 1597 for (int i = 0; i < numElement; ++i) 1598 { 1599 indexMap[i] = idx; 1600 if (2 == axis_domain_order(i)) 1601 { 1602 ++ssize; 1603 idx += 2; 1604 } 1605 else 1606 ++idx; 1607 } 1608 1457 1609 for (int n = 0; n < ranks.size(); n++) 1458 1610 { … … 1465 1617 if (0 == serverDistribution_) 1466 1618 { 1467 int idx = 0, numElement = axis_domain_order.numElements();1468 int ssize = numElement;1469 std::vector<int> indexMap(numElement);1470 for (int i = 0; i < numElement; ++i)1471 {1472 indexMap[i] = idx;1473 if (2 == axis_domain_order(i))1474 {1475 ++ssize;1476 idx += 2;1477 }1478 else1479 ++idx;1480 }1481 1482 1619 int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1; 1483 1620 std::vector<CDomain*> domainList = getDomains(); … … 1492 1629 nZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin; 1493 1630 nZoomSize[indexMap[i]] = domainList[domainId]->zoom_ni; 1494 nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin; 1495 // zoomIndex.push_back(domainList[domainId]->zoom_i_index); 1631 nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin; 1496 1632 nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 1497 1633 1498 1634 nZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin; 1499 1635 nZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj; 1500 nZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin; 1501 // zoomIndex.push_back(domainList[domainId]->zoom_j_index); 1636 nZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin; 1502 1637 nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 1503 1638 1504 // int nbZoom = domainList[domainId]->zoom_i_index.numElements();1505 // zoomIndex.push_back(CArray<int,1>(nbZoom));1506 // CArray<int,1>& zoomDomain = zoomIndex.back();1507 // for (int ind = 0; ind < nbZoom; ++ind)1508 // {1509 // zoomDomain(ind) = domainList[domainId]->zoom_i_index(ind) + domainList[domainId]->zoom_j_index(ind) * domainList[domainId]->ni_glo;1510 // }1511 1512 // globalSize *= domainList[domainId]->ni_glo * domainList[domainId]->nj_glo;1513 1639 ++domainId; 1514 1640 } … … 1517 1643 nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin; 1518 1644 nZoomSize[indexMap[i]] = axisList[axisId]->zoom_n; 1519 nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin; 1520 // zoomIndex.push_back(axisList[axisId]->zoom_index); 1521 nGlob[indexMap[i]] = axisList[axisId]->n_glo; 1522 // globalSize *= axisList[axisId]->n_glo; 1645 nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin; 1646 nGlob[indexMap[i]] = axisList[axisId]->n_glo; 1523 1647 ++axisId; 1524 1648 } 1525 1649 else // scalar 1526 { 1527 // CArray<int,1> zoomScalar(1); 1528 // zoomScalar(0) = 0; 1650 { 1529 1651 nZoomBegin[indexMap[i]] = 0; 1530 1652 nZoomSize[indexMap[i]] = 1; 1531 nZoomBeginGlobal[indexMap[i]] = 0; 1532 // zoomIndex.push_back(zoomScalar); 1653 nZoomBeginGlobal[indexMap[i]] = 0; 1533 1654 nGlob[indexMap[i]] = 1; 1655 1534 1656 ++scalarId; 1535 1657 } … … 1541 1663 serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 1542 1664 nZoomBeginGlobal, nGlob); 1543 // for (int i = 0; i < zoomIndex.size(); ++i)1544 // {1545 // dataSize *= zoomIndex[i].numElements();1546 // }1547 // serverDistribution_ = new CDistributionServer(server->intraCommRank, zoomIndex, nGlobElement);1548 1665 } 1549 1666 1550 1667 CArray<size_t,1> outIndex; 1551 1668 buffer >> outIndex; 1552 serverDistribution_->computeLocalIndex(outIndex);1669 outGlobalIndexFromClient.insert(std::make_pair(rank, outIndex)); 1553 1670 1554 1671 if (isDataDistributed_) … … 1568 1685 writtenDataSize_ += dataSize; 1569 1686 1570 outIndexFromClient.insert(std::make_pair(rank, outIndex));1687 // outIndexFromClient.insert(std::make_pair(rank, outIndex)); 1571 1688 // connectedDataSize_[p][rank] = outIndex.numElements(); 1572 1689 numberWrittenIndexes_ += outIndex.numElements(); 1573 1690 } 1574 1691 1575 // int sizeData = 0; 1576 // for (map<int, CArray<size_t, 1> >::iterator it = outIndexFromClient.begin(); it != outIndexFromClient.end(); ++it) 1577 // { 1578 // sizeData += it->second.numElements(); 1579 // } 1580 // indexFromClients.resize(sizeData); 1581 // sizeData = 0; 1582 // for (map<int, CArray<size_t, 1> >::iterator it = outIndexFromClient.begin(); it != outIndexFromClient.end(); ++it) 1583 // { 1584 // CArray<size_t, 1>& tmp0 = it->second; 1585 // CArray<size_t, 1> tmp1 = indexFromClients(Range(sizeData, sizeData + tmp0.numElements() - 1)); 1586 // tmp1 = tmp0; 1587 // sizeData += tmp0.numElements(); 1588 // } 1692 1693 // Compute mask of the current grid 1694 { 1695 int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1; 1696 std::vector<CDomain*> domainList = getDomains(); 1697 std::vector<CAxis*> axisList = getAxis(); 1698 std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize); 1699 for (int i = 0; i < numElement; ++i) 1700 { 1701 if (2 == axis_domain_order(i)) //domain 1702 { 1703 nBegin[indexMap[i]] = domainList[domainId]->ibegin; 1704 nSize[indexMap[i]] = domainList[domainId]->ni; 1705 nBeginGlobal[indexMap[i]] = 0; 1706 nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 1707 1708 nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 1709 nSize[indexMap[i] + 1] = domainList[domainId]->nj; 1710 nBeginGlobal[indexMap[i] + 1] = 0; 1711 nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 1712 1713 ++domainId; 1714 } 1715 else if (1 == axis_domain_order(i)) // axis 1716 { 1717 nBegin[indexMap[i]] = axisList[axisId]->begin; 1718 nSize[indexMap[i]] = axisList[axisId]->n; 1719 nBeginGlobal[indexMap[i]] = 0; 1720 nGlob[indexMap[i]] = axisList[axisId]->n_glo; 1721 ++axisId; 1722 } 1723 else // scalar 1724 { 1725 nBegin[indexMap[i]] = 0; 1726 nSize[indexMap[i]] = 1; 1727 nBeginGlobal[indexMap[i]] = 0; 1728 nGlob[indexMap[i]] = 1; 1729 1730 ++scalarId; 1731 } 1732 } 1733 1734 modifyMaskSize(nSize, true); 1735 // These below codes are reserved for future 1736 // CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob); 1737 // map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 1738 // ite = outGlobalIndexFromClient.end(), it; 1739 // const CDistributionServer::GlobalLocalMap& globalLocalMask = srvDist.getGlobalLocalIndex(); 1740 // CDistributionServer::GlobalLocalMap::const_iterator itSrv; 1741 // size_t nb = 0; 1742 // for (it = itb; it != ite; ++it) 1743 // { 1744 // CArray<size_t,1>& globalInd = it->second; 1745 // for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 1746 // { 1747 // if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 1748 // } 1749 // } 1750 1751 // CArray<int,1> indexToModify(nb); 1752 // nb = 0; 1753 // for (it = itb; it != ite; ++it) 1754 // { 1755 // CArray<size_t,1>& globalInd = it->second; 1756 // for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 1757 // { 1758 // itSrv = globalLocalMask.find(globalInd(idx)); 1759 // if (globalLocalMask.end() != itSrv) 1760 // { 1761 // indexToModify(nb) = itSrv->second; 1762 // ++nb; 1763 // } 1764 // } 1765 // } 1766 1767 // modifyMask(indexToModify, true); 1768 } 1589 1769 1590 1770 // if (isScalarGrid()) return; -
XIOS/dev/dev_olga/src/node/grid.hpp
r1099 r1129 140 140 void computeIndexScalarGrid(); 141 141 void computeCompressedIndex(); 142 void computeWrittenIndex(); 142 143 143 144 void solveDomainRef(bool checkAtt); … … 224 225 std::vector<map<int,int> > nbSenders; 225 226 226 map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; 227 map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient, outGlobalIndexFromClient; 228 229 // A client receives global index from other clients (via recvIndex) 230 // then does mapping these index into local index of STORE_CLIENTINDEX 231 // In this way, store_clientIndex can be used as an input of a source filter 232 // Maybe we need a flag to determine whether a client wants to write. TODO 233 map<int, CArray<size_t, 1> > outLocalIndexStoreOnClient; 234 235 // If a client wants to write out data, it'll use this index. 236 // A client receives global index of data from other clients (via recvIndex), 237 // then does remapping these index into local index to WRITE into a file 238 CArray<size_t,1> localIndexToWriteOnClient, localIndexToWriteOnServer; 239 227 240 CArray<size_t,1> indexFromClients; 228 241 void checkMask(void); 229 242 void createMask(void); 230 void modifyMask(const CArray<int,1>& indexToModify); 243 void modifyMask(const CArray<int,1>& indexToModify, bool valueToModify = false); 244 void modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue = false); 231 245 232 246 void computeGridGlobalDimension(const std::vector<CDomain*>& domains, … … 243 257 bool createMask = false); 244 258 template<int N> 245 void modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify); 259 void modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify); 260 261 template<int N> 262 void modifyGridMaskSize(CArray<bool,N>& gridMask, const std::vector<int>& eachDimSize, bool newValue); 246 263 247 264 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); … … 285 302 std::set<std::string> relFilesCompressed; 286 303 287 bool isTransformed_ ;288 bool isGenerated_;304 bool isTransformed_, isGenerated_; 305 bool computedWrittenIndex_; 289 306 std::vector<int> axisPositionInGrid_; 290 307 CGridTransformation* transformations_; … … 416 433 } 417 434 435 template<int N> 436 void CGrid::modifyGridMaskSize(CArray<bool,N>& gridMask, 437 const std::vector<int>& eachDimSize, 438 bool newValue) 439 { 440 if (N != eachDimSize.size()) 441 { 442 // ERROR("CGrid::modifyGridMaskSize(CArray<bool,N>& gridMask, 443 // const std::vector<int>& eachDimSize, 444 // bool newValue)", 445 // << "Dimension size of the mask is different from input dimension size." << std::endl 446 // << "Mask dimension is " << N << "." << std::endl 447 // << "Input dimension is " << eachDimSize.size() << "." << std::endl 448 // << "Grid = " << this->GetName()) 449 } 450 CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 451 gridMask = newValue; 452 } 453 454 418 455 /*! 419 456 Modify the current mask of grid, the local index to be modified will take value false … … 422 459 */ 423 460 template<int N> 424 void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify) 425 { 426 bool valueToModify = false; 461 void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify) 462 { 427 463 int num = indexToModify.numElements(); 428 464 for (int idx = 0; idx < num; ++idx) -
XIOS/dev/dev_olga/src/transformation/axis_algorithm_zoom.cpp
r933 r1129 60 60 void CAxisAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 61 61 { 62 // We use all index of source and destination to calculate the mapping index of zoom. 63 // The server who receives the "zoomed" fields will decide whether it will forward these fields or write "real zoomed" fields into file 64 // That means servers need to change to cover this problem. 62 65 StdSize niSource = axisSrc_->n.getValue(); 63 66 StdSize ibeginSource = axisSrc_->begin.getValue(); … … 66 69 StdSize ibegin = std::max(ibeginSource, zoomBegin_); 67 70 StdSize iend = std::min(iendSource, zoomEnd_); 71 // StdSize ibegin = ibeginSource; 72 // StdSize iend = iendSource; 68 73 StdSize ni = iend + 1 - ibegin; 69 74 if (iend < ibegin) ni = 0; … … 82 87 83 88 updateZoom(); 84 updateAxisDestinationMask();89 // updateAxisDestinationMask(); 85 90 } 86 91 -
XIOS/dev/dev_olga/src/transformation/domain_algorithm_zoom.cpp
r933 r1129 113 113 114 114 updateZoom(); 115 updateDomainDestinationMask();115 // updateDomainDestinationMask(); 116 116 } 117 117
Note: See TracChangeset
for help on using the changeset viewer.