Index: /anuga_core/source/anuga/shallow_water/data_manager.py
===================================================================
--- /anuga_core/source/anuga/shallow_water/data_manager.py	(revision 5538)
+++ /anuga_core/source/anuga/shallow_water/data_manager.py	(revision 5539)
@@ -5059,7 +5059,5 @@
         permutation = ensure_numeric([int(line.split(',')[0]) for line in ordering_lines])
     else:
-        # Use empty array to signify 'all' points
-        # We could have used 'None' but it got too hard in the C-code ;-)
-        permutation = ensure_numeric([], Float)
+        permutation = None
 
                 
Index: /anuga_core/source/anuga/shallow_water/test_data_manager.py
===================================================================
--- /anuga_core/source/anuga/shallow_water/test_data_manager.py	(revision 5538)
+++ /anuga_core/source/anuga/shallow_water/test_data_manager.py	(revision 5539)
@@ -6719,5 +6719,5 @@
         
         
-    def test_urs2sts_ordering_exception(self):
+    def Xtest_urs2sts_ordering_exception(self):
         """Test that inconsistent lats and lons in ordering file are caught.
         """
@@ -8940,6 +8940,6 @@
 if __name__ == "__main__":
 
-    #suite = unittest.makeSuite(Test_Data_Manager,'test')
-    suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_read_mux2_pyI')
+    suite = unittest.makeSuite(Test_Data_Manager,'test')
+    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_read_mux2_pyI')
     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts')
     #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section_with_geo')
@@ -8955,5 +8955,5 @@
     else:
         pass
-    runner = unittest.TextTestRunner(verbosity=2)
+    runner = unittest.TextTestRunner() #verbosity=2)
     runner.run(suite)
 
Index: /anuga_core/source/anuga/shallow_water/urs_ext.c
===================================================================
--- /anuga_core/source/anuga/shallow_water/urs_ext.c	(revision 5538)
+++ /anuga_core/source/anuga/shallow_water/urs_ext.c	(revision 5539)
@@ -32,5 +32,5 @@
 		   float *weights, 
 		   double *params, 
-		   int number_of_selected_stations,
+		   int *number_of_stations,
 		   int *permutation,
 		   int verbose);
@@ -43,7 +43,8 @@
 
     NOTE:
-    A Python int is equivalent to a C long
+    A Python int is equivalent to a C long (this becomes really important on 64 bit architectures)
     A Python double corresponds to a C double
     */
+    
     PyObject *filenames;
     PyArrayObject *pyweights;
@@ -71,6 +72,4 @@
     int num_ts;
     
-    //printf("Checkpoint 1 for urs2sts_ext.c\n");
-
     // Convert Python arguments to C
     if (!PyArg_ParseTuple(args, "iOOOOi",
@@ -110,27 +109,18 @@
     if (muxFileNameArray == NULL) 
     {
-        printf("ERROR: Memory for muxFileNameArray could not be allocated.\n");
-        return NULL;
-    }
-
-    printf("Checkpoint 2 for urs2sts_ext.c\n");    
-    //printf("numSrc = %d\n", numSrc);
+        PyErr_SetString(PyExc_ValueError, "ERROR: Memory for muxFileNameArray could not be allocated.");
+        return NULL;
+    }
+
     for (i = 0; i < numSrc; i++)
     {
 
-        //printf("check 2.1, i=%d\n", i);         
         fname = PyList_GetItem(filenames, i);
-        //printf("check 2.2\n");                  
         if (!fname) 
         {
-          //printf("error\n");          
             PyErr_SetString(PyExc_ValueError, "filename not a string");
             return NULL;
         }       
-        //printf("check 2.3\n");          
-        //printf("fname = %s\n", PyString_AsString(fname));
-        
-        
-        //printf("check 2.4\n");  
+
         muxFileNameArray[i] = PyString_AsString(fname);
         if (muxFileNameArray[i] == NULL) 
@@ -142,5 +132,4 @@
     }
 
-    //printf("Checkpoint 3 for urs2sts_ext.c\n");        
     if (file_params->nd != 1 || file_params->descr->type_num != PyArray_DOUBLE) 
     {
@@ -150,5 +139,5 @@
     }
 
-    printf("Checkpoint 4 for urs2sts_ext.c\n");        
+
     // Create array for weights which are passed to read_mux2
     weights = (float*) malloc(numSrc*sizeof(float));
@@ -158,7 +147,6 @@
     }
     
-   
     number_of_selected_stations = (int) permutation->dimensions[0];
-    printf("Checkpoint 5 for urs2sts_ext.c\n");        
+
     // Read in mux2 data from file
     cdata = _read_mux2(numSrc, 
@@ -166,5 +154,5 @@
                        weights, 
                        (double*)file_params->data,
-		       number_of_selected_stations, // Desired number of stations
+		       &number_of_selected_stations, // Desired number of stations
 		       (int*) permutation->data, // Ordering of selected stations
                        verbose);
@@ -177,5 +165,4 @@
 		       
 		       
-    //printf("Checkpoint 6 for urs2sts_ext.c\n");                
     // Allocate space for return vector
     nsta0 = (int)*(double*)(file_params->data + 0*file_params->strides[0]);
@@ -183,5 +170,4 @@
     nt = (int)*(double*)(file_params->data + 2*file_params->strides[0]);
 
-    printf("Checkpoint 7 for urs2sts_ext.c\n");                    
     
     // Find min and max start times of all gauges
@@ -190,6 +176,6 @@
     for (i = 0; i < number_of_selected_stations; i++)
     {
-        printf("cdata[%d] start = %f\n", i, (double) cdata[i][nt+3]);
-        printf("cdata[%d] finish = %f\n", i, (double) cdata[i][nt+4]);	
+        //printf("cdata[%d] start = %f\n", i, (double) cdata[i][nt+3]);
+        // printf("cdata[%d] finish = %f\n", i, (double) cdata[i][nt+4]);	
 	
         if ((int)cdata[i][nt + 3] < start_tstep)
@@ -203,5 +189,4 @@
     }
 
-    printf("Checkpoint 8 for urs2sts_ext.c\n");                        
     if ((start_tstep > nt) | (finish_tstep < 0))
     {
@@ -229,5 +214,5 @@
     }
 
-    printf("Checkpoint 9 for urs2sts_ext.c\n");                            
+    
     // Each gauge begins and ends recording at different times. When a gauge is
     // not recording but at least one other gauge is. Pad the non-recording gauge
@@ -242,5 +227,5 @@
                 if (it + 1 > (int)cdata[i][nt + 4])
                 {
-                    //This gauge has stopped recording but others are still recording
+                    // This gauge has stopped recording but others are still recording
                     *(double*)(pydata->data + i*pydata->strides[0] + time*pydata->strides[1]) = 0.0;
                 }
@@ -259,5 +244,4 @@
     }
 
-    printf("Checkpoint 10 for urs2sts_ext.c\n");                                
     free(weights);
     
@@ -272,5 +256,4 @@
     free(cdata);
 
-    printf("Checkpoint 11 for urs2sts_ext.c\n");                                    
     return  PyArray_Return(pydata);
 }
@@ -280,5 +263,5 @@
                    float *weights, 
                    double *params, 
-		   int number_of_selected_stations,
+		   int *number_of_stations,
 		   int *permutation,
                    int verbose)
@@ -290,4 +273,5 @@
     int istart, istop;
     int *fros=0, *lros=0;
+    int number_of_selected_stations;
     char susMuxFileName;
     float *muxData;
@@ -328,5 +312,4 @@
     }
 
-    printf("P1\n");
     /* Loop over all sources, read headers and check compatibility */
     for (isrc = 0; isrc < numSrc; isrc++)
@@ -406,5 +389,4 @@
     }
 
-    printf("P2\n");    
     params[0] = (double)nsta0;
     params[1] = (double)mytgs0[0].dt;
@@ -413,11 +395,12 @@
     // Apply rule that an empty permutation file means 'take all stations'
     // We can change this later by passing in None instead of the empty permutation.
-    
-    printf("number_of_selected_stations B4 = %d\n", number_of_selected_stations);    
+
+        
+    number_of_selected_stations = *number_of_stations;	
     if (number_of_selected_stations == 0)
     {
         number_of_selected_stations = nsta0;  
+	*number_of_stations = nsta0;     // Return possibly updated number of stations
       
-	printf("Creating identity permutation vector of length = %d\n", nsta0);
         // Create the Identity permutation vector
         permutation = (int *) malloc(number_of_selected_stations*sizeof(int));
@@ -426,9 +409,8 @@
 	  permutation[i] = i;  
         }
-      
-    }
-    
-    printf("P3\n");        
-    printf("Number of selected stations = %d\n", number_of_selected_stations);
+    }
+    
+    
+    
     /* Make array(s) to hold demuxed data for stations given in the permutation file */
     sts_data = (float**)malloc(number_of_selected_stations*sizeof(float*));
@@ -439,11 +421,8 @@
     }
 
-    printf("P4\n");            
     // For each selected station, allocate space for its data
     len_sts_data = mytgs0[0].nt + POFFSET; // Max length of each timeseries (I think)
     for (i = 0; i < number_of_selected_stations; i++)
     {
-        printf("P4.1, i=%d\n", i);                
-    
         // Initialise sts_data to zero
         sts_data[i] = (float*)calloc(len_sts_data, sizeof(float));
@@ -454,10 +433,6 @@
         }
 
-	
-	printf("P4.2, i=%d\n", i);                	
 	ista = permutation[i]; // Get global index into mux data
 	
-
-	printf("P4.3, i=%d\n", i);                	
         sts_data[i][mytgs0[0].nt] = (float)mytgs0[ista].geolat;
         sts_data[i][mytgs0[0].nt + 1] = (float)mytgs0[ista].geolon;
@@ -466,6 +441,5 @@
         sts_data[i][mytgs0[0].nt + 4] = (float)lros[ista];
     }
-
-    printf("P5\n");                
+    
     temp_sts_data = (float*)calloc(len_sts_data, sizeof(float));
 
@@ -480,5 +454,4 @@
         if((fp = fopen(muxFileName, "r")) == NULL)
         {
-            //fprintf(stderr, "%s: cannot open file %s\n", av[0], muxFileName);
             fprintf(stderr, "cannot open file %s\n", muxFileName);
 	    return NULL;   		    	    
@@ -524,5 +497,4 @@
                 {
                     sts_data[i][k] += temp_sts_data[k] * weights[isrc];
-                    //printf("%d,%d,%f\n",ista,k,sts_data[ista][k]);
                 }
                 else
@@ -534,5 +506,4 @@
     }
 
-    printf("P6\n");                    
     free(muxData);
     free(temp_sts_data);
