Index: XIOS/trunk/src/distribution_client.cpp
===================================================================
--- XIOS/trunk/src/distribution_client.cpp	(revision 864)
+++ XIOS/trunk/src/distribution_client.cpp	(revision 870)
@@ -488,5 +488,5 @@
       if (isCurrentIndexDataCorrect)
       {
-        int gridMaskIndex = 0; //currentIndex[0];
+        int gridMaskIndex = 0;
         for (int k = 0; k < this->numElement_; ++k)
         {
@@ -505,5 +505,5 @@
           if (isIndexOnServer)
           {
-            size_t globalIndex = 0; //currentGlobalIndex[0];
+            size_t globalIndex = 0;
             for (int k = 0; k < numElement_; ++k)
             {
@@ -524,80 +524,4 @@
 }
 
-///*!
-//  Create local index of domain(s).
-//  A domain can have data index which even contains the "ghost" points. Very often, these
-//data surround the true data. In order to send correct data to server,
-//a client need to know index of the true data.
-//*/
-//void CDistributionClient::createLocalDomainDataIndex()
-//{
-//  int numDomain = 0;
-//  for (int i = 0; i < axisDomainOrder_.numElements(); ++i)
-//    if (axisDomainOrder_(i)) ++numDomain;
-//
-//  localDomainIndex_.resize(numDomain*2);
-//  indexDomainData_.resize(numDomain);
-//
-//  int idxDomain = 0;
-//  for (int i = 0; i < axisDomainOrder_.numElements(); ++i)
-//  {
-//    if (axisDomainOrder_(i))
-//    {
-//      int iIdx, jIdx = 0, count = 0;
-//      indexDomainData_[idxDomain].resize(dataNIndex_[i], false);
-//      for (int j = 0; j < dataNIndex_[i]; ++j)
-//      {
-//        iIdx = getDomainIndex((*dataIndex_[indexMap_[i]])(j), (*dataIndex_[indexMap_[i]+1])(j),
-//                              dataBegin_[indexMap_[i]], dataBegin_[indexMap_[i]+1],
-//                              dataDims_[i], nLocal_[indexMap_[i]], jIdx);
-//
-//        if ((iIdx >= nBeginLocal_[indexMap_[i]]) && (iIdx < nLocal_[indexMap_[i]]) &&
-//           (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1]) &&
-//           (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]])))
-//        {
-//          (localDomainIndex_[idxDomain]).push_back(iIdx);
-//          (localDomainIndex_[idxDomain*2+1]).push_back(jIdx);
-//          indexDomainData_[idxDomain][j] = true;
-//        }
-//      }
-//      ++idxDomain;
-//    }
-//  }
-//}
-
-///*!
-//  Create local index of axis.
-//*/
-//void CDistributionClient::createLocalAxisDataIndex()
-//{
-//  int numAxis = 0;
-//  for (int i = 0; i < axisDomainOrder_.numElements(); ++i)
-//    if (!axisDomainOrder_(i)) ++numAxis;
-//
-//  localAxisIndex_.resize(numAxis);
-//  indexAxisData_.resize(numAxis);
-//
-//  int idxAxis = 0;
-//  for (int i = 0; i < axisDomainOrder_.numElements(); ++i)
-//  {
-//    if (!axisDomainOrder_(i))
-//    {
-//      int iIdx = 0;
-//      indexAxisData_[idxAxis].resize(dataNIndex_[i], false);
-//      for (int j = 0; j < dataNIndex_[i]; ++j)
-//      {
-//        iIdx = getAxisIndex((*dataIndex_[indexMap_[i]])(j), dataBegin_[indexMap_[i]], nLocal_[indexMap_[i]]);
-//        if ((iIdx >= nBeginLocal_[indexMap_[i]]) &&
-//           (iIdx < nLocal_[indexMap_[i]]) && (axisMasks_[idxAxis](iIdx)))
-//        {
-//          localAxisIndex_[idxAxis].push_back(iIdx);
-//          indexAxisData_[idxAxis][j] = true;
-//        }
-//      }
-//      ++idxAxis;
-//    }
-//  }
-//}
-
 void CDistributionClient::createGlobalIndex()
 {
@@ -652,289 +576,4 @@
 
 }
-
-
-///*!
-//   Create global index on client
-//   In order to do the mapping between client-server, each client creates its own
-//global index of sending data. This global index is then used to calculate to which server
-//the client needs to send it data as well as which part of data belongs to the server.
-//So as to make clients and server coherent in order of index, global index is calculated by
-//take into account of C-convention, the rightmost dimension varies faster.
-//*/
-//void CDistributionClient::createGlobalIndexSendToServer()
-//{
-//  if (isComputed_) return;
-//  isComputed_ = true;
-//  createLocalDomainDataIndex();
-//  createLocalAxisDataIndex();
-//
-//  int idxDomain = 0, idxAxis = 0;
-//  std::vector<int> eachElementSize(numElement_);
-//
-//  // Precompute size of the loop
-//  for (int i = 0; i < numElement_; ++i)
-//  {
-//    if(axisDomainOrder_(i))
-//    {
-//      eachElementSize[i] = localDomainIndex_[idxDomain].size();
-//      idxDomain += 2;
-//    }
-//    else
-//    {
-//      eachElementSize[i] = localAxisIndex_[idxAxis].size();
-//      ++idxAxis;
-//    }
-//  }
-//
-//  //   Compute size of the global index on client
-//  std::vector<StdSize> idxLoop(numElement_,0);
-//  std::vector<StdSize> currentIndex(this->dims_,0);
-//  int innerLoopSize = eachElementSize[0];
-//  size_t idx = 0, indexLocalDataOnClientCount = 0, indexSend2ServerCount = 0;
-//  size_t ssize = 1;
-//  for (int i = 0; i < numElement_; ++i) ssize *= eachElementSize[i];
-//  while (idx < ssize)
-//  {
-//    for (int i = 0; i < numElement_-1; ++i)
-//    {
-//      if (idxLoop[i] == eachElementSize[i])
-//      {
-//        idxLoop[i] = 0;
-//        ++idxLoop[i+1];
-//      }
-//    }
-//
-//    // Find out outer index
-//    // Depending the inner-most element is axis or domain,
-//    // The outer loop index begins correspondingly at one (1) or zero (0)
-//    idxDomain = idxAxis = 0;
-//    if (axisDomainOrder_(0)) ++idxDomain;
-//    else ++idxAxis;
-//    for (int i = 1; i < numElement_; ++i)
-//    {
-//      if (axisDomainOrder_(i))
-//      {
-//        currentIndex[indexMap_[i]]   = localDomainIndex_[idxDomain][idxLoop[i]];
-//        currentIndex[indexMap_[i]+1] = localDomainIndex_[idxDomain+1][idxLoop[i]];
-//        idxDomain += 2;
-//      }
-//      else
-//      {
-//        currentIndex[indexMap_[i]]   = localAxisIndex_[idxAxis][idxLoop[i]];
-//        ++idxAxis;
-//      }
-//    }
-//
-//    // Inner most index
-//    idxDomain = idxAxis = 0;
-//    for (int i = 0; i < innerLoopSize; ++i)
-//    {
-//      if (axisDomainOrder_(0))
-//      {
-//        currentIndex[0] = localDomainIndex_[idxDomain][i];
-//        currentIndex[1] = localDomainIndex_[idxDomain+1][i];
-//      }
-//      else currentIndex[0]   = localAxisIndex_[idxAxis][i];
-//
-//      StdSize gridMaskIndex = currentIndex[0];
-//      int mulDimMask = 1;
-//      for (int k = 1; k < this->dims_; ++k)
-//      {
-//        mulDimMask *= nLocal_[k-1];
-//        gridMaskIndex += (currentIndex[k])*mulDimMask;
-//      }
-//
-//      if (gridMask_(gridMaskIndex))
-//      {
-//        ++indexLocalDataOnClientCount;
-//        bool isIndexOnServer = true;
-//
-//        for (int idxElement = 0; idxElement < this->numElement_; ++idxElement)
-//        {
-//          int actualIdx = 0;
-//          if (axisDomainOrder_(idxElement))
-//          {
-//            actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]];
-//            isIndexOnServer = isIndexOnServer && (((*infoIndex_[indexMap_[idxElement]])(actualIdx)) <= nZoomEnd_[indexMap_[idxElement]])
-//                                              && (nZoomBegin_[indexMap_[idxElement]] <= ((*infoIndex_[indexMap_[idxElement]])(actualIdx)))
-//                                              && (((*infoIndex_[indexMap_[idxElement]+1])(actualIdx)) <= nZoomEnd_[indexMap_[idxElement]+1])
-//                                              && (nZoomBegin_[indexMap_[idxElement]+1] <= ((*infoIndex_[indexMap_[idxElement]+1])(actualIdx)));
-//          }
-//          else
-//          {
-//            isIndexOnServer = isIndexOnServer && (((*infoIndex_[indexMap_[idxElement]])(currentIndex[indexMap_[idxElement]])) <= nZoomEnd_[indexMap_[idxElement]])
-//                                              && (nZoomBegin_[indexMap_[idxElement]] <= ((*infoIndex_[indexMap_[idxElement]])(currentIndex[indexMap_[idxElement]])));
-//          }
-//        }
-//        if (isIndexOnServer) ++indexSend2ServerCount;
-//      }
-//
-//    }
-//    idxLoop[0] += innerLoopSize;
-//    idx += innerLoopSize;
-//  }
-//
-//  // Now allocate these arrays
-//  localDataIndex_.resize(indexLocalDataOnClientCount);
-//  localMaskIndex_.resize(indexSend2ServerCount);
-//  globalLocalDataSendToServerMap_.rehash(std::ceil(indexSend2ServerCount/globalLocalDataSendToServerMap_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount);
-//
-//  // We need to loop with data index
-//  idxLoop.assign(numElement_,0);
-//  idx = indexLocalDataOnClientCount = indexSend2ServerCount = 0;
-//  ssize = 1; for (int i = 0; i < numElement_; ++i) ssize *= dataNIndex_[i];
-//  innerLoopSize = dataNIndex_[0];
-//  int countLocalData = 0;
-//  std::vector<int> correctOuterIndex(numElement_,0);
-//  bool isOuterIndexCorrect = true;
-//  while (idx < ssize)
-//  {
-//    for (int i = 0; i < numElement_-1; ++i)
-//    {
-//      if (idxLoop[i] == dataNIndex_[i])
-//      {
-//        idxLoop[i] = 0;
-//        correctOuterIndex[i] = 0;
-//        ++idxLoop[i+1];
-//        if (isOuterIndexCorrect) ++correctOuterIndex[i+1];
-//      }
-//    }
-//
-//    // Depending the inner-most element axis or domain,
-//    // The outer loop index begins correspondingly at one (1) or zero (0)
-//    idxDomain = idxAxis = 0;
-//    if (axisDomainOrder_(0)) ++idxDomain;
-//    else ++idxAxis;
-//    bool isIndexDomainDataCorrect = true;
-//    bool isIndexAxisDataCorrect = true;
-//
-//    for (int i = 1; i < numElement_; ++i)
-//    {
-//      if (axisDomainOrder_(i))
-//      {
-//        if (indexDomainData_[idxDomain][idxLoop[i]])
-//        {
-//          currentIndex[indexMap_[i]]   = localDomainIndex_[idxDomain][correctOuterIndex[i]];
-//          currentIndex[indexMap_[i]+1] = localDomainIndex_[idxDomain*2+1][correctOuterIndex[i]];
-//          isIndexDomainDataCorrect &= true;
-//        }
-//        else isIndexDomainDataCorrect = false;
-//        ++idxDomain;
-//      }
-//      else
-//      {
-//        if (indexAxisData_[idxAxis][idxLoop[i]])
-//        {
-//          currentIndex[indexMap_[i]]   = localAxisIndex_[idxAxis][correctOuterIndex[i]];
-//          isIndexAxisDataCorrect &= true;
-//        }
-//        else isIndexAxisDataCorrect = false;
-//        ++idxAxis;
-//      }
-//    }
-//
-//    isOuterIndexCorrect = (isIndexAxisDataCorrect) && (isIndexDomainDataCorrect);
-//
-//    // Inner most index
-//    idxDomain = idxAxis = 0;
-//    int correctIndexDomain = 0, correctIndexAxis = 0;
-//    for (int i = 0; i < innerLoopSize; ++i)
-//    {
-//      bool isCurrentIndexDomainDataCorrect = isIndexDomainDataCorrect;
-//      bool isCurrentIndexAxisDataCorrect = isIndexAxisDataCorrect;
-//
-//      if (axisDomainOrder_(0))
-//      {
-//        if (indexDomainData_[idxDomain][i])
-//        {
-//          currentIndex[0] = localDomainIndex_[idxDomain][correctIndexDomain];
-//          currentIndex[1] = localDomainIndex_[idxDomain+1][correctIndexDomain];
-//          isCurrentIndexDomainDataCorrect &= true;
-//          ++correctIndexDomain;
-//        }
-//        else isCurrentIndexDomainDataCorrect = false;
-//      }
-//      else
-//      {
-//        if (indexAxisData_[idxAxis][i])
-//        {
-//          currentIndex[0] = localAxisIndex_[idxAxis][correctIndexAxis];
-//          isCurrentIndexAxisDataCorrect &= true;
-//          ++correctIndexAxis;
-//        }
-//        else isCurrentIndexAxisDataCorrect = false;
-//      }
-//
-//      int gridMaskIndex = currentIndex[0];
-//      int mulDimMask = 1;
-//      for (int k = 1; k < this->dims_; ++k)
-//      {
-//        mulDimMask *= nLocal_[k-1];
-//        gridMaskIndex += (currentIndex[k])*mulDimMask;
-//      }
-//
-//      if (isCurrentIndexDomainDataCorrect &&
-//          isCurrentIndexAxisDataCorrect &&
-//          gridMask_(gridMaskIndex))
-//      {
-//        localDataIndex_[indexLocalDataOnClientCount] = countLocalData;
-//        bool isIndexOnServer = true;
-//        for (int idxElement = 0; idxElement < this->numElement_; ++idxElement)
-//        {
-//          int actualIdx = 0;
-//          if (axisDomainOrder_(idxElement))
-//          {
-//            actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]];
-//            isIndexOnServer = isIndexOnServer && (((*infoIndex_[indexMap_[idxElement]])(actualIdx)) <= nZoomEnd_[indexMap_[idxElement]])
-//                                              && (nZoomBegin_[indexMap_[idxElement]] <= ((*infoIndex_[indexMap_[idxElement]])(actualIdx)))
-//                                              && (((*infoIndex_[indexMap_[idxElement]+1])(actualIdx)) <= nZoomEnd_[indexMap_[idxElement]+1])
-//                                              && (nZoomBegin_[indexMap_[idxElement]+1] <= ((*infoIndex_[indexMap_[idxElement]+1])(actualIdx)));
-//          }
-//          else
-//          {
-//            isIndexOnServer = isIndexOnServer && (((*infoIndex_[indexMap_[idxElement]])(currentIndex[indexMap_[idxElement]])) <= nZoomEnd_[indexMap_[idxElement]])
-//                                              && (nZoomBegin_[indexMap_[idxElement]] <= ((*infoIndex_[indexMap_[idxElement]])(currentIndex[indexMap_[idxElement]])));
-//          }
-//        }
-//
-//        if (isIndexOnServer)
-//        {
-//          int actualIdx = (axisDomainOrder_(0)) ? currentIndex[0]+currentIndex[1]*nLocal_[0]
-//                                                : currentIndex[0];
-//          size_t globalIndex = (*infoIndex_[0])(actualIdx); //idxLoop[0] + nBeginGlobal_[0];
-//          size_t mulDim = 1;
-//          for (int idxElement = 0; idxElement < this->numElement_; ++idxElement)
-//          {
-//            if (axisDomainOrder_(idxElement))
-//            {
-//              actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]];
-//              int jb = (0 == idxElement) ? 1 : 0;
-//              for (int j = jb; j <= 1; ++j)
-//              {
-//                mulDim *= nGlob_[indexMap_[idxElement]+j-1];
-//                globalIndex += ((*infoIndex_[indexMap_[idxElement]+j])(actualIdx))*mulDim;
-//              }
-//            }
-//            else
-//            {
-//              if (0 != idxElement)
-//              {
-//                mulDim *= nGlob_[indexMap_[idxElement]-1];
-//                globalIndex += ((*infoIndex_[indexMap_[idxElement]])(currentIndex[indexMap_[idxElement]]))*mulDim;
-//              }
-//            }
-//          }
-//          globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount;
-//          localMaskIndex_[indexSend2ServerCount] = gridMaskIndex;
-//          ++indexSend2ServerCount;
-//        }
-//        ++indexLocalDataOnClientCount;
-//      }
-//      ++countLocalData;
-//    }
-//    idxLoop[0] += innerLoopSize;
-//    idx += innerLoopSize;
-//  }
-//}
 
 /*!
