From 157d4a7ff67f168aeabe77985a126f560e6ff571 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 29 Oct 2010 11:42:46 -0400 Subject: [PATCH] Copy sort-check from src/sorting/main.c to assignments/archive/sorting/soln/main.c. --- assignments/archive/sorting/soln/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assignments/archive/sorting/soln/main.c b/assignments/archive/sorting/soln/main.c index 0810318..9bcb219 100644 --- a/assignments/archive/sorting/soln/main.c +++ b/assignments/archive/sorting/soln/main.c @@ -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 -- 2.26.2