Index: /issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
===================================================================
--- /issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py	(revision 26565)
+++ /issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py	(revision 26566)
@@ -8,18 +8,50 @@
 
 class ResTable:
-
     def __init__(self):
         self.data = []
-
-    def update(self, row):
-        if len(np.shape(row)) == 0:
-            self.data.append(row)
-        else:
-            for r in row:
+        self.sizes = []
+
+    def update(self, stepvar):
+        #if we have a scalar we just add it to the en
+        #we save the size of the current step for further treatment
+        if len(np.shape(stepvar)) == 0:
+            self.sizes.append(1)
+            self.data.append(stepvar)
+        # if it is an array we add the values one by one
+        #we save the size of the current step for further treatment
+        else:
+            self.sizes.append(len(stepvar))
+            for r in stepvar:
                 self.data.append(r)
 
     def finalize(self, rows):
+        #we have more scalars than steps, so we have an array
         if len(self.data) > rows:
-            return np.reshape(self.data, newshape=(rows, int(len(self.data) / rows)))
+            #first check if all steps are the same size
+            SameSize = np.sum(np.asarray(self.sizes) - self.sizes[0]) == 0
+            if SameSize:
+                #same size for all steps, just reshape
+                return np.reshape(self.data, newshape=(rows, int(len(self.data) / rows)))
+            else:
+                #different sizes at each steps, first create a table big enough for the biggest step
+                startpoint = 0
+                datadim = len(np.shape(self.data))
+                if datadim == 1:
+                    outdat = np.nan * np.ones((rows, np.nanmax(self.sizes)))
+                    for step in range(rows):
+                        curlen = self.sizes[step]
+                        outdat[step, :curlen] = self.data[startpoint: startpoint + curlen]
+                        startpoint += curlen
+                elif datadim == 2:
+                    outdat = np.nan * np.ones((rows, np.nanmax(self.sizes), np.shape(self.data)[1]))
+                    for step in range(rows):
+                        curlen = self.sizes[step]
+                        outdat[step, :curlen, :] = self.data[startpoint: startpoint + curlen]
+                        startpoint += curlen
+
+                else:
+                    print("ERROR, reult treatment cant cope with dimensions above 2")
+                return outdat
+        #as much scalars as stpes (or less) so just one value per step
         else:
             return np.asarray(self.data)
@@ -125,4 +157,5 @@
                             if subfield not in['errlog', 'outlog']:
                                 StackedVar = ResTable()
+                                #first loop over the field (result type) to find the index of the last subfield (variable)
                                 for listindex in range(0, Listsize):
                                     try:
@@ -135,4 +168,5 @@
                                         lastindex = listindex
                                         continue
+                                    #Add the  subfield at the current step
                                     Var = SqueezeVar(Var)
                                     StackedVar.update(Var)
