- Timestamp:
- 07/24/15 16:40:06 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/distribution.cpp
r553 r653 11 11 namespace xios { 12 12 13 CDistribution::CDistribution(int rank, int dims, CArray<size_t,1>*globalIndex)14 : rank_(rank), dims_(dims), globalIndex_(globalIndex )13 CDistribution::CDistribution(int rank, int dims, const CArray<size_t,1>& globalIndex) 14 : rank_(rank), dims_(dims), globalIndex_(globalIndex.shape()) 15 15 { 16 if (0 != globalIndex) 17 { 18 globalIndex_ = new CArray<size_t,1>(globalIndex->numElements()); 19 *globalIndex_ = *globalIndex; 20 } 16 if (0 != globalIndex.numElements()) 17 globalIndex_ = globalIndex; 21 18 } 22 19 23 20 CDistribution::~CDistribution() 24 { 25 if (0 != globalIndex_) delete globalIndex_; 26 } 21 { /* Nothing to do */ } 27 22 28 23 const CArray<size_t,1>& CDistribution::getGlobalIndex() const 29 24 { 30 return (*globalIndex_);25 return globalIndex_; 31 26 } 32 27 -
XIOS/trunk/src/distribution.hpp
r591 r653 24 24 public: 25 25 /** Default constructor */ 26 CDistribution(int rank, int dims, CArray<size_t,1>* globalIndex = 0);26 CDistribution(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 27 27 28 28 /** Default destructor */ … … 37 37 virtual void createGlobalIndex() = 0; 38 38 protected: 39 CArray<size_t,1> *globalIndex_;39 CArray<size_t,1> globalIndex_; 40 40 int dims_; 41 41 int rank_; -
XIOS/trunk/src/distribution_client.cpp
r631 r653 11 11 namespace xios { 12 12 13 CDistributionClient::CDistributionClient(int rank, int dims, CArray<size_t,1>* globalIndex) 14 : CDistribution(rank, dims, globalIndex), 15 globalDataSendToServer_(0), localDataIndex_(0), localDataIndexSendToServer_(0), localMaskIndex_(0), 16 axisDomainOrder_(), 17 nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_(), 18 dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 19 gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 20 isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 13 CDistributionClient::CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex) 14 : CDistribution(rank, dims, globalIndex) 15 , axisDomainOrder_() 16 , nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_() 17 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_() 18 , gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_() 19 , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 21 20 { 22 21 } 23 22 24 23 CDistributionClient::CDistributionClient(int rank, CGrid* grid) 25 : CDistribution(rank, 0, 0), 26 globalDataSendToServer_(0), localDataIndex_(0), localDataIndexSendToServer_(0), localMaskIndex_(0), 27 axisDomainOrder_(), 28 nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_(), 29 dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 30 gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 31 isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 24 : CDistribution(rank, 0) 25 , axisDomainOrder_() 26 , nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_() 27 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_() 28 , gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_() 29 , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 32 30 { 33 31 readDistributionInfo(grid); … … 37 35 38 36 CDistributionClient::~CDistributionClient() 39 { 40 if (0 != globalDataSendToServer_) delete globalDataSendToServer_; 41 if (0 != localDataIndex_) delete localDataIndex_; 42 if (0 != localDataIndexSendToServer_) delete localDataIndexSendToServer_; 43 if (0 != localMaskIndex_) delete localMaskIndex_; 44 } 37 { /* Nothing to do */ } 45 38 46 39 /*! … … 65 58 66 59 // Then check mask of grid 67 int gridDim = domList.size() *2 + axisList.size();60 int gridDim = domList.size() * 2 + axisList.size(); 68 61 grid->checkMask(); 69 62 switch (gridDim) { … … 333 326 ssize *= nLocal_[i]; 334 327 335 this->globalIndex_ = new CArray<size_t,1>(ssize);328 this->globalIndex_.resize(ssize); 336 329 std::vector<int> idxLoop(this->dims_,0); 337 330 int innnerLoopSize = nLocal_[0]; … … 356 349 globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim; 357 350 } 358 (*this->globalIndex_)(idx) = globalIndex;351 this->globalIndex_(idx) = globalIndex; 359 352 ++idxLoop[0]; 360 353 ++idx; … … 473 466 474 467 // Now allocate these arrays 475 this->globalDataSendToServer_ = new CArray<size_t,1>(indexSend2ServerCount);476 localDataIndex_ = new CArray<int,1>(indexLocalDataOnClientCount);477 localDataIndexSendToServer_ = new CArray<int,1>(indexSend2ServerCount);478 localMaskIndex_ = new CArray<int,1>(indexSend2ServerCount);468 globalDataSendToServer_.resize(indexSend2ServerCount); 469 localDataIndex_.resize(indexLocalDataOnClientCount); 470 localDataIndexSendToServer_.resize(indexSend2ServerCount); 471 localMaskIndex_.resize(indexSend2ServerCount); 479 472 480 473 // We need to loop with data index … … 576 569 gridMask_(gridMaskIndex)) 577 570 { 578 (*localDataIndex_)(indexLocalDataOnClientCount) = countLocalData;571 localDataIndex_(indexLocalDataOnClientCount) = countLocalData; 579 572 580 573 bool isIndexOnServer = true; … … 592 585 globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 593 586 } 594 (*this->globalDataSendToServer_)(indexSend2ServerCount) = globalIndex;595 (*localDataIndexSendToServer_)(indexSend2ServerCount) = indexLocalDataOnClientCount;596 (*localMaskIndex_)(indexSend2ServerCount) = gridMaskIndex;587 globalDataSendToServer_(indexSend2ServerCount) = globalIndex; 588 localDataIndexSendToServer_(indexSend2ServerCount) = indexLocalDataOnClientCount; 589 localMaskIndex_(indexSend2ServerCount) = gridMaskIndex; 597 590 ++indexSend2ServerCount; 598 591 } … … 650 643 const CArray<size_t,1>& CDistributionClient::getGlobalDataIndexSendToServer() const 651 644 { 652 return (*globalDataSendToServer_);645 return globalDataSendToServer_; 653 646 } 654 647 … … 658 651 const CArray<int,1>& CDistributionClient::getLocalDataIndexOnClient() const 659 652 { 660 return (*localDataIndex_);653 return localDataIndex_; 661 654 } 662 655 … … 666 659 const CArray<int,1>& CDistributionClient::getLocalMaskIndexOnClient() const 667 660 { 668 return (*localMaskIndex_);661 return localMaskIndex_; 669 662 } 670 663 … … 674 667 const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer() const 675 668 { 676 return (*localDataIndexSendToServer_);669 return localDataIndexSendToServer_; 677 670 } 678 671 -
XIOS/trunk/src/distribution_client.hpp
r623 r653 30 30 public: 31 31 /** Default constructor */ 32 CDistributionClient(int rank, int dims, CArray<size_t,1>* globalIndex = 0);32 CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 33 33 CDistributionClient(int rank, CGrid* grid); 34 34 … … 72 72 private: 73 73 //!< LocalData index on client 74 CArray<size_t,1> *globalDataSendToServer_;75 CArray<int,1> *localDataIndex_;76 CArray<int,1> *localDataIndexSendToServer_;77 CArray<int,1> *localMaskIndex_;74 CArray<size_t,1> globalDataSendToServer_; 75 CArray<int,1> localDataIndex_; 76 CArray<int,1> localDataIndexSendToServer_; 77 CArray<int,1> localMaskIndex_; 78 78 79 79 private: -
XIOS/trunk/src/distribution_server.cpp
r621 r653 11 11 namespace xios { 12 12 13 CDistributionServer::CDistributionServer(int rank, int dims, CArray<size_t,1>*globalIndex)13 CDistributionServer::CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex) 14 14 : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_() 15 15 { … … 48 48 for (int i = 0; i < nZoomSize_.size(); ++i) ssize *= nZoomSize_[i]; 49 49 50 this->globalIndex_ = new CArray<size_t,1>(ssize);50 this->globalIndex_.resize(ssize); 51 51 std::vector<int> idxLoop(this->getDims(),0); 52 52 std::vector<int> currentIndex(this->getDims()); … … 77 77 globalIndex += (currentIndex[k])*mulDim; 78 78 } 79 (*this->globalIndex_)(idx) = globalIndex;79 this->globalIndex_(idx) = globalIndex; 80 80 ++idx; 81 81 } … … 91 91 CArray<size_t,1> CDistributionServer::computeLocalIndex(const CArray<size_t,1>& globalIndex) 92 92 { 93 CArray<size_t,1>::const_iterator itBegin = (this->globalIndex_)->begin(),94 itEnd = (this->globalIndex_)->end(), it;93 CArray<size_t,1>::const_iterator itBegin = this->globalIndex_.begin(), 94 itEnd = this->globalIndex_.end(), it; 95 95 96 96 int ssize = globalIndex.numElements(), idx = 0; … … 117 117 void CDistributionServer::computeLocalIndex(CArray<size_t,1>& globalIndex) 118 118 { 119 CArray<size_t,1>::const_iterator itBegin = (this->globalIndex_)->begin(),120 itEnd = (this->globalIndex_)->end(), it;119 CArray<size_t,1>::const_iterator itBegin = this->globalIndex_.begin(), 120 itEnd = this->globalIndex_.end(), it; 121 121 122 122 int ssize = globalIndex.numElements(), idx = 0; -
XIOS/trunk/src/distribution_server.hpp
r621 r653 23 23 public: 24 24 /** Default constructor */ 25 CDistributionServer(int rank, int dims, CArray<size_t,1>* globalIndex = 0);25 CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 26 26 CDistributionServer(int rank, const std::vector<int>& nZoomBeginServer, 27 27 const std::vector<int>& nZoomSizeServer, const std::vector<int>& nGlobal); -
XIOS/trunk/src/filter/spatial_transform_filter.cpp
r644 r653 72 72 CContextClient* client = CContext::getCurrent()->client; 73 73 74 const std::map<int, CArray<int,1> *>& localIndexToSend = gridTransformation->getLocalIndexToSendFromGridSource();74 const std::map<int, CArray<int,1> >& localIndexToSend = gridTransformation->getLocalIndexToSendFromGridSource(); 75 75 const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& localIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 76 76 … … 78 78 79 79 // Sending data from field sources to do transformations 80 std::map<int, CArray<int,1> *>::const_iterator itbSend = localIndexToSend.begin(), itSend,81 80 std::map<int, CArray<int,1> >::const_iterator itbSend = localIndexToSend.begin(), itSend, 81 iteSend = localIndexToSend.end(); 82 82 int sendBuffSize = 0; 83 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < (itSend->second)->numElements())84 ? (itSend->second)->numElements(): sendBuffSize;83 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < itSend->second.numElements()) 84 ? itSend->second.numElements(): sendBuffSize; 85 85 double* sendBuff; 86 86 if (0 != sendBuffSize) sendBuff = new double[sendBuffSize]; … … 88 88 { 89 89 int destRank = itSend->first; 90 CArray<int,1>*localIndex_p = itSend->second;91 int countSize = localIndex_p ->numElements();90 const CArray<int,1>& localIndex_p = itSend->second; 91 int countSize = localIndex_p.numElements(); 92 92 for (int idx = 0; idx < countSize; ++idx) 93 93 { 94 sendBuff[idx] = dataSrc( (*localIndex_p)(idx));94 sendBuff[idx] = dataSrc(localIndex_p(idx)); 95 95 } 96 96 MPI_Send(sendBuff, countSize, MPI_DOUBLE, destRank, 12, client->intraComm); … … 99 99 // Receiving data on destination fields 100 100 std::map<int,std::vector<std::vector<std::pair<int,double> > > >::const_iterator itbRecv = localIndexToReceive.begin(), itRecv, 101 iteRecv = localIndexToReceive.end();101 iteRecv = localIndexToReceive.end(); 102 102 int recvBuffSize = 0; 103 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize = (recvBuffSize < (itRecv->second).size())104 ? (itRecv->second).size() : recvBuffSize;103 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize = (recvBuffSize < itRecv->second.size()) 104 ? itRecv->second.size() : recvBuffSize; 105 105 double* recvBuff; 106 106 if (0 != recvBuffSize) recvBuff = new double[recvBuffSize]; … … 109 109 MPI_Status status; 110 110 int srcRank = itRecv->first; 111 int countSize = (itRecv->second).size();111 int countSize = itRecv->second.size(); 112 112 MPI_Recv(recvBuff, recvBuffSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &status); 113 113 for (int idx = 0; idx < countSize; ++idx) 114 114 { 115 const std::vector<std::pair<int,double> >& localIndex_p = (itRecv->second)[idx];115 const std::vector<std::pair<int,double> >& localIndex_p = itRecv->second[idx]; 116 116 int numIndex = localIndex_p.size(); 117 117 for (int i = 0; i < numIndex; ++i) 118 118 { 119 // if ( (localIndex_p)[i].first >= dataDest.numElements())120 dataDest( (localIndex_p)[i].first) += recvBuff[idx] * ((localIndex_p)[i].second);119 // if (localIndex_p[i].first >= dataDest.numElements()) 120 dataDest(localIndex_p[i].first) += recvBuff[idx] * localIndex_p[i].second; 121 121 } 122 122 } -
XIOS/trunk/src/server_distribution_description.cpp
r569 r653 18 18 19 19 CServerDistributionDescription::~CServerDistributionDescription() 20 { 21 if (!vecGlobalIndex_.empty()) 22 for (int i = 0; i < vecGlobalIndex_.size(); ++i) delete vecGlobalIndex_[i]; 23 } 20 { /* Nothing to do */ } 24 21 25 22 /*! … … 51 48 size_t ssize = 1, idx = 0; 52 49 for (int j = 0; j < dim; ++j) ssize *= dimensionSizes_[idxServer][j]; 53 vecGlobalIndex_[idxServer] = new CArray<size_t,1>(ssize);50 vecGlobalIndex_[idxServer].resize(ssize); 54 51 55 52 std::vector<int> idxLoop(dim,0); … … 79 76 { 80 77 mulDim *= nGlobal_[k-1]; 81 globalIndex += (currentIndex[k])*mulDim;78 globalIndex += currentIndex[k] * mulDim; 82 79 } 83 (*vecGlobalIndex_[idxServer])(idx) = globalIndex;80 vecGlobalIndex_[idxServer](idx) = globalIndex; 84 81 ++idx; 85 82 } … … 241 238 \return global index on server(s) 242 239 */ 243 const std::vector<CArray<size_t,1> *>& CServerDistributionDescription::getGlobalIndex() const240 const std::vector<CArray<size_t,1> >& CServerDistributionDescription::getGlobalIndex() const 244 241 { 245 242 return vecGlobalIndex_; -
XIOS/trunk/src/server_distribution_description.hpp
r591 r653 43 43 std::vector<std::vector<int> > getServerIndexBegin() const; 44 44 std::vector<std::vector<int> > getServerDimensionSizes() const; 45 const std::vector<CArray<size_t,1> *>& getGlobalIndex() const;45 const std::vector<CArray<size_t,1> >& getGlobalIndex() const; 46 46 const boost::unordered_map<size_t,int>& getGlobalIndexRange() const; 47 47 … … 56 56 57 57 //!< General case, index describes distribution of each server (rarely use) 58 std::vector<CArray<size_t,1> *> vecGlobalIndex_;58 std::vector<CArray<size_t,1> > vecGlobalIndex_; 59 59 60 60 //!< In case we need only global index of one server with specific rank -
XIOS/trunk/src/transformation/grid_transformation.cpp
r634 r653 72 72 { 73 73 CContext* context = CContext::getCurrent(); 74 CContextClient* client =context->client;74 CContextClient* client = context->client; 75 75 76 76 CDistributionClient distribution(client->clientRank, originalGridSource_); 77 77 const CArray<size_t,1>& globalIndexGridDestSendToServer = distribution.getGlobalDataIndexSendToServer(); 78 78 79 globalIndexOfCurrentGridSource_ = new CArray<size_t,1>(globalIndexGridDestSendToServer.numElements());80 globalIndexOfOriginalGridSource_ = new CArray<size_t,1>(globalIndexGridDestSendToServer.numElements());81 weightOfGlobalIndexOfOriginalGridSource_ = new CArray<double,1>(globalIndexGridDestSendToServer.numElements());82 *globalIndexOfCurrentGridSource_ = globalIndexGridDestSendToServer;83 *globalIndexOfOriginalGridSource_ = globalIndexGridDestSendToServer;84 *weightOfGlobalIndexOfOriginalGridSource_ = 1.0;79 globalIndexOfCurrentGridSource_.resize(globalIndexGridDestSendToServer.numElements()); 80 globalIndexOfOriginalGridSource_.resize(globalIndexGridDestSendToServer.numElements()); 81 weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridDestSendToServer.numElements()); 82 globalIndexOfCurrentGridSource_ = globalIndexGridDestSendToServer; 83 globalIndexOfOriginalGridSource_ = globalIndexGridDestSendToServer; 84 weightOfGlobalIndexOfOriginalGridSource_ = 1.0; 85 85 } 86 86 … … 90 90 ite = algoTransformation_.end(); 91 91 for (it = itb; it != ite; ++it) delete (*it); 92 93 std::map<int, CArray<int,1>* >::const_iterator itMap, iteMap;94 itMap = localIndexToSendFromGridSource_.begin();95 iteMap = localIndexToSendFromGridSource_.end();96 for (; itMap != iteMap; ++itMap) delete (itMap->second);97 98 if (0 != globalIndexOfCurrentGridSource_) delete globalIndexOfCurrentGridSource_;99 if (0 != globalIndexOfOriginalGridSource_) delete globalIndexOfOriginalGridSource_;100 if (0 != weightOfGlobalIndexOfOriginalGridSource_) delete weightOfGlobalIndexOfOriginalGridSource_;101 92 } 102 93 … … 344 335 { 345 336 CContext* context = CContext::getCurrent(); 346 CContextClient* client =context->client;337 CContextClient* client = context->client; 347 338 348 339 ListAlgoType::const_iterator itb = listAlgos_.begin(), … … 394 385 { 395 386 CContext* context = CContext::getCurrent(); 396 CContextClient* client =context->client;387 CContextClient* client = context->client; 397 388 398 389 //First of all, retrieve info of local mask of grid destination … … 406 397 407 398 // Then find out which index became invalid (become masked after being applied the algorithms, or demande some masked points from grid source) 408 int num = globalIndexOfOriginalGridSource_ ->numElements();399 int num = globalIndexOfOriginalGridSource_.numElements(); 409 400 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 410 401 int maskIndexNum = 0; 411 402 for (int idx = 0; idx < num; ++idx) 412 403 { 413 if (sfmax == (*globalIndexOfOriginalGridSource_)(idx))414 { 415 size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx);404 if (sfmax == globalIndexOfOriginalGridSource_(idx)) 405 { 406 size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_(idx); 416 407 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 417 408 if (iteArr != itArr) ++maskIndexNum; … … 419 410 } 420 411 421 CArray<int,1> * maskIndexToModify = new CArray<int,1>(maskIndexNum);412 CArray<int,1> maskIndexToModify(maskIndexNum); 422 413 maskIndexNum = 0; 423 414 for (int idx = 0; idx < num; ++idx) 424 415 { 425 if (sfmax == (*globalIndexOfOriginalGridSource_)(idx))426 { 427 size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx);416 if (sfmax == globalIndexOfOriginalGridSource_(idx)) 417 { 418 size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_(idx); 428 419 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 429 420 if (iteArr != itArr) 430 421 { 431 422 int localIdx = std::distance(itbArr, itArr); 432 (*maskIndexToModify)(maskIndexNum) = (localMaskIndexOnClientDest)(localIdx);423 maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest(localIdx); 433 424 ++maskIndexNum; 434 425 } … … 436 427 } 437 428 438 gridDestination_->modifyMask(*maskIndexToModify); 439 440 delete maskIndexToModify; 429 gridDestination_->modifyMask(maskIndexToModify); 441 430 } 442 431 … … 449 438 { 450 439 CContext* context = CContext::getCurrent(); 451 CContextClient* client =context->client;440 CContextClient* client = context->client; 452 441 453 442 CTransformationMapping transformationMap(gridDestination_, gridSource_); … … 462 451 std::map<int,std::vector<size_t> >::const_iterator itbSend = globalIndexToSend.begin(), itSend, 463 452 iteSend = globalIndexToSend.end(); 464 CArray<size_t,1>::const_iterator itbArr = globalIndexOfCurrentGridSource_ ->begin(), itArr,465 iteArr = globalIndexOfCurrentGridSource_ ->end();453 CArray<size_t,1>::const_iterator itbArr = globalIndexOfCurrentGridSource_.begin(), itArr, 454 iteArr = globalIndexOfCurrentGridSource_.end(); 466 455 int sendBuffSize = 0; 467 456 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); … … 486 475 { 487 476 int index = std::distance(itbArr, itArr); 488 sendBuff[idx+currentBuffPosition] = (*globalIndexOfOriginalGridSource_)(index);477 sendBuff[idx+currentBuffPosition] = globalIndexOfOriginalGridSource_(index); 489 478 } 490 479 } … … 525 514 } 526 515 527 if (globalIndexOfCurrentGridSource_ ->numElements()!= nbCurrentGridSource)516 if (globalIndexOfCurrentGridSource_.numElements() != nbCurrentGridSource) 528 517 { 529 delete globalIndexOfCurrentGridSource_; 530 globalIndexOfCurrentGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 531 delete globalIndexOfOriginalGridSource_; 532 globalIndexOfOriginalGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 533 delete weightOfGlobalIndexOfOriginalGridSource_; 534 weightOfGlobalIndexOfOriginalGridSource_ = new CArray<double,1>(nbCurrentGridSource); 518 globalIndexOfCurrentGridSource_.resize(nbCurrentGridSource); 519 globalIndexOfOriginalGridSource_.resize(nbCurrentGridSource); 520 weightOfGlobalIndexOfOriginalGridSource_.resize(nbCurrentGridSource); 535 521 } 536 522 … … 545 531 for (int i = 0; i < ssize; ++i) 546 532 { 547 (*globalIndexOfCurrentGridSource_)(k) = ((itRecv->second)[idx][i]).first;548 (*weightOfGlobalIndexOfOriginalGridSource_)(k) = ((itRecv->second)[idx][i]).second;549 (*globalIndexOfOriginalGridSource_)(k) = *currentRecvBuff;533 globalIndexOfCurrentGridSource_(k) = ((itRecv->second)[idx][i]).first; 534 weightOfGlobalIndexOfOriginalGridSource_(k) = ((itRecv->second)[idx][i]).second; 535 globalIndexOfOriginalGridSource_(k) = *currentRecvBuff; 550 536 ++k; 551 537 } … … 569 555 { 570 556 CContext* context = CContext::getCurrent(); 571 CContextClient* client =context->client;557 CContextClient* client = context->client; 572 558 573 559 CTransformationMapping transformationMap(gridDestination_, originalGridSource_); 574 560 575 561 std::map<size_t, std::vector<std::pair<size_t,double> > > globaIndexWeightFromDestToSource; 576 int nb = globalIndexOfCurrentGridSource_ ->numElements();562 int nb = globalIndexOfCurrentGridSource_.numElements(); 577 563 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 578 564 for (int idx = 0; idx < nb; ++idx) 579 565 { 580 if (sfmax != (*globalIndexOfOriginalGridSource_)(idx))581 globaIndexWeightFromDestToSource[ (*globalIndexOfCurrentGridSource_)(idx)].push_back(make_pair((*globalIndexOfOriginalGridSource_)(idx),(*weightOfGlobalIndexOfOriginalGridSource_)(idx))) ;566 if (sfmax != globalIndexOfOriginalGridSource_(idx)) 567 globaIndexWeightFromDestToSource[globalIndexOfCurrentGridSource_(idx)].push_back(make_pair(globalIndexOfOriginalGridSource_(idx), weightOfGlobalIndexOfOriginalGridSource_(idx))) ; 582 568 } 583 569 … … 638 624 for (itMap = itbMap; itMap != iteMap; ++itMap) 639 625 { 640 CArray<int,1>* ptr = new CArray<int,1>((itMap->second).size());641 localIndexToSendFromGridSource_[itMap->first] = ptr;642 626 int destRank = itMap->first; 643 int vecSize = (itMap->second).size(); 627 int vecSize = itMap->second.size(); 628 localIndexToSendFromGridSource_[destRank].resize(vecSize); 644 629 for (int idx = 0; idx < vecSize; ++idx) 645 630 { 646 itArr = std::find(itbArr, iteArr, (itMap->second)[idx]);631 itArr = std::find(itbArr, iteArr, itMap->second[idx]); 647 632 if (iteArr != itArr) 648 633 { 649 634 int localIdx = std::distance(itbArr, itArr); 650 (*localIndexToSendFromGridSource_[destRank])(idx) = (localIdx);635 localIndexToSendFromGridSource_[destRank](idx) = localIdx; 651 636 } 652 637 } … … 658 643 \return local index of data 659 644 */ 660 const std::map<int, CArray<int,1> *>& CGridTransformation::getLocalIndexToSendFromGridSource() const645 const std::map<int, CArray<int,1> >& CGridTransformation::getLocalIndexToSendFromGridSource() const 661 646 { 662 647 return localIndexToSendFromGridSource_; -
XIOS/trunk/src/transformation/grid_transformation.hpp
r632 r653 40 40 void computeAll(); 41 41 42 const std::map<int, CArray<int,1> *>& getLocalIndexToSendFromGridSource() const;42 const std::map<int, CArray<int,1> >& getLocalIndexToSendFromGridSource() const; 43 43 const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& getLocalIndexToReceiveOnGridDest() const; 44 44 CGrid* getGridSource() {return gridSource_; } … … 90 90 91 91 //! Local index of data to send from grid source 92 std::map<int, CArray<int,1> *> localIndexToSendFromGridSource_;92 std::map<int, CArray<int,1> > localIndexToSendFromGridSource_; 93 93 94 94 //! Local index of data to receive on grid destination … … 99 99 100 100 //! (Grid) Global index of grid source 101 CArray<size_t,1> *globalIndexOfCurrentGridSource_;102 CArray<size_t,1> *globalIndexOfOriginalGridSource_;103 CArray<double,1> *weightOfGlobalIndexOfOriginalGridSource_;101 CArray<size_t,1> globalIndexOfCurrentGridSource_; 102 CArray<size_t,1> globalIndexOfOriginalGridSource_; 103 CArray<double,1> weightOfGlobalIndexOfOriginalGridSource_; 104 104 }; 105 105
Note: See TracChangeset
for help on using the changeset viewer.