def run_checker(): # get environment variables env = read_environ() verbose = int(env['VERBOSE']) rundir = env['RUNDIR'] log_output = env['LOGFILE'] icon = str_to_bool(env['ICON']) # construct stdout filename working_dir = dir_path(rundir).replace("./", "", 1) logfile = os.path.join(working_dir, log_output) if icon: patterns = [ # Class/Type Name RegularExpression OccurrenceCrashPattern( "Cleanup pattern", "0") ] else: patterns = [ # Class/Type Name RegularExpression WarningPattern( "CFL pattern", "CFL" ), OccurrenceCrashPattern( "Cleanup pattern", "(.*)^(.*)CLEAN(\s*)UP(.*)" ) ] cosmo_filechecker = FileChecker(verbose) cosmo_filechecker.add_pattern_list(patterns) return cosmo_filechecker.check(logfile, verbose)
def check(): # get name of myself myname = os.path.basename(__file__) header = myname + ': ' # get environment variables env = read_environ() verbose = int(env['VERBOSE']) rundir = dir_path(env['RUNDIR']) refoutdir = dir_path(env['REFOUTDIR']) switch = env['DT_FILE'] tune_thresholds = env['TUNE_THRESHOLDS'] if (str_to_bool(tune_thresholds)): print( "WARNING: Skipped as identical checker as it isn't usable while tuning thresholds" ) return 15 #SKIP # defines the 2 file that belongs logically to the checker yufile1 = rundir + yufile yufile2 = refoutdir + yufile if switch: # extract timestep nlfile = switch # namelist file containing dt try: dt = get_param(rundir + nlfile, 'dt') assert (dt != '') dt = float(dt) except: if verbose: print(header + 'failed to extract dt from ' + rundir + nlfile) return 20 # FAIL # define tolerances for comparing YUPRTEST files nts = [maxsize] tols = [0.0] tas = [0.0] try: # check for bit identical results if verbose > 1: print(header + 'Checking if results are bit identical') if verbose > 2: print(header + 'comp_yuprtest()') print(header + ' file1 = ' + yufile1) print(header + ' file2 = ' + yufile2) print(header + ' minval = ' + str(-1)) print(header + ' nts = [%s]' % ','.join(map(str, nts))) print(header + ' tols = [%s]' % ','.join(map(str, tols))) print(header + ' tas = [%s]' % ','.join(map(str, tas))) error_count = comp_yuprtest.cmp_(yufile1, yufile2, 0, -1, nts, tols, tas) if verbose > 1: if error_count == 0: print(header + 'Results are bit identical') else: print(header + 'Results are not bit identical') except RuntimeError as e: if verbose: print(e) return 20 # FAIL if error_count: return 20 # FAIL else: return 0 # MATCH
def check(): # get name of myself myname = os.path.basename(__file__) header = myname + ': ' # get environment variables env = read_environ() verbose = int(env['VERBOSE']) rundir = dir_path(env['RUNDIR']) refoutdir = dir_path(env['REFOUTDIR']) namelistdir = dir_path(env['NAMELISTDIR']) switch = env['DT_FILE'] tolerance = env['TOLERANCE'] forcematch = int(env['FORCEMATCH']) == 1 tune_thresholds = str_to_bool(env['TUNE_THRESHOLDS']) # defines the 2 file that belongs logically to the checker yufile1 = rundir + yufile yufile2 = refoutdir + yufile if not switch: # no need to extract timestep and to check output lists nlfile = env['NL_TS_SWITCH'] else: nlfile = 'INPUT_IO' # namelist file containing yuswitch nlfile2 = 'INPUT_ORG' # namelist file containing dt # extract timestep try: dt = get_param(rundir + nlfile2, 'dt') assert (dt != '') dt = float(dt) except: if verbose: print(header + 'failed to extract dt from ' + rundir + nlfile2) return 20 # FAIL # check for output lists try: nout_list = get_param(rundir + nlfile, lnout) assert (nout_list != '') nout_list = int(nout_list) except: if verbose: print(header + 'no output lists in ' + rundir + nlfile) return 20 # FAIL # check if special testsuite output was activated in every output list yuswitch_value = get_param(rundir + nlfile, yuswitch, occurrence=nout_list) assert (yuswitch_value != '') if yuswitch_value in ['.FALSE.', '.false.']: if verbose: print(yuswitch + ' is set to .false. in ' + rundir + nlfile + ' for this simulation') return 20 # FAIL #check if tolerance file exists in namelistdir tolerance_path = namelistdir + tolerance if os.path.exists(tolerance_path): tolerance_file = tolerance_path #in namelist dir ltol_file = True else: tolerance_file = '' ltol_file = False # Create Thresholds object thres = """ minval = 1e-12 steps = 1 20 60 100 * = 1.00e-7 1.00e-4 1.00e-06 1.00e-02 """ threshold = ts_thresholds.Thresholds(thres) threshold_var = '*' # define tolerances for comparing YUCHKDAT files # Use tolerance file if exists if ltol_file: if verbose == 2: print(header + 'Using tolerance values from file') elif verbose > 2: print(header + 'Using tolerance values from file ' + tolerance_file) try: threshold = ts_thresholds.Thresholds(tolerance_file) if "CHKDAT" in threshold.variables: threshold_var = "CHKDAT" except: if verbose: print(header + 'Error while reading ' + tolerance_file) print( header + 'Cannot read one of the following parameter: tol_times,tol_out,minval' ) return 20 # FAIL # Identical thresholds thres = """ minval = 0.0 steps = 0 * = 0 """ threshold_identical = ts_thresholds.Thresholds(thres) # Override the tolerances in case FORCEMATCH is enabled if forcematch: threshold = threshold_identical try: # check for bit identical results if verbose > 1: print(header + 'Checking first if results are bit identical') err_count_identical = ts_yuchdat.compare(yufile1, yufile2, threshold_identical, threshold_var, v_level=-1) if verbose > 1: if err_count_identical == 0: print(header + 'Results are bit identical') else: print(header + 'Results are not bit identical') # check if results are within tolerance values if verbose > 1: print(header + 'Checking if results are within tolerance') error_count = ts_yuchdat.compare(yufile1, yufile2, threshold, threshold_var, tune_thresholds, v_level=0) if (tune_thresholds): threshold.to_file(tolerance_path) if verbose > 1: if error_count == 0: print(header + 'Results are within thresholds') else: print(header + 'Results are not within thresholds') except Exception as e: if verbose: print(e) return 20 # FAIL if err_count_identical == 0: return 0 # MATCH elif error_count == 0: return 10 # OK else: return 20 # FAIL
def check(): # get name of myself myname = os.path.basename(__file__) header = myname+': ' # get environment variables env = read_environ() verbosity = int(env['VERBOSE']) rundir = dir_path(env['RUNDIR']) refoutdir = dir_path(env['REFOUTDIR']) namelistdir = dir_path(env['NAMELISTDIR']) tolerance = env['TOLERANCE'] switch = env['NL_TS_SWITCH'] forcematch = int(env['FORCEMATCH']) == 1 tune_thresholds = str_to_bool(env['TUNE_THRESHOLDS']) tune_times = int(env['TUNING_ITERATIONS']) reset_thresholds = str_to_bool(env['RESET_THRESHOLDS']) #check if namelist file with switch exists in namelistdir switch_path = namelistdir + switch if not os.path.exists(switch_path): if verbosity>0: print header + "unable to find namelist file with switch in " + switch_path return 20 # FAIL # defines the 1 file that belongs logically to the checker yufile1 = rundir + yufile yufile2 = refoutdir + yufile # check if special testsuite output was activated if get_param(rundir+switch, yuswitch) in ['.FALSE.', '.false.']: if verbosity: print yuswitch +' is set to .false. in '+ rundir + switch +' for this simulation' return 20 # FAIL #check if tolerance file exists in namelistdir or type dir tolerance_path = namelistdir + tolerance # The forcematch option gives precedence over the tolerance file if forcematch: thresh = """ minval = 0.0 steps = {maxsteps} * = 0.0""".format(maxsteps=maxsize) elif os.path.exists(tolerance_path): thresh=tolerance_path #in namelist dir else: if verbosity>0: print header + "unable to find tolerance file at " + tolerance return 20 # FAIL try: c = Compare(yufile1, yufile2, thresh) if reset_thresholds: c.reset_thresholds() if tune_thresholds: c.update_thresholds() c.write_threshold_to_file(tolerance_path) result = c.compare_data() if (verbosity > 1) or (result >= 2): print(header) c.print_results() elif verbosity > 1: print(header) except Exception as e : traceback.print_exc(file=sys.stdout) print(header + str(e)) return 30 # CRASH if (result == 0): if verbosity>1: print header + "Results are within the thresholds and bit identical" return 0 # MATCH if (result == 1): if verbosity>1: print header + "Results are within thresholds, but are not bit identical" return 10 # OK if (result == 2): if verbosity>1: print header + "Some or all Results are not within thresholds" return 20 # FAIL