Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 2767)
+++ trunk/tools/nc_var_tools.py	(revision 2768)
@@ -1471,5 +1471,5 @@
 
   attvar = var.ncattrs()
-  if searchInlist(attvar, values):
+  if gen.searchInlist(attvar, values):
       attr = var.delncattr(values)
   else:
@@ -1495,5 +1495,5 @@
 
   attvar = ncf.ncattrs()
-  if searchInlist(attvar, values):
+  if gen.searchInlist(attvar, values):
       attr = ncf.delncattr(values)
   else:
@@ -2890,5 +2890,5 @@
 # Checking fill value
 ## 
-  if searchInlist(varattr, '_FillValue'):
+  if gen.searchInlist(varattr, '_FillValue'):
       varfil = var._FillValue
   else:
@@ -2925,5 +2925,5 @@
   newvar = ncfo.variables['time']
   newvarattrs = newvar.ncattrs()
-  if searchInlist(newvarattrs, 'bounds'):
+  if gen.searchInlist(newvarattrs, 'bounds'):
       if newvar.getncattr('bounds') == 'time_bnds':
           ncf = NetCDFFile(ncfile,'r')
@@ -3080,5 +3080,5 @@
 # Checking fill value
 ## 
-  if searchInlist(varattr, '_FillValue'):
+  if gen.searchInlist(varattr, '_FillValue'):
       varfil = var._FillValue
   else:
@@ -3115,5 +3115,5 @@
   newvar = ncfo.variables['time']
   newvarattrs = newvar.ncattrs()
-  if searchInlist(newvarattrs, 'bounds'):
+  if gen.searchInlist(newvarattrs, 'bounds'):
       if newvar.getncattr('bounds') == 'time_bnds':
           ncf = NetCDFFile(ncfile,'r')
@@ -5162,5 +5162,5 @@
     for var in ncft.variables:
         varobj = ncft.variables[var]
-        if searchInlist(varobj.dimensions, tname):
+        if gen.searchInlist(varobj.dimensions, tname):
             print fname + ': time-sorting variable: "' + var + '" '
             varvals = varobj[:]
@@ -5754,6 +5754,6 @@
 #       Looking if variable has lon and/or lat:
         varlonlat = False
-        if searchInlist(vardims, oldlonlatdim[0]): varlonlat = True
-        if searchInlist(vardims, oldlonlatdim[1]): varlonlat = True
+        if gen.searchInlist(vardims, oldlonlatdim[0]): varlonlat = True
+        if gen.searchInlist(vardims, oldlonlatdim[1]): varlonlat = True
 
         if varn != oldlon and varn != oldlat and varlonlat:
@@ -5782,9 +5782,9 @@
                     newslice0 = newslice[:]
 
-                    if searchInlist(vardims,oldlat):
+                    if gen.searchInlist(vardims,oldlat):
                         oldslice0.append(mappairs[0,jnew,inew])
                         newslice0.append(jnew)
 
-                    if searchInlist(vardims,oldlon):
+                    if gen.searchInlist(vardims,oldlon):
                         oldslice0.append(mappairs[1,jnew,inew])
                         newslice0.append(inew)
@@ -5819,5 +5819,5 @@
             newvarval = ovar[:]
 
-        if searchInlist(varattrs, '_FillValue'):
+        if gen.searchInlist(varattrs, '_FillValue'):
             fvalv = ovar.getncattr('_FillValue')
             newvar = ncfnew.createVariable(varn, vartype, tuple(newvardimn),         \
@@ -7395,5 +7395,5 @@
                     otime = objfile.variables['time']
                     timevals = otime[:]
-                    if searchInlist(otime.ncattrs(),'units'):
+                    if gen.searchInlist(otime.ncattrs(),'units'):
                         tunits = otime.getncattr['units']
                     else:
@@ -7444,5 +7444,5 @@
                     otime = objfile.variables['time']
                     timevals = otime[:]
-                    if searchInlist(otime.ncattrs(),'units'):
+                    if gen.searchInlist(otime.ncattrs(),'units'):
                         tunits = otime.getncattr['units']
                     else:
@@ -7462,13 +7462,13 @@
             newvar[it,:,:] = valsvar[inside]
 
-        if searchInlist(varobj.ncattrs(),'standard_name'):
+        if gen.searchInlist(varobj.ncattrs(),'standard_name'):
             vsname = varobj.getncattr('standard_name')
         else:
             vsname = varn
-        if searchInlist(varobj.ncattrs(),'long_name'):
+        if gen.searchInlist(varobj.ncattrs(),'long_name'):
             vlname = varobj.getncattr('long_name')
         else:
             vlname = varn
-        if searchInlist(varobj.ncattrs(),'units'):
+        if gen.searchInlist(varobj.ncattrs(),'units'):
             vunits = varobj.getncattr('units')
         else:
@@ -8256,9 +8256,9 @@
         if opern == 'add':
             newvarv[tuple(tnewvar)] = newvarv[tuple(tnewvar)] + varobj[tuple(tslice)]
-            if searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
+            if gen.searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
                 newunits = varobj.getncattr('units')
         elif opern == 'sub':
             newvarv[tuple(tnewvar)] = newvarv[tuple(tnewvar)] - varobj[tuple(tslice)]
-            if searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
+            if gen.searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
                 newunits = varobj.getncattr('units')
         elif opern == 'mul':
@@ -8426,9 +8426,9 @@
         if opern == 'add':
             newvarv[tuple(tslice)] = newvarv[tuple(prevslice)] + varobj[tuple(tslice)]
-            if searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
+            if gen.searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
                 newunits = varobj.getncattr('units')
         elif opern == 'sub':
             newvarv[tuple(tslice)] = newvarv[tuple(prevslice)] - varobj[tuple(tslice)]
-            if searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
+            if gen.searchInlist(varobj.ncattrs(), 'units') and newunits != '-':
                 newunits = varobj.getncattr('units')
         elif opern == 'mul':
@@ -9090,5 +9090,5 @@
             otime = objfile.variables['time']
             timevals = otime[:]
-            if searchInlist(otime.ncattrs(),'units'):
+            if gen.searchInlist(otime.ncattrs(),'units'):
                 tunits = otime.getncattr['units']
             else:
@@ -9146,5 +9146,5 @@
             otime = objfile.variables['time']
             timevals = otime[:]
-            if searchInlist(otime.ncattrs(),'units'):
+            if gen.searchInlist(otime.ncattrs(),'units'):
                 tunits = otime.getncattr['units']
             else:
@@ -9164,13 +9164,13 @@
             newvar[it,:,:,:] = valsvar[inside3D]
 
-    if searchInlist(varobj.ncattrs(),'standard_name'):
+    if gen.searchInlist(varobj.ncattrs(),'standard_name'):
         vsname = varobj.getncattr('standard_name')
     else:
         vsname = varn
-    if searchInlist(varobj.ncattrs(),'long_name'):
+    if gen.searchInlist(varobj.ncattrs(),'long_name'):
         vlname = varobj.getncattr('long_name')
     else:
         vlname = varn
-    if searchInlist(varobj.ncattrs(),'units'):
+    if gen.searchInlist(varobj.ncattrs(),'units'):
         vunits = varobj.getncattr('units')
     else:
@@ -9230,5 +9230,5 @@
     arguments = '[trajfile]@[Tbeg],[lonname],[latname],[zname],[timename],' +        \
       '[timekind],[boxsize],[circler]]'
-    check_arguments(fname,values,arguments,',')
+    gen.check_arguments(fname,values,arguments,',')
 
     trajfile = values.split(',')[0].split('@')[0]
@@ -9284,5 +9284,5 @@
             varns = [varn]
 
-    lonv, latv = lonlat2D(lonobj[:],latobj[:])
+    lonv, latv = gen.lonlat2D(lonobj[:],latobj[:])
 
     dimx = lonv.shape[1]
@@ -9293,5 +9293,5 @@
 # Selecting accordingly a trajectory
 ##
-    Ttraj = file_nlines(trajfile,'#')
+    Ttraj = gen.file_nlines(trajfile,'#')
     if timekind == 'wrf':
         dimt = objfile.variables[timn].shape[0]
@@ -9342,5 +9342,5 @@
 
 # Slicing brings to reduce 1 time-step.... ???
-        if line[0:1] != '#':
+        if len(line) > 1 and line[0:1] != '#':
             gtrajvals[it,0] = Tbeg + iline - 1
             gtrajvals[it,1] = int(line.split(' ')[1])
@@ -9349,7 +9349,7 @@
         
             if timekind == 'wrf':
-                gdate = datetimeStr_conversion(timv[gtrajvals[it,0]],'WRFdatetime',  \
-                  'matYmdHMS')
-                trajvals[it,0] = realdatetime1_CFcompilant(gdate, '19491201000000',  \
+                gdate = gen.datetimeStr_conversion(timv[gtrajvals[it,0]],            \
+                  'WRFdatetime', 'matYmdHMS')
+                trajvals[it,0]= gen.realdatetime1_CFcompilant(gdate,'19491201000000',\
                   'hours')
                 tunits = 'hours since 1949-12-01 00:00:00'
@@ -9417,5 +9417,5 @@
 
 # circle values
-            circdist[it,:,:] = radius_dist(dimy,dimx,gtrajvals[it,2],gtrajvals[it,1])
+            circdist[it,:,:] = gen.radius_dist(dimy,dimx,gtrajvals[it,2],gtrajvals[it,1])
             if gtrajvals[it,2]-Nrad < 0 or gtrajvals[it,2]+Nrad + 1 > dimy + 1 \
               or gtrajvals[it,1]-Nrad < 0 or gtrajvals[it,1]+Nrad + 1 > dimx + 1:
@@ -9495,6 +9495,6 @@
 
     for vn in varns:
-        vnst = variables_values(vn)[0]
-        if not searchInlist(objfile.variables, vn):
+        vnst = gen.variables_values(vn)[0]
+        if not gen.searchInlist(objfile.variables, vn):
             print errormsg
             print '  ' + fname + ": variable name '" + vn + "' is not in file " +    \
@@ -9529,17 +9529,18 @@
 
                 objofile.createDimension('z', dimz)
-                newvar = objofile.createVariable(zn, 'f4', ('z'),fill_value=fillValue)
-                if searchInlist(varzobj.ncattrs(),'standard_name'):
+                newvar = objofile.createVariable(zn, 'f4', ('z'),                    \
+                  fill_value=gen.fillValueF)
+                if gen.searchInlist(varzobj.ncattrs(),'standard_name'):
                     vsname = varzobj.getncattr('standard_name')
                 else:
-                    vsname = variables_values(zn)[1]
-                if searchInlist(varzobj.ncattrs(),'long_name'):
+                    vsname = gen.variables_values(zn)[1]
+                if gen.searchInlist(varzobj.ncattrs(),'long_name'):
                     vlname = varzobj.getncattr('long_name')
                 else:
-                    vlname = variables_values(zn)[4].replace('|',' ')
-                if searchInlist(varzobj.ncattrs(),'units'):
+                    vlname = gen.variables_values(zn)[4].replace('|',' ')
+                if gen.searchInlist(varzobj.ncattrs(),'units'):
                     vunits = varzobj.getncattr('units')
                 else:
-                    vunits = variables_values(zn)[5].replace('|',' ')
+                    vunits = gen.variables_values(zn)[5].replace('|',' ')
     
                 newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -9586,5 +9587,5 @@
 
                     rvarvalst = np.ones((dimz, Nrad*2+1, Nrad*2+1),dtype=np.float)*  \
-                      fillValue
+                      gen.fillValueF
 
                     varvalst[tuple(slice2D)] = varobj[tuple(slicev)]
@@ -9592,5 +9593,5 @@
     
 # box stats values
-                    maskedvals = ma.masked_values (varvalst, fillValue)
+                    maskedvals = ma.masked_values (varvalst, gen.fillValueF)
                     maskedvals2 = maskedvals*maskedvals
                     for iz in range(dimz):
@@ -9660,5 +9661,5 @@
 
                     rvarvalst = np.ones((dimz,Nrad*2+1,Nrad*2+1),dtype=np.float)*    \
-                      fillValue
+                      gen.fillValueF
                     rvarvalst[tuple(cslice2D)] = varobj[tuple(cslicev)]
                     for iz in range(dimz):
@@ -9666,10 +9667,10 @@
                         zslice = [slice(iz,iz)]+cslice2Dhor
                         rvarvalst[tuple(zslice)] = np.where(circdist[tuple(tslice)] > \
-                          np.float(Nrad), fillValue, rvarvalst[tuple(zslice)]) 
+                          np.float(Nrad), gen.fillValueF, rvarvalst[tuple(zslice)]) 
 
                     rvarvals[it,:,:,:] = rvarvalst
 
 # circle stats values
-                    maskedvals = ma.masked_values (rvarvalst, fillValue)
+                    maskedvals = ma.masked_values (rvarvalst, gen.fillValueF)
                     maskedvals2 = maskedvals*maskedvals
                     for iz in range(dimz):
@@ -9707,10 +9708,10 @@
                         tslice = [it]+cslicevnoThor
                         rvarvalst[iz,:,:] = np.where(circdist[tuple(tslice)] >       \
-                          np.float(Nrad), fillValue, rvarvalst[iz,:,:]) 
+                          np.float(Nrad), gen.fillValueF, rvarvalst[iz,:,:]) 
 
                     rvarvals[it,:,:,:] = rvarvalst
 
 # circle stats values
-                    maskedvals = ma.masked_values (rvarvalst, fillValue)
+                    maskedvals = ma.masked_values (rvarvalst, gen.fillValueF)
                     maskedvals2 = maskedvals*maskedvals
                     for iz in range(dimz):
@@ -9728,17 +9729,17 @@
 # variable box values
             newvar = objofile.createVariable(vnst + 'box', 'f4', ('time','z','y','x'),\
-              fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+              fill_value=gen.fillValueF)
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -9748,5 +9749,5 @@
 # center of the trajectory
             newvar = objofile.createVariable('trj_' + vnst, 'f', ('time','z'),     \
-              fill_value=fillValue)
+              fill_value=gen.fillValueF)
             newattr = basicvardef(newvar, 'trj_' + vsname, 'value along the ' +    \
               'trajectory of '+ vn, vunits)
@@ -9757,5 +9758,5 @@
             for statn in statnames:
                 newvar = objofile.createVariable(statn + '_' + vnst,'f',('time','z'),\
-                  fill_value=fillValue)
+                  fill_value=gen.fillValueF)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
                   ' the box ('+str(boxs)+'x'+str(boxs)+') of ' + vnst, vunits)
@@ -9766,17 +9767,17 @@
 # variable circle values
             newvar = objofile.createVariable(vnst + 'circle','f4',('time','z','yr',    \
-              'xr'), fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+              'xr'), fill_value=gen.fillValueF)
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -9788,5 +9789,5 @@
             for statn in cstatnames:
                 newvar = objofile.createVariable(statn + '_' + vnst,'f',('time','z'),\
-                  fill_value=fillValue)
+                  fill_value=gen.fillValueF)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
                   ' the circle of radius ('+ str(circler)+') of ' + vnst, vunits)
@@ -9834,10 +9835,10 @@
                     slice2D.append(slice(0,xrangeslice[it][1]-xrangeslice[it][0]))
 
-                    rvarvalst = np.ones((Nrad*2+1, Nrad*2+1),dtype=np.float)*fillValue
+                    rvarvalst = np.ones((Nrad*2+1, Nrad*2+1),dtype=np.float)*gen.fillValueF
                     varvalst[tuple(slice2D)] = varobj[tuple(slicev)]
                     varvals[it,:,:] = varvalst
     
 # box stats values
-                    maskedvals = ma.masked_values (varvalst, fillValue)
+                    maskedvals = ma.masked_values (varvalst, gen.fillValueF)
                     statvarvals[it,0] = varvalst[box2,box2]
                     statvarvals[it,1] = maskedvals.min()
@@ -9905,13 +9906,13 @@
                     cslice2D.append(slice(0,maxx - cxrangeslice[it][0]))
 
-                    rvarvalst = np.ones((Nrad*2+1,Nrad*2+1),dtype=np.float)*fillValue
+                    rvarvalst = np.ones((Nrad*2+1,Nrad*2+1),dtype=np.float)*gen.fillValueF
                     rvarvalst[tuple(cslice2D)] = varobj[tuple(cslicev)]
                     rvarvalst[tuple(cslice2D)] = np.where(circdist[tuple(cslicev)] >\
-                      np.float(Nrad), fillValue, rvarvalst[tuple(cslice2D)])
+                      np.float(Nrad), gen.fillValueF, rvarvalst[tuple(cslice2D)])
 
                     rvarvals[it,:,:] = rvarvalst
 
 # circle stats values
-                    maskedvals = ma.masked_values (rvarvalst, fillValue)
+                    maskedvals = ma.masked_values (rvarvalst, gen.fillValueF)
                     rstatvarvals[it,0] = rvarvalst[Nrad,Nrad]
                     rstatvarvals[it,1] = maskedvals.min()
@@ -9942,9 +9943,9 @@
                     cdist = circdist[tuple(cslicevC)]
 # circle values
-                    rvarvalst = np.where(cdist > np.float(Nrad),fillValue,rvarvalst)
+                    rvarvalst = np.where(cdist > np.float(Nrad),gen.fillValueF,rvarvalst)
                     rvarvals[it,:,:] = rvarvalst
 
 # circle stats values
-                    maskedvals = ma.masked_values (rvarvalst, fillValue)
+                    maskedvals = ma.masked_values (rvarvalst, gen.fillValueF)
                     rstatvarvals[it,0] = rvarvalst[Nrad,Nrad]
                     rstatvarvals[it,1] = maskedvals.min()
@@ -9961,17 +9962,17 @@
 # variable box values
             newvar = objofile.createVariable(vnst + 'box', 'f4', ('time', 'y', 'x'), \
-              fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+              fill_value=gen.fillValueF)
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -9981,5 +9982,5 @@
 # center of the trajectory
             newvar = objofile.createVariable('trj_' + vnst, 'f', ('time'),           \
-              fill_value=fillValue)
+              fill_value=gen.fillValueF)
             newattr = basicvardef(newvar, 'trj_' + vsname, 'value along the ' +      \
               'trajectory of '+ vnst, vunits)
@@ -9990,5 +9991,5 @@
             for statn in statnames:
                 newvar = objofile.createVariable(statn + '_' + vnst, 'f', ('time'),  \
-                  fill_value=fillValue)
+                  fill_value=gen.fillValueF)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
                   ' the box ('+str(boxs)+'x'+str(boxs)+') of ' + vnst, vunits)
@@ -9999,17 +10000,17 @@
 # variable circle values
             newvar = objofile.createVariable(vnst + 'circle','f4',('time','yr','xr'),\
-              fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+              fill_value=gen.fillValueF)
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -10021,5 +10022,5 @@
             for statn in cstatnames:
                 newvar = objofile.createVariable(statn + '_' + vnst, 'f', ('time'),  \
-                  fill_value=fillValue)
+                  fill_value=gen.fillValueF)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
                   ' the circle of radius ('+ str(circler)+') of ' + vnst, vunits)
@@ -10056,5 +10057,5 @@
 
             newvar = objofile.createVariable('lon', 'f8', ('time', 'y', 'x'),        \
-              fill_value=fillValue)
+              fill_value=gen.fillValueF)
             newattr = basicvardef(newvar, 'longitude', 'longitude',                  \
               'degrees west_east')
@@ -10062,5 +10063,5 @@
 
             newvar = objofile.createVariable('lat', 'f8', ('time', 'y', 'x'),        \
-              fill_value=fillValue)
+              fill_value=gen.fillValueF)
             newattr = basicvardef(newvar, 'latitude', 'latitude',                    \
               'degrees north_south')
@@ -10071,13 +10072,5 @@
 
 # global attributes
-    objofile.setncattr('author', 'L. Fita')
-    objofile.setncattr('institution', 'Laboratire de Meteorologie Dynamique')
-    objofile.setncattr('university', 'Pierre Marie Curie - Jussieu')
-    objofile.setncattr('center', 'Centre National de Recherches Scientifiques')
-    objofile.setncattr('city', 'Paris')
-    objofile.setncattr('country', 'France')
-    objofile.setncattr('script', 'nc_var_tools.py')
-    objofile.setncattr('function', 'compute_tevolboxtraj')
-    objofile.setncattr('version', '1.0')
+    add_global_PyNCplot(objofile, 'nc_var_tools', fname, '1.1')
     objofile.setncattr('data_file',ncfile)
 
@@ -10358,16 +10351,16 @@
     varattrs = ovar.ncattrs()
 
-    if searchInlist(varattrs,'std_name'):
+    if gen.searchInlist(varattrs,'std_name'):
         stdn = ovar.getncattr('std_name')
     else:
-        vvalues = variables_values(ovar._name)
+        vvalues = gen.variables_values(ovar._name)
         stdn = vvalues[1]
 
-    if searchInlist(varattrs,'long_name'):
+    if gen.searchInlist(varattrs,'long_name'):
         lonn = ovar.getncattr('long_name')
     else:
         lonn = vvalues[4].replace('|',' ')
 
-    if searchInlist(varattrs,'units'):
+    if gen.searchInlist(varattrs,'units'):
         un = ovar.getncattr('units')
     else:
@@ -11108,8 +11101,8 @@
         nvals = len(listline)
         if nvals > 0:
-            if searchInlist(add1,listline[0]):
+            if gen.searchInlist(add1,listline[0]):
                 nmlval = int(listline[nvals-1].replace(',','')) + 1
                 onmlobj.write(' ' + listline[0] + ' = ' + str(nmlval) + ',\n')
-            elif searchInlist(add1value,listline[0]):
+            elif gen.searchInlist(add1value,listline[0]):
                 if Ndomref == 1:
                     nmlval = 1
@@ -11118,5 +11111,5 @@
                 onmlobj.write(' ' + listline[0] + ' = ' +                            \
                   numVector_String(listline[2:nvals+1], ' ') + ' ' +str(nmlval)+',\n')
-            elif searchInlist(repeatvalue,listline[0]):
+            elif gen.searchInlist(repeatvalue,listline[0]):
                 nmlval = listline[nvals-1]
                 onmlobj.write(' ' + listline[0] + ' = ' +                            \
@@ -12630,5 +12623,5 @@
                     newnc.createDimension(dimn, len(dimobj))
 
-        if searchInlist(varvobj.ncattrs(),'_FillValue'): 
+        if gen.searchInlist(varvobj.ncattrs(),'_FillValue'): 
             vfillValue = varvobj._FillValue
         else:
@@ -12636,5 +12629,5 @@
 
         vtype = varvobj.dtype
-        if searchInlist(dimvhorns,vn):
+        if gen.searchInlist(dimvhorns,vn):
             print '  ' + fname + ': dimension values variable!'
             print "    keeping original values as '" + vn + "' and filtered as '" +  \
@@ -12651,11 +12644,11 @@
             newvar = newnc.createVariable(vn, vtype, vardims, fill_value = fillValue)
 
-        if searchInlist(vardims,dimnh1) or searchInlist(vardims,dimnh2):
+        if gen.searchInlist(vardims,dimnh1) or searchInlist(vardims,dimnh2):
             varv = varvobj[:]
             varfilt = varvobj[:]
             dimh1id = -1
             dimh2id = -1
-            if searchInlist(vardims,dimnh1): dimh1id= vardims.index(dimnh1)
-            if searchInlist(vardims,dimnh2): dimh2id= vardims.index(dimnh2)
+            if gen.searchInlist(vardims,dimnh1): dimh1id= vardims.index(dimnh1)
+            if gen.searchInlist(vardims,dimnh2): dimh2id= vardims.index(dimnh2)
 
             if dimh1id != -1 and dimh2id != -1:
@@ -13221,5 +13214,5 @@
         varatts = vno.ncattrs()
 
-        if searchInlist(varatts, '_FillValue'):
+        if gen.searchInlist(varatts, '_FillValue'):
             fillv = vno.getncattr('_FillValue')
             newvar = newnc.createVariable(vn, vtype, vdim, fill_value=fillv)
@@ -13276,5 +13269,5 @@
 
     dims = onc.dimensions
-    if searchInlist(dims, dimname):
+    if gen.searchInlist(dims, dimname):
         print errormsg
         print '  ' + fname + ": file '"  + ncfile + "' already has dimension '" +    \
@@ -13356,5 +13349,5 @@
         varatts = vno.ncattrs()
 
-        if searchInlist(varatts, '_FillValue'):
+        if gen.searchInlist(varatts, '_FillValue'):
             fillv = vno.getncattr('_FillValue')
             newvar = newnc.createVariable(vn, vtype, vdim, fill_value=fillv)
@@ -13450,5 +13443,5 @@
         quit(-1) 
     
-    if searchInlist(varatts, '_FillValue'):
+    if gen.searchInlist(varatts, '_FillValue'):
         fillv = varo.getncattr('_FillValue')
         newvar = newnc.createVariable(varn, newtype, vardims, fill_value=fillv)
@@ -13472,5 +13465,5 @@
             varatts = vno.ncattrs()
 
-            if searchInlist(varatts, '_FillValue'):
+            if gen.searchInlist(varatts, '_FillValue'):
                 fillv = vno.getncattr('_FillValue')
                 newvar = newnc.createVariable(vn, vtype, vdim, fill_value=fillv)
@@ -13755,5 +13748,5 @@
             else:
                 for ir in trjSQradii[it].keys():
-                    if searchInlist(TOTradii,ir): TOTradii.append(ir)
+                    if gen.searchInlist(TOTradii,ir): TOTradii.append(ir)
             it = it + 1
             iline = iline + 1
@@ -13800,5 +13793,5 @@
 
     for vn in varns:
-        vnst = variables_values(vn)[0]
+        vnst = gen.variables_values(vn)[0]
         if not searchInlist(objfile.variables, vn):
             print errormsg
@@ -13835,16 +13828,16 @@
                 objofile.createDimension('z', dimz)
                 newvar = objofile.createVariable(zn, 'f4', ('z'),fill_value=fillValue)
-                if searchInlist(varzobj.ncattrs(),'standard_name'):
+                if gen.searchInlist(varzobj.ncattrs(),'standard_name'):
                     vsname = varzobj.getncattr('standard_name')
                 else:
-                    vsname = variables_values(zn)[1]
-                if searchInlist(varzobj.ncattrs(),'long_name'):
+                    vsname = gen.variables_values(zn)[1]
+                if gen.searchInlist(varzobj.ncattrs(),'long_name'):
                     vlname = varzobj.getncattr('long_name')
                 else:
-                    vlname = variables_values(zn)[4].replace('|',' ')
-                if searchInlist(varzobj.ncattrs(),'units'):
+                    vlname = gen.variables_values(zn)[4].replace('|',' ')
+                if gen.searchInlist(varzobj.ncattrs(),'units'):
                     vunits = varzobj.getncattr('units')
                 else:
-                    vunits = variables_values(zn)[5].replace('|',' ')
+                    vunits = gen.variables_values(zn)[5].replace('|',' ')
     
                 newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -14055,16 +14048,16 @@
             newvar = objofile.createVariable(vnst + 'box', 'f4', ('time','z','y','x'),\
               fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -14093,16 +14086,16 @@
             newvar = objofile.createVariable(vnst + 'circle','f4',('time','z','yr',    \
               'xr'), fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -14290,16 +14283,16 @@
             newvar = objofile.createVariable(vnst + 'box', 'f4', ('time', 'y', 'x'), \
               fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -14328,16 +14321,16 @@
             newvar = objofile.createVariable(vnst + 'circle','f4',('time','yr','xr'),\
               fill_value=fillValue)
-            if searchInlist(varobj.ncattrs(),'standard_name'):
+            if gen.searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(vn)[1]
-            if searchInlist(varobj.ncattrs(),'long_name'):
+                vsname = gen.variables_values(vn)[1]
+            if gen.searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(vn)[4].replace('|',' ')
-            if searchInlist(varobj.ncattrs(),'units'):
+                vlname = gen.variables_values(vn)[4].replace('|',' ')
+            if gen.searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(vn)[5].replace('|',' ')
+                vunits = gen.variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -14491,5 +14484,5 @@
             DT = endT - iniT
             # Python version depending
-            if searchInlist(dir(DT), 'total_seconds'):
+            if gen.searchInlist(dir(DT), 'total_seconds'):
                 diffT = DT.total_seconds()
             else:
@@ -14503,5 +14496,5 @@
         foundclosest = False
         for fn in ncobjs.keys():
-            if searchInlist(ncobjs[fn], dtv):
+            if gen.searchInlist(ncobjs[fn], dtv):
                 istep = ncobjs[fn].index(dtv)
 
@@ -14515,5 +14508,5 @@
                 DT = endT - iniT
                 # Python version depending
-                if searchInlist(dir(DT), 'total_seconds'):
+                if gen.searchInlist(dir(DT), 'total_seconds'):
                     diffitv = np.abs(DT.total_seconds())
                 else:
@@ -14671,5 +14664,5 @@
 # Removing time dimension from the variable dimensions
         Vndims = oVn.dimensions
-        if searchInlist(Vndims, tdim) and Vn != tvdim:
+        if gen.searchInlist(Vndims, tdim) and Vn != tvdim:
             varNOtdimns = []
             varNOtdimvs = []
