Index: /XIOS/trunk/inputs/REMAP/iodef.xml
===================================================================
--- /XIOS/trunk/inputs/REMAP/iodef.xml	(revision 824)
+++ /XIOS/trunk/inputs/REMAP/iodef.xml	(revision 825)
@@ -81,5 +81,5 @@
        <generate_rectilinear_domain />
      </domain>
-     <domain id="src_domain_curvilinear" type="rectilinear">
+     <domain id="src_domain_curvilinear" type="curvilinear">
        <generate_rectilinear_domain />
      </domain>
Index: /XIOS/trunk/src/io/inetcdf4.cpp
===================================================================
--- /XIOS/trunk/src/io/inetcdf4.cpp	(revision 824)
+++ /XIOS/trunk/src/io/inetcdf4.cpp	(revision 825)
@@ -28,5 +28,5 @@
     this->timeCounterName = timeCounterName;
     if (!CNetCdfInterface::isDimExisted(this->ncidp, this->timeCounterName)) this->timeCounterName=this->getUnlimitedDimensionName() ;
-    
+
   }
 
@@ -63,5 +63,6 @@
     int varid = 0;
     int grpid = this->getGroup(path);
-    CNetCdfInterface::inqVarId(grpid, varname, varid);
+    if (this->hasVariable(varname, path))
+      CNetCdfInterface::inqVarId(grpid, varname, varid);
     return varid;
   }
@@ -344,5 +345,5 @@
     {
       const StdString& varname = *it;
-      if (varname.compare(0, name.size(), name) == 0) return true;
+      if ((varname.compare(0, name.size(), name) == 0) && (0 != name.size()))  return true;
     }
     return false;
@@ -726,4 +727,5 @@
                                        const CVarPath* const path)
   {
+    StdString lonName;
     std::list<StdString>::const_iterator itbList, itList, iteList;
     std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
@@ -735,7 +737,11 @@
         StdString unit = this->getAttributeValue(CCFKeywords::XIOS_CF_units, &(*itList), path);
         if (CCFConvention::XIOS_CF_Longitude_units.end() != CCFConvention::XIOS_CF_Longitude_units.find(unit))
-          return *itList;
-      }
-    }
+        {
+          lonName = *itList;
+          return lonName;
+        }
+      }
+    }
+    return lonName;
   }
 
@@ -743,4 +749,5 @@
                                        const CVarPath* const path)
   {
+    StdString latName;
     std::list<StdString>::const_iterator itbList, itList, iteList;
     std::list<StdString> clist = this->getCoordinatesIdList(varname, path);
@@ -752,7 +759,11 @@
         StdString unit = this->getAttributeValue(CCFKeywords::XIOS_CF_units, &(*itList), path);
         if (CCFConvention::XIOS_CF_Latitude_units.end() != CCFConvention::XIOS_CF_Latitude_units.find(unit))
-          return *itList;
-      }
-    }
+        {
+          latName = *itList;
+          return latName;
+        }
+      }
+    }
+    return latName;
   }
 
Index: /XIOS/trunk/src/io/nc4_data_input.cpp
===================================================================
--- /XIOS/trunk/src/io/nc4_data_input.cpp	(revision 824)
+++ /XIOS/trunk/src/io/nc4_data_input.cpp	(revision 825)
@@ -147,5 +147,5 @@
     std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId);
     std::list<StdString> dimList = SuperClassWriter::getDimensionsList(&fieldId);
-    
+
     realGridDim = SuperClassWriter::isTemporal(fieldId) ? dimSizeMap.size() - 1 : dimSizeMap.size();
     if (isUnstructuredGrid) ++realGridDim;
@@ -157,10 +157,10 @@
 
     // Remove unlimited dimension from the map, we dont need it anymore
-    if (SuperClassWriter::isTemporal(fieldId)) 
+    if (SuperClassWriter::isTemporal(fieldId))
     {
       dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName());
       dimList.pop_front() ;  // assume time dimension is first
     }
-    
+
     int mapSize = dimSizeMap.size() - 1;
     std::list<std::pair<StdString, StdSize> > listDimSize;
@@ -232,17 +232,25 @@
     itMapNj = itMapNi; ++itMapNj;
 
-    if (this->isRectilinear(fieldId))
+    if ((CDomain::type_attr::rectilinear == domain->type))// || this->isRectilinear(fieldId))
     {
       // Ok, try to read some f.. attributes such as longitude and latitude
-      domain->latvalue_rectilinear_read_from_file.resize(itMapNj->second);
-      std::vector<StdSize> nBeginLat(1, 0), nSizeLat(1, itMapNj->second);
-      readFieldVariableValue(domain->latvalue_rectilinear_read_from_file, itMapNj->first, nBeginLat, nSizeLat, true);
-
-      domain->lonvalue_rectilinear_read_from_file.resize(itMapNi->second);
-      std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second);
-      readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true);
+      bool hasLat = SuperClassWriter::hasVariable(itMapNj->first);
+      if (hasLat)
+      {
+        domain->latvalue_rectilinear_read_from_file.resize(itMapNj->second);
+        std::vector<StdSize> nBeginLat(1, 0), nSizeLat(1, itMapNj->second);
+        readFieldVariableValue(domain->latvalue_rectilinear_read_from_file, itMapNj->first, nBeginLat, nSizeLat, true);
+      }
+
+      bool hasLon = SuperClassWriter::hasVariable(itMapNi->first);
+      if (hasLon)
+      {
+        domain->lonvalue_rectilinear_read_from_file.resize(itMapNi->second);
+        std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second);
+        readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true);
+      }
       domain->fillInRectilinearLonLat();
     }
-    else if (this->isCurvilinear(fieldId))
+    else if ((CDomain::type_attr::curvilinear == domain->type))// || (this->isCurvilinear(fieldId)))
     {
       int ni = domain->ni;
@@ -253,25 +261,22 @@
 
       StdString latName = this->getLatCoordName(fieldId);
-      domain->latvalue_2d.resize(ni,nj);
-      readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon);
+      if (SuperClassWriter::hasVariable(latName)) //(0 != latName.compare(""))
+      {
+        domain->latvalue_2d.resize(ni,nj);
+        readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon);
+      }
       StdString lonName = this->getLonCoordName(fieldId);
-      domain->lonvalue_2d.resize(ni,nj);
-      readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon);
+      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare(""))
+      {
+        domain->lonvalue_2d.resize(ni,nj);
+        readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon);
+      }
 
       StdString boundsLatName = this->getBoundsId(latName);
-      if (0 == boundsLatName.compare(""))
-         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",
-              << "Field '" << fieldId << std::endl
-              << "Trying to read attributes from curvilinear grid."
-              << "Latitude variable " << latName << " does not have bounds.");
       StdString boundsLonName = this->getBoundsId(lonName);
-      if (0 == boundsLonName.compare(""))
-         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",
-              << "Field '" << fieldId << std::endl
-              << "Trying to read attributes from curvilinear grid."
-              << "Longitude variable " << lonName << " does not have bounds.");
 
       int nbVertex = this->getNbVertex(fieldId);
-      domain->nvertex.setValue(nbVertex);
+      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) //if ((0 != boundsLatName.compare("")) || (0 != boundsLonName.compare("")))
+        domain->nvertex.setValue(nbVertex);
       std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3);
       nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj;
@@ -279,10 +284,17 @@
       nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex;
 
-      domain->bounds_lat_2d.resize(nbVertex,ni,nj);
-      readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon);
-      domain->bounds_lon_2d.resize(nbVertex,ni,nj);
-      readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon);
-    }
-    else if (this->isUnstructured(fieldId))
+      if (SuperClassWriter::hasVariable(boundsLatName)) //(0 != boundsLatName.compare(""))
+      {
+        domain->bounds_lat_2d.resize(nbVertex,ni,nj);
+        readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon);
+
+      }
+      if (SuperClassWriter::hasVariable(boundsLonName)) //(0 != boundsLonName.compare(""))
+      {
+        domain->bounds_lon_2d.resize(nbVertex,ni,nj);
+        readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon);
+      }
+    }
+    else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId)))
     {
       /*
@@ -292,5 +304,5 @@
               << "Trying to read attributes from unstructured grid."
               << "i_index of domain" << domain->getId() << " is mandatory");
-      
+
       int ni = domain->i_index.numElements();
 */
@@ -302,5 +314,5 @@
         for(int idx = 0; idx < ni; ++idx) domain->i_index(idx)=ibegin+idx ;
       }
-      
+
       std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0);
       nSizeLatLon[0]  = domain->ni_glo.getValue();
@@ -308,46 +320,51 @@
 
       StdString latName = this->getLatCoordName(fieldId);
-      readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon);
-      domain->latvalue_1d.resize(ni);
-      for (int idx = 0; idx < ni; ++idx)
-        domain->latvalue_1d(idx) =  globalLonLat(domain->i_index(idx));
+      if (SuperClassWriter::hasVariable(latName)) //(0 != latName.compare(""))
+      {
+        readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon);
+        domain->latvalue_1d.resize(ni);
+        for (int idx = 0; idx < ni; ++idx)
+          domain->latvalue_1d(idx) =  globalLonLat(domain->i_index(idx));
+      }
 
       StdString lonName = this->getLonCoordName(fieldId);
-      readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon);
-      domain->lonvalue_1d.resize(ni);
-      for (int idx = 0; idx < ni; ++idx)
-        domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx));
+      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare(""))
+      {
+        readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon);
+        domain->lonvalue_1d.resize(ni);
+        for (int idx = 0; idx < ni; ++idx)
+          domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx));
+      }
 
       StdString boundsLatName = this->getBoundsId(latName);
-      if (0 == boundsLatName.compare(""))
-         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",
-              << "Field '" << fieldId << std::endl
-              << "Trying to read attributes from unstructured grid."
-              << "Latitude variable " << latName << " does not have bounds.");
       StdString boundsLonName = this->getBoundsId(lonName);
-      if (0 == boundsLonName.compare(""))
-         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)",
-              << "Field '" << fieldId << std::endl
-              << "Trying to read attributes from unstructured grid."
-              << "Longitude variable " << lonName << " does not have bounds.");
 
       int nbVertex = this->getNbVertex(fieldId);
-      domain->nvertex.setValue(nbVertex);
+      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) // (0 != boundsLatName.compare("")) || (0 != boundsLonName.compare("")))
+        domain->nvertex.setValue(nbVertex);
+
       std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2);
       nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue();
       nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex;
 
-      CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]);
-      readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon);
-      domain->bounds_lat_1d.resize(nbVertex,ni);
-      for (int idx = 0; idx < ni; ++idx)
-        for (int jdx = 0; jdx < nbVertex; ++jdx)
-          domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx));
-
-      readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon);
-      domain->bounds_lon_1d.resize(nbVertex,ni);
-      for (int idx = 0; idx < ni; ++idx)
-        for (int jdx = 0; jdx < nbVertex; ++jdx)
-          domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx));
+      if (SuperClassWriter::hasVariable(boundsLatName)) //(0 != boundsLatName.compare(""))
+      {
+        CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]);
+        readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon);
+        domain->bounds_lat_1d.resize(nbVertex,ni);
+        for (int idx = 0; idx < ni; ++idx)
+          for (int jdx = 0; jdx < nbVertex; ++jdx)
+            domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx));
+      }
+
+      if (SuperClassWriter::hasVariable(boundsLonName)) //(0 != boundsLonName.compare(""))
+      {
+        CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]);
+        readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon);
+        domain->bounds_lon_1d.resize(nbVertex,ni);
+        for (int idx = 0; idx < ni; ++idx)
+          for (int jdx = 0; jdx < nbVertex; ++jdx)
+            domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx));
+      }
     }
   }
