Index: XIOS/dev/dev_trunk_omp/src/io/nc4_data_output.cpp
===================================================================
--- XIOS/dev/dev_trunk_omp/src/io/nc4_data_output.cpp	(revision 1601)
+++ XIOS/dev/dev_trunk_omp/src/io/nc4_data_output.cpp	(revision 1646)
@@ -54,4 +54,5 @@
 
       void CNc4DataOutput::writeDomain_(CDomain* domain)
+      TRY
       {
         StdString lonName,latName ;
@@ -154,5 +155,5 @@
 */
 
-         CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer;
+         CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer;
          int nbWritten = indexToWrite.numElements();
          CArray<double,1> writtenLat, writtenLon;
@@ -166,16 +167,15 @@
            for (int idx = 0; idx < nbWritten; ++idx)
            {
-        	  if (idx < domain->latvalue.numElements())
-        	  {
-                writtenLat(idx) = domain->latvalue(indexToWrite(idx));
-                writtenLon(idx) = domain->lonvalue(indexToWrite(idx));
-        	  }
-        	  else
-        	  {
-                writtenLat(idx) = 0.;
-                writtenLon(idx) = 0.;
-        	  }
+             if (indexToWrite(idx) < 0)
+             {
+               writtenLat(idx) = -1.;   // hole
+               writtenLon(idx) = -1.;
+             }
+             else
+             {
+               writtenLat(idx) = domain->latvalue(indexToWrite(idx));
+               writtenLon(idx) = domain->lonvalue(indexToWrite(idx));
+             }
            }
-         
 
            if (domain->hasBounds)
@@ -189,14 +189,14 @@
                for (int nv = 0; nv < nvertex; ++nv)
                {
-            	 if (idx < boundslat.columns())
-            	 {
+                 if (indexToWrite(idx) < 0)
+                 {
+                   writtenBndsLat(nv, idx) = -1.;  // hole
+                   writtenBndsLon(nv, idx) = -1.;
+                 }
+                 else
+                 {
                    writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx)));
                    writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx)));
-            	 }
-            	 else
-            	 {
-                   writtenBndsLat(nv, idx) = 0.;
-                   writtenBndsLon(nv, idx) = 0.;
-            	 }
+                 }
                }
            }
@@ -208,8 +208,8 @@
            for (int idx = 0; idx < nbWritten; ++idx)
            {
-        	  if (idx < domain->areavalue.numElements())
-                writtenArea(idx) = domain->areavalue(indexToWrite(idx));
+        	  if (indexToWrite(idx) < 0)
+              writtenArea(idx) = -1.;
         	  else
-                writtenArea(idx) = 0.;
+              writtenArea(idx) = domain->areavalue(indexToWrite(idx));
            }
          }
@@ -426,10 +426,11 @@
                      std::vector<StdSize> start(2) ;
                      std::vector<StdSize> count(2) ;
-                     if (domain->isEmpty())
-                     {
-                       start[0]=0 ; start[1]=0 ;
-                       count[0]=0 ; count[1]=0 ;
-                     }
-                     else
+// Comment out: it is not working for a hole
+//                     if (domain->isEmpty())
+//                     {
+//                       start[0]=0 ; start[1]=0 ;
+//                       count[0]=0 ; count[1]=0 ;
+//                     }
+//                     else
                      {
                        start[1]=domain->ibegin;
@@ -540,4 +541,5 @@
          domain->addRelFile(this->filename);
       }
+      CATCH
 
     //--------------------------------------------------------------
@@ -875,4 +877,7 @@
           case (MULTI_FILE) :
           {
+            ERROR("CNc4DataOutput::writeDomain(domain)",
+            << "[ type = multiple_file ]"
+            << " is not yet implemented for UGRID files !");
             break;
           }
@@ -940,5 +945,5 @@
          int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex;
 
-         CArray<size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer;
+         CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer;
          int nbWritten = indexToWrite.numElements();
          CArray<double,1> writtenLat, writtenLon;
@@ -952,14 +957,14 @@
            for (int idx = 0; idx < nbWritten; ++idx)
            {
-       	     if (idx < domain->latvalue.numElements())
-     	     {
-               writtenLat(idx) = domain->latvalue(indexToWrite(idx));
-               writtenLon(idx) = domain->lonvalue(indexToWrite(idx));
-     	     }
-     	     else
-     	     {
-               writtenLat(idx) = 0.;
-               writtenLon(idx) = 0.;
-     	     }
+       	     if (indexToWrite(idx) < 0)
+       	     {
+               writtenLat(idx) = -1.;
+               writtenLon(idx) = -1.;
+       	     }
+       	     else
+       	     {
+       	       writtenLat(idx) = domain->latvalue(indexToWrite(idx));
+       	       writtenLon(idx) = domain->lonvalue(indexToWrite(idx));
+       	     }
            }
          }
@@ -976,13 +981,13 @@
              for (int nv = 0; nv < nvertex; ++nv)
              {
-               if (idx < boundslat.columns())
+               if (indexToWrite(idx) < 0)
+               {
+                 writtenBndsLat(nv, idx) = -1.;
+                 writtenBndsLon(nv, idx) = -1.;
+               }
+               else
                {
                  writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx)));
                  writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx)));
-               }
-               else
-               {
-                 writtenBndsLat(nv, idx) = 0.;
-                 writtenBndsLon(nv, idx) = 0.;
                 }
              }
@@ -995,8 +1000,8 @@
            for (int idx = 0; idx < nbWritten; ++idx)
            {
-        	  if (idx < domain->areavalue.numElements())
-                writtenArea(idx) = domain->areavalue(indexToWrite(idx));
-        	  else
-                writtenArea(idx) = 0.;
+             if (indexToWrite(idx) < 0)
+               writtenArea(idx) = -1.;
+             else
+               writtenArea(idx) = domain->areavalue(indexToWrite(idx));
            }
          }
@@ -1275,5 +1280,5 @@
           SuperClassWriter::definition_end();
 
-          CArray<size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer;
+          CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer;
           int nbWritten = indexToWrite.numElements();
           CArray<double,1> axis_value(indexToWrite.numElements());
@@ -1282,8 +1287,8 @@
             for (int i = 0; i < nbWritten; i++)
             {
-              if (i < axis->value.numElements())
+              if (indexToWrite(i) < 0)
+                axis_value(i) = -1;   // Some value in case of a hole
+              else
                 axis_value(i) = axis->value(indexToWrite(i));
-              else
-                axis_value(i) = 0.;
             }
           }
@@ -1295,8 +1300,8 @@
             for (int i = 0; i < nbWritten; i++)
             {
-              if (i < axis->label.numElements())
+              if (indexToWrite(i) < 0)
+                axis_label(i) = boost::lexical_cast<string>(-1);  // Some value in case of a hole
+              else
                 axis_label(i) = axis->label(indexToWrite(i));
-              else
-                axis_label(i) = boost::lexical_cast<string>(0);  // Write 0 as a label
             }
           }
@@ -1316,14 +1321,13 @@
                   for (int i = 0; i < nbWritten; ++i)
                   {
-                    if (i < axis->bounds.columns())
+                    if (indexToWrite(i) < 0)
+                    {
+                      axis_bounds(0, i) = -1.; // Some value in case of a hole
+                      axis_bounds(1, i) = -1.;
+                    }
+                    else
                     {
                       axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i)));
                       axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i)));
-                    }
-                    else
-                    {
-                      axis_bounds(0, i) = 0.;
-                      axis_bounds(1, i) = 0.;
-
                     }
                   }
@@ -1356,13 +1360,13 @@
                   for (int i = 0; i < nbWritten; ++i)
                   {
-                    if (i < axis->bounds.columns())
+                    if (indexToWrite(i) < 0)
+                    {
+                      axis_bounds(0, i) = -1.;
+                      axis_bounds(1, i) = -1.;
+                    }
+                    else
                     {
                       axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i)));
                       axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i)));
-                    }
-                    else
-                    {
-                      axis_bounds(0, i) = 0.;
-                      axis_bounds(1, i) = 0.;
                     }
                   }
