Index: /tags/ipp-20110218/Ohana/src/dvomerge/src/dvoverify.c
===================================================================
--- /tags/ipp-20110218/Ohana/src/dvomerge/src/dvoverify.c	(revision 31099)
+++ /tags/ipp-20110218/Ohana/src/dvomerge/src/dvoverify.c	(revision 31100)
@@ -14,4 +14,6 @@
 
 int VERBOSE;
+int CHECKSORTED;
+int NNotSorted = 0;
 
 int main (int argc, char **argv) {
@@ -31,4 +33,9 @@
     remove_argument (N, &argc, argv);
   }
+  if ((N = get_argument (argc, argv, "-s"))) {
+    CHECKSORTED = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
 
   // restrict to a portion of the sky
@@ -50,5 +57,5 @@
 
   if (argc != 2) {
-    fprintf (stderr, "USAGE: dvoverify (catdir) [-region Rmin Rmax Dmin Dmax]\n");
+    fprintf (stderr, "USAGE: dvoverify (catdir) [-region Rmin Rmax Dmin Dmax] [-v -s]\n\n -v = verbose \n -s = checks if sorted, return error if not\n");
     fprintf (stderr, "  catdir : database of interest\n");
     exit (2);
@@ -89,5 +96,5 @@
   for (i = 0; i < inlist[0].Nregions; i++) {
     if (!inlist[0].regions[i][0].table) continue;
-
+    if ((NNotSorted > 0) && CHECKSORTED) continue;
     if (i % 1000 == 0) fprintf (stderr, ".");
 
@@ -115,4 +122,8 @@
     fprintf (stderr, "ERROR: %d files are bad\n", Nbad);
     exit (1);
+  }
+  if ((NNotSorted > 0) && CHECKSORTED) {
+    fprintf (stderr, "ERROR: files are not sorted\n");
+     exit (1);
   }
 
@@ -267,4 +278,6 @@
     dvo_catalog_unlock (&catalog);
     dvo_catalog_free (&catalog);
+    NNotSorted++;
+    if (VERBOSE) fprintf (stderr, "file is not sorted: %s\n", filename);
     return TRUE;
   }
