Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 938)
+++ trunk/tools/nc_var_tools.py	(revision 939)
@@ -5683,50 +5683,70 @@
 # Creating dimensions
 ## 
+
+    dimsecslice = {}
     for dims in nciobj.dimensions:
+        ibegv = begv
+        iendv = endv
+        iintv = intv
         objdim = nciobj.dimensions[dims]
 
         if objdim.isunlimited():
             dimsize = None
+
+        if dims == dimn:
+            if begv != -9:
+                if begv > len(objdim):
+                    print errormsg
+                    print '  ' + fname + ': beginning value' ,begv,              \
+                      'is larger than dimension (', len(objdim), ')!!!!'
+                    quit(-1)
+                if endv > len(objdim):
+                    print errormsg
+                    print '  ' + fname + ': endining value' ,endv,               \
+                      'is larger than dimension (', len(objdim), ')!!!!'
+                    quit(-1)
+
+                if endv == -1: iendv = len(objdim)
+                print 'Lluis endv, begv, intv:', ibegv, iendv, iintv,':', begv, endv, intv
+                dimsize = (iendv - ibegv + 1)/iintv - 1
+            else:
+                dimsize == 0                       
+                if begv == -9:
+                    ibegv = len(objdim) - 1
+                    iendv = len(objdim) - 1
+                    iintv = 0
+            print fname + '; Lluis dimn beg end int:', ibegv, iendv, iintv
         else:
-            if dims == dimn:
-                if begv != -9 and begv != 0:
-                    if begv > len(objdim):
-                        print errormsg
-                        print '  ' + fname + ': beginning value' ,begv,              \
-                          'is larger than dimension (', len(objdim), ')!!!!'
-                        quit(-1)
-                    if endv > len(objdim):
-                        print errormsg
-                        print '  ' + fname + ': endining value' ,endv,               \
-                          'is larger than dimension (', len(objdim), ')!!!!'
-                        quit(-1)
-
-                    if endv == -1: endv = len(objdim)
-                    dimsize = (endv - begv + 1)/intv - 1
-                else:
-                    dimsize == 0                       
-                    if begv == 0:
-                        begv = 0
-                        endv = 0
-                        intv = 0
-                    elif begv == -9:
-                        begv = len(objdim)
-                        endv = len(objdim)
-                        intv = 0
-
+            if len(objdim) > 1:
+                dimsize = len(objdim)
+                ibegv = 0
+                iendv = dimsize - 1
+                iintv = 1
             else:
-                dimsize = len(objdim)
-
-        print '    ' + fname + ': adding dimension: ' + dims + ' size:',dimsize
+                dimsize = 0
+                ibegv = 0
+                iendv = 0
+                iintv = 0
+
+        print fname + '; Lluis begv, endv:', ibegv, iendv, iintv, '<>', begv, endv, intv
+        if ibegv != iendv:
+            dimsecslice[dims] = slice(ibegv,iendv,iintv)
+        else:
+            dimsecslice[dims] = ibegv
+
         if dimsize != 0:
-            if begv != -9 and begv != 0:
+            if begv != -9:
                dim = ncoobj.createDimension(dims, dimsize)
+               print '    ' + fname + ': adding dimension: ' + dims + ' size:',dimsize
             else:
                if dims != dimn:
                    dim = ncoobj.createDimension(dims, dimsize)
+                   print '    ' + fname + ': adding dimension: ' + dims + ' size:',dimsize
 
     ncoobj.sync()
+    print fname + '; Lluis: dimsecslice:', dimsecslice
 # Creating variables
 ## 
+    filedims = ncoobj.dimensions
     for varns in nciobj.variables:
         print '    ' + fname + ': adding variable "' + varns + '"...'
@@ -5736,6 +5756,18 @@
 
         if not gen.searchInlist(list(vardims),dimn):
-            varvals = varobj[:]
-            filevardims = list(vardims)
+            # removing monotones
+            print fname + '; Lluis looking for monotones!'
+            varslice = []
+            filevardims = []
+            for dimname in varobj.dimensions:
+                lendim = len(nciobj.dimensions[dimname])
+                print fname + '; Lluis monotone?:', dimname,' len;', lendim
+                if lendim > 1:
+                    varslice.append(slice(0, lendim))
+                    filevardims.append(dimname)
+                else:
+                    varslice.append(0)
+
+            varvals = varobj[tuple(varslice)]
         else:
             varslice = []
@@ -5743,20 +5775,18 @@
             for dimname in varobj.dimensions:
                 if dimname == dimn:
-                    if begv != -9 and begv != 0:
-                        varslice.append(slice(begv,endv,intv))
+                    varslice.append(dimsecslice[dimn])
+                    filevardims.append(dimname)
+                else:
+                    Ldim = len(nciobj.dimensions[dimname])
+                    if Ldim > 1:
+                        varslice.append(slice(0,Ldim))
                         filevardims.append(dimname)
                     else:
-                        if begv == -9:
-                            varslice.append(len(nciobj.dimensions[dimn])-1)
-                        elif begv == 0:
-                            varslice.append(0)
-
-                else:
-                    Ldim = len(nciobj.dimensions[dimname])
-                    varslice.append(slice(0,Ldim))
-                    filevardims.append(dimname)
-
+                        varslice.append(0)
+
+                print fname  + '; Lluis varslice:', varslice,' filevardims:', filevardims
             varvals = varobj[tuple(varslice)]
 
+        print fname + ': Lluis filevardims:', filevardims
 # Adding fill value attribute
 ##
