Index: inundation/parallel/run_parallel_sw_merimbula.py
===================================================================
--- inundation/parallel/run_parallel_sw_merimbula.py	(revision 2131)
+++ inundation/parallel/run_parallel_sw_merimbula.py	(revision 2152)
@@ -7,10 +7,4 @@
 # file.
 #
-#  *) The test files currently avaliable are of the form
-# test*.out, eg test_5l_4c.out. The term infront of the l
-# corresponds to the number of levels of refinement
-# required to build the grid, i.e. a higher number
-# corresponds to a finer grid. The term infront of the c
-# corresponds to the number of processors.
 #
 # *) The (new) files that have been added to manage the
@@ -40,29 +34,37 @@
 #
 #########################################################
+
 import sys
 import pypar    # The Python-MPI interface
 import time
 
-
 from os import sep
 sys.path.append('..'+sep+'pyvolution')
 
-from Numeric import array
+# Numeric arrays
+
+from Numeric import array, zeros, Float
+
 # pmesh
-
-#from shallow_water import Domain
 
 from shallow_water import Domain
 from parallel_shallow_water import Parallel_Domain
-
-# mesh partition routines
+from pmesh2domain import pmesh_to_domain_instance
+
+# Reuse previous mesh import
+
+from caching import cache
+
+# Mesh partition routines
 
 from pmesh_divide import pmesh_divide, pmesh_divide_steve
-from build_submesh import *
-from build_local import *
-from build_commun import *
-from pmesh2domain import pmesh_to_domain_instance
-
-# read in the processor information
+from build_submesh import build_submesh, extract_hostmesh
+from build_local   import build_local_mesh
+from build_commun  import send_submesh, rec_submesh
+
+
+###############################
+# Read in processor information
+###############################
 
 numprocs = pypar.size()
@@ -70,6 +72,8 @@
 processor_name = pypar.Get_processor_name()
 
-#-------
-# Domain
+############################
+# Set the initial conditions
+############################
+
 rect = zeros( 4, Float) # Buffer for results
 
@@ -86,8 +90,11 @@
         return self.h*((x>self.x0)&(x<self.x1))
 
+#######################
+# Partition the domain
+#######################
 
 if myid == 0:
 
-    # read in the test files
+    # Read in the test files
 
 #    filename = 'test-100.tsh'
@@ -98,35 +105,52 @@
         print "WARNING: number of subboxes is not equal to the number of proc"
 
-    domain_full = pmesh_to_domain_instance(filename, Domain)
-
+    # Build the whole domain
+    
+#    domain_full = pmesh_to_domain_instance(filename, Domain)
+
+    domain_full = cache(pmesh_to_domain_instance,
+               (filename, Domain),
+              dependencies = [filename])
+
+    rect = array(domain_full.xy_extent, Float)
+    
+    # Initialise the wave
+    
 #    domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
     domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,2.0))
 
+    # Subdivide the domain
+    
     nodes, triangles, boundary, triangles_per_proc, quantities = \
          pmesh_divide_steve(domain_full, nx, ny)
 
-    rect = array(domain_full.xy_extent, Float)
-
     submesh = build_submesh(nodes, triangles, boundary,\
                             quantities, triangles_per_proc)
     
-    # send the mesh partition to the appropriate processor
+    # Send the mesh partition to the appropriate processor
 
     for p in range(1, numprocs):
       send_submesh(submesh, triangles_per_proc, p)
 
+    # Build the local mesh for processor 0
+
     hostmesh = extract_hostmesh(submesh)
-    
-    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \
-             build_local_mesh(hostmesh, 0, triangles_per_proc[0], numprocs)
-
-# read in the mesh partition that belongs to this
+    points, vertices, boundary, quantities, ghost_recv_dict, \
+            full_send_dict = build_local_mesh(hostmesh, 0, \
+                                              triangles_per_proc[0], \
+                                              numprocs)
+
+# Read in the mesh partition that belongs to this
 # processor (note that the information is in the
 # correct form for the GA data structure
 
 else:
-    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict \
-            = rec_submesh(0)
-
+    points, vertices, boundary, quantities, ghost_recv_dict, \
+            full_send_dict = rec_submesh(0)
+
+
+###########################################
+# Start the computations on each subpartion
+###########################################
 
 ##    ########### start profile testing
@@ -149,12 +173,13 @@
 ######## end profile testing
     
-    
+
+# The visualiser needs to know the size of the whole domain
+
 pypar.broadcast(rect,0)
-#print rect
+
 
 domain = Parallel_Domain(points, vertices, boundary,
                          full_send_dict  = full_send_dict,
                          ghost_recv_dict = ghost_recv_dict)
-
 
 try:
