Index: trunk/tools/nc_var.py
===================================================================
--- trunk/tools/nc_var.py	(revision 396)
+++ trunk/tools/nc_var.py	(revision 397)
@@ -20,5 +20,6 @@
   'chgtimestep', 'chvarname', 'compute_deaccum', 'compute_opersvarsfiles',           \
   'compute_opervaralltime', 'compute_opervartimes', 'compute_tevolboxtraj',          \
-  'DataSetSection', 'DataSetSection_multidims', 'dimVar_creation', 'fattradd',       \
+  'DataSetSection', 'DataSetSection_multidims', 'dimToUnlimited', 'dimVar_creation', \
+   'fattradd',                                                                       \
   'fdimadd', 'fgaddattr', 'field_stats', 'file_creation', 'file_oper_alongdims',     \
   'filter_2dim',                                                                     \
@@ -121,4 +122,6 @@
 elif oper == 'DataSetSection_multidims':
     ncvar.DataSetSection_multidims(opts.values, opts.ncfile)
+elif oper == 'dimToUnlimited':
+    ncvar.dimToUnlimited(opts.values, opts.ncfile)
 elif oper == 'dimVar_creation':
     ncvar.dimVar_creation(opts.values, opts.ncfile)
Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 396)
+++ trunk/tools/nc_var_tools.py	(revision 397)
@@ -13824,11 +13824,12 @@
 #        newvar[:] = np.zeros(tuple(dsize), dtype=np.float)
     if kind == 'f' or kind == 'f4':
-        newvar = onc.createVariable(varn, 'f4', tuple(dnames))
+        newvar = onc.createVariable(varn, 'f4', tuple(dnames), fill_value=fillValue)
         newvar[:] = np.zeros(tuple(dsize), dtype=np.float)
     elif kind == 'f8':
-        newvar = onc.createVariable(varn, 'f8', tuple(dnames))
+        newvar = onc.createVariable(varn, 'f8', tuple(dnames),                       \
+          fill_value= np.float64(fillValue))
         newvar[:] = np.zeros(tuple(dsize), dtype=np.float64)
     elif kind == 'i':
-        newvar = onc.createVariable(varn, 'i', tuple(dnames))
+        newvar = onc.createVariable(varn, 'i', tuple(dnames), fill_value=-999999)
         newvar[:] = np.zeros(tuple(dsize), dtype=int)
     else:
@@ -13911,11 +13912,12 @@
 #        newvar[:] = np.zeros(tuple(dsize), dtype=np.float)
     if kind == 'f' or kind == 'f4':
-        newvar = onc.createVariable(varn, 'f4', tuple(dnames))
+        newvar = onc.createVariable(varn, 'f4', tuple(dnames), fill_value=fillValue)
         newvar[:] = np.zeros(tuple(dsize), dtype=np.float)
     elif kind == 'f8':
-        newvar = onc.createVariable(varn, 'f8', tuple(dnames))
+        newvar = onc.createVariable(varn, 'f8', tuple(dnames),                       \
+          fill_value=np.float64(fillValue))
         newvar[:] = np.zeros(tuple(dsize), dtype=np.float64)
     elif kind == 'i':
-        newvar = onc.createVariable(varn, 'i', tuple(dnames))
+        newvar = onc.createVariable(varn, 'i', tuple(dnames), fill_value=-99999)
         newvar[:] = np.zeros(tuple(dsize), dtype=int)
     else:
@@ -13934,4 +13936,73 @@
 
 #var_creation('dim1:12,sizes:24|time@time@seconds since 1949-12-01 00:00:00|f4', 'test.nc', 'var2')
+#quit()
+
+def dimToUnlimited(values, ncfile):
+    """ Operation to create an unlimited dimension from an existing one
+      values= Name of the dimension to transform
+      ncfile= name of the file
+    """
+    fname = 'dimToUnlimited'
+
+    if values == 'h':
+        print fname + '_____________________________________________________________'
+        print dimToUnlimited.__doc__
+        quit()
+
+    dimn = values
+
+    ncobj = NetCDFFile(ncfile, 'r')
+    dimnames = ncobj.dimensions.keys()
+    variables = ncobj.variables.keys()
+
+    if not searchInlist(dimnames,dimn):
+        print errormsg
+        print '  ' + fname + ": dimension '" + dimn + "' does not exist in file '" + \
+          ncfile + "' !!"
+        print '    existing ones are:',ncobj.dimensions.keys()
+        quit(-1)
+
+# Creation of a new file
+    newnc = NetCDFFile('new_' + ncfile, 'w')
+
+# Creation of dimensions
+    for dn in dimnames:
+        print 'adding dim:',dn
+        if ncobj.dimensions[dn].isunlimited() or dn == dimn:
+            newdim = newnc.createDimension(dn, None)
+        else:
+            newdim = newnc.createDimension(dn, len(ncobj.dimensions[dn]))
+
+#    ncobj.close()
+    newnc.sync()
+#    newnc.close()
+
+# Adding variables
+    for vn in variables:
+        print 'adding variable:',vn
+        vno = ncobj.variables[vn]
+        vdim = vno.dimensions
+        vtype = vno.dtype
+        varatts = vno.ncattrs()
+
+        if searchInlist(varatts, '_FillValue'):
+            fillv = vno.getncattr('_FillValue')
+            newvar = newnc.createVariable(vn, vtype, vdim, fill_value=fillv)
+        else:
+            newvar = newnc.createVariable(vn, vtype, vdim)
+
+        newvar[:] = vno[:]
+        for nattr in vno.ncattrs():
+            if not nattr == '_FillValue':
+                nattrv = vno.getncattr(nattr)
+                newattr = newvar.setncattr(nattr, nattrv)
+
+# Adding attributes
+    fgaddattr(ncfile, 'new_' + ncfile)
+    sub.call('mv new_' + ncfile + ' ' + ncfile)
+
+    return
+
+#dimToUnlimited('lon', 'test.nc')
 #quit()
 
