Changeset 653


Ignore:
Timestamp:
07/24/15 16:40:06 (6 years ago)
Author:
rlacroix
Message:

Distributions and transformations: Avoid using heap allocations.

Location:
XIOS/trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/distribution.cpp

    r553 r653  
    1111namespace xios { 
    1212 
    13 CDistribution::CDistribution(int rank, int dims, CArray<size_t,1>* globalIndex) 
    14   : rank_(rank), dims_(dims), globalIndex_(globalIndex) 
     13CDistribution::CDistribution(int rank, int dims, const CArray<size_t,1>& globalIndex) 
     14  : rank_(rank), dims_(dims), globalIndex_(globalIndex.shape()) 
    1515{ 
    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; 
    2118} 
    2219 
    2320CDistribution::~CDistribution() 
    24 { 
    25   if (0 != globalIndex_) delete globalIndex_; 
    26 } 
     21{ /* Nothing to do */ } 
    2722 
    2823const CArray<size_t,1>& CDistribution::getGlobalIndex() const 
    2924{ 
    30   return (*globalIndex_); 
     25  return globalIndex_; 
    3126} 
    3227 
  • XIOS/trunk/src/distribution.hpp

    r591 r653  
    2424  public: 
    2525    /** 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>()); 
    2727 
    2828    /** Default destructor */ 
     
    3737    virtual void createGlobalIndex() = 0; 
    3838  protected: 
    39     CArray<size_t,1>* globalIndex_; 
     39    CArray<size_t,1> globalIndex_; 
    4040    int dims_; 
    4141    int rank_; 
  • XIOS/trunk/src/distribution_client.cpp

    r631 r653  
    1111namespace xios { 
    1212 
    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_() 
     13CDistributionClient::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_() 
    2120{ 
    2221} 
    2322 
    2423CDistributionClient::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_() 
    3230{ 
    3331  readDistributionInfo(grid); 
     
    3735 
    3836CDistributionClient::~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 */ } 
    4538 
    4639/*! 
     
    6558 
    6659  // Then check mask of grid 
    67   int gridDim = domList.size()*2 + axisList.size(); 
     60  int gridDim = domList.size() * 2 + axisList.size(); 
    6861  grid->checkMask(); 
    6962  switch (gridDim) { 
     
    333326    ssize *= nLocal_[i]; 
    334327 
    335   this->globalIndex_ = new CArray<size_t,1>(ssize); 
     328  this->globalIndex_.resize(ssize); 
    336329  std::vector<int> idxLoop(this->dims_,0); 
    337330  int innnerLoopSize = nLocal_[0]; 
     
    356349        globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim; 
    357350      } 
    358       (*this->globalIndex_)(idx) = globalIndex; 
     351      this->globalIndex_(idx) = globalIndex; 
    359352      ++idxLoop[0]; 
    360353      ++idx; 
     
    473466 
    474467  // 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); 
    479472 
    480473  // We need to loop with data index 
     
    576569          gridMask_(gridMaskIndex)) 
    577570      { 
    578         (*localDataIndex_)(indexLocalDataOnClientCount) = countLocalData; 
     571        localDataIndex_(indexLocalDataOnClientCount) = countLocalData; 
    579572 
    580573        bool isIndexOnServer = true; 
     
    592585            globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 
    593586          } 
    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; 
    597590          ++indexSend2ServerCount; 
    598591        } 
     
    650643const CArray<size_t,1>& CDistributionClient::getGlobalDataIndexSendToServer() const 
    651644{ 
    652   return (*globalDataSendToServer_); 
     645  return globalDataSendToServer_; 
    653646} 
    654647 
     
    658651const CArray<int,1>& CDistributionClient::getLocalDataIndexOnClient() const 
    659652{ 
    660   return (*localDataIndex_); 
     653  return localDataIndex_; 
    661654} 
    662655 
     
    666659const CArray<int,1>& CDistributionClient::getLocalMaskIndexOnClient() const 
    667660{ 
    668   return (*localMaskIndex_); 
     661  return localMaskIndex_; 
    669662} 
    670663 
     
    674667const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer() const 
    675668{ 
    676   return (*localDataIndexSendToServer_); 
     669  return localDataIndexSendToServer_; 
    677670} 
    678671 
  • XIOS/trunk/src/distribution_client.hpp

    r623 r653  
    3030  public: 
    3131    /** 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>()); 
    3333    CDistributionClient(int rank, CGrid* grid); 
    3434 
     
    7272  private: 
    7373    //!< 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_; 
    7878 
    7979  private: 
  • XIOS/trunk/src/distribution_server.cpp

    r621 r653  
    1111namespace xios { 
    1212 
    13 CDistributionServer::CDistributionServer(int rank, int dims, CArray<size_t,1>* globalIndex) 
     13CDistributionServer::CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex) 
    1414  : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_() 
    1515{ 
     
    4848  for (int i = 0; i < nZoomSize_.size(); ++i) ssize *= nZoomSize_[i]; 
    4949 
    50   this->globalIndex_ = new CArray<size_t,1>(ssize); 
     50  this->globalIndex_.resize(ssize); 
    5151  std::vector<int> idxLoop(this->getDims(),0); 
    5252  std::vector<int> currentIndex(this->getDims()); 
     
    7777        globalIndex += (currentIndex[k])*mulDim; 
    7878      } 
    79       (*this->globalIndex_)(idx) = globalIndex; 
     79      this->globalIndex_(idx) = globalIndex; 
    8080      ++idx; 
    8181    } 
     
    9191CArray<size_t,1> CDistributionServer::computeLocalIndex(const CArray<size_t,1>& globalIndex) 
    9292{ 
    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; 
    9595 
    9696  int ssize = globalIndex.numElements(), idx = 0; 
     
    117117void CDistributionServer::computeLocalIndex(CArray<size_t,1>& globalIndex) 
    118118{ 
    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; 
    121121 
    122122  int ssize = globalIndex.numElements(), idx = 0; 
  • XIOS/trunk/src/distribution_server.hpp

    r621 r653  
    2323  public: 
    2424    /** 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>()); 
    2626    CDistributionServer(int rank, const std::vector<int>& nZoomBeginServer, 
    2727                        const std::vector<int>& nZoomSizeServer, const std::vector<int>& nGlobal); 
  • XIOS/trunk/src/filter/spatial_transform_filter.cpp

    r644 r653  
    7272    CContextClient* client = CContext::getCurrent()->client; 
    7373 
    74     const std::map<int, CArray<int,1>* >& localIndexToSend = gridTransformation->getLocalIndexToSendFromGridSource(); 
     74    const std::map<int, CArray<int,1> >& localIndexToSend = gridTransformation->getLocalIndexToSendFromGridSource(); 
    7575    const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& localIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 
    7676 
     
    7878 
    7979    // Sending data from field sources to do transformations 
    80     std::map<int, CArray<int,1>* >::const_iterator itbSend = localIndexToSend.begin(), itSend, 
    81                                                    iteSend = localIndexToSend.end(); 
     80    std::map<int, CArray<int,1> >::const_iterator itbSend = localIndexToSend.begin(), itSend, 
     81                                                  iteSend = localIndexToSend.end(); 
    8282    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; 
    8585    double* sendBuff; 
    8686    if (0 != sendBuffSize) sendBuff = new double[sendBuffSize]; 
     
    8888    { 
    8989      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(); 
    9292      for (int idx = 0; idx < countSize; ++idx) 
    9393      { 
    94         sendBuff[idx] = dataSrc((*localIndex_p)(idx)); 
     94        sendBuff[idx] = dataSrc(localIndex_p(idx)); 
    9595      } 
    9696      MPI_Send(sendBuff, countSize, MPI_DOUBLE, destRank, 12, client->intraComm); 
     
    9999    // Receiving data on destination fields 
    100100    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(); 
    102102    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; 
    105105    double* recvBuff; 
    106106    if (0 != recvBuffSize) recvBuff = new double[recvBuffSize]; 
     
    109109      MPI_Status status; 
    110110      int srcRank = itRecv->first; 
    111       int countSize = (itRecv->second).size(); 
     111      int countSize = itRecv->second.size(); 
    112112      MPI_Recv(recvBuff, recvBuffSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &status); 
    113113      for (int idx = 0; idx < countSize; ++idx) 
    114114      { 
    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]; 
    116116        int numIndex = localIndex_p.size(); 
    117117        for (int i = 0; i < numIndex; ++i) 
    118118        { 
    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; 
    121121        } 
    122122      } 
  • XIOS/trunk/src/server_distribution_description.cpp

    r569 r653  
    1818 
    1919CServerDistributionDescription::~CServerDistributionDescription() 
    20 { 
    21   if (!vecGlobalIndex_.empty()) 
    22     for (int i = 0; i < vecGlobalIndex_.size(); ++i) delete vecGlobalIndex_[i]; 
    23 } 
     20{ /* Nothing to do */ } 
    2421 
    2522/*! 
     
    5148      size_t ssize = 1, idx = 0; 
    5249      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); 
    5451 
    5552      std::vector<int> idxLoop(dim,0); 
     
    7976          { 
    8077            mulDim *= nGlobal_[k-1]; 
    81             globalIndex += (currentIndex[k])*mulDim; 
     78            globalIndex += currentIndex[k] * mulDim; 
    8279          } 
    83           (*vecGlobalIndex_[idxServer])(idx) = globalIndex; 
     80          vecGlobalIndex_[idxServer](idx) = globalIndex; 
    8481          ++idx; 
    8582        } 
     
    241238  \return global index on server(s) 
    242239*/ 
    243 const std::vector<CArray<size_t,1>* >& CServerDistributionDescription::getGlobalIndex() const 
     240const std::vector<CArray<size_t,1> >& CServerDistributionDescription::getGlobalIndex() const 
    244241{ 
    245242  return vecGlobalIndex_; 
  • XIOS/trunk/src/server_distribution_description.hpp

    r591 r653  
    4343    std::vector<std::vector<int> > getServerIndexBegin() const; 
    4444    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; 
    4646    const boost::unordered_map<size_t,int>& getGlobalIndexRange() const; 
    4747 
     
    5656 
    5757    //!< 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_; 
    5959 
    6060    //!< In case we need only global index of one server with specific rank 
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r634 r653  
    7272{ 
    7373  CContext* context = CContext::getCurrent(); 
    74   CContextClient* client=context->client; 
     74  CContextClient* client = context->client; 
    7575 
    7676  CDistributionClient distribution(client->clientRank, originalGridSource_); 
    7777  const CArray<size_t,1>& globalIndexGridDestSendToServer = distribution.getGlobalDataIndexSendToServer(); 
    7878 
    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; 
    8585} 
    8686 
     
    9090                                                              ite = algoTransformation_.end(); 
    9191  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_; 
    10192} 
    10293 
     
    344335{ 
    345336  CContext* context = CContext::getCurrent(); 
    346   CContextClient* client=context->client; 
     337  CContextClient* client = context->client; 
    347338 
    348339  ListAlgoType::const_iterator itb = listAlgos_.begin(), 
     
    394385{ 
    395386  CContext* context = CContext::getCurrent(); 
    396   CContextClient* client=context->client; 
     387  CContextClient* client = context->client; 
    397388 
    398389  //First of all, retrieve info of local mask of grid destination 
     
    406397 
    407398  // 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(); 
    409400  const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
    410401  int maskIndexNum = 0; 
    411402  for (int idx = 0; idx < num; ++idx) 
    412403  { 
    413     if (sfmax == (*globalIndexOfOriginalGridSource_)(idx)) 
    414     { 
    415       size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx); 
     404    if (sfmax == globalIndexOfOriginalGridSource_(idx)) 
     405    { 
     406      size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_(idx); 
    416407      itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 
    417408      if (iteArr != itArr) ++maskIndexNum; 
     
    419410  } 
    420411 
    421   CArray<int,1>* maskIndexToModify = new CArray<int,1>(maskIndexNum); 
     412  CArray<int,1> maskIndexToModify(maskIndexNum); 
    422413  maskIndexNum = 0; 
    423414  for (int idx = 0; idx < num; ++idx) 
    424415  { 
    425     if (sfmax == (*globalIndexOfOriginalGridSource_)(idx)) 
    426     { 
    427       size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx); 
     416    if (sfmax == globalIndexOfOriginalGridSource_(idx)) 
     417    { 
     418      size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_(idx); 
    428419      itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 
    429420      if (iteArr != itArr) 
    430421      { 
    431422        int localIdx = std::distance(itbArr, itArr); 
    432         (*maskIndexToModify)(maskIndexNum) = (localMaskIndexOnClientDest)(localIdx); 
     423        maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest(localIdx); 
    433424        ++maskIndexNum; 
    434425      } 
     
    436427  } 
    437428 
    438   gridDestination_->modifyMask(*maskIndexToModify); 
    439  
    440   delete maskIndexToModify; 
     429  gridDestination_->modifyMask(maskIndexToModify); 
    441430} 
    442431 
     
    449438{ 
    450439  CContext* context = CContext::getCurrent(); 
    451   CContextClient* client=context->client; 
     440  CContextClient* client = context->client; 
    452441 
    453442  CTransformationMapping transformationMap(gridDestination_, gridSource_); 
     
    462451  std::map<int,std::vector<size_t> >::const_iterator itbSend = globalIndexToSend.begin(), itSend, 
    463452                                                     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(); 
    466455 int sendBuffSize = 0; 
    467456 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 
     
    486475     { 
    487476       int index = std::distance(itbArr, itArr); 
    488        sendBuff[idx+currentBuffPosition] = (*globalIndexOfOriginalGridSource_)(index); 
     477       sendBuff[idx+currentBuffPosition] = globalIndexOfOriginalGridSource_(index); 
    489478     } 
    490479   } 
     
    525514 } 
    526515 
    527  if (globalIndexOfCurrentGridSource_->numElements() != nbCurrentGridSource) 
     516 if (globalIndexOfCurrentGridSource_.numElements() != nbCurrentGridSource) 
    528517 { 
    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); 
    535521 } 
    536522 
     
    545531     for (int i = 0; i < ssize; ++i) 
    546532     { 
    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; 
    550536       ++k; 
    551537     } 
     
    569555{ 
    570556  CContext* context = CContext::getCurrent(); 
    571   CContextClient* client=context->client; 
     557  CContextClient* client = context->client; 
    572558 
    573559  CTransformationMapping transformationMap(gridDestination_, originalGridSource_); 
    574560 
    575561  std::map<size_t, std::vector<std::pair<size_t,double> > > globaIndexWeightFromDestToSource; 
    576   int nb = globalIndexOfCurrentGridSource_->numElements(); 
     562  int nb = globalIndexOfCurrentGridSource_.numElements(); 
    577563  const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
    578564  for (int idx = 0; idx < nb; ++idx) 
    579565  { 
    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))) ; 
    582568  } 
    583569 
     
    638624  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    639625  { 
    640     CArray<int,1>* ptr = new CArray<int,1>((itMap->second).size()); 
    641     localIndexToSendFromGridSource_[itMap->first] = ptr; 
    642626    int destRank = itMap->first; 
    643     int vecSize = (itMap->second).size(); 
     627    int vecSize = itMap->second.size(); 
     628    localIndexToSendFromGridSource_[destRank].resize(vecSize); 
    644629    for (int idx = 0; idx < vecSize; ++idx) 
    645630    { 
    646       itArr = std::find(itbArr, iteArr, (itMap->second)[idx]); 
     631      itArr = std::find(itbArr, iteArr, itMap->second[idx]); 
    647632      if (iteArr != itArr) 
    648633      { 
    649634        int localIdx = std::distance(itbArr, itArr); 
    650         (*localIndexToSendFromGridSource_[destRank])(idx) = (localIdx); 
     635        localIndexToSendFromGridSource_[destRank](idx) = localIdx; 
    651636      } 
    652637    } 
     
    658643  \return local index of data 
    659644*/ 
    660 const std::map<int, CArray<int,1>* >& CGridTransformation::getLocalIndexToSendFromGridSource() const 
     645const std::map<int, CArray<int,1> >& CGridTransformation::getLocalIndexToSendFromGridSource() const 
    661646{ 
    662647  return localIndexToSendFromGridSource_; 
  • XIOS/trunk/src/transformation/grid_transformation.hpp

    r632 r653  
    4040  void computeAll(); 
    4141 
    42   const std::map<int, CArray<int,1>* >& getLocalIndexToSendFromGridSource() const; 
     42  const std::map<int, CArray<int,1> >& getLocalIndexToSendFromGridSource() const; 
    4343  const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& getLocalIndexToReceiveOnGridDest() const; 
    4444  CGrid* getGridSource() {return gridSource_; } 
     
    9090 
    9191  //! 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_; 
    9393 
    9494  //! Local index of data to receive on grid destination 
     
    9999 
    100100  //! (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_; 
    104104}; 
    105105 
Note: See TracChangeset for help on using the changeset viewer.