Changeset 668


Ignore:
Timestamp:
08/24/15 14:53:36 (9 years ago)
Author:
mhnguyen
Message:

Implementing some code factoring

+) Replace some slow searching function by faster ones

Test
+) On Curie
+) test_client and test_complete are correct

Location:
XIOS/trunk/src
Files:
17 edited

Legend:

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

    r666 r668  
    1818   , gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_() 
    1919   , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 
     20   , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_() 
    2021{ 
    2122} 
     
    2829   , gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_() 
    2930   , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 
     31   , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_() 
    3032{ 
    3133  readDistributionInfo(grid); 
     
    568570          gridMask_(gridMaskIndex)) 
    569571      { 
    570         localDataIndex_(indexLocalDataOnClientCount) = countLocalData; 
     572        localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 
    571573 
    572574        bool isIndexOnServer = true; 
     
    584586            globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 
    585587          } 
    586           globalDataSendToServer_(indexSend2ServerCount) = globalIndex; 
    587           localDataIndexSendToServer_(indexSend2ServerCount) = indexLocalDataOnClientCount; 
    588           localMaskIndex_(indexSend2ServerCount) = gridMaskIndex; 
     588          globalDataSendToServer_[indexSend2ServerCount] = globalIndex; 
     589          localDataIndexSendToServer_[indexSend2ServerCount] = indexLocalDataOnClientCount; 
     590          localMaskIndex_[indexSend2ServerCount] = gridMaskIndex; 
    589591          ++indexSend2ServerCount; 
    590592        } 
     
    639641} 
    640642 
    641 const CArray<size_t,1>& CDistributionClient::getGlobalDataIndexSendToServer() const 
     643const std::vector<size_t>& CDistributionClient::getGlobalDataIndexSendToServer() const 
    642644{ 
    643645  return globalDataSendToServer_; 
     
    647649  Return local data index of client 
    648650*/ 
    649 const CArray<int,1>& CDistributionClient::getLocalDataIndexOnClient() const 
     651const std::vector<int>& CDistributionClient::getLocalDataIndexOnClient() const 
    650652{ 
    651653  return localDataIndex_; 
     
    655657  Return local mask index of client 
    656658*/ 
    657 const CArray<int,1>& CDistributionClient::getLocalMaskIndexOnClient() const 
     659const std::vector<int>& CDistributionClient::getLocalMaskIndexOnClient() const 
    658660{ 
    659661  return localMaskIndex_; 
     
    663665  Return local data index on client which are sent to servers 
    664666*/ 
    665 const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer() const 
     667const std::vector<int>& CDistributionClient::getLocalDataIndexSendToServer() const 
    666668{ 
    667669  return localDataIndexSendToServer_; 
  • XIOS/trunk/src/distribution_client.hpp

    r664 r668  
    3636    virtual ~CDistributionClient(); 
    3737 
    38     virtual const CArray<int,1>& getLocalDataIndexOnClient() const; 
    39     virtual const CArray<int,1>& getLocalDataIndexSendToServer() const; 
    40     const CArray<size_t,1>& getGlobalDataIndexSendToServer() const; 
    41     const CArray<int,1>& getLocalMaskIndexOnClient() const; 
     38    virtual const std::vector<int>& getLocalDataIndexOnClient() const; 
     39    virtual const std::vector<int>& getLocalDataIndexSendToServer() const; 
     40    const std::vector<size_t>& getGlobalDataIndexSendToServer() const; 
     41    const std::vector<int>& getLocalMaskIndexOnClient() const; 
    4242 
    4343    std::vector<int> getNGlob() { return nGlob_; } 
     
    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    std::vector<size_t> globalDataSendToServer_; 
     75    std::vector<int> localDataIndex_; 
     76    std::vector<int> localDataIndexSendToServer_; 
     77    std::vector<int> localMaskIndex_; 
    7878 
    7979  private: 
  • XIOS/trunk/src/distribution_server.cpp

    r653 r668  
    88 */ 
    99#include "distribution_server.hpp" 
     10#include "utils.hpp" 
    1011 
    1112namespace xios { 
     
    9192CArray<size_t,1> CDistributionServer::computeLocalIndex(const CArray<size_t,1>& globalIndex) 
    9293{ 
    93   CArray<size_t,1>::const_iterator itBegin = this->globalIndex_.begin(), 
    94                                    itEnd   = this->globalIndex_.end(), it; 
     94  int ssize = globalIndex.numElements(); 
     95  int nbGlobalIndex = this->globalIndex_.numElements(); 
    9596 
    96   int ssize = globalIndex.numElements(), idx = 0; 
     97  std::vector<int>::iterator it; 
     98  std::vector<int> permutIndex(nbGlobalIndex); 
     99  XIOSAlgorithms::fillInIndex(nbGlobalIndex, permutIndex); 
     100  XIOSAlgorithms::sortWithIndex<size_t, CArrayStorage>(this->globalIndex_, permutIndex); 
     101  typedef XIOSBinarySearchWithIndex<size_t, CArrayStorage> BinarySearch; 
     102  BinarySearch binarySearch(this->globalIndex_); 
     103 
    97104  CArray<size_t,1> localIndex(ssize); 
    98   it = itBegin; 
     105  int idx = 0; 
    99106  for (int i = 0; i < ssize; ++i) 
    100107  { 
    101     it = std::find(itBegin, itEnd, globalIndex(i)); 
    102 //    it = std::lower_bound(it, itEnd, globalIndex(i)); 
    103     if (itEnd != it) 
     108    if (binarySearch.search(permutIndex.begin(), permutIndex.end(), globalIndex(i), it)) 
    104109    { 
    105       localIndex(idx) = std::distance(itBegin, it); 
     110      localIndex(idx) = *it; 
    106111      ++idx; 
    107112    } 
     
    117122void CDistributionServer::computeLocalIndex(CArray<size_t,1>& globalIndex) 
    118123{ 
    119   CArray<size_t,1>::const_iterator itBegin = this->globalIndex_.begin(), 
    120                                    itEnd   = this->globalIndex_.end(), it; 
     124  int ssize = globalIndex.numElements(); 
     125  int nbGlobalIndex = this->globalIndex_.numElements(); 
    121126 
    122   int ssize = globalIndex.numElements(), idx = 0; 
     127  std::vector<int>::iterator it; 
     128  std::vector<int> permutIndex(nbGlobalIndex); 
     129  XIOSAlgorithms::fillInIndex(nbGlobalIndex, permutIndex); 
     130  XIOSAlgorithms::sortWithIndex<size_t, CArrayStorage>(this->globalIndex_, permutIndex); 
     131  typedef XIOSBinarySearchWithIndex<size_t, CArrayStorage> BinarySearch; 
     132  BinarySearch binarySearch(this->globalIndex_); 
     133 
    123134  CArray<size_t,1> localIndex(ssize); 
    124   it = itBegin; 
     135  int idx = 0; 
    125136  for (int i = 0; i < ssize; ++i) 
    126137  { 
    127     it = std::find(itBegin, itEnd, globalIndex(i)); 
    128 //    it = std::lower_bound(it, itEnd, globalIndex(i)); 
    129     if (itEnd != it) 
     138    if (binarySearch.search(permutIndex.begin(), permutIndex.end(), globalIndex(i), it)) 
    130139    { 
    131       localIndex(idx) = std::distance(itBegin, it); 
     140      localIndex(idx) = *it; 
    132141      ++idx; 
    133142    } 
  • XIOS/trunk/src/node/domain.cpp

    r667 r668  
    832832    std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(), 
    833833                                                       ite = globalIndexDomainOnServer.end(); 
     834    typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     835    std::vector<int>::iterator itVec; 
     836 
    834837    indSrv_.clear(); 
    835838    for (; it != ite; ++it) 
    836839    { 
    837840      int rank = it->first; 
    838       std::vector<size_t>::const_iterator itbVec  = (it->second).begin(), 
    839                                            iteVec = (it->second).end(); 
     841      int indexSize = it->second.size(); 
     842      std::vector<int> permutIndex(indexSize); 
     843      XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
     844      XIOSAlgorithms::sortWithIndex<size_t>(it->second, permutIndex); 
     845      BinarySearch binSearch(it->second); 
    840846      int nb = globalIndexDomainZoom.numElements(); 
    841847      for (int i = 0; i < nb; ++i) 
    842848      { 
    843         if (iteVec != std::find(itbVec, iteVec, globalIndexDomainZoom(i))) 
     849        if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 
    844850        { 
    845851          indSrv_[rank].push_back(localIndexDomainZoom(i)); 
  • XIOS/trunk/src/node/grid.cpp

    r666 r668  
    317317     clientDistribution_ = new CDistributionClient(client->clientRank, this); 
    318318     // Get local data index on client 
    319      storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().numElements()); 
    320      storeIndex_client = (clientDistribution_->getLocalDataIndexOnClient()); 
     319     storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
     320     int nbStoreIndex = storeIndex_client.numElements(); 
     321     for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
    321322     isDataDistributed_= clientDistribution_->isDataDistributed(); 
    322323 
     
    325326        if (0 == client->clientRank) 
    326327        { 
    327           size_t ssize = clientDistribution_->getLocalDataIndexOnClient().numElements(); 
     328          size_t ssize = clientDistribution_->getLocalDataIndexOnClient().size(); 
    328329          for (int rank = 0; rank < client->serverSize; ++rank) 
    329330            connectedDataSize_[rank] = ssize; 
     
    359360     clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex()); 
    360361     const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    361      const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
     362     const std::vector<size_t>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
    362363     std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
    363364     itbGlobalMap = itGlobalMap = globalIndexOnServer.begin(); 
    364365     iteGlobalMap = globalIndexOnServer.end(); 
    365366 
    366      int nbGlobalIndex = globalIndexSendToServer.numElements(); 
    367     for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    368     { 
    369       int serverRank = itGlobalMap->first; 
    370       std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), itVecGlobal, 
    371                                           iteVecGlobal = (itGlobalMap->second).end(); 
    372       for (int i = 0; i < nbGlobalIndex; ++i) 
    373       { 
    374         if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i))) 
    375         { 
    376           if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
    377             connectedDataSize_[serverRank] = 1; 
    378           else 
    379             ++connectedDataSize_[serverRank]; 
    380         } 
    381       } 
    382     } 
    383  
    384    connectedServerRank_.clear(); 
    385    for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 
    386      connectedServerRank_.push_back(it->first); 
    387    } 
    388    if (!connectedDataSize_.empty()) 
    389    { 
     367     typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     368     std::vector<int>::iterator itVec; 
     369     int nbGlobalIndex = globalIndexSendToServer.size(); 
     370     for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
     371     { 
     372       int serverRank = itGlobalMap->first; 
     373       int indexSize = itGlobalMap->second.size(); 
     374       std::vector<int> permutIndex(indexSize); 
     375       XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
     376       XIOSAlgorithms::sortWithIndex<size_t>(itGlobalMap->second, permutIndex); 
     377       BinarySearch binSearch(itGlobalMap->second); 
     378       for (int i = 0; i < nbGlobalIndex; ++i) 
     379       { 
     380         if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexSendToServer[i], itVec)) 
     381         { 
     382           if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
     383             connectedDataSize_[serverRank] = 1; 
     384           else 
     385             ++connectedDataSize_[serverRank]; 
     386         } 
     387       } 
     388     } 
     389 
    390390     connectedServerRank_.clear(); 
    391      for (std::map<int,size_t>::const_iterator it = connectedDataSize_.begin(); it != connectedDataSize_.end(); ++it) 
     391     for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 
    392392       connectedServerRank_.push_back(it->first); 
    393    } 
    394  
    395     nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
     393     } 
     394     if (!connectedDataSize_.empty()) 
     395     { 
     396       connectedServerRank_.clear(); 
     397       for (std::map<int,size_t>::const_iterator it = connectedDataSize_.begin(); it != connectedDataSize_.end(); ++it) 
     398         connectedServerRank_.push_back(it->first); 
     399     } 
     400 
     401     nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    396402   } 
    397403 
     
    562568    list<CArray<size_t,1> > listOutIndex; 
    563569    const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    564     const CArray<int,1>& localIndexSendToServer = clientDistribution_->getLocalDataIndexSendToServer(); 
    565     const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
     570    const std::vector<int>& localIndexSendToServer = clientDistribution_->getLocalDataIndexSendToServer(); 
     571    const std::vector<size_t>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
    566572 
    567573    if (!doGridHaveDataDistributed()) 
     
    569575      if (0 == client->clientRank) 
    570576      { 
    571         const CArray<size_t, 1>& outGlobalIndexOnServer = globalIndexSendToServer; 
    572         const CArray<int,1>& outLocalIndexToServer = localIndexSendToServer; 
     577        CArray<size_t,1> outGlobalIndexOnServer(globalIndexSendToServer.size()); 
     578        for (int idx = 0; idx < globalIndexSendToServer.size();++idx) 
     579          outGlobalIndexOnServer(idx) = globalIndexSendToServer[idx]; 
     580 
     581        CArray<int,1> outLocalIndexToServer(localIndexSendToServer.size()); 
     582        for (int idx = 0; idx < localIndexSendToServer.size();++idx) 
     583          outLocalIndexToServer(idx) = localIndexSendToServer[idx]; 
    573584 
    574585        for (rank = 0; rank < client->serverSize; ++rank) 
     
    594605      iteGlobalMap = globalIndexOnServer.end(); 
    595606 
    596       int nbGlobalIndex = globalIndexSendToServer.numElements(); 
     607      int nbGlobalIndex = globalIndexSendToServer.size(); 
    597608      std::map<int,std::vector<int> >localIndexTmp; 
    598609      std::map<int,std::vector<size_t> > globalIndexTmp; 
    599610 
     611      typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     612      std::vector<int>::iterator itVec; 
    600613      for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    601614      { 
    602615        int serverRank = itGlobalMap->first; 
    603         std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), 
    604                                             iteVecGlobal = (itGlobalMap->second).end(); 
     616        int indexSize = itGlobalMap->second.size(); 
     617        std::vector<int> permutIndex(indexSize); 
     618        XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
     619        XIOSAlgorithms::sortWithIndex<size_t>(itGlobalMap->second, permutIndex); 
     620        BinarySearch binSearch(itGlobalMap->second); 
     621 
    605622        for (int i = 0; i < nbGlobalIndex; ++i) 
    606623        { 
    607           if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i))) 
     624          if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexSendToServer[i], itVec)) 
    608625          { 
    609             globalIndexTmp[serverRank].push_back(globalIndexSendToServer(i)); 
    610             localIndexTmp[serverRank].push_back(localIndexSendToServer(i)); 
     626            globalIndexTmp[serverRank].push_back(globalIndexSendToServer[i]); 
     627            localIndexTmp[serverRank].push_back(localIndexSendToServer[i]); 
    611628          } 
    612629        } 
  • XIOS/trunk/src/test/test_client.f90

    r666 r668  
    7979  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj,type='curvilinear') 
    8080  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
    81 !  CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat) 
     81  CALL xios_set_domain_attr("domain_A",lonvalue_2D=lon,latvalue_2D=lat) 
    8282  CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 
    8383 
     
    113113 
    114114  ni=0 ; lonvalue(:,:)=0; 
    115 !  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue_2D=lon) 
     115  CALL xios_get_domain_attr("domain_A",ni=ni,lonvalue_2D=lonvalue) 
    116116 
    117117  print *,"ni",ni 
    118   print *,"lonvalue",lon; 
     118  print *,"lonvalue",lonvalue; 
    119119 
    120120  CALL xios_is_defined_field_attr("field_A",enabled=ok) 
  • XIOS/trunk/src/transformation/axis_algorithm_interpolate.cpp

    r666 r668  
    5050 
    5151  retrieveAllAxisValue(recvBuff, indexVec); 
    52   order<double>(recvBuff, indexVec); 
     52  XIOSAlgorithms::sortWithIndex<double, CVectorStorage>(recvBuff, indexVec); 
    5353  computeInterpolantPoint(recvBuff, indexVec); 
    5454} 
  • XIOS/trunk/src/transformation/axis_algorithm_transformation.cpp

    r666 r668  
    3939  \param[in] axisPositionInGrid position of the axis in the grid 
    4040  \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the axis on which transformation is performed) 
    41   \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s) 
     41  \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s), this array is already acsending sorted 
    4242  \param[in/out] globalIndexDestGrid array of global index (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
    4343  \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
     
    4848                                                                          const std::vector<int>& gridDestGlobalDim, 
    4949                                                                          const std::vector<int>& gridSrcGlobalDim, 
    50                                                                           const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     50                                                                          const std::vector<size_t>& globalIndexGridDestSendToServer, 
    5151                                                                          CArray<size_t,1>& globalIndexDestGrid, 
    5252                                                                          std::vector<std::vector<size_t> >& globalIndexSrcGrid) 
     
    6666  } 
    6767 
    68   CArray<size_t,1>::const_iterator itbArr = globalIndexGridDestSendToServer.begin(), itArr, 
    69                                    iteArr = globalIndexGridDestSendToServer.end(); 
     68  std::vector<size_t>::const_iterator itbArr = globalIndexGridDestSendToServer.begin(), itArr, 
     69                                      iteArr = globalIndexGridDestSendToServer.end(); 
    7070 
    7171  while (idx < ssize) 
     
    9191    } 
    9292 
    93     itArr = std::find(itbArr, iteArr, globIndex); 
    94     if (iteArr != itArr) ++realGlobalIndexSize; 
     93    if (std::binary_search(itbArr, iteArr, globIndex)) ++realGlobalIndexSize; 
    9594    ++idxLoop[0]; 
    9695    ++idx; 
     
    130129    } 
    131130 
    132     itArr = std::find(itbArr, iteArr, globIndex); 
    133     if (iteArr != itArr) 
     131    if (std::binary_search(itbArr, iteArr, globIndex)) 
    134132    { 
    135133      globalIndexDestGrid(realGlobalIndex) = globIndex; 
  • XIOS/trunk/src/transformation/axis_algorithm_transformation.hpp

    r631 r668  
    3232                                                        const std::vector<int>& gridDestGlobalDim, 
    3333                                                        const std::vector<int>& gridSrcGlobalDim, 
    34                                                         const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     34                                                        const std::vector<size_t>& globalIndexGridDestSendToServer, 
    3535                                                        CArray<size_t,1>& globalIndexDestGrid, 
    3636                                                        std::vector<std::vector<size_t> >& globalIndexSrcGrid); 
  • XIOS/trunk/src/transformation/domain_algorithm_transformation.cpp

    r663 r668  
    3232  \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed) 
    3333  \param[in] gridSrcGlobalDim dimension size of source grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed) 
    34   \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s) 
     34  \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s), this array is already acsending sorted 
    3535  \param[in/out] globalIndexDestGrid array of global index (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
    3636  \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
     
    4141                                                                          const std::vector<int>& gridDestGlobalDim, 
    4242                                                                          const std::vector<int>& gridSrcGlobalDim, 
    43                                                                           const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     43                                                                          const std::vector<size_t>& globalIndexGridDestSendToServer, 
    4444                                                                          CArray<size_t,1>& globalIndexDestGrid, 
    4545                                                                          std::vector<std::vector<size_t> >& globalIndexSrcGrid) 
     
    7878  for (int i = 0; i< numElement; ++i) ssize *= gridDomainGlobalDim[i]; 
    7979 
    80   CArray<size_t,1>::const_iterator itbArr = globalIndexGridDestSendToServer.begin(), itArr, 
    81                                    iteArr = globalIndexGridDestSendToServer.end(); 
     80  std::vector<size_t>::const_iterator itbArr = globalIndexGridDestSendToServer.begin(), itArr, 
     81                                      iteArr = globalIndexGridDestSendToServer.end(); 
    8282  idx = 0; 
    8383  while (idx < ssize) 
     
    111111    } 
    112112 
    113     itArr = std::find(itbArr, iteArr, globIndex); 
    114     if (iteArr != itArr) ++realGlobalIndexSize; 
     113    if (std::binary_search(itbArr, iteArr, globIndex)) ++realGlobalIndexSize; 
    115114    ++idxLoop[0]; 
    116115    ++idx; 
     
    158157    } 
    159158 
    160     itArr = std::find(itbArr, iteArr, globIndex); 
    161     if (iteArr != itArr) 
     159    if (std::binary_search(itbArr, iteArr, globIndex)) 
    162160    { 
    163161      globalIndexDestGrid(realGlobalIndex) = globIndex; 
  • XIOS/trunk/src/transformation/domain_algorithm_transformation.hpp

    r631 r668  
    3232                                                        const std::vector<int>& gridDestGlobalDim, 
    3333                                                        const std::vector<int>& gridSrcGlobalDim, 
    34                                                         const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     34                                                        const std::vector<size_t>& globalIndexGridDestSendToServer, 
    3535                                                        CArray<size_t,1>& globalIndexDestGrid, 
    3636                                                        std::vector<std::vector<size_t> >& globalIndexSrcGrid); 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp

    r657 r668  
    2929                                                             const std::vector<int>& gridDestGlobalDim, 
    3030                                                             const std::vector<int>& gridSrcGlobalDim, 
    31                                                              const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     31                                                             const std::vector<size_t>& globalIndexGridDestSendToServer, 
    3232                                                             std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource) 
    3333{ 
     
    4040  std::vector<std::vector<size_t> > globalIndexSrcGrid; 
    4141  CArray<size_t,1> globalIndexDestGrid; 
    42  
     42  std::vector<size_t> vecGlobalIndexGridSendToServer(globalIndexGridDestSendToServer.begin(), globalIndexGridDestSendToServer.end()); 
     43  std::sort(vecGlobalIndexGridSendToServer.begin(), vecGlobalIndexGridSendToServer.end()); 
    4344  for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap, ++itTransWeight) 
    4445  { 
     
    4849                                                   gridDestGlobalDim, 
    4950                                                   gridSrcGlobalDim, 
    50                                                    globalIndexGridDestSendToServer, 
     51                                                   vecGlobalIndexGridSendToServer, 
    5152                                                   globalIndexDestGrid, 
    5253                                                   globalIndexSrcGrid); 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp

    r631 r668  
    2929                                const std::vector<int>& gridDestGlobalDim, 
    3030                                const std::vector<int>& gridSrcGlobalDim, 
    31                                 const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     31                                const std::vector<size_t>& globalIndexGridDestSendToServer, 
    3232                                std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource); 
    3333 
     
    4444    \param[in] elementPositionInGrid position of the element in the grid (for example: a grid with one domain and one axis, position of domain is 1, position of axis is 2) 
    4545    \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the element on which transformation is performed) 
    46     \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s) 
     46    \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s), this array is already acsending sorted 
    4747    \param[in/out] globalIndexDestGrid array of global index (for 2d grid, this array maybe a line, for 3d, this array may represent a plan). It should be preallocated 
    4848    \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
     
    5353                                                        const std::vector<int>& gridDestGlobalDim, 
    5454                                                        const std::vector<int>& gridSrcGlobalDim, 
    55                                                         const CArray<size_t,1>& globalIndexGridDestSendToServer, 
     55                                                        const std::vector<size_t>& globalIndexGridDestSendToServer, 
    5656                                                        CArray<size_t,1>& globalIndexDestGrid, 
    5757                                                        std::vector<std::vector<size_t> >& globalIndexSrcGrid) = 0; 
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r660 r668  
    2222CGridTransformation::CGridTransformation(CGrid* destination, CGrid* source) 
    2323: gridSource_(source), gridDestination_(destination), originalGridSource_(source), 
    24   globalIndexOfCurrentGridSource_(0), globalIndexOfOriginalGridSource_(0), weightOfGlobalIndexOfOriginalGridSource_(0), algoTypes_() 
     24  globalIndexOfCurrentGridSource_(), globalIndexOfOriginalGridSource_(), weightOfGlobalIndexOfOriginalGridSource_(0), algoTypes_() 
    2525{ 
    2626  //Verify the compatibity between two grids 
     
    7777 
    7878  CDistributionClient distribution(client->clientRank, originalGridSource_); 
    79   const CArray<size_t,1>& globalIndexGridDestSendToServer = distribution.getGlobalDataIndexSendToServer(); 
    80  
    81   globalIndexOfCurrentGridSource_.resize(globalIndexGridDestSendToServer.numElements()); 
    82   globalIndexOfOriginalGridSource_.resize(globalIndexGridDestSendToServer.numElements()); 
    83   weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridDestSendToServer.numElements()); 
     79  const std::vector<size_t>& globalIndexGridDestSendToServer = distribution.getGlobalDataIndexSendToServer(); 
     80 
     81  weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridDestSendToServer.size()); 
    8482  globalIndexOfCurrentGridSource_  = globalIndexGridDestSendToServer; 
    8583  globalIndexOfOriginalGridSource_ = globalIndexGridDestSendToServer; 
     
    362360    // Recalculate the distribution of grid destination 
    363361    CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
    364     const CArray<size_t,1>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 
     362    const std::vector<size_t>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 
    365363 
    366364    // ComputeTransformation of global index of each element 
     
    397395  //First of all, retrieve info of local mask of grid destination 
    398396  CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
    399   const CArray<int, 1>& localMaskIndexOnClientDest = distributionClientDest.getLocalMaskIndexOnClient(); 
    400   const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 
    401  
    402   CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 
     397  const std::vector<int>& localMaskIndexOnClientDest = distributionClientDest.getLocalMaskIndexOnClient(); 
     398  const std::vector<size_t>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 
     399 
     400  std::vector<size_t>::const_iterator itbArr, itArr, iteArr; 
    403401  itbArr = globalIndexOnClientDest.begin(); 
    404402  iteArr = globalIndexOnClientDest.end(); 
    405403 
    406404  // Then find out which index became invalid (become masked after being applied the algorithms, or demande some masked points from grid source) 
    407   int num = globalIndexOfOriginalGridSource_.numElements(); 
     405  int num = globalIndexOfOriginalGridSource_.size(); 
    408406  const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
    409407  int maskIndexNum = 0; 
    410408  for (int idx = 0; idx < num; ++idx) 
    411409  { 
    412     if (sfmax == globalIndexOfOriginalGridSource_(idx)) 
    413     { 
    414       size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_(idx); 
     410    if (sfmax == globalIndexOfOriginalGridSource_[idx]) 
     411    { 
     412      size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_[idx]; 
    415413      itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 
    416414      if (iteArr != itArr) ++maskIndexNum; 
     
    422420  for (int idx = 0; idx < num; ++idx) 
    423421  { 
    424     if (sfmax == globalIndexOfOriginalGridSource_(idx)) 
    425     { 
    426       size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_(idx); 
     422    if (sfmax == globalIndexOfOriginalGridSource_[idx]) 
     423    { 
     424      size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_[idx]; 
    427425      itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 
    428426      if (iteArr != itArr) 
    429427      { 
    430428        int localIdx = std::distance(itbArr, itArr); 
    431         maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest(localIdx); 
     429        maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest[localIdx]; 
    432430        ++maskIndexNum; 
    433431      } 
     
    459457  std::map<int,std::vector<size_t> >::const_iterator itbSend = globalIndexToSend.begin(), itSend, 
    460458                                                     iteSend = globalIndexToSend.end(); 
    461   CArray<size_t,1>::const_iterator itbArr = globalIndexOfCurrentGridSource_.begin(), itArr, 
    462                                    iteArr = globalIndexOfCurrentGridSource_.end(); 
     459  std::vector<size_t>::const_iterator itbArr = globalIndexOfCurrentGridSource_.begin(), itArr, 
     460                                      iteArr = globalIndexOfCurrentGridSource_.end(); 
    463461 int sendBuffSize = 0; 
    464462 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 
     
    471469 std::map<int, MPI_Request> requests; 
    472470 
     471 std::vector<int> permutIndex(globalIndexOfCurrentGridSource_.size()); 
     472 typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     473 XIOSAlgorithms::fillInIndex(globalIndexOfCurrentGridSource_.size(), permutIndex); 
     474 XIOSAlgorithms::sortWithIndex<size_t>(globalIndexOfCurrentGridSource_, permutIndex); 
     475 BinarySearch searchCurrentSrc(globalIndexOfCurrentGridSource_); 
     476 std::vector<int>::iterator itbIndex = permutIndex.begin(), itIndex, 
     477                            iteIndex = permutIndex.end(); 
     478 
     479  // Find out local index on grid destination (received) 
    473480 int currentBuffPosition = 0; 
    474481 for (itSend = itbSend; itSend != iteSend; ++itSend) 
     
    479486   for (int idx = 0; idx < (countSize); ++idx) 
    480487   { 
    481      itArr = std::find(itbArr, iteArr, globalIndexOfCurrentGridSourceToSend[idx]); 
    482      if (iteArr != itArr) 
     488     if (searchCurrentSrc.search(itbIndex, iteIndex, globalIndexOfCurrentGridSourceToSend[idx], itIndex)) 
    483489     { 
    484        int index = std::distance(itbArr, itArr); 
    485        sendBuff[idx+currentBuffPosition] = globalIndexOfOriginalGridSource_(index); 
     490//       int index = std::distance(itbArr, itArr); 
     491       sendBuff[idx+currentBuffPosition] = globalIndexOfOriginalGridSource_[*itIndex]; //[index]; 
    486492     } 
    487493   } 
     
    522528 } 
    523529 
    524  if (globalIndexOfCurrentGridSource_.numElements() != nbCurrentGridSource) 
     530 if (globalIndexOfCurrentGridSource_.size() != nbCurrentGridSource) 
    525531 { 
    526532   globalIndexOfCurrentGridSource_.resize(nbCurrentGridSource); 
     
    539545     for (int i = 0; i < ssize; ++i) 
    540546     { 
    541        globalIndexOfCurrentGridSource_(k) = ((itRecv->second)[idx][i]).first; 
     547       globalIndexOfCurrentGridSource_[k] = ((itRecv->second)[idx][i]).first; 
    542548       weightOfGlobalIndexOfOriginalGridSource_(k) = ((itRecv->second)[idx][i]).second; 
    543        globalIndexOfOriginalGridSource_(k) = *currentRecvBuff; 
     549       globalIndexOfOriginalGridSource_[k] = *currentRecvBuff; 
    544550       ++k; 
    545551     } 
     
    568574 
    569575  std::map<size_t, std::vector<std::pair<size_t,double> > > globaIndexWeightFromDestToSource; 
    570   int nb = globalIndexOfCurrentGridSource_.numElements(); 
     576  int nb = globalIndexOfCurrentGridSource_.size(); 
    571577  const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
    572578  for (int idx = 0; idx < nb; ++idx) 
    573579  { 
    574     if (sfmax != globalIndexOfOriginalGridSource_(idx)) 
    575       globaIndexWeightFromDestToSource[globalIndexOfCurrentGridSource_(idx)].push_back(make_pair(globalIndexOfOriginalGridSource_(idx), weightOfGlobalIndexOfOriginalGridSource_(idx))) ; 
     580    if (sfmax != globalIndexOfOriginalGridSource_[idx]) 
     581      globaIndexWeightFromDestToSource[globalIndexOfCurrentGridSource_[idx]].push_back(make_pair(globalIndexOfOriginalGridSource_[idx], weightOfGlobalIndexOfOriginalGridSource_(idx))) ; 
    576582  } 
    577583 
     
    585591  CDistributionClient distributionClientSrc(client->clientRank, originalGridSource_); 
    586592 
    587   const CArray<int, 1>& localIndexOnClientDest = distributionClientDest.getLocalDataIndexSendToServer(); 
    588   const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 
    589  
    590   const CArray<int, 1>& localIndexOnClientSrc = distributionClientSrc.getLocalDataIndexOnClient(); 
    591   const CArray<size_t,1>& globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); 
    592  
    593   std::vector<size_t>::const_iterator itbVec, itVec, iteVec; 
    594   CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 
    595  
     593  const std::vector<size_t>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 
     594  const std::vector<size_t>& globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); 
     595 
     596  std::vector<size_t>::const_iterator itbArr, itArr, iteArr; 
     597  std::vector<int>::const_iterator itIndex, itbIndex, iteIndex; 
    596598  std::map<int,std::vector<std::vector<std::pair<size_t,double> > > >::const_iterator itbMapRecv, itMapRecv, iteMapRecv; 
    597599 
     600  std::vector<int> permutIndex; 
     601  typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
     602 
    598603  // Find out local index on grid destination (received) 
     604  XIOSAlgorithms::fillInIndex(globalIndexOnClientDest.size(), permutIndex); 
     605  XIOSAlgorithms::sortWithIndex<size_t>(globalIndexOnClientDest, permutIndex); 
     606  itbIndex = permutIndex.begin(); 
     607  iteIndex = permutIndex.end(); 
     608  BinarySearch searchClientDest(globalIndexOnClientDest); 
    599609  itbMapRecv = globalIndexToReceive.begin(); 
    600610  iteMapRecv = globalIndexToReceive.end(); 
    601   itbArr = globalIndexOnClientDest.begin(); 
    602   iteArr = globalIndexOnClientDest.end(); 
    603611  for (itMapRecv = itbMapRecv; itMapRecv != iteMapRecv; ++itMapRecv) 
    604612  { 
     
    613621        size_t globalIndex = (itMapRecv->second)[i][idx].first; 
    614622        double weight = (itMapRecv->second)[i][idx].second; 
    615         itArr = std::find(itbArr, iteArr, globalIndex); 
    616         if (iteArr != itArr) 
     623        if (searchClientDest.search(itbIndex, iteIndex, globalIndex, itIndex)) 
    617624        { 
    618           int localIdx = std::distance(itbArr, itArr); 
    619           tmpVec.push_back(make_pair(localIdx, weight)); 
     625          tmpVec.push_back(make_pair(*itIndex, weight)); 
    620626        } 
    621627      } 
     
    626632  // Find out local index on grid source (to send) 
    627633  std::map<int,std::vector<size_t> >::const_iterator itbMap, itMap, iteMap; 
     634  XIOSAlgorithms::fillInIndex(globalIndexOnClientSrc.size(), permutIndex); 
     635  XIOSAlgorithms::sortWithIndex<size_t>(globalIndexOnClientSrc, permutIndex); 
     636  itbIndex = permutIndex.begin(); 
     637  iteIndex = permutIndex.end(); 
     638  BinarySearch searchClientSrc(globalIndexOnClientSrc); 
    628639  itbMap = globalIndexToSend.begin(); 
    629640  iteMap = globalIndexToSend.end(); 
    630   itbArr = globalIndexOnClientSrc.begin(); 
    631   iteArr = globalIndexOnClientSrc.end(); 
    632641  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    633642  { 
     
    637646    for (int idx = 0; idx < vecSize; ++idx) 
    638647    { 
    639       itArr = std::find(itbArr, iteArr, itMap->second[idx]); 
    640       if (iteArr != itArr) 
     648      if (searchClientSrc.search(itbIndex, iteIndex, itMap->second[idx], itIndex)) 
    641649      { 
    642         int localIdx = std::distance(itbArr, itArr); 
    643         localIndexToSendFromGridSource_[destRank](idx) = localIdx; 
     650        localIndexToSendFromGridSource_[destRank](idx) = *itIndex; 
    644651      } 
    645652    } 
  • XIOS/trunk/src/transformation/grid_transformation.hpp

    r653 r668  
    9999 
    100100  //! (Grid) Global index of grid source 
    101   CArray<size_t,1> globalIndexOfCurrentGridSource_; 
    102   CArray<size_t,1> globalIndexOfOriginalGridSource_; 
     101  std::vector<size_t> globalIndexOfCurrentGridSource_; 
     102  std::vector<size_t> globalIndexOfOriginalGridSource_; 
    103103  CArray<double,1> weightOfGlobalIndexOfOriginalGridSource_; 
    104104}; 
  • XIOS/trunk/src/transformation/transformation_mapping.cpp

    r666 r668  
    2525  CDistributionClient distributionClientSrc(client->clientRank, gridSource_); 
    2626 
    27   const CArray<size_t,1>& globalIndexGridSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer(); 
     27  const std::vector<size_t>& globalIndexGridSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer(); 
    2828  boost::unordered_map<size_t,int> globalIndexOfServer; 
    29   int globalIndexSize = globalIndexGridSrc.numElements(); 
     29  int globalIndexSize = globalIndexGridSrc.size(); 
    3030  for (int idx = 0; idx < globalIndexSize; ++idx) 
    3131  { 
    32     globalIndexOfServer[globalIndexGridSrc(idx)] = clientRank; 
     32    globalIndexOfServer[globalIndexGridSrc[idx]] = clientRank; 
    3333  } 
    3434 
  • XIOS/trunk/src/utils.hpp

    r630 r668  
    222222}; 
    223223 
    224 template<class T> 
    225 class sorter 
    226 { 
    227   const std::vector<T>& values; 
    228 public: 
    229   sorter(const std::vector<T> &v) : values(v) {} 
    230   bool operator()(int a, int b) { return values[a] < values[b]; } 
    231 }; 
    232  
    233 template<class T> 
    234 void order(const std::vector<T>& values, std::vector<int>& rv) 
    235 { 
    236   std::sort(rv.begin(), rv.end(), sorter<T>(values)); 
     224template<typename T> 
     225class CArrayStorage 
     226{ 
     227public: 
     228  typedef CArray<T,1> StorageType; 
     229 
     230public: 
     231  CArrayStorage(const CArray<T,1>& arr) : values(arr) {} 
     232 
     233protected: 
     234  const T& atIndex(int idx) const { return values(idx); } 
     235  const StorageType& values; 
     236}; 
     237 
     238template<typename T> 
     239class CVectorStorage 
     240{ 
     241public: 
     242  typedef std::vector<T> StorageType; 
     243 
     244public: 
     245  CVectorStorage(const std::vector<T>& vec) : values(vec) {} 
     246 
     247protected: 
     248  const T& atIndex(int idx) const { return values[idx]; } 
     249  const StorageType& values; 
     250}; 
     251 
     252 
     253template< 
     254  typename T, 
     255  template <class> class StoragePolicy = CVectorStorage 
     256  > 
     257class XIOSComparatorWithIndex : 
     258  public StoragePolicy<T> 
     259{ 
     260public: 
     261  typedef typename  StoragePolicy<T>::StorageType StorageType; 
     262 
     263public: 
     264  XIOSComparatorWithIndex(const StorageType& v) : StoragePolicy<T>(v) {} 
     265  bool operator()(int a, int b) { return this->atIndex(a) < this->atIndex(b); } 
     266}; 
     267 
     268template< 
     269  typename T, 
     270  template <class> class StoragePolicy = CVectorStorage 
     271  > 
     272class XIOSLowerBoundWithIndex : 
     273  public StoragePolicy<T> 
     274{ 
     275public: 
     276  typedef typename  StoragePolicy<T>::StorageType StorageType; 
     277 
     278public: 
     279  XIOSLowerBoundWithIndex(const StorageType &v) : StoragePolicy<T>(v) {} 
     280  bool operator()(const int a, const T& b) { return this->atIndex(a) < b; } 
     281}; 
     282 
     283template< 
     284  typename T, 
     285  template <class> class StoragePolicy = CVectorStorage 
     286  > 
     287class XIOSBinarySearchWithIndex : 
     288  public StoragePolicy<T> 
     289{ 
     290public: 
     291  typedef typename  StoragePolicy<T>::StorageType StorageType; 
     292 
     293public: 
     294  XIOSBinarySearchWithIndex(const StorageType& v) : StoragePolicy<T>(v) {} 
     295 
     296  template<typename ForwardIterator> 
     297  bool search(ForwardIterator first, ForwardIterator last, const T& val, ForwardIterator& position) 
     298  { 
     299    first = std::lower_bound(first, last, val, XIOSLowerBoundWithIndex<T, StoragePolicy>(this->values)); 
     300    position = first; 
     301    return (first!=last && !(val<this->atIndex(*first))); 
     302  } 
     303}; 
     304 
     305 
     306struct XIOSAlgorithms 
     307{ 
     308public: 
     309  template<typename T, template <class> class StoragePolicy = CVectorStorage> 
     310  static void sortWithIndex(const typename StoragePolicy<T>::StorageType& values, std::vector<int>& rv) 
     311  { 
     312    std::sort(rv.begin(), rv.end(), XIOSComparatorWithIndex<T, StoragePolicy>(values)); 
     313  } 
     314 
     315  //! Fill in an vector with index begin at 0 
     316  static void fillInIndex(int nbIndex, std::vector<int>& rvIndex) 
     317  { 
     318    if ((0 < nbIndex) && (nbIndex != rvIndex.size())) rvIndex.resize(nbIndex); 
     319    for (int idx = 0; idx < nbIndex; ++idx) rvIndex[idx] = idx; 
     320  } 
     321}; 
     322 
    237323} 
    238324 
    239 } 
    240  
    241325#endif // __UTILS_HPP__ 
Note: See TracChangeset for help on using the changeset viewer.