Index: XIOS/trunk/src/node/field.cpp
===================================================================
--- XIOS/trunk/src/node/field.cpp	(revision 745)
+++ XIOS/trunk/src/node/field.cpp	(revision 746)
@@ -651,5 +651,5 @@
      std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters;
      // Check if a spatial transformation is needed
-     if (!grid_ref.isEmpty() && !fieldRef->grid_ref.isEmpty() && grid_ref.getValue() != fieldRef->grid_ref.getValue())
+     if (grid && grid != fieldRef->grid)
        filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid);
      else
@@ -819,6 +819,5 @@
    void CField::solveTransformedGrid()
    {
-     if (!grid_ref.isEmpty() && hasDirectFieldReference() && !getDirectFieldReference()->grid_ref.isEmpty()
-         && grid_ref.getValue() != getDirectFieldReference()->grid_ref.getValue() && !grid->isTransformed())
+     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid)
        grid->transformGrid(getDirectFieldReference()->grid);
    }
@@ -826,6 +825,5 @@
    void CField::solveGenerateGrid()
    {
-     if (!grid_ref.isEmpty() && hasDirectFieldReference() && !getDirectFieldReference()->grid_ref.isEmpty()
-         && grid_ref.getValue() != getDirectFieldReference()->grid_ref.getValue() && !grid->isTransformed())
+     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid)
        grid->completeGrid(getDirectFieldReference()->grid);
    }
Index: XIOS/trunk/src/node/grid.cpp
===================================================================
--- XIOS/trunk/src/node/grid.cpp	(revision 745)
+++ XIOS/trunk/src/node/grid.cpp	(revision 746)
@@ -1266,4 +1266,37 @@
   void CGrid::completeGrid(CGrid* transformGridSrc)
   {
+    if (!transformGridSrc)
+      ERROR("CGrid::completeGrid(CGrid* transformGridSrc)",
+            << "Impossible to complete grid '" << getId() << "', the source grid is null.");
+
+    if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements())
+    {
+      ERROR("CGrid::completeGrid(CGrid* transformGridSrc)",
+           << "Two grids have different dimension size"
+           << "Dimension of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl
+           << "Dimension of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements());
+    }
+    else
+    {
+      int ssize = axis_domain_order.numElements();
+      for (int i = 0; i < ssize; ++i)
+        if (axis_domain_order(i) != (transformGridSrc->axis_domain_order)(i))
+          ERROR("CGrid::completeGrid(CGrid* transformGridSrc)",
+                << "Grids " << this->getId() << " and " << transformGridSrc->getId()
+                << " don't have elements in the same order");
+    }
+
+    CGridGenerate gridGenerate(this, transformGridSrc);
+    gridGenerate.completeGrid();
+  }
+
+  void CGrid::transformGrid(CGrid* transformGridSrc)
+  {
+    if (!transformGridSrc)
+      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
+            << "Impossible to transform grid '" << getId() << "', the source grid is null.");
+
+    if (isTransformed()) return;
+    setTransformed();
     if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements())
     {
@@ -1283,29 +1316,4 @@
     }
 
-    CGridGenerate gridGenerate(this, transformGridSrc);
-    gridGenerate.completeGrid();
-  }
-
-  void CGrid::transformGrid(CGrid* transformGridSrc)
-  {
-    if (isTransformed()) return;
-    setTransformed();
-    if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements())
-    {
-      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
-           << "Two grids have different dimension size"
-           << "Dimension of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl
-           << "Dimension of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements());
-    }
-    else
-    {
-      int ssize = axis_domain_order.numElements();
-      for (int i = 0; i < ssize; ++i)
-        if (axis_domain_order(i) != (transformGridSrc->axis_domain_order)(i))
-          ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
-                << "Grids " << this->getId() << " and " << transformGridSrc->getId()
-                << " don't have elements in the same order");
-    }
-
     transformations_ = new CGridTransformation(this, transformGridSrc);
     transformations_->computeAll();
