Index: XIOS/trunk/src/distribution_client.cpp
===================================================================
--- XIOS/trunk/src/distribution_client.cpp	(revision 817)
+++ XIOS/trunk/src/distribution_client.cpp	(revision 818)
@@ -19,4 +19,5 @@
    , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_()
    , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_()
+   , infoIndex_()
 {
 }
@@ -30,4 +31,5 @@
    , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_()
    , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_()
+   , infoIndex_()
 {
   readDistributionInfo(grid);
@@ -176,4 +178,5 @@
   // Data_*_index of each dimension
   dataIndex_.resize(this->dims_);
+  infoIndex_.resize(this->dims_);
 
   // A trick to determine position of each domain in domainList
@@ -201,4 +204,6 @@
       dataIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->data_j_index.numElements());
       dataIndex_.at(indexMap_[idx]+1) = domList[domIndex]->data_j_index;
+      infoIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->j_index.numElements());
+      infoIndex_.at(indexMap_[idx]+1) = domList[domIndex]->j_index;
 
       // On the i axis
@@ -213,4 +218,6 @@
       dataIndex_.at(indexMap_[idx]).resize(domList[domIndex]->data_i_index.numElements());
       dataIndex_.at(indexMap_[idx]) = domList[domIndex]->data_i_index;
+      infoIndex_.at(indexMap_[idx]).resize(domList[domIndex]->i_index.numElements());
+      infoIndex_.at(indexMap_[idx]) = domList[domIndex]->i_index;
 
       dataNIndex_.at(idx) = domList[domIndex]->data_i_index.numElements();
@@ -233,4 +240,6 @@
       dataIndex_.at(indexMap_[idx]).resize(axisList[axisIndex]->data_index.numElements());
       dataIndex_.at(indexMap_[idx]) = axisList[axisIndex]->data_index;
+      infoIndex_.at(indexMap_[idx]).resize(axisList[axisIndex]->index.numElements());
+      infoIndex_.at(indexMap_[idx]) = axisList[axisIndex]->index;
       dataNIndex_.at(idx) = axisList[axisIndex]->data_index.numElements();
       dataDims_.at(idx) = 1;
@@ -326,14 +335,14 @@
   size_t ssize = 1, idx = 0;
   for (int i = 0; i < this->dims_; ++i)
-    ssize *= nLocal_[i];
+  ssize *= nLocal_[i];
 
   this->globalIndex_.resize(ssize);
-  std::vector<int> idxLoop(this->dims_,0);
-  int innnerLoopSize = nLocal_[0];
+  std::vector<int> idxLoop(this->numElement_,0);
+  int innnerLoopSize = infoIndex_[0].numElements();
   while (idx < ssize)
   {
-    for (int i = 0; i < this->dims_; ++i)
-    {
-      if (idxLoop[i] == nLocal_[i])
+    for (int i = 0; i < this->numElement_; ++i)
+    {
+      if (idxLoop[i] == infoIndex_[indexMap_[i]].numElements())
       {
         idxLoop[i] = 0;
@@ -344,11 +353,27 @@
     for (int i = 0; i < innnerLoopSize; ++i)
     {
-      size_t globalIndex = idxLoop[0] + nBeginGlobal_[0];
+      size_t globalIndex = infoIndex_[0](idxLoop[0]);
       size_t mulDim = 1;
-      for (int k = 1; k < this->dims_; ++k)
-      {
-        mulDim *= nGlob_[k-1];
-        globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim;
-      }
+      for (int idxElement = 0; idxElement < this->numElement_; ++idxElement)
+      {
+        if (axisDomainOrder_(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](idxLoop[idxElement]))*mulDim;
+          }
+        }
+        else
+        {
+          if (0 != idxElement)
+          {
+            mulDim *= nGlob_[indexMap_[idxElement]-1];
+            globalIndex += (infoIndex_[indexMap_[idxElement]](idxLoop[idxElement]))*mulDim;
+          }
+        }
+      }
+
       this->globalIndex_(idx) = globalIndex;
       ++idxLoop[0];
@@ -356,4 +381,5 @@
     }
   }
+
 }
 
@@ -429,7 +455,4 @@
     }
 
-    int maskIndex = currentIndex[0];
-    for (int j = 0; j < this->dims_; ++j)
-
     // Inner most index
     idxDomain = idxAxis = 0;
@@ -451,11 +474,26 @@
       }
 
-      if (gridMask_(gridMaskIndex)) //(gridMask_(currentIndex[0], currentIndex[1], currentIndex[2]))
+      if (gridMask_(gridMaskIndex))
       {
         ++indexLocalDataOnClientCount;
         bool isIndexOnServer = true;
-        for (int j = 0; j < this->dims_; ++j)
-          isIndexOnServer = isIndexOnServer && ((currentIndex[j]+nBeginGlobal_[j]) <= nZoomEnd_[j])
-                                            && (nZoomBegin_[j] <= (currentIndex[j]+nBeginGlobal_[j]));
+
+        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;
       }
@@ -571,18 +609,49 @@
       {
         localDataIndex_[indexLocalDataOnClientCount] = countLocalData;
-
         bool isIndexOnServer = true;
-        for (int j = 0; j < this->dims_; ++j)
-          isIndexOnServer = isIndexOnServer &&
-                            ((currentIndex[j]+nBeginGlobal_[j]) <= nZoomEnd_[j]) &&
-                            (nZoomBegin_[j] <= (currentIndex[j]+nBeginGlobal_[j]));
+        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)
         {
-          size_t globalIndex = currentIndex[0] + nBeginGlobal_[0];
+          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 k = 1; k < this->dims_; ++k)
+          for (int idxElement = 0; idxElement < this->numElement_; ++idxElement)
           {
-            mulDim *= nGlob_[k-1];
-            globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim;
+            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;
+              }
+            }
           }
           globalDataSendToServer_[indexSend2ServerCount] = globalIndex;
Index: XIOS/trunk/src/distribution_client.hpp
===================================================================
--- XIOS/trunk/src/distribution_client.hpp	(revision 817)
+++ XIOS/trunk/src/distribution_client.hpp	(revision 818)
@@ -97,4 +97,5 @@
     std::vector<int> dataBegin_; //!< Data begin (data_ibegin, data_jbegin, etc)
     std::vector<CArray<int,1> > dataIndex_; //!< Data index
+    std::vector<CArray<int,1> > infoIndex_; //!< i_index, j_index
 
     std::vector<CArray<bool,1> > domainMasks_; //!< Domain mask
