Index: trunk/tools/checking_output.py
===================================================================
--- trunk/tools/checking_output.py	(revision 403)
+++ trunk/tools/checking_output.py	(revision 2407)
@@ -1,6 +1,7 @@
-## Python script to check model outputs within a given set of values from an external ASII file
-# L. Fita, LMD. April 2015
+## PyNCplot
+## Python script to check model outputs within a given set of values from an external ASCII file
+# L. Fita, CIMA. March 2019
 ## e.g. # checking_output.py -f histins.nc -v t2m -l 'limitsVariables.inf'
-## e.g. # python checking_output.py -f limit.nc -v SST,ALB -l 'limitsVariables.inf'
+## e.g. # checking_output.py -f limit.nc -v SST,ALB -l 'limitsVariables.inf'
 # NOTE:
 # `nc_var_tools.py' set of python scripts is required
@@ -12,4 +13,5 @@
 from optparse import OptionParser
 import nc_var_tools as ncvar
+import generic_tools as gen
 
 main = 'checking_output.py'
@@ -125,4 +127,18 @@
     print '    >: Error if variable has values bigger than the limit'
     print '    %N: Error if variable has values +/- N % than the limit'
+    print '  Thus each variable is checked by the n-[stats], n-[verifs] by ' 
+    print '    the n-[values] as:'
+    print '    stat[i](varname) verif[i] value[i] i=1, n'
+    print '    e.g. _______'
+    print '    varname min max mean stddev'
+    print '     - < > %10 %10'
+    print '    SST 273. 310. 300. 5.'
+    print '    T2 200. 320. 293. 40.'
+    print ' ------- ------ ----- ---- --- -- - '
+    print '    error if :'
+    print '       min(T2) < 200.'
+    print '       max(T2) > 320.'
+    print '       mean(T2)*0.9 < 293. or mean(T2)*1.1 > 293.'
+    print '       stddev(T2)*0.9 < 40. or stddev(T2)*1.1 > 40.'
     quit()
 
@@ -153,6 +169,8 @@
 
 for line in olval:
-    linevals = ncvar.reduce_spaces(line)
-    if len(linevals) != 0 and linevals[0][0:0] != '#':
+    if len(line) < 2: continue
+    linevals = gen.reduce_spaces(line)
+    print 'Linevals:', linevals[0]
+    if len(linevals) != 0 and linevals[0][0:1] != '#':
 #        print ili,linevals
         if ili == 0:
@@ -171,5 +189,5 @@
 # Checking stats to compute
 for st in stats:
-    if not ncvar.searchInlist(Availablestats,st):
+    if not gen.searchInlist(Availablestats,st):
         print errormsg
         print '  ' + main + ": statistics/value '" + st + "' not ready!!"
@@ -180,5 +198,5 @@
 for st in stats:
     verin = statsverif[st]
-    if not ncvar.searchInlist(Availableverifs,verin[0:1]):
+    if not gen.searchInlist(Availableverifs,verin[0:1]):
         print errormsg
         print '  ' + main + ": verification '" + verin + "' not ready!!"
@@ -232,11 +250,16 @@
     vn = vns[iv]
     print vn + '...'
-    if not ncvar.searchInlist(filevars, vn):
+    if not gen.searchInlist(filevars, vn):
         print errormsg
         print '  ' + main + ": file '" + opts.ncfile + "' does not have variable '" +\
           vn + "' !!"
+        Varns = ncobj.variables.keys()
+        Varns.sort()
+        print '    available ones:', Varns
         quit(-1)
 
-    vals = ncobj.variables[vn][:]
+    ovals = ncobj.variables[vn]
+
+    vals = ovals[:]
     wrongstats = []
     for ist in range(NVals):
@@ -268,11 +291,9 @@
 
             wrongstats.append(stn)
-            if not ncvar.searchInlist(oobj.variables.keys(), vn):
-                oobj.close()
-                ncvar.fvaradd(opts.ncfile + ':' + vn, ofile)
-
-            oobj = NetCDFFile(ofile ,'a')
+            if not oobj.variables.has_key(vn):
+                ncvar.add_vars(ncobj, oobj, [vn])
+
             vobj = oobj.variables[vn]
-            if ncvar.searchInlist(vobj.ncattrs(),('units')):
+            if gen.searchInlist(vobj.ncattrs(),('units')):
                 vunits = vobj.getncattr('units')
             else:
@@ -306,5 +327,5 @@
         if len(wrongstats) != 0: wrongVars[vn] = wrongstats
     newattr = ncvar.set_attribute(vobj, 'wrong',                                     \
-      ncvar.numVector_String(wrongVars[vn], ' '))
+      gen.numVector_String(wrongVars[vn], ' '))
 
     newvar = oobj.createVariable(vn + 'checks', 'f4', ('checks', 'stats'))
