Index: /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
===================================================================
--- /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py	(revision 8017)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py	(revision 8018)
@@ -1528,6 +1528,7 @@
                     raise Exception, msg
 
-                # Yield final time and stop
+                # Log and then Yield final time and stop
                 self.time = finaltime
+                self.log_operator_timestepping_statistics()
                 yield(self.time)
                 break
@@ -1540,5 +1541,6 @@
                     self.delete_old_checkpoints()
 
-                # Pass control on to outer loop for more specific actions
+                # Log and then Pass control on to outer loop for more specific actions
+                self.log_operator_timestepping_statistics()
                 yield(self.time)
 
@@ -1860,4 +1862,21 @@
         for operator in self.fractional_step_operators:
             operator()
+
+
+
+    ##
+    # @brief log_timestepping_statistics.
+    # Goes through all fractional step operators and logs timestepping statistics
+    def log_operator_timestepping_statistics(self):
+        for operator in self.fractional_step_operators:
+            operator.log_timestepping_statistics()
+
+    ##
+    # @brief print_timestepping_statistics.
+    # Goes through all fractional step operators and logs timestepping statistics
+    def print_operator_timestepping_statistics(self):
+        for operator in self.fractional_step_operators:
+            operator.print_timestepping_statistics()
+
 
     ##
Index: /trunk/anuga_core/source/anuga/structures/boyd_box_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/boyd_box_operator.py	(revision 8017)
+++ /trunk/anuga_core/source/anuga/structures/boyd_box_operator.py	(revision 8018)
@@ -12,5 +12,6 @@
     Input: Two points, pipe_size (either diameter or width, height), 
     mannings_rougness,
-    """ 
+    """
+
 
     def __init__(self,
@@ -27,5 +28,9 @@
                  use_velocity_head=True,
                  description=None,
+                 label=None,
+                 structure_type='boyd_box',
+                 logging=False,
                  verbose=False):
+
                      
         anuga.Structure_operator.__init__(self,
@@ -39,5 +44,8 @@
                                           enquiry_gap,                                                       
                                           description,
-                                          verbose)            
+                                          label,
+                                          structure_type,
+                                          logging,
+                                          verbose)     
         
         
@@ -57,5 +65,4 @@
 
         self.max_velocity = 10.0
-        self.log_filename = None
 
         self.inlets = self.get_inlets()
Index: /trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py	(revision 8017)
+++ /trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py	(revision 8018)
@@ -26,5 +26,10 @@
                  use_velocity_head=True,
                  description=None,
+                 label=None,
+                 structure_type='boyd_pipe',
+                 logging=False,
                  verbose=False):
+
+
                      
         anuga.Structure_operator.__init__(self,
@@ -38,4 +43,7 @@
                                           enquiry_gap=enquiry_gap,                                                       
                                           description=description,
+                                          label=label,
+                                          structure_type=structure_type,
+                                          logging=logging,
                                           verbose=verbose)            
 
@@ -55,5 +63,4 @@
 
         self.max_velocity = 10.0
-        self.log_filename = None
 
         self.inlets = self.get_inlets()
@@ -77,7 +84,4 @@
             # Water has risen above inlet
 
-            if self.log_filename is not None:
-                s = 'Specific energy  = %f m' % self.inflow.get_enquiry_specific_energy()
-                log_to_file(self.log_filename, s)
 
             msg = 'Specific energy at inlet is negative'
@@ -108,7 +112,4 @@
             # Water has risen above inlet
 
-            if self.log_filename is not None:
-                s = 'Specific energy  = %f m' % self.inflow.get_average_specific_energy()
-                log_to_file(self.log_filename, s)
 
             msg = 'Specific energy at inlet is negative'
@@ -120,7 +121,5 @@
             # Note for to SUBMERGED TO OCCUR self.inflow.get_average_specific_energy() should be > 1.2 x diameter.... Should Check !!!
 
-            if self.log_filename is not None:
-                s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' % (Q_inlet_unsubmerged, Q_inlet_submerged)
-                log_to_file(self.log_filename, s)
+
             Q = min(Q_inlet_unsubmerged, Q_inlet_submerged)
 
@@ -205,7 +204,5 @@
             hyd_rad = flow_area/perimeter
 
-            if self.log_filename is not None:
-                s = 'hydraulic radius at outlet = %f' %hyd_rad
-                log_to_file(self.log_filename, s)
+
 
             # Outlet control velocity using tail water
@@ -222,7 +219,5 @@
                 anuga.log.critical('VELOCITY = %s' % str(culvert_velocity))
                 anuga.log.critical('Outlet Ctrl Q = %s' % str(Q_outlet_tailwater))
-            if self.log_filename is not None:
-                s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater
-                log_to_file(self.log_filename, s)
+
             Q = min(Q, Q_outlet_tailwater)
             if local_debug =='true':
Index: /trunk/anuga_core/source/anuga/structures/structure_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/structure_operator.py	(revision 8017)
+++ /trunk/anuga_core/source/anuga/structures/structure_operator.py	(revision 8018)
@@ -4,4 +4,7 @@
 import inlet
 
+from anuga.utilities.system_tools import log_to_file
+
+
 class Structure_operator:
     """Structure Operator - transfer water from one rectangular box to another.
@@ -14,4 +17,6 @@
     mannings_rougness,
     """ 
+
+    counter = 0
 
     def __init__(self,
@@ -25,4 +30,7 @@
                  enquiry_gap,
                  description,
+                 label,
+                 structure_type,
+                 logging,
                  verbose):
         
@@ -30,4 +38,6 @@
         self.domain.set_fractional_step_operator(self)
         self.end_points = [end_point0, end_point1]
+
+        
         
         if height is None:
@@ -42,7 +52,30 @@
         self.manning = manning
         self.enquiry_gap = enquiry_gap
-        self.description = description
+
+        if description == None:
+            self.description = ' '
+        else:
+            self.description = description
+        
+
+        if label == None:
+            self.label = "structure_%g" % Structure_operator.counter
+        else:
+            self.label = label
+        print label
+
+        if structure_type == None:
+            self.structure_type = 'generic structure'
+        else:
+            self.structure_type = structure_type
+            
         self.verbose = verbose
 
+        
+        
+        # Keep count of structures
+        Structure_operator.counter += 1
+
+        # Slots for recording current statistics
         self.discharge = 0.0
         self.velocity = 0.0
@@ -63,4 +96,5 @@
         self.inlets.append(inlet.Inlet(self.domain, polygon1, exchange_polygon1, outward_vector1))
 
+        self.set_logging(logging)
 
     def __call__(self):
@@ -221,36 +255,49 @@
             
 
-    def print_stats(self):
-
-        print '====================================='
-        print 'Generic Culvert Operator'
-        print '====================================='
-
-        print 'Culvert'
-        print self.culvert
-
-        print 'Culvert Routine'
-        print self.routine
+    def structure_statistics(self):
+
+
+        message  = '=====================================\n'
+        message += 'Structure Operator: %s\n' % self.label
+        message += '=====================================\n'
+
+        message += 'Structure Type: %s\n' % self.structure_type
+
+        message += 'Description\n'
+        message += '%s' % self.description
+        message += '\n'
         
         for i, inlet in enumerate(self.inlets):
-            print '-------------------------------------'
-            print 'Inlet %i' % i
-            print '-------------------------------------'
-
-            print 'inlet triangle indices and centres'
-            print inlet.triangle_indices
-            print self.domain.get_centroid_coordinates()[inlet.triangle_indices]
-        
-            print 'polygon'
-            print inlet.polygon
-
-        print '====================================='
-
-
-    def structure_statistics(self):
+            message += '-------------------------------------\n'
+            message +=  'Inlet %i\n' % i
+            message += '-------------------------------------\n'
+
+            message += 'inlet triangle indices and centres\n'
+            message += '%s' % inlet.triangle_indices
+            message += '\n'
+            
+            message += '%s' % self.domain.get_centroid_coordinates()[inlet.triangle_indices]
+            message += '\n'
+
+            message += 'polygon\n'
+            message += '%s' % inlet.polygon
+            message += '\n'
+
+        message += '=====================================\n'
+
+        return message
+
+
+    def print_structure_statistics(self):
+
+        print self.structure_statistics()
+
+
+    def print_timestepping_statistics(self):
 
         message = '---------------------------\n'
-        message += 'Structure report for structure %s:\n' % self.description
+        message += 'Structure report for %s:\n' % self.label
         message += '--------------------------\n'
+        message += 'Type: %s\n' % self.structure_type
         message += 'Discharge [m^3/s]: %.2f\n' % self.discharge
         message += 'Velocity  [m/s]: %.2f\n' % self.velocity
@@ -258,6 +305,35 @@
         message += 'delta total energy %.2f\n' % self.delta_total_energy
 
+        print message
+
+
+    def set_logging(self, flag=True):
+
+        self.logging = flag
+
+        # If flag is true open file with mode = "w" to form a clean file for logging
+        if self.logging:
+            self.log_filename = self.label + '.log'
+            log_to_file(self.log_filename, self.structure_statistics(), mode='w')
+            log_to_file(self.log_filename, 'time,discharge,velocity,driving_energy,delta_total_energy')
+
+            #log_to_file(self.log_filename, self.culvert_type)
+
+
+    def timestepping_statistics(self):
+
+        message  = '%.5f, ' % self.domain.get_time()
+        message += '%.5f, ' % self.discharge
+        message += '%.5f, ' % self.velocity
+        message += '%.5f, ' % self.driving_energy
+        message += '%.5f' % self.delta_total_energy
+
         return message
 
+    def log_timestepping_statistics(self):
+
+         if self.logging:
+             log_to_file(self.log_filename, self.timestepping_statistics())
+
 
     def get_inlets(self):
Index: /trunk/anuga_core/source/anuga/structures/test_Outlet_Ctrl.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/test_Outlet_Ctrl.py	(revision 8017)
+++ /trunk/anuga_core/source/anuga/structures/test_Outlet_Ctrl.py	(revision 8018)
@@ -159,5 +159,5 @@
 
 culverts = []
-number_of_culverts = 1
+number_of_culverts = 2
 for i in range(number_of_culverts):
     culvert_width = 50.0/number_of_culverts
@@ -175,4 +175,5 @@
                             use_velocity_head=True,
                             manning=0.013,
+                            logging=True,
                             verbose=False))
 
@@ -204,4 +205,5 @@
 
 
+
 #------------------------------------------------------------------------------
 # Evolve system through time
@@ -210,6 +212,5 @@
 for t in domain.evolve(yieldstep = 1, finaltime = 100):
     print domain.timestepping_statistics()
-    print domain.volumetric_balance_statistics()
-    for culvert in culverts:
-        print culvert.structure_statistics()
-
+
+    domain.print_operator_timestepping_statistics()
+
Index: /trunk/anuga_core/source/anuga/utilities/system_tools.py
===================================================================
--- /trunk/anuga_core/source/anuga/utilities/system_tools.py	(revision 8017)
+++ /trunk/anuga_core/source/anuga/utilities/system_tools.py	(revision 8018)
@@ -21,9 +21,9 @@
 
 
-def log_to_file(filename, s, verbose=False):
+def log_to_file(filename, s, verbose=False, mode='a'):
     """Log string to file name
     """
 
-    fid = open(filename, 'a')
+    fid = open(filename, mode)
     if verbose: print s
     fid.write(s + '\n')
