Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 706)
+++ trunk/tools/nc_var_tools.py	(revision 707)
@@ -18433,7 +18433,5 @@
 #    print 'frac lon, lat:', fraclon[ilatlonfrac[0],ilatlonfrac[1]], ',',             \
 #      fraclat[ilatlonfrac[0],ilatlonfrac[1]]
-#    ilatlon = [ilatlonfrac[0]*fracy, ilatlonfrac[1]*fracx]
-#    print 'input index:',ilatlon, 'lon lat:', ilon[ilatlon[0],ilatlon[1]], ',',      \
-#      ilat[ilatlon[0],ilatlon[1]]
+#    print 'values lon, lat:', lonv, latv
       
 # Providing fraction range
@@ -18464,7 +18462,11 @@
             iybeg = 0
             iyend = fracy+1
-        if ilatlonfrac[1] < fracdx: 
-            ixbeg = (ilatlonfrac[1]-1)*fracx
-            ixend = ilatlonfrac[1]*fracx+1
+        if ilatlonfrac[1] < fracdx:
+            if ilatlonfrac[1] != 0:
+                ixbeg = (ilatlonfrac[1]-1)*fracx
+                ixend = ilatlonfrac[1]*fracx+1
+            else:
+                ixbeg = 0
+                ixend = fracx+1
         else:
             ixbeg = fracdx*fracx
@@ -18475,12 +18477,20 @@
 #        ifracend = [ilatlonfrac[0]+1, ilatlonfrac[1]+1]
         if ilatlonfrac[0] < fracdy: 
-            iybeg = (ilatlonfrac[0]-1)*fracy
-            iyend = ilatlonfrac[0]*fracy+1
+            if ilatlonfrac[0] != 0:
+                iybeg = (ilatlonfrac[0]-1)*fracy
+                iyend = ilatlonfrac[0]*fracy+1
+            else:
+                iybeg = 0
+                iyend = fracy+1
         else:
             iybeg = fracdy*fracy
             iyend = dy+1
         if ilatlonfrac[1] < fracdx: 
-            ixbeg = (ilatlonfrac[1]-1)*fracx
-            ixend = ilatlonfrac[1]*fracx+1
+            if ilatlonfrac[1] != 0:
+                ixbeg = (ilatlonfrac[1]-1)*fracx
+                ixend = ilatlonfrac[1]*fracx+1
+            else:
+                ixbeg = 0
+                ixend = fracx+1
         else:
             ixbeg = fracdx*fracx
@@ -18491,6 +18501,10 @@
 #        ifracend = [ilatlonfrac[0]+1, ilatlonfrac[1]]
         if ilatlonfrac[0] < fracdy: 
-            iybeg = (ilatlonfrac[0]-1)*fracy
-            iyend = ilatlonfrac[0]*fracy+1
+            if ilatlonfrac[0] != 0:
+                iybeg = (ilatlonfrac[0]-1)*fracy
+                iyend = ilatlonfrac[0]*fracy+1
+            else:
+                iybeg = 0
+                iyend = fracy+1
         else:
             iybeg = fracdy*fracy
@@ -18840,13 +18854,14 @@
 #    print fraclat
 
+# Error at 150024, 150025, 151709, 153421
     print '  ' + fname + ': re-locating:',Ninpts,'points...'
     if kind == 'Goode':
-        for iv in range(Ninpts):
+        for iv in range(150024,Ninpts):
             if newvarinpt[iv] == 0:
 
-                difflonlat = np.sqrt((projlon-lonvs[iv])**2. + (projlat-latvs[iv])**2.)
-                mindiffLl = np.min(difflonlat)
-                ilatlon = index_mat(difflonlat, mindiffLl)
-#                ilatlon2, mindiffLl2 = CoarselonlatFind(projlon, projlat, lonvs[iv], latvs[iv], .1)
+#                difflonlat = np.sqrt((projlon-lonvs[iv])**2. + (projlat-latvs[iv])**2.)
+#                mindiffLl = np.min(difflonlat)
+#                ilatlon = index_mat(difflonlat, mindiffLl)
+                ilatlon, mindiffLl = CoarselonlatFind(projlon,projlat,lonvs[iv],latvs[iv],.1)
 
 #                if ilatlon[0] != ilatlon2[0] or ilatlon[1] != ilatlon2[1]:
@@ -18855,45 +18870,49 @@
 #                    quit(-1)
 
-                if type(newvar[ilatlon[0],ilatlon[1]]) != type(amsk): 
-                    print errormsg
-                    print '  ' + main + ': point', projlon[ilatlon[0],ilatlon[1]],  \
-                      ',', projlat[ilatlon[0],ilatlon[1]], 'already filled!!'
-                    print '    value:', newvar[ilatlon[0],ilatlon[1]], 'distance:', \
-                      newvarindiff[newvarin[ilatlon[0],ilatlon[1]]]
-
-                    print '   iv:', iv, 'lon:', lonvs[iv],'lat:',latvs[iv]
-                    print '   mindiffLl:',mindiffLl,'ilatlon:',ilatlon
-                    quit(-1)
-#            print '  Lluis; ' + fname + ' iv:', iv, 'lon:', lonvs[iv],'lat:',latvs[iv]
-#            print '  Lluis; ' + fname + ' mindiffLl:',mindiffLl,'ilatlon:',ilatlon
-#            print '  Lluis; ' + fname + ' A found lon:',projlon[ilatlon[0], ilatlon[1]], 'lat:', projlat[ilatlon[0], ilatlon[1]]
-#            quit()
-
-                percendone(iv,Ninpts,0.5,'done:')
-                if mindiffLl > mindiff:
-                    print errormsg
-                    print '  ' + fname + ': for point #', iv,'lon,lat in ' +         \
-                      'incomplet map:', lonvs[iv], ',', latvs[iv], 'there is not ' + \
-                      'a set of lon,lat in the completed map closer than: ', mindiff,\
-                      '!!'
-                    print '    minimum difference:', mindiffLl
-                    quit()
-
-                if ilatlon[0] >= 0 and ilatlon[1] >= 0:
-                    newvar[ilatlon[0],ilatlon[1]] = ovar[iv]
-                    newvarin[ilatlon[0],ilatlon[1]] = iv
-                    newvarinpt[iv] = 1
-                    newvarindiff[iv] = mindiffLl
-#                    print 'Lluis iv:', newvarin[ilatlon[0],ilatlon[1]],              \
-#                      'localized:', newvarinpt[iv], 'values:',                       \
-#                      newvar[ilatlon[0],ilatlon[1]], 'invalues:', ovar[iv],          \
-#                      'mindist:', newvarindiff[iv], 'point:',ilatlon
-                else:
-                    print errormsg
-                    print '  ' + fname + ': point iv:', iv, 'at', lonvs[iv], ',' ,   \
-                      latvs[iv],' not relocated !!'
-                    print '    mindiffl:', mindiffLl, 'ilon:', ilatlon[1],           \
-                      'ilatlon:', ilatlon[1]
-                    quit(-1)
+#                if mindiffLl != 0. or type(newvar[ilatlon[0],ilatlon[1]]) != type(amsk): 
+#                    print errormsg
+#                    if mindiffLl !=0.:
+#                        print '  ' + main + ': no zero', newvarindiff[iv], 'distance!!'
+#                    else:
+#                        print '  ' + main+': point',projlon[ilatlon[0],ilatlon[1]],  \
+#                          ',', projlat[ilatlon[0],ilatlon[1]], 'already filled!!'
+#                        print '    value:',newvar[ilatlon[0],ilatlon[1]],'distance:',\
+#                          newvarindiff[iv]
+#
+##                    print '   iv:', iv, 'lon:', lonvs[iv],'lat:',latvs[iv]
+##                    print '   mindiffLl:',mindiffLl,'ilatlon:',ilatlon
+##                    quit(-1)
+##            print '  Lluis; ' + fname + ' iv:', iv, 'lon:', lonvs[iv],'lat:',latvs[iv]
+##            print '  Lluis; ' + fname + ' mindiffLl:',mindiffLl,'ilatlon:',ilatlon
+##            print '  Lluis; ' + fname + ' A found lon:',projlon[ilatlon[0], ilatlon[1]], 'lat:', projlat[ilatlon[0], ilatlon[1]]
+##            quit()
+#                else:
+                if mindiffLl == 0. and type(newvar[ilatlon[0],ilatlon[1]]) == type(amsk): 
+                    percendone(iv,Ninpts,0.5,'done:')
+                    if mindiffLl > mindiff:
+                        print errormsg
+                        print '  ' + fname + ': for point #', iv,'lon,lat in ' +     \
+                          'incomplet map:', lonvs[iv], ',', latvs[iv], 'there is ' + \
+                          'not a set of lon,lat in the completed map closer than: ', \
+                          mindiff, '!!'
+                        print '    minimum difference:', mindiffLl
+                        quit(-1)
+
+                    if ilatlon[0] >= 0 and ilatlon[1] >= 0:
+                        newvar[ilatlon[0],ilatlon[1]] = ovar[iv]
+                        newvarin[ilatlon[0],ilatlon[1]] = iv
+                        newvarinpt[iv] = 1
+                        newvarindiff[iv] = mindiffLl
+#                        print 'Lluis iv:', newvarin[ilatlon[0],ilatlon[1]],          \
+#                          'localized:', newvarinpt[iv], 'values:',                   \
+#                          newvar[ilatlon[0],ilatlon[1]], 'invalues:', ovar[iv],      \
+#                          'mindist:', newvarindiff[iv], 'point:',ilatlon    
+                    else:
+                        print errormsg
+                        print '  ' + fname + ': point iv:', iv, 'at', lonvs[iv], ',',\
+                          latvs[iv],' not relocated !!'
+                        print '    mindiffl:', mindiffLl, 'ilon:', ilatlon[1],       \
+                          'ilatlon:', ilatlon[1]
+                        quit(-1)
 
                 if np.mod(iv,100) == 0: 
