Index: XIOS3/trunk/src/io/nc4_data_output.cpp
===================================================================
--- XIOS3/trunk/src/io/nc4_data_output.cpp	(revision 2612)
+++ XIOS3/trunk/src/io/nc4_data_output.cpp	(revision 2613)
@@ -411,5 +411,7 @@
                        start[0]=domain->ibeginValue_;
                        count[0]=domain->niValue_;
-                       CArray<double,1> lon = domain->lonvalue(Range(0,domain->niValue_-1));
+                       CArray<double,1> lon;
+                       lon.resize( domain->niValue_);
+                       for (int i=0;i<domain->niValue_;i++) lon(i) = domain->lonvalue(i);
                        SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count);
                      }
Index: XIOS3/trunk/src/io/onetcdf4.cpp
===================================================================
--- XIOS3/trunk/src/io/onetcdf4.cpp	(revision 2612)
+++ XIOS3/trunk/src/io/onetcdf4.cpp	(revision 2613)
@@ -478,32 +478,34 @@
                 normalizingWeight = userChunkingWeights[i];
               }
-
-            std::vector<double> chunkingRatioPerDims; // will store coefficients used to compute chunk size
-            double productRatios = 1; // last_coeff = pow( shrink_ratio / (product of all ratios), 1/countChunkingDims )
-            for (int i=0;i<userChunkingWeights.size();i++)
+            if (normalizingWeight!=0) // no chunk for scalar
             {
-              chunkingRatioPerDims.push_back( userChunkingWeights[i] / normalizingWeight );
-              if (chunkingRatioPerDims[i]) productRatios *= chunkingRatioPerDims[i];
-            }
-            for (int i=0;i<userChunkingWeights.size();i++)
-            {
-              chunkingRatioPerDims[i] *= pow( chunkingRatio / productRatios, 1./countChunkingDims );
-            }
-            
-            std::vector<double>::iterator itChunkingRatios = chunkingRatioPerDims.begin();
-            //itId = dim.rbegin();
-            double correctionFromPreviousDim = 1.;
-            for (vector<StdSize>::reverse_iterator itDim = dimsizes.rbegin(); itDim != dimsizes.rend(); ++itDim, ++itChunkingRatios, ++itId)
-            {
-              *itChunkingRatios *= correctionFromPreviousDim;
-              correctionFromPreviousDim = 1;
-              if (*itChunkingRatios > 1) // else target larger than size !
+              std::vector<double> chunkingRatioPerDims; // will store coefficients used to compute chunk size
+              double productRatios = 1; // last_coeff = pow( shrink_ratio / (product of all ratios), 1/countChunkingDims )
+              for (int i=0;i<userChunkingWeights.size();i++)
               {
-                StdSize dimensionSize = *itDim;
-                //info(0) << *itId << " " << *itDim << " " << *itChunkingRatios << " " << (*itDim)/(*itChunkingRatios) << endl;
-                *itDim = ceil( *itDim / ceil(*itChunkingRatios) );
-                correctionFromPreviousDim = *itChunkingRatios/ ((double)dimensionSize/(*itDim));
+                chunkingRatioPerDims.push_back( userChunkingWeights[i] / normalizingWeight );
+                if (chunkingRatioPerDims[i]) productRatios *= chunkingRatioPerDims[i];
               }
-            }
+              for (int i=0;i<userChunkingWeights.size();i++)
+              {
+                chunkingRatioPerDims[i] *= pow( chunkingRatio / productRatios, 1./countChunkingDims );
+              }
+              
+              std::vector<double>::iterator itChunkingRatios = chunkingRatioPerDims.begin();
+              //itId = dim.rbegin();
+              double correctionFromPreviousDim = 1.;
+              for (vector<StdSize>::reverse_iterator itDim = dimsizes.rbegin(); itDim != dimsizes.rend(); ++itDim, ++itChunkingRatios, ++itId)
+              {
+                *itChunkingRatios *= correctionFromPreviousDim;
+                correctionFromPreviousDim = 1;
+                if (*itChunkingRatios > 1) // else target larger than size !
+                {
+                  StdSize dimensionSize = *itDim;
+                  //info(0) << *itId << " " << *itDim << " " << *itChunkingRatios << " " << (*itDim)/(*itChunkingRatios) << endl;
+                  *itDim = ceil( *itDim / ceil(*itChunkingRatios) );
+                  correctionFromPreviousDim = *itChunkingRatios/ ((double)dimensionSize/(*itDim));
+                }
+              }
+	    }
             int storageType = (0 == dimSize) ? NC_CONTIGUOUS : NC_CHUNKED;
             CNetCdfInterface::defVarChunking(grpid, varid, storageType, &dimsizes[0]);
Index: XIOS3/trunk/src/manager/contexts_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/contexts_manager.cpp	(revision 2612)
+++ XIOS3/trunk/src/manager/contexts_manager.cpp	(revision 2613)
@@ -237,5 +237,8 @@
     if (comm!=MPI_COMM_NULL) 
     {
-      MPI_Bcast(&ret,1,MPI_INT,0,comm) ;
+      int cast_ret = 0;
+      if (commRank==0) cast_ret = ret;
+      MPI_Bcast(&cast_ret,1,MPI_INT,0,comm) ;
+      ret = cast_ret;
       if (ret)
       {
Index: XIOS3/trunk/src/node/axis.cpp
===================================================================
--- XIOS3/trunk/src/node/axis.cpp	(revision 2612)
+++ XIOS3/trunk/src/node/axis.cpp	(revision 2613)
@@ -310,5 +310,5 @@
      int sz(1);
      MPI_Comm_size( comm, &sz );
-     size_t distributedHash = 0;
+     unsigned long long distributedHash = 0;
      if (sz!=1) // compute the connector only if the element is distributed
      {
@@ -324,8 +324,8 @@
        gridTransformConnector->transfer(this->value, distributedValue );
           
-       size_t localHash = 0;
-       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc);
+       unsigned long long localHash = 0;
+       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=((unsigned long long)(abs(globalIndex(iloc)*distributedValue(iloc))))%LLONG_MAX;
        distributedHash = 0;
-       MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm  );
+       MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, comm  );
      }
      else // if the element is not distributed, the local hash is valid
@@ -333,6 +333,6 @@
        int globalSize = this->n_glo.getValue();
        int localSize = globalSize;
-       size_t localHash = 0;
-       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=iloc*this->value(iloc);
+       unsigned long long localHash = 0;
+       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=((unsigned long long)(abs(iloc*this->value(iloc))))%LLONG_MAX;
        distributedHash = localHash;
      }
Index: XIOS3/trunk/src/node/domain.cpp
===================================================================
--- XIOS3/trunk/src/node/domain.cpp	(revision 2612)
+++ XIOS3/trunk/src/node/domain.cpp	(revision 2613)
@@ -1809,5 +1809,5 @@
      int sz(1);
      MPI_Comm_size( comm, &sz );
-     size_t distributedHash = 0;
+     unsigned long long distributedHash = 0;
      if (sz!=1) // compute the connector only if the element is distributed
      {
@@ -1826,8 +1826,11 @@
        // Compute the distributed hash (v0) of the element
        // it will be associated to the default element name (= map key), and to the name really written
-       size_t localHash = 0;
-       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc);
+       unsigned long long localHash = 0;
+       for (int iloc=0; iloc<localSize ; iloc++ )
+       {
+         localHash+=((unsigned long long)(abs(globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc))))%LLONG_MAX;
+       }
        distributedHash = 0;
-       MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm  );
+       MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, comm  );
      }
      else // if the element is not distributed, the local hash is valid
@@ -1835,6 +1838,6 @@
        int globalSize = this->ni_glo.getValue()*this->nj_glo.getValue();
        int localSize = globalSize;
-       size_t localHash = 0;
-       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=iloc*this->lonvalue(iloc)*this->latvalue(iloc);
+       unsigned long long localHash = 0;
+       for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=((unsigned long long)(abs(iloc*this->lonvalue(iloc)*this->latvalue(iloc))))%LLONG_MAX;
        distributedHash = localHash;
      }
Index: XIOS3/trunk/src/transformation/scalar_algorithm/scalar_algorithm_redistribute.cpp
===================================================================
--- XIOS3/trunk/src/transformation/scalar_algorithm/scalar_algorithm_redistribute.cpp	(revision 2612)
+++ XIOS3/trunk/src/transformation/scalar_algorithm/scalar_algorithm_redistribute.cpp	(revision 2613)
@@ -95,12 +95,4 @@
     CArray<double,1> valSrc, valDst ;
     valSrc.resize(scalarSource->getLocalView(CElementView::FULL)->getSize()) ;
-    valDst.resize(scalarDestination->getLocalView(CElementView::FULL)->getSize()) ;
-    
-    if (scalarSource->hasValue())
-    {
-      if (valSrc.numElements()>0)  valSrc(0)=scalarSource->value ;
-      transformConnector->transfer(valSrc, valDst) ;
-      if (valDst.numElements()>0)  scalarDestination->value = valDst(0) ;
-    }
 
     if (scalarSource->hasBounds()) 
@@ -124,7 +116,19 @@
     
     transformMask->transfer(workflow, mask, false) ;   
-    scalarDestination->mask = mask(0) ;
+    if (mask.numElements()>0)
+    {
+      scalarDestination->mask = mask(0) ;
+    }
 
     scalarDestination->checkAttributes() ;
+    this->computeAlgorithm(scalarSource->getLocalView(CElementView::WORKFLOW), scalarDestination->getLocalView(CElementView::WORKFLOW)) ;
+
+    valDst.resize(scalarDestination->getLocalView(CElementView::FULL)->getSize()) ;
+    if (scalarSource->hasValue())
+    {
+      if (valSrc.numElements()>0)  valSrc(0)=scalarSource->value ;
+      transformConnector->transfer(valSrc, valDst) ;
+      if (valDst.numElements()>0)  scalarDestination->value = valDst(0) ;
+    }
   }
   CATCH
