Index: trunk/tools/diagnostics.py
===================================================================
--- trunk/tools/diagnostics.py	(revision 648)
+++ trunk/tools/diagnostics.py	(revision 649)
@@ -77,4 +77,38 @@
 # Mathematical operators
 ##
+def compute_accum(varv, dimns, dimvns):
+    """ Function to compute the accumulation of a variable
+    compute_accum(varv, dimnames, dimvns)
+      [varv]= values to accum (assuming [t,])
+      [dimns]= list of the name of the dimensions of the [varv]
+      [dimvns]= list of the name of the variables with the values of the 
+        dimensions of [varv]
+    """
+    fname = 'compute_accum'
+
+    deacdims = dimns[:]
+    deacvdims = dimvns[:]
+
+    slicei = []
+    slicee = []
+
+    Ndims = len(varv.shape)
+    for iid in range(0,Ndims):
+        slicei.append(slice(0,varv.shape[iid]))
+        slicee.append(slice(0,varv.shape[iid]))
+
+    slicee[0] = np.arange(varv.shape[0])
+    slicei[0] = np.arange(varv.shape[0])
+    slicei[0][1:varv.shape[0]] = np.arange(varv.shape[0]-1)
+
+    vari = varv[tuple(slicei)]
+    vare = varv[tuple(slicee)]
+
+    ac = vari*0.
+    for it in range(1,varv.shape[0]):
+        ac[it,] = ac[it-1,] + vare[it,]
+
+    return ac, deacdims, deacvdims
+
 def compute_deaccum(varv, dimns, dimvns):
     """ Function to compute the deaccumulation of a variable
@@ -761,6 +795,9 @@
 ## MAIN
     #######
-availdiags = ['ACRAINTOT', 'clt', 'cllmh', 'deaccum', 'LMDZrh', 'mslp', 'RAINTOT',   \
+availdiags = ['ACRAINTOT', 'accum', 'clt', 'cllmh', 'deaccum', 'LMDZrh', 'mslp',     \
+  'OMEGAw', 'RAINTOT',   \
   'rvors', 'td', 'turbulence', 'WRFrvors', 'wds', 'wss']
+
+methods = ['accum', 'deaccum']
 
 # Variables not to check
@@ -931,7 +968,9 @@
         depvars = diags[idiag].split('|')[1].split('@')
         if depvars[0] == 'deaccum': diag='deaccum'
+        if depvars[0] == 'accum': diag='accum'
         for depv in depvars:
             if not ncobj.variables.has_key(depv) and not                             \
-              ncvar.searchInlist(NONcheckingvars, depv) and depvars[0] != 'deaccum':
+              ncvar.searchInlist(NONcheckingvars, depv) and                          \
+              not ncvar.searchInlist(methods, depv):
                 print errormsg
                 print '  ' + main + ": file '" + opts.ncfile +                       \
@@ -941,6 +980,7 @@
         depvars = diags[idiag].split('|')[1]
         if not ncobj.variables.has_key(depvars) and not                              \
-          ncvar.searchInlist(NONcheckingvars, depvars) and depvars[0] != 'deaccum':
-            print errormsg
+          ncvar.searchInlist(NONcheckingvars, depvars) and                           \
+          not ncvar.searchInlist(methods, depvars):
+            print errormsg, 'Lluis',methods
             print '  ' + main + ": file '" + opts.ncfile +                           \
               "' does not have variable '" + depvars + "' !!"
@@ -959,5 +999,31 @@
         dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
 
-        ncvar.insert_variable(ncobj, 'acpr', diagout, dnamesvar, dvnamesvar, newnc)
+        ncvar.insert_variable(ncobj, 'pracc', diagout, dnamesvar, dvnamesvar, newnc)
+
+# accum: acumulation of any variable as (Variable, time [as [tunits] 
+#   from/since ....], newvarname)
+    elif diag == 'accum':
+
+        var0 = ncobj.variables[depvars[0]]
+        var1 = ncobj.variables[depvars[1]]
+
+        dnamesvar = var0.dimensions
+        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
+
+        diagout, diagoutd, diagoutvd = compute_accum(var0,dnamesvar,dvnamesvar)
+
+        CFvarn = ncvar.variables_values(depvars[0])[0]
+
+# Removing the flux
+        if depvars[1] == 'XTIME':
+            dtimeunits = var1.getncattr('description')
+            tunits = dtimeunits.split(' ')[0]
+        else:
+            dtimeunits = var1.getncattr('units')
+            tunits = dtimeunits.split(' ')[0]
+
+        dtime = (var1[1] - var1[0])*timeunits_seconds(tunits)
+
+        ncvar.insert_variable(ncobj, CFvarn + 'acc', diagout*dtime, diagoutd, diagoutvd, newnc)
 
 # cllmh with cldfra, pres
