Index: /trunk/tools/nc_var.py
===================================================================
--- /trunk/tools/nc_var.py	(revision 507)
+++ /trunk/tools/nc_var.py	(revision 508)
@@ -84,5 +84,6 @@
 
 # Operations which file name is not a real file
-NotCheckingFile = ['file_creation', 'list_operations', 'netcdf_concatenation', 'netcdf_fold_concatenation']
+NotCheckingFile = ['DatesFiles', 'file_creation', 'list_operations',                 \
+  'netcdf_concatenation', 'netcdf_fold_concatenation']
 
 ####### ###### ##### #### ### ## #
Index: /trunk/tools/nc_var_tools.py
===================================================================
--- /trunk/tools/nc_var_tools.py	(revision 507)
+++ /trunk/tools/nc_var_tools.py	(revision 508)
@@ -15875,4 +15875,5 @@
     """
     import subprocess as sub
+    import datetime as dt
     fname='DatesFiles'
 
@@ -15884,7 +15885,7 @@
     arguments = '[dates],[fold]'
     check_arguments(fname, len(values.split(',')), arguments, ',',                   \
-      len(argumenst.split(',')))
-
-    dates = values.split(',')[0].split(',')
+      len(arguments.split(',')))
+
+    dates = values.split(',')[0].split(':')
     fold = values.split(',')[1]
 
@@ -15893,31 +15894,66 @@
 
     print '  ' + fname +': looking on:',Nfiles,'files'
-    print confiles
 
 # Opening all files and getting times
     ncobjs = {}
     for filen in confiles:
-        print 'charging: ',filen
         filename = fold + '/' + filen
-        ncf = NetCDFFile(fname, 'r')
+        ncf = NetCDFFile(filename, 'r')
+        datesv = []
         if varn == 'WRFt':
             fdates = ncf.variables['Times'][:]
-            datesv = datetimeStr_conversion(fdates, 'WRFdatetime', 'YmdHMS')
+            for it in range(fdates.shape[0]):
+                datesv.append(datetimeStr_conversion(fdates[it,:], 'WRFdatetime',    \
+                  'YmdHMS'))
         else:
             tunits = ncf.variables[varn].getncattr('units')
             fdates = ncf.variables[varn][:]
-            datesv = datetimeStr_conversion(fdates, 'cfTime,' + tunits , 'YmdHMS')
-
-        ncobjs[fname] = datesv
-    
-    founddates = {}
-    for dt in dates:
+            for it in range(fdates.shape[0]):
+                datesv.append(datetimeStr_conversion(fdates[it], 'cfTime,' + tunits ,\
+                   'YmdHMS'))
+
+        ncobjs[filename] = datesv
+        ncf.close()
+
+# Computing time-step inside files (assuming regular)
+        if filen == confiles[0]:
+            ini=datesv[0]
+            end=datesv[1]
+
+            iniT = dt.datetime.strptime(ini,'%Y%m%d%H%M%S')
+            endT = dt.datetime.strptime(end,'%Y%m%d%H%M%S')
+
+            DT = endT - iniT
+            diffT = DT.total_seconds()
+            print '  ' + fname + ': seconds between time-steps in files:', diffT
+
+    Efounddates = {}
+    Cfounddates = {}
+    for dtv in dates:
+        foundclosest = False
         for fn in ncobjs.keys():
-            if searchInlist(ncobjs[fn], dt):
-                founddates[dt] = fn
-                istep = ncobjs[fn].index(dt)
-
-                print fname + ':',dt,fn,istep
-
+            if searchInlist(ncobjs[fn], dtv):
+                founddates[dtv] = fn
+                istep = ncobjs[fn].index(dtv)
+
+                print fname + 'Exact:',dtv,fn,istep,'(date, filname, time-step)'
+                Efounddates[dtv] = [dtv,fn,istep]
+
+            for it in ncobjs[fn]:
+                iniT = dt.datetime.strptime(it,'%Y%m%d%H%M%S')
+                endT = dt.datetime.strptime(dtv,'%Y%m%d%H%M%S')
+
+                DT = endT - iniT
+                diffitv = DT.total_seconds()
+
+                if diffT > DT.total_seconds():
+                    istep = ncobjs[fn].index(it)
+                    print fname + 'Closest:',dtv,fn,it,diffitv,'(date, filname, ' +  \
+                      'time-step, distance in seconds)'
+                    Cfounddates[dtv] = [dtv,fn,istep,diffitv]
+                    foundclosest = True
+                    break
+
+            if foundclosest: break
     return
 
