Copy sort-check from src/sorting/main.c to assignments/archive/sorting/soln/main.c.
authorW. Trevor King <wking@drexel.edu>
Fri, 29 Oct 2010 15:42:46 +0000 (11:42 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 29 Oct 2010 15:42:46 +0000 (11:42 -0400)
assignments/archive/sorting/soln/main.c

index 0810318ab6ec3a51ed527e80bf92095325806789..9bcb2195e4fda89d3b09e3ca3221d82d152b526a 100644 (file)
@@ -320,6 +320,14 @@ void master(int rank, int size, const char *file_name)
        printarray(stderr, array_size, array, NUM_SHOWN);
        fprintf(stderr, "check: sum of %d elements = %g\n",
                array_size, checkarray(array_size, array));
+       for (i = 0; i < array_size - 1; i++) {
+               if (array[i] > array[i + 1]) {
+                       fprintf(stderr,
+                               "error: sorted array[%d] = %g > %g = array[%d]\n",
+                               i, array[i], array[i + 1], i + 1);
+                       exit(EXIT_FAILURE);
+               }
+       }
 #endif                         /* DEBUG */
 
 #ifdef DEBUG_TIMING