Index: /XIOS/trunk/src/declare_ref_func.hpp
===================================================================
--- /XIOS/trunk/src/declare_ref_func.hpp	(revision 769)
+++ /XIOS/trunk/src/declare_ref_func.hpp	(revision 770)
@@ -12,5 +12,5 @@
 // Declarations
 
-#define DECLARE_REF_FUNC(type, name)                        \
+#define DECLARE_REF_FUNC(type, name_)                       \
 public:                                                     \
   bool hasDirect##type##Reference(void) const;              \
@@ -21,4 +21,5 @@
   void solveRefInheritance(bool apply = true);              \
   void solveBaseReference(void);                            \
+  const StdString& get##type##OutputName(void) const;       \
                                                             \
 private:                                                    \
@@ -27,5 +28,5 @@
 // Definitions
 
-#define DEFINE_REF_FUNC(type, name)                                    \
+#define DEFINE_REF_FUNC(type, name_)                                   \
 void C##type::solveRefInheritance(bool apply)                          \
 {                                                                      \
@@ -42,5 +43,5 @@
     {                                                                  \
       ERROR("void C" #type "::solveRefInheritance(bool apply)",        \
-            << "Circular dependency stopped for " #name " object "     \
+            << "Circular dependency stopped for " #name_ " object "    \
             << "with id = \"" << refer_ptr->getId() << "\".");         \
     }                                                                  \
@@ -52,6 +53,6 @@
 void C##type::removeRefInheritance()                                   \
 {                                                                      \
-  if (!this->name##_ref.isEmpty())                                     \
-    this->name##_ref.reset();                                          \
+  if (!this->name_##_ref.isEmpty())                                    \
+    this->name_##_ref.reset();                                         \
 }                                                                      \
                                                                        \
@@ -70,5 +71,5 @@
     {                                                                  \
       ERROR("void C" #type "::solveBaseReference(void)",               \
-            << "Circular dependency stopped for " #name " object "     \
+            << "Circular dependency stopped for " #name_ " object "    \
             << "with id = \"" << baseRefObject->getId() << "\".");     \
     }                                                                  \
@@ -78,13 +79,13 @@
 C##type* C##type::getDirect##type##Reference(void) const               \
 {                                                                      \
-  if (this->name##_ref.isEmpty())                                      \
+  if (this->name_##_ref.isEmpty())                                     \
     return this->getBase##type##Reference();                           \
                                                                        \
-  if (!C##type::has(this->name##_ref))                                 \
+  if (!C##type::has(this->name_##_ref))                                \
     ERROR("C" #type "* C" #type "::getDirect" #type "Reference(void)", \
-          << this->name##_ref                                          \
-          << " refers to an unknown " #name " id.");                   \
+          << this->name_##_ref                                         \
+          << " refers to an unknown " #name_ " id.");                  \
                                                                        \
-  return C##type::get(this->name##_ref);                               \
+  return C##type::get(this->name_##_ref);                              \
 }                                                                      \
                                                                        \
@@ -98,8 +99,17 @@
   return this->getBase##type##Reference()->getId();                    \
 }                                                                      \
-                                                                       \
 bool C##type::hasDirect##type##Reference(void) const                   \
 {                                                                      \
-  return !this->name##_ref.isEmpty();                                  \
+  return !this->name_##_ref.isEmpty();                                 \
+}                                                                      \
+                                                                       \
+const StdString& C##type::get##type##OutputName(void) const            \
+{                                                                      \
+  if (!this->name.isEmpty())                                           \
+    return this->name;                                                 \
+  else if (hasAutoGeneratedId() && hasDirect##type##Reference())       \
+    return this->name_##_ref;                                          \
+  else                                                                 \
+    return getId();                                                    \
 }                                                                      \
 
Index: /XIOS/trunk/src/io/nc4_data_input.cpp
===================================================================
--- /XIOS/trunk/src/io/nc4_data_input.cpp	(revision 769)
+++ /XIOS/trunk/src/io/nc4_data_input.cpp	(revision 770)
@@ -21,5 +21,5 @@
   StdSize CNc4DataInput::getFieldNbRecords_(CField* field)
   {
-    StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId();
+    StdString fieldId = field->getFieldOutputName();
 
     if (SuperClassWriter::isTemporal(fieldId))
@@ -41,5 +41,5 @@
       if (SuperClass::type==MULTI_FILE || !isCollective) return;
 
-    StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId();
+    StdString fieldId = field->getFieldOutputName();
 
     CArray<double,1> fieldData(grid->getWrittenDataSize());
Index: /XIOS/trunk/src/io/nc4_data_output.cpp
===================================================================
--- /XIOS/trunk/src/io/nc4_data_output.cpp	(revision 769)
+++ /XIOS/trunk/src/io/nc4_data_output.cpp	(revision 770)
@@ -1058,6 +1058,5 @@
                              : latid;
 */
-         StdString fieldid   = (!field->name.isEmpty())
-                             ? field->name.getValue() : field->getBaseFieldReference()->getId();
+         StdString fieldid = field->getFieldOutputName();
 
 //         unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue();
@@ -1384,7 +1383,5 @@
           if (SuperClass::type == MULTI_FILE || !isCollective) return;
 
-        StdString fieldid = !field->name.isEmpty()
-                          ? field->name.getValue()
-                          : field->getBaseFieldReference()->getId();
+        StdString fieldid = field->getFieldOutputName();
 
         StdOStringStream oss;
Index: /XIOS/trunk/src/node/field.cpp
===================================================================
--- /XIOS/trunk/src/node/field.cpp	(revision 769)
+++ /XIOS/trunk/src/node/field.cpp	(revision 770)
@@ -760,10 +760,10 @@
       {
         ERROR("CField::solveGridReference(void)",
-              << "A grid must be defined for field '" << (!name.isEmpty() ? name.getValue() : getId()) << "' .");
+              << "A grid must be defined for field '" << getFieldOutputName() << "' .");
       }
       else if (!grid_ref.isEmpty() && (!domain_ref.isEmpty() || !axis_ref.isEmpty()))
       {
         ERROR("CField::solveGridReference(void)",
-              << "Field '" << (!name.isEmpty() ? name.getValue() : getId()) << "' has both a grid and a domain/axis." << std::endl
+              << "Field '" << getFieldOutputName() << "' has both a grid and a domain/axis." << std::endl
               << "Please define either 'grid_ref' or 'domain_ref'/'axis_ref'.");
       }
Index: /XIOS/trunk/src/node/file.cpp
===================================================================
--- /XIOS/trunk/src/node/file.cpp	(revision 769)
+++ /XIOS/trunk/src/node/file.cpp	(revision 770)
@@ -956,13 +956,11 @@
    void CFile::sendEnabledFields()
    {
-     int size = this->enabledFields.size();
-     CField* fieldPtr(0);
-     for (int i = 0; i < size; ++i)
+     size_t size = this->enabledFields.size();
+     for (size_t i = 0; i < size; ++i)
      {
-       fieldPtr = this->enabledFields[i];
-       if (fieldPtr->name.isEmpty()) fieldPtr->name.setValue(fieldPtr->getBaseFieldReference()->getId());
-       this->sendAddField(fieldPtr->getId());
-       fieldPtr->sendAllAttributesToServer();
-       fieldPtr->sendAddAllVariables();
+       CField* field = this->enabledFields[i];
+       this->sendAddField(field->getId());
+       field->sendAllAttributesToServer();
+       field->sendAddAllVariables();
      }
    }
