Index: branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/cmpsww.py
===================================================================
--- branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/cmpsww.py	(revision 7148)
+++ branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/cmpsww.py	(revision 7149)
@@ -228,15 +228,20 @@
     #####
 
+    error_msg = ''
+    glob_vars_bad = {}
+    data_vars_bad = {}
+
     # check values of global attributes
     for glob_name in globals:
         if getattr(fid1, glob_name) != getattr(fid2, glob_name):
-            error_msg += ("\nFiles differ in global '%s':\n"
-                          "%s: '%s',\n"
-                          "%s: '%s'\n"
-                          % (glob_name, filename1, str(g1), filename2, str(g2)))
+            print("\nFiles differ in global '%s':\n"
+                  "%s: '%s',\n"
+                  "%s: '%s'"
+                  % (glob_name, filename1, str(g1), filename2, str(g2)))
+            glob_vars_bad[glob_name] = glob_vars_bad.get(glob_name, 0) + 1
             error = True
 
     # check data variables, be clever with time series data
-    max_difference = -1
+    max_rel_difference = -1
     diff_count = 0
     for var_name in variables:
@@ -254,16 +259,28 @@
                                             rtol=rel_tolerance,
                                             atol=abs_tolerance):
+                            abs_difference = num.abs(var1[i]-var2[i])
+                            max_a_b = num.max(num.abs(var1[i]),
+                                              num.abs(var2[i]))
+                            rel_difference = num.abs(abs_difference/max_a_b)
+
                             if not quiet:
-                                error_msg += ('\nFiles differ in variable '
-                                                  '%s[%d,%d]:\n'
-                                              '%s: %f\n'
-                                              '%s: %f\n'
-                                              'difference=%e\n'
-                                              % (var_name, t, i,
-                                                 filename1, var1[i],
-                                                 filename2, var2[i],
-                                                 num.abs(var1[i]-var2[i])))
-                            max_difference = max(max_difference,
-                                                 num.abs(var1[i]-var2[i]))
+                                print('\nFiles differ in variable '
+                                      '%s[%d,%d]:\n'
+                                      '%s: %f\n'
+                                      '%s: %f\n'
+                                      'abs. difference=%e, rel. difference=%e\n'
+                                      % (var_name, t, i,
+                                         filename1, var1[i],
+                                         filename2, var2[i],
+                                         abs_difference,
+                                         rel_difference))
+
+                            if rel_difference > max_rel_difference:
+                                max_rel_difference = rel_difference
+                                max_rel_difference_abs = abs_difference
+                                max_rel_difference_a = var1[i]
+                                max_rel_difference_b = var2[i]
+
+                            data_vars_bad[var_name] = data_vars_bad.get(var_name, 0) + 1
                             diff_count += 1
         else:
@@ -276,16 +293,28 @@
                     if not num.allclose(var1[j], var2[j],
                                           rtol=rel_tolerance, atol=abs_tolerance):
+                        abs_difference = num.abs(var1[j]-var2[j])
+                        max_a_b = num.max(num.abs(var1[j]),
+                                          num.abs(var2[j]))
+                        rel_difference = num.abs(abs_difference/max_a_b)
+
                         if not quiet:
-                            error_msg += ('\nFiles differ in variable '
-                                          '%s[%d]:\n'
-                                          '%s: %f\n'
-                                          '%s: %f\n'
-                                          'difference=%e\n'
-                                           % (var_name, j,  
-                                              filename1, var1[j],
-                                              filename2, var2[j],
-                                              num.abs(var1[j]-var2[j])))
-                        max_difference = max(max_difference,
-                                             num.abs(var1[i]-var2[i]))
+                            print('\nFiles differ in variable '
+                                  '%s[%d]:\n'
+                                  '%s: %f\n'
+                                  '%s: %f\n'
+                                  'abs. difference=%e, rel. difference=%e\n'
+                                   % (var_name, j,  
+                                      filename1, var1[j],
+                                      filename2, var2[j],
+                                      abs_difference,
+                                      rel_difference))
+
+                        if rel_difference > max_rel_difference:
+                            max_rel_difference = rel_difference
+                            max_rel_difference_abs = abs_difference
+                            max_rel_difference_a = var1[j]
+                            max_rel_difference_b = var2[j]
+
+                        data_vars_bad[var_name] = data_vars_bad.get(var_name, 0) + 1
                         diff_count += 1
                 error = True
@@ -300,6 +329,12 @@
     if error:
         error_msg += ('\nNumber of data differences=%d\n'
-                      'Maximum data difference=%e\n'
-                      % (diff_count, max_difference))
+                      'Maximum relative data difference=%e\n'
+                      'associated absolute difference=%e\n'
+                      "associated 'a' value=%e\n"
+                      "associated 'b' value=%e\n"
+                      % (diff_count, max_rel_difference, max_rel_difference_abs,
+                         max_rel_difference_a, max_rel_difference_b))
+        error_msg += ('\nglob_vars bad=%s\n' % str(glob_vars_bad))
+        error_msg += ('\ndata_vars bad=%s\n' % str(data_vars_bad))
         raise RuntimeError, error_msg
 
