diff --git a/src/scripts/pycompare.py b/src/scripts/pycompare.py index 316199011b682915a738dcb499846afb4ffe2b1f..ec8a5bec9e95e93489b5041d2140b0155268eb61 100755 --- a/src/scripts/pycompare.py +++ b/src/scripts/pycompare.py @@ -343,8 +343,9 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): log_line + "" + c_groups[-1] + "" + c_line[c_ends[-1]:len(c_line) - 2] ) - log_file.write(log_line + "\n") - log_file.write(ref_line) + if ((not config['hide_noise']) or warnings > 0 or errors > 0): + log_file.write(log_line + "\n") + log_file.write(ref_line) else: # The two lines contain a different number of numeric values if (log_file is not None): num_format = "
{0:0%dd}"%num_len
@@ -430,7 +431,10 @@ def mismatch_severities(str_f_values, str_c_values, config):
                         if (fractional <= config['warning_threshold']):
                             result[i] = 2
                         else:
-                            result[i] = 3
+                            if (log_f_value > config['data_order']):
+                                result[i] = 3
+                            else:
+                                result[i] = 1
                     else:
                         result[i] = 1
                 else: # f_values[i] == 0 and c_values[i] != 0
@@ -443,7 +447,10 @@ def mismatch_severities(str_f_values, str_c_values, config):
                         if (fractional <= config['warning_threshold']):
                             result[i] = 2
                         else:
-                            result[i] = 3
+                            if (log_c_value > config['data_order']):
+                                result[i] = 3
+                            else:
+                                result[i] = 1
                     else:
                         result[i] = 1
         # End number comparison
@@ -460,25 +467,40 @@ def mismatch_severities(str_f_values, str_c_values, config):
 #  \returns config: `dict` A dictionary containing the script configuration.
 def parse_arguments():
     config = {
-        'fortran_file_name': '',
         'c_file_name': '',
+        'check_all': True,
+        'data_order': -99.0,
+        'fortran_file_name': '',
         'full_log': False,
+        'help_mode': False,
+        'hide_noise': False,
+        'html_output': 'pycompare.html',
         'linewise': True,
         'log_html': False,
-        'html_output': 'pycompare.html',
         'say_progress': True,
         'warning_threshold': 0.005,
-        'help_mode': False,
-        'check_all': True,
     }
+    arg_index = 1
+    skip_arg = False
     for arg in argv[1:]:
+        if skip_arg:
+            skip_arg = False
+            continue
         split_arg = arg.split("=")
         if (arg.startswith("--ffile")):
-            config['fortran_file_name'] = split_arg[1]
+            config['fortran_file_name'] = argv[arg_index + 1]
+            arg_index += 1
+            skip_arg = True
         elif (arg.startswith("--cfile")):
-            config['c_file_name'] = split_arg[1]
+            config['c_file_name'] = argv[arg_index + 1]
+            arg_index += 1
+            skip_arg = True
+        elif (arg.startswith("--data-order")):
+            config['data_order'] = float(split_arg[1])
         elif (arg.startswith("--full")):
             config['full_log'] = True
+        elif (arg.startswith("--hide-noise")):
+            config['hide_noise'] = True
         elif (arg.startswith("--html")):
             config['log_html'] = True
             if (len(split_arg) == 2):
@@ -495,6 +517,7 @@ def parse_arguments():
             config['check_all'] = False
         else:
             raise Exception("Unrecognized argument \'{0:s}\'".format(arg))
+        arg_index += 1
     return config
 
 ## \brief Print a command-line help summary.
@@ -507,10 +530,12 @@ def print_help():
     print("Usage: \"./pycompare.py OPTIONS\"           ")
     print("                                            ")
     print("Valid options are:                          ")
-    print("--ffile=FORTRAN_OUTPUT    File containing the output of the FORTRAN code (mandatory).")
-    print("--cfile=C++_OUTPUT        File containing the output of the C++ code (mandatory).")
+    print("--ffile FORTRAN_OUTPUT    File containing the output of the FORTRAN code (mandatory).")
+    print("--cfile C++_OUTPUT        File containing the output of the C++ code (mandatory).")
+    print("--data-order=ORDER        Consider data only down to specified order (default order is -99).")
     print("--full                    Print all lines to log file (default prints only mismatches).")
     print("--help                    Print this help and exit.")
+    print("--hide-noise              Hide noise in reports (default is to show it).")
     print("--html[=OPT_OUTPUT_NAME]  Enable logging to HTML file (default logs to \"pycompare.html\").")
     print("--linewise                Load only one line at a time. Useful to compare big files (True by default).")
     print("--no-progress             Disable progress logging.")