Index: trunk/tools/module_scientific.f90
===================================================================
--- trunk/tools/module_scientific.f90	(revision 2561)
+++ trunk/tools/module_scientific.f90	(revision 2562)
@@ -7360,8 +7360,9 @@
 
     ! Local
-    INTEGER                                              :: ixA, iyA, ixB, iyB, iv, iv1, iv2
+    INTEGER                                              :: ixA, iyA, ixB, iyB, iv, iv1, iv2, iiv
     INTEGER                                              :: NA, NB
     INTEGER, DIMENSION(dxyA)                             :: ptsA, ptsB
     INTEGER, DIMENSION(dxyA, 2)                          :: pts
+    LOGICAL                                              :: found
 
 
@@ -7396,4 +7397,13 @@
                 IF ( (pointsA(ixA,iyA,iv1,1) == pointsB(ixB,iyB,iv2,1)) .AND.                         &
                   (pointsA(ixA,iyA,iv1,2) == pointsB(ixB,iyB,iv2,2)) ) THEN
+                  ! need to avoid double count (in ix[X] == 1)
+                  found = .FALSE.
+                  DO iiv = 1, iv
+                    IF ( (pointsA(ixA,iyA,iv1,1) == points(ixA,iyB,ixB,iyB,iiv,1)) .AND.              &
+                      (pointsA(ixA,iyA,iv1,2) == points(ixA,iyB,ixB,iyB,iiv,2)) ) THEN
+                      found = .TRUE.
+                    END IF
+                  END DO
+                  IF (found) CYCLE
                   iv = iv + 1
                   points(ixA,iyA,ixB,iyB,iv,1) = pointsA(ixA,iyA,iv1,1)
Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 2561)
+++ trunk/tools/nc_var_tools.py	(revision 2562)
@@ -29212,5 +29212,9 @@
                         reflat1D = varslcv[3]
                         refblat1D = varslcv[4]
-                        dref.append(varn)
+                        #dref.append(varn)
+                        Nv = gen.ntimesHval_inlist(list(onewnc.dimensions), dimvars[ydim])
+                        varnS = dimvars[ydim] + str(Nv)
+                        dref.append(varnS)
+#                        dref.append(dimvars[ydim])
                     else:
                         print infmsg
@@ -29245,5 +29249,8 @@
                         reflon1D = varslcv[3]
                         refblon1D = varslcv[4]
-                        dref.append(varn)
+#                        dref.append(varn)
+                        Nv = gen.ntimesHval_inlist(list(onewnc.dimensions), dimvars[xdim])
+                        varnS = dimvars[xdim] + str(Nv)
+                        dref.append(varnS)
                     else:
                         print infmsg
@@ -29633,6 +29640,4 @@
                 newdim = onewnc.createDimension('coord',2)
 
-            print '    Lluis dims ', dn+'Ngrid', 'Srgrid', Srgrid
-
             newvar = onewnc.createVariable(dn+'Ngrid','i', tuple(Srgrid))
             if Ngridsin.shape[1] == 1:
@@ -29764,7 +29769,4 @@
     dxyB = osliceinB.shape[1]
 
-    print 'Lluis dims osliceNB', osliceNB.dimensions, 'osliceNA', osliceNA.dimensions
-
-
     Srgrid = list(osliceNB.dimensions) + list(osliceNA.dimensions)
     Sigrid = ['coord', dn+'gridin'] + Srgrid
@@ -29786,8 +29788,4 @@
     #sliceinBt[...,1] = sliceinBt0[...,0]+1
 
-    iiB = 3
-    jjB = 0
-    iiA = 0
-    jjA = 3
     NpointsABt, pointsABt, inpA, inpB = fsci.module_scientific.coincident_gridsin2d( \
       npointsa=sliceNAt, pointsa=sliceinAt, npointsb=sliceNBt, pointsb=sliceinBt,    \
@@ -29798,5 +29796,4 @@
     inpointsB = inpB.transpose()
 
-    print 'Lluis here 00'
 
     # Remembering that it is python (C-like...)
@@ -29815,8 +29812,4 @@
     if not gen.searchInlist(onewnc.dimensions, dn+'gridin'):
         newdim = onewnc.createDimension(dn+'gridin', maxNpointsAB)
-
-    print 'Lluis file creation'
-
-    print 'Lluis shapes: newvar', newvar.shape, 'NpointsAB', NpointsAB.shape, 'Srgrid', Srgrid
 
     newvar = onewnc.createVariable(dn+'Ngrid','i', tuple(Srgrid))
@@ -29826,6 +29819,4 @@
     newvar.setncattr('coordinates',' '.join(Srgrid[::-1]))
     
-    print 'Lluis file creation 1'
-
     innewvar = onewnc.createVariable(dn+'gridin', 'i', tuple(Sigrid),                \
       fill_value=gen.fillValueI)
@@ -29834,6 +29825,4 @@
     innewvar.setncattr('coordinates',' '.join(Srgrid[::-1]))
 
-    print 'Lluis file creation 2'
-
     aanewvar = onewnc.createVariable(dn+'area','f',tuple(Srgrid),                    \
       fill_value=gen.fillValueF)
@@ -29842,6 +29831,4 @@
     aanewvar.setncattr('coordinates',' '.join(Srgrid[::-1]))
 
-    print 'Lluis file creation 3'
-
     anewvar = onewnc.createVariable(dn+'gridarea','f',tuple(Spgrid),                 \
       fill_value=gen.fillValueF)
@@ -29850,6 +29837,4 @@
     anewvar.setncattr('coordinates',' '.join(Spgrid[::-1]))
 
-    print 'Lluis file creation 4'
-
     pnewvar = onewnc.createVariable(dn+'gridpercen','f',tuple(Spgrid),               \
       fill_value=gen.fillValueF)
@@ -29857,6 +29842,4 @@
       "grids cells from " + newslcvarns[0] + " laying within " + newslcvarns[1], '1')
     pnewvar.setncattr('coordinates',' '.join(Spgrid[::-1]))
-
-    print 'Lluis prior to... dyA, dxA, dyB, dxB', dyA, dxA, dyB, dxB
 
     for jA in range(dyA):
@@ -29896,6 +29879,4 @@
     #onewnc.close()
     #quit()
-
-    print 'Lluis here !!'
 
     if Nnewslcs >= 3:
