Index: XIOS/trunk/src/node/field.cpp
===================================================================
--- XIOS/trunk/src/node/field.cpp	(revision 873)
+++ XIOS/trunk/src/node/field.cpp	(revision 887)
@@ -34,5 +34,5 @@
       , nstep(0), nstepMax(0)
       , hasOutputFile(false)
-      , domAxisIds_("", ""), areAllReferenceSolved(false), isReferenceSolved(false)
+      , domAxisScalarIds_(vector<StdString>(3,"")), areAllReferenceSolved(false), isReferenceSolved(false)
       , useCompressedOutput(false)
       , isReadDataRequestPending(false)
@@ -45,5 +45,5 @@
       , nstep(0), nstepMax(0)
       , hasOutputFile(false)
-      , domAxisIds_("", ""), areAllReferenceSolved(false), isReferenceSolved(false)
+      , domAxisScalarIds_(vector<StdString>(3,"")), areAllReferenceSolved(false), isReferenceSolved(false)
       , useCompressedOutput(false)
       , isReadDataRequestPending(false)
@@ -889,14 +889,14 @@
    void CField::solveGridReference(void)
    {
-      if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty())
+      if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty() && scalar_ref.isEmpty())
       {
         ERROR("CField::solveGridReference(void)",
               << "A grid must be defined for field '" << getFieldOutputName() << "' .");
       }
-      else if (!grid_ref.isEmpty() && (!domain_ref.isEmpty() || !axis_ref.isEmpty()))
+      else if (!grid_ref.isEmpty() && (!domain_ref.isEmpty() || !axis_ref.isEmpty() || !scalar_ref.isEmpty()))
       {
         ERROR("CField::solveGridReference(void)",
-              << "Field '" << getFieldOutputName() << "' has both a grid and a domain/axis." << std::endl
-              << "Please define either 'grid_ref' or 'domain_ref'/'axis_ref'.");
+              << "Field '" << getFieldOutputName() << "' has both a grid and a domain/axis/scalar." << std::endl
+              << "Please define either 'grid_ref' or 'domain_ref'/'axis_ref'/'scalar_ref'.");
       }
 
@@ -905,4 +905,5 @@
         std::vector<CDomain*> vecDom;
         std::vector<CAxis*> vecAxis;
+        std::vector<CScalar*> vecScalar;
 
         if (!domain_ref.isEmpty())
@@ -925,10 +926,19 @@
         }
 
+        if (!scalar_ref.isEmpty())
+        {
+          if (CScalar::has(scalar_ref))
+            vecScalar.push_back(CScalar::get(scalar_ref));
+          else
+            ERROR("CField::solveGridReference(void)",
+                  << "Invalid reference to scalar '" << scalar_ref.getValue() << "'.");
+        }
+
         // Warning: the gridId shouldn't be set as the grid_ref since it could be inherited
-        StdString gridId = CGrid::generateId(vecDom, vecAxis);
+        StdString gridId = CGrid::generateId(vecDom, vecAxis, vecScalar);
         if (CGrid::has(gridId))
           this->grid = CGrid::get(gridId);
         else
-          this->grid = CGrid::createGrid(gridId, vecDom, vecAxis);
+          this->grid = CGrid::createGrid(gridId, vecDom, vecAxis, vecScalar);
       }
       else
@@ -1138,5 +1148,5 @@
    \return pair of Domain and Axis id
    */
-   const std::pair<StdString,StdString>& CField::getRefDomainAxisIds()
+   const std::vector<StdString>& CField::getRefDomainAxisIds()
    {
      CGrid* cgPtr = getRelGrid();
@@ -1148,5 +1158,5 @@
          std::vector<StdString> domainList = cgPtr->getDomainList();
          it = std::find(domainList.begin(), domainList.end(), domain_ref.getValue());
-         if (domainList.end() != it) domAxisIds_.first = *it;
+         if (domainList.end() != it) domAxisScalarIds_[0] = *it;
        }
 
@@ -1155,8 +1165,15 @@
          std::vector<StdString> axisList = cgPtr->getAxisList();
          it = std::find(axisList.begin(), axisList.end(), axis_ref.getValue());
-         if (axisList.end() != it) domAxisIds_.second = *it;
-       }
-     }
-     return (domAxisIds_);
+         if (axisList.end() != it) domAxisScalarIds_[1] = *it;
+       }
+
+       if (!scalar_ref.isEmpty())
+       {
+         std::vector<StdString> scalarList = cgPtr->getScalarList();
+         it = std::find(scalarList.begin(), scalarList.end(), scalar_ref.getValue());
+         if (scalarList.end() != it) domAxisScalarIds_[2] = *it;
+       }
+     }
+     return (domAxisScalarIds_);
    }
 
