Changeset 2214


Ignore:
Timestamp:
09/03/21 11:44:11 (3 months ago)
Author:
jderouillat
Message:

Introduce a tolerance threshold in XIOS_COUPLING test suite (moving from cdo diff to a Python comparison, especially to compare results of different compilers)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/xios_test_suite/TEST_SUITE/step2.py

    r2210 r2214  
    77import copy 
    88 
     9import netCDF4 
     10from netCDF4 import Dataset 
     11import numpy as np 
    912 
    1013mode=os.getenv("mode") 
     
    8285                for checkfile in checkfiles: 
    8386                    if os.path.exists(config+"/"+checkfile) and os.path.exists("reference/ref_"+config+"/"+checkfile): 
    84                         OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+"  2>&1 |grep -v 'Found more than one time variable'|grep -v 'cdo diffn: Processed'|grep -v 'cdo    diffn: Processed'|grep -v 'Time variable >time_counter< not found!' > diff_"+checkfile+".txt") 
    85                         if os.stat("diff_"+checkfile+".txt").st_size==0: # if no diff -> set 0 
    86                             report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n") 
    87                         else: # if cdo diffn returns diff -> set -1 
    88                             report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(-1)+"\n") 
     87                        #OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+"  2>&1 |grep -v 'Found more than one time variable'|grep -v 'cdo diffn: Processed'|grep -v 'cdo    diffn: Processed'|grep -v 'Time variable >time_counter< not found!' > diff_"+checkfile+".txt") 
     88                        #if os.stat("diff_"+checkfile+".txt").st_size==0: # if no diff -> set 0 
     89                        #    report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n") 
     90                        #else: # if cdo diffn returns diff -> set -1 
     91                        #    report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(-1)+"\n") 
     92                        ref = Dataset( "reference/ref_"+config+"/"+checkfile ) 
     93                        res = Dataset( config+"/"+checkfile ) 
     94                        validated = 1 
     95                        for var in res.variables: 
     96                            if (not (var.startswith('lon_'))) and (not (var.startswith('lat_'))) and (not (var.startswith('time_'))): 
     97                                ref_interp = ref.variables[var] 
     98                                ref_array = ref_interp[:] 
     99                                res_interp = res.variables[var] 
     100                                res_array = res_interp[:] 
     101                                diff = (ref_array-res_array)/ref_array 
     102                                if ( np.max(np.abs(diff)) >  2*10**-3 ): 
     103                                    print( var,  ", max relative error : ", np.max(diff) ) 
     104                                    validated = -1 
     105                        report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(validated)+"\n") 
    89106 
    90107                    elif os.path.exists(config+"/"+checkfile): # if no ref file -> set 0 
Note: See TracChangeset for help on using the changeset viewer.