Index: /trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/distribute_mesh.py	(revision 8544)
+++ /trunk/anuga_core/source/anuga_parallel/distribute_mesh.py	(revision 8545)
@@ -65,5 +65,5 @@
     # Find the new ordering of the triangles
 
-    for i in range(N):
+    for i in xrange(N):
         bin = tri_index[i][0]
         bin_off_set = tri_index[i][1]
@@ -133,5 +133,5 @@
     
     proc_sum = []
-    for i in range(n_procs):
+    for i in xrange(n_procs):
         tri_list.append([])
         triangles_per_proc.append(0)
@@ -168,5 +168,5 @@
         
         triangles = []        
-        for i in range(n_tri):
+        for i in xrange(n_tri):
             triangles_per_proc[epart[i]] = triangles_per_proc[epart[i]] + 1
             tri_list[epart[i]].append(domain.triangles[i])
@@ -178,5 +178,5 @@
         # i+1
 
-        for i in range(n_procs):
+        for i in xrange(n_procs):
             for t in tri_list[i]:
                 triangles.append(t)
@@ -186,5 +186,5 @@
 
         proc_sum[0] = 0
-        for i in range(n_procs - 1):
+        for i in xrange(n_procs - 1):
             proc_sum[i+1]=proc_sum[i]+triangles_per_proc[i]
 
@@ -219,5 +219,5 @@
 
     ttriangles = num.zeros((len(triangles), 3), num.int)
-    for i in range(len(triangles)):
+    for i in xrange(len(triangles)):
         ttriangles[i] = triangles[i]
 
@@ -290,5 +290,5 @@
     # Loop over processors
 
-    for p in range(nproc):
+    for p in xrange(nproc):
 
         # Find triangles on processor p
@@ -375,12 +375,13 @@
         
         n = mesh.neighbours[t, 0]
-
         if n >= 0:
             if n < tlower or n >= tupper:
                 trianglemap[n] = 1
+
         n = mesh.neighbours[t, 1]
         if n >= 0:
             if n < tlower or n >= tupper:
                 trianglemap[n] = 1
+
         n = mesh.neighbours[t, 2]
         if n >= 0:
@@ -394,12 +395,15 @@
         for t in range(len(trianglemap)):
             if trianglemap[t]==i+1:
+
                 n = mesh.neighbours[t, 0]
                 if n >= 0:
                     if (n < tlower or n >= tupper) and trianglemap[n] == 0:
                         trianglemap[n] = i+2
+
                 n = mesh.neighbours[t, 1]
                 if n >= 0:
                     if (n < tlower or n >= tupper) and trianglemap[n] == 0:
                         trianglemap[n] = i+2
+
                 n = mesh.neighbours[t, 2]
                 if n >= 0:
@@ -410,12 +414,9 @@
 
 
-
-
-
     nodemap = num.zeros(ncoord, 'i')
     fullnodes = submesh["full_nodes"][p]
 
     subtriangles = []
-    for i in range(len(trianglemap)):
+    for i in xrange(len(trianglemap)):
         if trianglemap[i] != 0:
             t = list(mesh.triangles[i])
@@ -547,5 +548,5 @@
     ghost_commun = num.zeros((len(subtri), 2), num.int)
 
-    for i in range(len(subtri)):
+    for i in xrange(len(subtri)):
         global_no = subtri[i][0]
 
@@ -555,5 +556,5 @@
         neigh = nproc-1
         sum = 0
-        for q in range(nproc-1):
+        for q in xrange(nproc-1):
             if (global_no < sum+tri_per_proc[q]):
                 neigh = q
@@ -598,5 +599,5 @@
     # Loop over the processor
 
-    for p in range(nproc):
+    for p in xrange(nproc):
 
         # Loop over the full triangles in the current processor
@@ -605,5 +606,5 @@
         fcommun = {}
         tupper = tri_per_proc[p]+tlower
-        for i in range(tlower, tupper):
+        for i in xrange(tlower, tupper):
             fcommun[i] = []
         full_commun.append(fcommun)
@@ -612,5 +613,5 @@
     # Loop over the processor again
 
-    for p in range(nproc):
+    for p in xrange(nproc):
 
         # Loop over the ghost triangles in the current processor,
@@ -664,5 +665,5 @@
     # Loop over the processors
 
-    for p in range(nproc):
+    for p in xrange(nproc):
 
         # Find the full triangles in this processor
@@ -746,5 +747,5 @@
     # Loop trough the subdomains
 
-    for p in range(nproc):
+    for p in xrange(nproc):
         upper =   lower+triangles_per_proc[p]
 
@@ -753,5 +754,5 @@
         global_id = []
         M = len(submesh["ghost_triangles"][p])
-        for j in range(M):
+        for j in xrange(M):
             global_id.append(submesh["ghost_triangles"][p][j][0])
 
@@ -862,5 +863,5 @@
 
     NGlobal = 0
-    for i in range(Nnodes):
+    for i in xrange(Nnodes):
         if nodes[i][0] > NGlobal:
             NGlobal = nodes[i][0]
@@ -923,5 +924,5 @@
     ghostc = num.sort(ghostc, 0)
     
-    for c in range(nproc):
+    for c in xrange(nproc):
         s = ghostc[:,0]
         d = num.compress(num.equal(ghostc[:,1],c), s)
@@ -937,5 +938,5 @@
     tmp_send = {}
     for global_id in fullc:
-        for i in range(len(fullc[global_id])):
+        for i in xrange(len(fullc[global_id])):
             neigh = fullc[global_id][i]
             if not tmp_send.has_key(neigh):
@@ -999,5 +1000,5 @@
 
     NGlobal = upper_t
-    for i in range(len(submesh["ghost_triangles"])):
+    for i in xrange(len(submesh["ghost_triangles"])):
         id = submesh["ghost_triangles"][i][0]
         if id > NGlobal:
@@ -1006,5 +1007,5 @@
     tri_map = -1*num.ones(int(NGlobal)+1, num.int)
     tri_map[lower_t:upper_t]=num.arange(upper_t-lower_t)
-    for i in range(len(submesh["ghost_triangles"])):
+    for i in xrange(len(submesh["ghost_triangles"])):
         tri_map[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t
     
@@ -1096,19 +1097,8 @@
 
 
-    def protocol(x):
-        vanilla=False
-        control_info, x = pypar.create_control_info(x, vanilla, return_object=True)
-        print 'protocol', control_info[0]
-
-    # FIXME SR: Creates cPickle dump
-    print 'tagmap', tagmap
-    protocol(tagmap)
+    # send boundary tags
     pypar.send(tagmap, p)
 
     # send the quantities key information
-
-    # FIXME SR: Creates cPickle dump
-    print 'full_quant keys', submesh["full_quan"].keys()
-    protocol(submesh["full_quan"].keys())
     pypar.send(submesh["full_quan"].keys(), p)
 
@@ -1133,6 +1123,4 @@
     setup_array[8] = len(submesh["full_quan"])
 
-    i=0
-
     x = num.array(setup_array, num.int)
     pypar.send(x, p, bypass=True)
@@ -1238,10 +1226,7 @@
 
     # receive the quantities key information
-
     qkeys = pypar.receive(p)
 
-
     # recieve information about the array sizes
-
     x = num.zeros((9,),num.int)
     pypar.receive(p, buffer=x,  bypass=True)
@@ -1258,7 +1243,4 @@
     no_quantities      = setup_array[8]
 
-
-
-    print 'setup_array', setup_array
     
     # ghost layer width
Index: /trunk/anuga_core/source/anuga_parallel/parallel_api.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_api.py	(revision 8544)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_api.py	(revision 8545)
@@ -136,27 +136,24 @@
             
         # Send serial to parallel (s2p) and parallel to serial (p2s) triangle mapping to proc 1 .. numprocs
+
+
+
+        n = len(s2p_map)
+        s2p_map_keys_flat = num.reshape(num.array(s2p_map.keys(),num.int), (n,1) )
+        s2p_map_values_flat = num.array(s2p_map.values(),num.int)
+        s2p_map_flat = num.concatenate( (s2p_map_keys_flat, s2p_map_values_flat), axis=1 )
+
+        n = len(p2s_map)
+        p2s_map_keys_flat = num.reshape(num.array(p2s_map.keys(),num.int), (n,2) )
+        p2s_map_values_flat = num.reshape(num.array(p2s_map.values(),num.int) , (n,1))
+        p2s_map_flat = num.concatenate( (p2s_map_keys_flat, p2s_map_values_flat), axis=1 )
+        
         for p in range(1, numprocs):
+
             # FIXME SR: Creates cPickle dump
-
-            print '*** s2p'
-            protocol(s2p_map)
-
-            n = len(s2p_map)
-            s2p_map_keys_flat = num.reshape(num.array(s2p_map.keys(),num.int), (n,1) )
-
-            print s2p_map_keys_flat.shape
-
-            s2p_map_values_flat = num.array(s2p_map.values(),num.int)
-            print s2p_map_values_flat.shape
-            
-            s2p_map_flat = num.concatenate( (s2p_map_keys_flat, s2p_map_values_flat), axis=1 )
-            #print s2p_map_keys_flat
-            #print s2p_map_values_flat
-            #print s2p_map_flat
-
             send(s2p_map_flat, p)
             # FIXME SR: Creates cPickle dump
             #print p2s_map
-            send(p2s_map, p)
+            send(p2s_map_flat, p)
 
         if verbose: print 'Communication done'
@@ -182,6 +179,8 @@
         s2p_map = dict.fromkeys(s2p_map_flat[:,0], s2p_map_flat[:,1:2])
 
-        p2s_map = receive(0)
-
+        p2s_map_flat = receive(0)
+        p2s_map_keys = [tuple(x) for x in p2s_map_flat[:,0:1]]
+
+        p2s_map = dict.fromkeys(p2s_map_keys, p2s_map_flat[:,2])
 
     #------------------------------------------------------------------------
