Index: /trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py	(revision 8876)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py	(revision 8877)
@@ -3,4 +3,5 @@
 import math
 import parallel_inlet_enquiry 
+import pypar
 
 from anuga.utilities.system_tools import log_to_file
@@ -57,5 +58,5 @@
                  enquiry_proc = None):
 
-        import pypar
+
         self.myid = pypar.rank()
         self.num_procs = pypar.size()
@@ -210,6 +211,4 @@
 
     def __call__(self):
-
-        import pypar
 
         timestep = self.domain.get_timestep()
@@ -424,6 +423,4 @@
         # with this structure
 
-        import pypar
-
         message = ' '
 
@@ -588,6 +585,6 @@
         # Should be called from all processors associated with operator
 
-        import pypar
-        
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_stage()'
@@ -622,6 +619,6 @@
         # Should be called from all processors associated with operator
 
-        import pypar
-
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_depth()'
@@ -657,5 +654,6 @@
     def get_enquiry_positions(self):
 
-        import pypar
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_position()'
@@ -691,9 +689,10 @@
     def get_enquiry_xmoms(self):
 
+        enq0 = None
+        enq1 = None
+
         get0 = 'self.inlets[0].get_enquiry_xmom()'
         get1 = 'self.inlets[1].get_enquiry_xmom()'
 
-        import pypar
-
 
         if self.myid == self.master_proc:
@@ -723,10 +722,11 @@
 
     def get_enquiry_ymoms(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_ymom()'
         get1 = 'self.inlets[1].get_enquiry_ymom()'
 
-        import pypar
-
 
         if self.myid == self.master_proc:
@@ -757,10 +757,11 @@
 
     def get_enquiry_elevations(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_elevation()'
         get1 = 'self.inlets[1].get_enquiry_elevation()'
 
-        import pypar
-
 
         if self.myid == self.master_proc:
@@ -792,10 +793,11 @@
 
     def get_enquiry_water_depths(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_water_depth()'
         get1 = 'self.inlets[1].get_enquiry_water_depth()'
 
-        import pypar
-
 
         if self.myid == self.master_proc:
@@ -826,10 +828,11 @@
 
     def get_enquiry_invert_elevations(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_invert_elevation()'
         get1 = 'self.inlets[1].get_enquiry_invert_elevation()'
 
-        import pypar
-
 
         if self.myid == self.master_proc:
@@ -860,11 +863,11 @@
 
     def get_enquiry_velocitys(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_velocity()'
         get1 = 'self.inlets[1].get_enquiry_velocity()'
 
-        import pypar
-
-
         if self.myid == self.master_proc:
 
@@ -894,11 +897,11 @@
 
     def get_enquiry_xvelocitys(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_xvelocity()'
         get1 = 'self.inlets[1].get_enquiry_xvelocity()'
 
-        import pypar
-
-
         if self.myid == self.master_proc:
 
@@ -927,9 +930,11 @@
 
     def get_enquiry_yvelocitys(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_yvelocity()'
         get1 = 'self.inlets[1].get_enquiry_yvelocity()'
 
-        import pypar
 
         if self.myid == self.master_proc:
@@ -960,11 +965,12 @@
 
     def get_enquiry_speeds(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_speed()'
         get1 = 'self.inlets[1].get_enquiry_speed()'
 
-        import pypar
-
-
+        
         if self.myid == self.master_proc:
 
@@ -994,11 +1000,11 @@
 
     def get_enquiry_velocity_heads(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_velocity_head()'
         get1 = 'self.inlets[1].get_enquiry_velocity_head()'
 
-        import pypar
-
-
         if self.myid == self.master_proc:
 
@@ -1028,11 +1034,11 @@
 
     def get_enquiry_total_energys(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_total_energy()'
         get1 = 'self.inlets[1].get_enquiry_total_energy()'
 
-        import pypar
-
-
         if self.myid == self.master_proc:
 
@@ -1062,35 +1068,35 @@
 
     def get_enquiry_specific_energys(self):
+
+        enq0 = None
+        enq1 = None
 
         get0 = 'self.inlets[0].get_enquiry_specific_energy()'
         get1 = 'self.inlets[1].get_enquiry_specific_energy()'
 
-        import pypar
-
-
-        if self.myid == self.master_proc:
-
-            if self.myid == self.enquiry_proc[0]:
-                enq0 = eval(get0)
-            else:
-                enq0 = pypar.receive(self.enquiry_proc[0])
-
-
-            if self.myid == self.enquiry_proc[1]:
-                enq1 = eval(get1)
-            else:
-                enq1 = pypar.receive(self.enquiry_proc[1])
-
-        else:
-            if self.myid == self.enquiry_proc[0]:
-                enq0 = eval(get0)
-                pypar.send(enq0, self.master_proc)
-
-            if self.myid == self.enquiry_proc[1]:
-                enq1 = eval(get1)
-                pypar.send(enq1, self.master_proc)
-
-
-        return [enq0, enq1]
-
-
+        if self.myid == self.master_proc:
+
+            if self.myid == self.enquiry_proc[0]:
+                enq0 = eval(get0)
+            else:
+                enq0 = pypar.receive(self.enquiry_proc[0])
+
+
+            if self.myid == self.enquiry_proc[1]:
+                enq1 = eval(get1)
+            else:
+                enq1 = pypar.receive(self.enquiry_proc[1])
+
+        else:
+            if self.myid == self.enquiry_proc[0]:
+                enq0 = eval(get0)
+                pypar.send(enq0, self.master_proc)
+
+            if self.myid == self.enquiry_proc[1]:
+                enq1 = eval(get1)
+                pypar.send(enq1, self.master_proc)
+
+
+        return [enq0, enq1]
+
+
Index: /trunk/anuga_core/source/anuga_parallel/run_parallel_gate_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/run_parallel_gate_operator.py	(revision 8876)
+++ /trunk/anuga_core/source/anuga_parallel/run_parallel_gate_operator.py	(revision 8877)
@@ -12,6 +12,4 @@
 
                             
-#from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
-     
 from math import pi, pow, sqrt
 
@@ -82,5 +80,5 @@
     domain.set_name('run_gate_operator')                 # Output name
     domain.set_flow_algorithm('2_0')
-    #domain.set_beta(1.5)
+
 
 
@@ -116,5 +114,6 @@
 
 # Close the gate
-gate.set_culvert_height(0.0)
+if gate is not None:
+    gate.set_culvert_height(0.0)
 
 line = [[0.0, 5.0], [0.0, 10.0]]
@@ -162,4 +161,5 @@
         [w0, w1] = gate.get_enquiry_water_depths()
 
+        output = gate.discharge_routine()
 
         if myid == gate.get_master_proc():
@@ -170,6 +170,6 @@
             print 'myid ', myid, w0,w1
 
-
-            print gate.discharge_routine()
+            print 'myid ',myid, output
+
 
             if d0 > 0.2: gate.set_culvert_height(10.0)
