Index: /trunk/anuga_work/development/mem_time_tests/NCIparallel/area/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/NCIparallel/area/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/NCIparallel/area/main.py	(revision 8326)
@@ -22,10 +22,9 @@
 # Setup computational domain
 #------------------------------------------------------------------------------
-a = []
 #SpaceUsed = 0.0
 #number = 0
 
 home1 = os.getenv('INUNDATIONHOME')
-scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","area"])
+scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","logarea"])
 file1 = 'ex1.csv'
 file_path = os.path.join(scenariodir, file1)
@@ -39,5 +38,4 @@
 file_path_storen = os.path.join(scenariodir, storen)
 
-log.log_filename = os.path.join(scenariodir, 'log.txt
 
 spamWriter = csv.writer(open(file_path, 'wb'))
@@ -53,7 +51,6 @@
 
 
-def rum(d):
-     f = 4
-     for l in range(400,500,100):
+for m in range(1,2,1):
+     for l in range(700,800,100):
 
         g = open(file_path_storel,'r+')
@@ -61,10 +58,10 @@
 
         h = open(file_path_storea,'r+')
-        h.write(str(d))
+        h.write(str(m))
 
         z = time.time()
-        subprocess.call(['mpirun','-np','8','-x','PYTHONPATH','-x','INUNDATIONHOME','python','runcairns.py'])
-        #subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado','-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'ru$
-        #subprocess.call(['python2.5', 'runcairns.py'])
+        #subprocess.call(['mpirun','-np','8','-x','PYTHONPATH','-x','INUNDATIONHOME','python','runcairns.py'])
+        #subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado','-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'runcairns.py'])
+        subprocess.call(['python2.5', 'runcairns.py'])
         y = time.time()
 
@@ -77,9 +74,7 @@
         f.close()
 
-        spamWriter.writerow([i,d,(l*l),x ,(y-z)])
+        spamWriter.writerow(['i,d,(l*l),x ,(y-z)'])
         liststore.store = [0,0,0,0]
 
-for m in range(90,100,10):
-    rum(m)
 
 print 'Done'
Index: /trunk/anuga_work/development/mem_time_tests/NCIparallel/area/runcairns.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/NCIparallel/area/runcairns.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/NCIparallel/area/runcairns.py	(revision 8326)
@@ -30,5 +30,5 @@
 home2 = os.getenv('INUNDATIONHOME')
 
-scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
+scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "logarea"])
 
 h = 'CAIRNS.msh'
@@ -52,5 +52,5 @@
 
 scenariodirV = add_directories(home2, ["data","mem_time_test", "triangles",
-                                     "area", "triangles-" + str(area) +"-"+ str(length)])
+                                       "logarea", "triangles-" + str(area) +"-"+ str(length)])
 
 h = 'CAIRNS.msh'
@@ -60,5 +60,5 @@
 log._setup = False
 
-system_tools.MemoryUpdate()
+log.resource_usage_timing(prefix = 'BeforeSimulation')
 #------------------------------------------------------------------------------
 # Create the triangular mesh and domain based on 
@@ -82,5 +82,6 @@
 else:
     domain = None
-     
+
+log.resource_usage_timing(prefix = 'AfterMesh')     
 domain = distribute(domain)
                                
@@ -97,5 +98,5 @@
 def topography(x,y):
     return 0.0
-
+log.resource_usage_timing(prefix='beforeinitialconditions')
 tide = 100.0
 friction = 0.0
@@ -103,5 +104,5 @@
 domain.set_quantity('friction', friction) 
 domain.set_quantity('elevation',topography,alpha=0.1)
-
+log.resource_usage_timing(prefix='afterinitialconditions')
 
 
@@ -120,5 +121,5 @@
                      'top': Br})
 
-
+log.resource_usage_timing(prefix='afterboundary')
 #------------------------------------------------------------------------------
 # Evolve system through time
@@ -126,11 +127,12 @@
 
 # Save every two mins leading up to wave approaching land
-for t in domain.evolve(yieldstep=500, finaltime=2000): 
-    print domain.timestepping_statistics()
+#for t in domain.evolve(yieldstep=500, finaltime=2000): 
+#    print domain.timestepping_statistics()
     
 
-liststore.store[myid] = system_tools.MemoryUpdate()[0]
-a = sum(liststore.store)
+#liststore.store[myid] = system_tools.MemoryUpdate()[0]
+#a = sum(liststore.store)
 
+a = 1
 v = open(file_path_store, 'r+')
 v.write(str(a))
Index: /trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py	(revision 8326)
@@ -5,45 +5,36 @@
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
-import random
 import subprocess
 import csv
 import os
 import time
-import liststore
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-a = []
+#--------------------------------------------------------------------------------------
+# Set up variables for the correct directories to store the output
+#--------------------------------------------------------------------------------------
 host = os.getenv('HOST')
-home1 = os.getenv('INUNDATIONHOME')
-scenariodir = add_directories(home1, ["data","mem_time_test", "parallel","cairns"])
+home = os.getenv('INUNDATIONHOME')
+scenariodir = add_directories(home, ["data","mem_time_test", "parallel","cairns"])
 file1 = 'ex1.csv'
 file_path = os.path.join(scenariodir, file1)
-store ='store.txt'
-file_path_store = os.path.join(scenariodir, store)
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
 
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s'])
-e = open(file_path_store,'a')
-e.close()
 
+
+# main loop that runs macpus - 1 times
 maxcpus = 18
 
 for n in range(1,maxcpus,1):
-    z = time.time()
-    y = time.time()
+    z = time.time() # time it
 
+    #the necessary ways to run this script in parallel on the different hosts we use
     if (host == 'cyclone.agso.gov.au'):
-        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 
+        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
     if (host == 'tornado.agso.gov.au'):
-        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
+        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
     if (host == 'vayu1'):
         subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
@@ -53,9 +44,7 @@
         subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
 
-    liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
-    f = open(file_path_store,'r+')
-    x = float(f.readline())
-    f.close()
-    spamWriter.writerow([n,x ,(y-z)])
-print a
+    y = time.time()# time it
+    spamWriter.writerow([n,'x' ,(y-z)]) # write recorded results
+print 'DONE'
 
+analyse_log(scenariodir, 'metalog.csv') # interrogate log files for the memory usage information
Index: /trunk/anuga_work/development/mem_time_tests/hardware/cairns/project.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/hardware/cairns/project.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/hardware/cairns/project.py	(revision 8326)
@@ -1,4 +1,6 @@
 """ Common filenames and locations for topographic data, meshes and outputs.
     This file defines the parameters of the scenario you wish to run.
+
+    Parameters differ from example to make the code run faster, and so the data is stored and found in the correct places
 """
 
Index: /trunk/anuga_work/development/mem_time_tests/hardware/cairns/runcairns.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/hardware/cairns/runcairns.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/hardware/cairns/runcairns.py	(revision 8326)
@@ -10,4 +10,7 @@
 
 Geoscience Australia, 2004-present
+
+This has remained unchanged aside from the parallelism added, the resource statistics
+and the output directories, its also been scaled down so it runs faster
 """
 
@@ -19,29 +22,28 @@
 import time
 import sys
+import anuga
+from anuga_parallel import distribute, myid, numprocs
+from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
-# Related major packages
-import anuga
-import liststore
 
 # Application specific imports
 import project                 # Definition of file names and polygons
 
-from anuga_parallel import distribute, myid, numprocs, finalize, barrier
-from anuga.abstract_2d_finite_volumes.util import add_directories
-from anuga.utilities import system_tools, log
+
+# set up variables for the correct output directories
+home = os.getenv('INUNDATIONHOME')
+scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "cairns"])
+h = 'CAIRNS.msh'
+file_pathh = os.path.join(scenariodir, h)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+scenariodirV = add_directories(home, ["data","mem_time_test", "parallel",
+                                       "cairns", "parrallel-" + str(numprocs) +"-"+str(myid)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
 
 
-home2 = os.getenv('INUNDATIONHOME')
-
-scenariodir2 = add_directories(home2, ["data", "mem_time_test", "parallel", "cairns"])
-
-h = 'CAIRNS.msh'
-file_pathh = os.path.join(scenariodir2, h)
-store ='store.txt'
-file_path_store = os.path.join(scenariodir2, store)
-
-
-system_tools.MemoryUpdate()
-
+log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics at this point
 #------------------------------------------------------------------------------
 # Preparation of topographic data
@@ -49,8 +51,8 @@
 #------------------------------------------------------------------------------
 # Create DEM from asc data
-anuga.asc2dem(os.path.join(scenariodir2, 'cairns.asc'), use_cache=True, verbose=True)
+anuga.asc2dem(os.path.join(scenariodir, 'cairns.asc'), use_cache=True, verbose=True)
 
 # Create pts file for onshore DEM
-anuga.dem2pts(os.path.join(scenariodir2,'cairns.dem'), use_cache=True, verbose=True)
+anuga.dem2pts(os.path.join(scenariodir,'cairns.dem'), use_cache=True, verbose=True)
 
 #------------------------------------------------------------------------------
@@ -58,4 +60,5 @@
 # overall clipping polygon with a tagged
 # boundary and interior regions as defined in project.py
+# (in serial, so the set up only runs once)
 #------------------------------------------------------------------------------
 if myid == 0:
@@ -77,5 +80,8 @@
 else:
     domain = None
+
+log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics at this point
      
+#parallel
 domain = distribute(domain)
                                
@@ -84,5 +90,5 @@
 #------------------------------------------------------------------------------
 domain.set_name('cairns_' + project.scenario) # Name of sww file
-domain.set_datadir(scenariodir2)                       # Store sww output here
+domain.set_datadir(scenariodirV)                       # Store sww output here
 domain.set_minimum_storable_height(0.01)      # Store only depth > 1cm
 
@@ -95,8 +101,9 @@
 domain.set_quantity('friction', 0.0) 
 domain.set_quantity('elevation', 
-                    filename=os.path.join(scenariodir2, 'cairns.pts'),
+                    filename=os.path.join(scenariodir, 'cairns.pts'),
                     use_cache=True,
                     verbose=True,
                     alpha=0.1)
+log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics at this point
 
 #------------------------------------------------------------------------------
@@ -138,5 +145,5 @@
                          'onshore': Bd,
                          'top': Bd})
-
+log.resource_usage_timing(prefix='afterboundary') #get memory statistics at this point
 #------------------------------------------------------------------------------
 # Evolve system through time
@@ -175,10 +182,6 @@
         print domain.boundary_statistics(tags='ocean_east')
             
+
 print 'That took %.2f seconds' %(time.time()-t0)
 
-liststore.spacelist[myid] = system_tools.MemoryUpdate()[0]
-a = sum(liststore.spacelist)
-
-f = open(file_path_store, 'r+')
-f.write(str(a))
-
+log.resource_usage_timing(prefix='aftersimulation') #get memory statistics at this point
Index: /trunk/anuga_work/development/mem_time_tests/hardware/template/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/hardware/template/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/hardware/template/main.py	(revision 8326)
@@ -5,21 +5,16 @@
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import random
 import subprocess
-import run_parallel
 import csv
 import os
 import time
-import liststore
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-a = []
+#-------------------------------------------------------------------------------
+# Set up variables for the correct directories to store the output
+#-------------------------------------------------------------------------------
 host = os.getenv('HOST')
 home = os.getenv('INUNDATIONHOME')
@@ -27,28 +22,19 @@
 file1 = 'ex1.csv'
 file_path = os.path.join(scenariodir, file1)
-storel ='storel.txt'
-file_path_storel = os.path.join(scenariodir, storel)
-storea ='storea.txt'
-file_path_storea = os.path.join(scenariodir, storea)
-store ='store.txt'
-file_path_store = os.path.join(scenariodir, store)
-storen ='storen.txt'
-file_path_storen = os.path.join(scenariodir, storen)
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s','Total Space'])
-e = open(file_path_store,'a')
-e.close()
 
 
+#main loop that runs maxcpus - 1 times
+maxcpus = 40
 
-for n in range(1,40,1):
-    z = time.time()
+for n in range(1,maxcpus,1):
+    z = time.time()# time it
+
+    #the different ways each HOST requires the parallel script to be run
     if (host == 'cyclone.agso.gov.au'):
-        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 
+        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
     if (host == 'tornado.agso.gov.au'):
-        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
+        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
     if (host == 'vayu1'):
         subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
@@ -57,11 +43,10 @@
     if (host == 'xe'):
         subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
- 
-    y = time.time()
-    f = open(file_path_store,'r+')
-    x = float(f.readline())
-    f.close()
-    spamWriter.writerow([n,liststore.spacelist,(y-z),x])
-    liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
-print a
+    
 
+    y = time.time() #time it
+    spamWriter.writerow([n,(y-z)]) #record it
+
+print 'Done'
+
+analyse_log(scenariodir, 'metalog.csv') #get all the memory usage statistics
Index: /trunk/anuga_work/development/mem_time_tests/hardware/template/runcairns.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/hardware/template/runcairns.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/hardware/template/runcairns.py	(revision 8326)
@@ -1,13 +1,7 @@
-"""Script for running a tsunami inundation scenario for Cairns, QLD Australia.
+"""
+This experiment was based heavily on the cairns demo given in the user manual and found in
+the anuga repository.
 
-Source data such as elevation and boundary data is assumed to be available in
-directories specified by project.py
-The output sww file is stored in directory named after the scenario, i.e
-slide or fixed_wave.
-
-The scenario is defined by a triangular mesh created from project.polygon,
-the elevation data and a tsunami wave generated by a submarine mass failure.
-
-Geoscience Australia, 2004-present
+However, it has been simplified so that it doesnt require all the files the cairns demo does
 """
 
@@ -15,34 +9,27 @@
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Standard modules
 import os
 import time
 import sys
+import anuga
+from anuga_parallel import distribute, myid, numprocs
+from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
-# Related major packages
-import anuga
+#set up variables for the correct I/O directories for data storage
+home = os.getenv('INUNDATIONHOME')
+scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "template"])
+scenariodirV = add_directories(home, ["data","mem_time_test", "parallel",
+                                       "template", "template-" + str(numprocs) +"-"+ str(myid)])
+h = 'CAIRNS.msh'
+file_pathh = os.path.join(scenariodirV, h)
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
 
-from anuga_parallel import distribute, myid
-import liststore
-from anuga.abstract_2d_finite_volumes.util import add_directories
-from anuga.utilities import system_tools, log
+log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics here
+#------------------------------------------------------------------------------
+#Create the domain and mesh for the resource experiment on only one processor
+#------------------------------------------------------------------------------
 
-
-home2 = os.getenv('INUNDATIONHOME')
-
-scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
-
-store ='store.txt'
-file_path_store = os.path.join(scenariodir2, store)
-h = 'cairnsmesh.msh'
-file_pathh = os.path.join(scenariodir2, h)
-
-
-system_tools.MemoryUpdate()
-#------------------------------------------------------------------------------
-# Create the triangular mesh and domain based on 
-# overall clipping polygon with a tagged
-# boundary and interior regions as defined in project.py
-#------------------------------------------------------------------------------
 if myid == 0:
     domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)],
@@ -52,24 +39,13 @@
                                                    'left': [3]},
                                     maximum_triangle_area=100.0,
-                                    mesh_filename=file_pathh
-                                    #,interior_regions=INTERIORREGIONS#,
-                                    #use_cache=True,
-                                    #verbose=True)
-                                    )
-
-    # Print some stats about mesh and domain
-    #print 'Number of triangles = ', len(domain)
-    #print 'The extent is ', domain.get_extent()
-    #print domain.statistics()
+                                    mesh_filename=file_pathh)
 else:
     domain = None
-     
+
+#parallel   
 domain = distribute(domain)
-                               
-#------------------------------------------------------------------------------
-# Setup parameters of computational domain
-#------------------------------------------------------------------------------
 domain.set_name('CAIRNS') # Name of sww file
-domain.set_datadir(scenariodir2)                       # Store sww output here
+domain.set_datadir(scenariodirV)# Store sww output here
+log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics here
 
 #------------------------------------------------------------------------------
@@ -86,5 +62,5 @@
 domain.set_quantity('elevation',topography,alpha=0.1)
 
-
+log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here
 
 #------------------------------------------------------------------------------
@@ -94,26 +70,13 @@
 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
-Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
 Br = anuga.Reflective_boundary(domain)
-#Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
-domain.set_boundary({'right': Bo,
-                     'bottom': Br,
-                     'left': Bi,
-                     'top': Br})
+domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
 
+log.resource_usage_timing(prefix='afterboundary') #get memory statistics here
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-
-# Save every two mins leading up to wave approaching land
 for t in domain.evolve(yieldstep=120, finaltime=2000): 
     print domain.timestepping_statistics()
-    
 
-liststore.spacelist[myid] = system_tools.MemoryUpdate()[0]
-a = sum(liststore.spacelist)
-print liststore.spacelist
-
-f = open(file_path_store, 'r+')
-f.write(str(a))
-
+log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here  
Index: /trunk/anuga_work/development/mem_time_tests/parameters/friction/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/friction/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/friction/ex1.py	(revision 8326)
@@ -10,4 +10,5 @@
 import os
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
 home = os.getenv('INUNDATIONHOME')
@@ -16,46 +17,56 @@
 
 
-file = 'CAIRNS.sww'
-file_path = os.path.join(scenariodir, file)
+#store = 'store.txt'
+#file_path_store = os.path.join(scenariodir, store)
 
-h = 'CAIRNS.msh'
-file_pathh = os.path.join(scenariodir, h)
+f = open(os.path.join(scenariodir, "store.txt"),'r+') # SQRT extent this is set
+friction = float(f.readline())
+f.close()
+
+scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
+                                     "friction","friction-" + str(friction)])
+
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+log.resource_usage_timing(prefix = 'BeforeSimulation')
+
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
+points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_datadir(scenariodirV)
+domain.set_name('channel1') # Output name
 
-
-
-def runex(f):
-   points, vertices, boundary = anuga.rectangular_cross(10,5,
-   len1=10.0, len2=5.0) # Mesh
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_datadir(scenariodir)
-   domain.set_name('channel1') # Output name
- 
+log.resource_usage_timing(prefix = 'AfterMesh')
    
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
-   def topography(x, y):
-       return -x/10 # linear bed slope
-       domain.set_quantity('elevation', topography) # Use function for elevation
-       domain.set_quantity('friction', f) # Constant friction
-       domain.set_quantity('stage', # Dry bed
+def topography(x, y):
+    return -x/10 # linear bed slope
+
+log.resource_usage_timing(prefix = 'BeforeInitial')
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', friction) # Constant friction
+domain.set_quantity('stage', # Dry bed
                            expression='elevation')
+log.resource_usage_timing(prefix = 'AfterInitial')
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+log.resource_usage_timing(prefix = 'BeforeBoundary')
+Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+log.resource_usage_timing(prefix = 'AfterBoundary')
 
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
-      print domain.timestepping_statistics()
-   return f
+for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
+    print domain.timestepping_statistics()
 
-
+log.resource_usage_timing(prefix = 'AfterSimulation')
Index: /trunk/anuga_work/development/mem_time_tests/parameters/friction/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/friction/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/friction/main.py	(revision 8326)
@@ -9,13 +9,12 @@
 import time
 import subprocess
-import ex1
 import csv
 import os
 from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
-a = []
 home = os.getenv('INUNDATIONHOME')
 
@@ -24,6 +23,12 @@
 file = 'ex1.csv'
 file_path = os.path.join(scenariodir, file)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
 
-log.log_filename = os.path.join(scenariodir, 'log.txt')
+e = open(file_path_store,'a')
+e.close()
+
+
+
 
 spamWriter = csv.writer(open(file_path, 'wb'))
@@ -32,10 +37,11 @@
 
 for n in range(1,10000,100):
-    system_tools.MemoryUpdate()
+    f = open(file_path_store,'wb')
+    f.write(str(n))
     x = time.clock()
-    h = ex1.runex(n)
+    subprocess.call(['python2.5', 'ex1.py'])
     y = time.clock() 
-    b = system_tools.MemoryUpdate()[0]
-    spamWriter.writerow([n ,(y-x),b])
-print a
+    spamWriter.writerow([n ,(y-x)])
+print 'Done'
 
+analyse_log(scenariodir, 'metalog.csv')
Index: /trunk/anuga_work/development/mem_time_tests/parameters/nothing/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/nothing/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/nothing/ex1.py	(revision 8326)
@@ -1,61 +1,64 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
 import os
-
+from anuga.utilities import log
 from anuga.abstract_2d_finite_volumes.util import add_directories
 
+#set up the variables to correctly store the temporary data
 home = os.getenv('INUNDATIONHOME')
-scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
-                                     "nothing"])
+scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
 
+#get the run number from the store text file
+f = open(file_path_store,'r+')
+n = float(f.readline())
+f.close()
 
-file = 'CAIRNS.sww'
-file_path = os.path.join(scenariodir, file)
+#set up the variables to correctly store the output data and log file
+scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
+                                     "nothing","nothing"+"-"+str(n)])
 
-h = 'CAIRNS.msh'
-file_pathh = os.path.join(scenariodir, h)
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
 
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
+points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
 
+domain.set_name('channel1') # Output name
+domain.set_datadir(scenariodir) 
 
+log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
 
-def runex():
-   points, vertices, boundary = anuga.rectangular_cross(10,5,
-   len1=10.0, len2=5.0) # Mesh
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_name('channel1') # Output name
-   domain.set_datadir(scenariodir) 
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
-   def topography(x, y):
-       return -x/10 # linear bed slope
-       domain.set_quantity('elevation', topography) # Use function for elevation
-       domain.set_quantity('friction', 0.01) # Constant friction
-       domain.set_quantity('stage', # Dry bed
-                           expression='elevation')
+def topography(x, y):
+    return -x/10 # linear bed slope
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage',expression='elevation')
+log.resource_usage_timing(prefix='afterinitialconditions')
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+Bi = anuga.Dirichlet_boundary([400, 0, 0]) # Inflow
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
 
+log.resource_usage_timing(prefix='afterboundary')  #get memory usage here
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
-      print domain.timestepping_statistics()
-   return len(domain)
+for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
+    print domain.timestepping_statistics()
 
-
+log.resource_usage_timing(prefix='aftersimulation')  #get memory usage here
Index: /trunk/anuga_work/development/mem_time_tests/parameters/nothing/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/nothing/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/nothing/main.py	(revision 8326)
@@ -1,47 +1,43 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
 import random
 import subprocess
-import ex1
 import csv
 import os
 from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-a = []
+from anuga.utilities.log_analyser import analyse_log
 
+#--------------------------------------------------------------------------------------
+# Set up variables for the correct directories to store the output
+#--------------------------------------------------------------------------------------
 home = os.getenv('INUNDATIONHOME')
-
-
-scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
-                                     "nothing"])
+scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"])
 file = 'ex1.csv'
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
 file_path = os.path.join(scenariodir, file)
+store = 'store.txt'
+file_path_store = os.path.join(scenariodir, store)
 
 spamWriter = csv.writer(open(file_path, 'wb'))
+spamWriter.writerow(['Run Number' , 'Time Taken','Space Used'])
+e = open(file_path_store,'a') #create the file
+e.close()
 
-spamWriter.writerow(['Run Number' , 'Time Taken','Space Used'])
+#main loop, that stores the current run number so that unique folders exist for the information
+for n in range(0,300,1):
 
+    e = open(file_path_store,'r+') 
+    e.write(str(n)) #store the run number
+   
+    x = time.clock() #time it
+    subprocess.call(['python2.5', 'ex1.py']) #run script
+    y = time.clock() #time it
 
-for n in range(0,300,1):
-    system_tools.MemoryUpdate()
-    x = time.clock()
-    ex1.runex()
-    y = time.clock() 
-    d = system_tools.MemoryUpdate()[0]
-    spamWriter.writerow([n ,(y-x),d])
-    a.append((n,y-x,d))
-print a
+    spamWriter.writerow([n ,(y-x)])
 
+print "DONE"
+
+analyse_log(scenariodir, 'metalog.csv') #get the memory usage from the log files
Index: /trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/ex1.py	(revision 8326)
@@ -1,50 +1,71 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
 import random
 import os
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
+#set up variables to store the temporary data
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
                                      "timelen-over-timestep"])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 
-def runex(g,f):
-   points, vertices, boundary = anuga.rectangular_cross(10,5,
-   len1=10.0, len2=5.0) # Mesh
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_name('channel1') # Output name
-   domain.set_datadir(scenariodir) 
+#get the time length and time step from the text files
+f = open(file_path_store,'r+') 
+g = float(f.readline())
+f.close()
+f = open(file_path_storen,'r+')
+h = float(f.readline())
+f.close()
+
+#set up variables to store the data and the log files
+scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
+                                       "timelen-over-timestep", "TT-" + str(g) +"-"+ str(h)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
+
+#------------------------------------------------------------------------------
+#Create Domain and Mesh
+#------------------------------------------------------------------------------
+points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_name('channel1') # Output name
+domain.set_datadir(scenariodirV) 
+
+log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
+
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
-   def topography(x, y):
-       return -x/10 # linear bed slope
-       domain.set_quantity('elevation', topography) # Use function for elevation
-       domain.set_quantity('friction', 0.01) # Constant friction
-       domain.set_quantity('stage', # Dry bed
-                           expression='elevation')
+def topography(x, y):
+    return -x/10 # linear bed slope
+
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage', expression='elevation')
+log.resource_usage_timing(prefix='afterinitialconditions')  #get memory usage here
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
-
+Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+log.resource_usage_timing(prefix='afterboundary')  #get memory usage here
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=f, finaltime=g):
-      print domain.timestepping_statistics()
+for t in domain.evolve(yieldstep=h, finaltime=g):
+    print domain.timestepping_statistics()
 
-
+log.resource_usage_timing(prefix='aftersimulation')  #get memory usage here
Index: /trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py	(revision 8326)
@@ -1,5 +1,2 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
@@ -10,39 +7,51 @@
 import random
 import subprocess
-import ex1
 import csv
 import os
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-a = []
-home = os.getenv('INUNDATIONHOME')
+from anuga.utilities.log_analyser import analyse_log
 
 
+#------------------------------------------------------------------------------
+# Set up variables for the correct directories to store the output
+#------------------------------------------------------------------------------
+home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
                                      "timelen-over-timestep"])
 file = 'ex1.csv'
+file_path = os.path.join(scenariodir, file)
+spamWriter = csv.writer(open(file_path, 'wb'))
+spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used'])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 
-log.log_filename = os.path.join(scenariodir, 'log.txt')
+#create each file
+e = open(file_path_store,'a') 
+e.close()
+e = open(file_path_storen,'a')
+e.close()
 
-file_path = os.path.join(scenariodir, file)
 
-spamWriter = csv.writer(open(file_path, 'wb'))
 
-spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used'])
-
+# main loops that give the time length (m) and the time step (n)
 for m in range(1,1000,50):
 
     for n in range(1,1000,5):
-        n = n/1000.0
-        system_tools.MemoryUpdate()
-        x = time.clock()
-        ex1.runex(float(m),n)
-        y = time.clock() 
-        b = system_tools.MemoryUpdate()[0]
-        spamWriter.writerow([m,n ,(y-x),b])
-        a.append((n,y-x,b))
-print a
+        n = n/1000.0 #adjust it so its small enough to see the nature of the relationship
 
+        #write to file
+        s = open(file_path_store,'r+')
+        s.write(str(float(m)))
+        t = open(file_path_storen,'r+')
+        t.write(str(n))
+
+        x = time.clock()#time it
+        subprocess.call(['python2.5', 'ex1.py'])#run it
+        y = time.clock()#time it
+        spamWriter.writerow([m,n ,(y-x),'b'])#write the results
+
+print 'Done'
+
+analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the log files
Index: /trunk/anuga_work/development/mem_time_tests/parameters/timelen/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/timelen/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/timelen/ex1.py	(revision 8326)
@@ -1,50 +1,67 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
 import os
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
+#set up variables for the temporary data files
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
                                      "timelength"])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
 
-def runex(f):
-   points, vertices, boundary = anuga.rectangular_cross(10,5,
-   len1=10.0, len2=5.0) # Mesh
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_name('channel1') # Output name
-   domain.set_datadir(scenariodir)  
+#get the time length from the store text file
+s = open(file_path_store,'r+')
+f = float(s.readline())
+s.close()
+
+#set up variables to store the results and the log files of each experiment
+scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
+                                       "timelength", "timelength-" + str(f)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
+
+#------------------------------------------------------------------------------
+# Create the domain and the mesh of the run
+#------------------------------------------------------------------------------
+points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_name('channel1') # Output name
+domain.set_datadir(scenariodirV)  
+
+log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
-   def topography(x, y):
-       return -x/10 # linear bed slope
-       domain.set_quantity('elevation', topography) # Use function for elevation
-       domain.set_quantity('friction', 0.01) # Constant friction
-       domain.set_quantity('stage', # Dry bed
-                           expression='elevation')
+def topography(x, y):
+    return -x/10 # linear bed slope
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage',expression='elevation')
+
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+
+log.resource_usage_timing(prefix='afterboundary')#get memory usage here
 
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=0.2, finaltime=f):
-      print domain.timestepping_statistics()
-   return f
+for t in domain.evolve(yieldstep=0.2, finaltime=f):
+    print domain.timestepping_statistics()
 
 
+log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
+
Index: /trunk/anuga_work/development/mem_time_tests/parameters/timelen/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/timelen/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/timelen/main.py	(revision 8326)
@@ -1,47 +1,44 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
-import random
 import subprocess
-import ex1
 import csv
 import os
 from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-a = []
-
-home = os.getenv('INUNDATIONHOME')
+from anuga.utilities.log_analyser import analyse_log
 
 
+#------------------------------------------------------------------------------
+# Set up variables for the correct directories to store the output
+#------------------------------------------------------------------------------
+home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
                                      "timelength"])
 file = 'ex1.csv'
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
 file_path = os.path.join(scenariodir, file)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
 
 spamWriter = csv.writer(open(file_path, 'wb'))
+spamWriter.writerow(['Time Length(s)' , 'Time Taken(s)', 'Space Used'])
+e = open(file_path_store,'a')
+e.close()
 
-spamWriter.writerow(['Number Of Triangles' , 'Time Taken', 'Space Used'])
+#main loop that does the same experiment with different time lengths
+for n in range(1,100000,100):
 
+    h = open(file_path_store,'r+')
+    h.write(str(n)) #store the time length
 
-for n in range(1,1000,100):
-    system_tools.MemoryUpdate()
-    x = time.clock()
-    h = ex1.runex(n)
-    y = time.clock() 
-    b = system_tools.MemoryUpdate()[0]
-    spamWriter.writerow([h ,(y-x),b])
-    a.append((h,y-x,b))
-print a
+    x = time.clock() #time it
+    subprocess.call(['python2.5', 'ex1.py']) #run script
+    y = time.clock() #time it
+    spamWriter.writerow([n ,(y-x)]) #write results
 
+print 'Done'
+
+#get the memory usage from the log files of each run
+analyse_log(scenariodir, 'metalog.csv')
Index: /trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py	(revision 8326)
@@ -1,5 +1,2 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
@@ -10,41 +7,59 @@
 import random
 import os
+from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
+
+#set up the variables for the temporary file directories
+home = os.getenv('INUNDATIONHOME')
+scenariodir = add_directories(home, ["data","mem_time_test", "parameters","timestep"])
+
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+
+s = open(file_path_store,'r+') # read the timestep from the text file
+f = float(s.readline())
+s.close()
+
+#set up the variables for the log files and data directories
+scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
+                                       "timestep", "timestep-" + str(f)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
-from anuga.abstract_2d_finite_volumes.util import add_directories
+points, vertices, boundary = anuga.rectangular_cross(10,5,len1=10.0, len2=5.0) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_name('channel1') # Output name
+domain.set_datadir(scenariodirV) 
 
-home = os.getenv('INUNDATIONHOME')
-scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
-                                     "timestep"])
-
-def runex(f):
-   points, vertices, boundary = anuga.rectangular_cross(10,5,
-   len1=10.0, len2=5.0) # Mesh
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_name('channel1') # Output name
-   domain.set_datadir(scenariodir) 
+log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
-   def topography(x, y):
-       return -x/10 # linear bed slope
-       domain.set_quantity('elevation', topography) # Use function for elevation
-       domain.set_quantity('friction', 0.01) # Constant friction
-       domain.set_quantity('stage', # Dry bed
-                           expression='elevation')
+def topography(x, y):
+    return -x/10 # linear bed slope
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage', expression='elevation')
+
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
+Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
 
+log.resource_usage_timing(prefix='afterboundary') #get memory usage here
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=f, finaltime=40.0):
-      print domain.timestepping_statistics()
+for t in domain.evolve(yieldstep=f, finaltime=40.0):
+    print domain.timestepping_statistics()
 
+log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
 
Index: /trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py	(revision 8326)
@@ -1,47 +1,44 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
-import random
 import subprocess
-import ex1
 import csv
 import os
-from anuga.utilities import system_tools, log
+from anuga.utilities import log
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
+
 #------------------------------------------------------------------------------
-# Setup computational domain
+# Set up variables for the correct directories to store the output
 #------------------------------------------------------------------------------
-a = []
 home = os.getenv('INUNDATIONHOME')
-
-
 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
                                      "timestep"])
 file = 'ex1.csv'
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
 file_path = os.path.join(scenariodir, file)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
 
 spamWriter = csv.writer(open(file_path, 'wb'))
+spamWriter.writerow(['TimeStep' , 'Time Taken','Space Used'])
 
-spamWriter.writerow(['Friction' , 'Time Taken','Space Used'])
+e = open(file_path_store,'a') # create file
+e.close()
 
+#main loop that runs the script with different time steps (yield steps)
+for n in range(1,10000,10):
+    n = n/100.0 # get it in the right range
 
-for n in range(1,100,1):
-    n = n/100.0
-    system_tools.MemoryUpdate()
-    x = time.clock()
-    ex1.runex(n)
-    y = time.clock() 
-    b = system_tools.MemoryUpdate()[0]
-    spamWriter.writerow([n ,(y-x),b])
-    a.append((n,y-x,b))
-print a
+    g = open(file_path_store,'r+')
+    g.write(str(n)) #write the time step to the file
 
+    x = time.clock()#time it
+    subprocess.call(['python2.5', 'ex1.py']) # run it
+    y = time.clock() #time it
+    spamWriter.writerow([n ,(y-x),'b']) #record results
+
+print 'Done'
+
+analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
Index: /trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/ex1.py	(revision 8326)
@@ -1,9 +1,5 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
@@ -11,53 +7,73 @@
 import os
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
+#set up the variables for the temporary storage files
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
                                      "channelflow"])
+store = 'store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen = 'storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 
+#read the percentage of water coverage and the length of the boundary
+f = open(file_path_store,'r+')
+length = float(f.readline())
+f.close()
+f = open(file_path_storen,'r+')
+lower = float(f.readline())
+f.close()
+
+#set up variables to store the experiment data and the log file
+scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
+                                       "channelflow", "channelflow-" + str(lower) +"-"+ str(length)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
-def runex(lower,length):
-   points, vertices, boundary = anuga.rectangular_cross(50,50,
-                                                     len1=length, len2=length) # Mesh
+points, vertices, boundary = anuga.rectangular_cross(100,300,len1=length, len2=length) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_datadir(scenariodir) 
+domain.set_name('channel1.sww') # Output name
 
+log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
 #--------------------------------------------------------------------------
-# Setup Domain only on processor 0
+# Setup Initial Conditions
 #--------------------------------------------------------------------------
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_datadir(scenariodir) 
-   domain.set_name('channel1.sww') # Output name
+def topography(x, y):
+    z = -x/10
+    N = len(x)
+    
+    #makes a step 
+    for i in range(N):
 
-   def topography(x, y):
-      z = -x/10
-      N = len(x)
-      for i in range(N):
-         if y[i] > lower:
-            z[i] += 1
+        if y[i] > lower:
+           z[i] += 1
               
-      return  z
+    return  z
 
-   domain.set_quantity('elevation', topography) # Use function for elevation
-   domain.set_quantity('friction', 0.01) # Constant friction
-   domain.set_quantity('stage', -1000.0)
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage', -10000000000000000000000.0)
 
-
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow
-   Bo = anuga.Dirichlet_boundary([-100,0,0]) 
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow
+Bo = anuga.Dirichlet_boundary([-100,0,0]) 
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
 
+log.resource_usage_timing(prefix='afterboundary')#get memory usage
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
-     #if myid == 0:
-       domain.write_time()
+for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
+    domain.write_time()
 
-#domain.sww_merge()
-#finalize()
-
+log.resource_usage_timing(prefix='aftersimulation') #get memory usage
Index: /trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/main.py	(revision 8326)
@@ -1,48 +1,55 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import random
 import subprocess
-import ex1
 import csv
 import os
 import time
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 
 #------------------------------------------------------------------------------
-# Setup computational domain
+# Set up variables for the correct directories to store the output
 #------------------------------------------------------------------------------
-a = []
-
-
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
                                      "channelflow"])
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 file = 'ex1.csv'
 file_path = os.path.join(scenariodir, file)
 
+#set up the output files
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Length','Stage','Time','Space'])
+e = open(file_path_store,'a')
+e.close()
+e = open(file_path_storen,'a')
+e.close()
 
+#the main loops that give the length of the inflow boundary (i) and the place to begin the step (n)
 for i in range(100,100000,10000):
+    for n in range(1,i/10,i/100):
+        
+        #adjust
+        i = i /100.0
+        n = n/10.0 
 
-    for n in range(1,i/10,i/100):
-        i = i /100.0
-        n = n/float(i) 
-        system_tools.MemoryUpdate()
-        z = time.time()
-        ex1.runex(n,i)
-        b = system_tools.MemoryUpdate()[0]
-        y = time.time()
-        spamWriter.writerow([i,(n/float(i)) ,(y-z), b])
-print a
+        #write these values to files
+        g = open(file_path_store,'r+')
+        g.write(str(i))
+        h = open(file_path_storen,'r+')
+        h.write(str(n))
 
+        z = time.time() #time it
+        subprocess.call(['python2.5', 'ex1.py'])#run the script
+        y = time.time() #time it
+
+        spamWriter.writerow([i,n,(y-z), 'b'])#record it
+print 'DONE'
+
+analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the various log files
Index: /trunk/anuga_work/development/mem_time_tests/scenarios/stage/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/scenarios/stage/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/scenarios/stage/ex1.py	(revision 8326)
@@ -1,9 +1,5 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
@@ -11,49 +7,65 @@
 import os
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
+#set up the variables for the temporary data storage
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
                                      "stage"])
+store = 'store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen = 'storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 
+#read the values from the text files
+f = open(file_path_store,'r+')
+l = float(f.readline())
+f.close()
+f = open(file_path_storen,'r+')
+tide = float(f.readline())
+f.close()
 
+#set up variables to store the output of the simulation and the log files
+scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
+                                       "stage", "stage-" + str(tide) +"-"+ str(l)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
 
+log.resource_usage_timing(prefix = 'BeforeSimulation')# get memory usage
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
-def runex(l,tide):
+points, vertices, boundary = anuga.rectangular_cross(100,300,
+                                                     len1=l, len2=(l/2)) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_datadir(scenariodirV) 
+domain.set_name('channel1') # Output name
 
-   points, vertices, boundary = anuga.rectangular_cross(50,50,
-                                                     len1=l, len2=(l/2)) # Mesh
-
+log.resource_usage_timing(prefix = 'AfterMesh')# get memory usage
 
 #--------------------------------------------------------------------------
-# Setup Domain only on processor 0
+# Setup initial conditions
 #--------------------------------------------------------------------------
+def topography(x, y):
+    return  0 #flat land
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage', tide)
 
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_datadir(scenariodir) 
-   domain.set_name('channel1') # Output name
-
-   def topography(x, y):
-       return  0 #-x/10  linear bed slope
-   domain.set_quantity('elevation', topography) # Use function for elevation
-   domain.set_quantity('friction', 0.01) # Constant friction
-   domain.set_quantity('stage', tide)
-    
+log.resource_usage_timing(prefix='afterinitialconditions') # get memory usage
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-#Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+
+log.resource_usage_timing(prefix='afterboundary')# get memory usage
 
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
-       domain.write_time()
+for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
+    domain.write_time()
 
-#domain.sww_merge()
-#finalize()
-
+log.resource_usage_timing(prefix='aftersimulation')# get memory usage
Index: /trunk/anuga_work/development/mem_time_tests/scenarios/stage/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/scenarios/stage/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/scenarios/stage/main.py	(revision 8326)
@@ -1,48 +1,51 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import random
 import subprocess
-import ex1
 import csv
 import os
 import time
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
-
+from anuga.utilities.log_analyser import analyse_log
 
 #------------------------------------------------------------------------------
-# Setup computational domain
+# Set up variables for the correct directories to store the output
 #------------------------------------------------------------------------------
-a = []
-
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
                                      "stage"])
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
 file = 'ex1.csv'
 file_path = os.path.join(scenariodir, file)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 
+#create files
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Stage','Extent','Time','Space'])
+e = open(file_path_store,'a')
+e.close()
+e = open(file_path_storen,'a')
+e.close()
 
+#these are the main loops that determine the side length of the bounding square(m)
+#and the depth of the initial water (n)
+for m in range(100,1000,100):
+    for n in range(1,100,10):
+ 
+        # thsese values are written to the files
+        g = open(file_path_store,'r+')
+        g.write(str(m))
+        h = open(file_path_storen,'r+')
+        h.write(str(n))
 
-def onevar(b):
-    for n in range(1,100,10):
-        system_tools.MemoryUpdate()
-        z = time.time()
-        ex1.runex(b,n)
-        y = time.time()
-        a = system_tools.MemoryUpdate()[0]
-        spamWriter.writerow([n ,((b**2)/2),(y-z),a])
-    print a
+        z = time.time() #time it
+        subprocess.call(['python2.5', 'ex1.py']) # run the simulation script
+        y = time.time() #time it
+        spamWriter.writerow([n ,((m**2)/2),(y-z),'a']) #record it
+print 'DONE'
 
-for m in range(100,1000,100):
-    onevar(m)
-
+analyse_log(scenariodir, 'metalog.csv') #get the memory usage information from the log files
Index: /trunk/anuga_work/development/mem_time_tests/scenarios/vel2/ex1.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/scenarios/vel2/ex1.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/scenarios/vel2/ex1.py	(revision 8326)
@@ -1,9 +1,5 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import time
@@ -11,47 +7,75 @@
 import os
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
+# set up the variables for the temporary files
 home = os.getenv('INUNDATIONHOME')
-scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
-                                     "serial"])
+scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
+                                     "velocity"])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen = 'storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
+storea = 'storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
 
+# read the velocity and the map side length from the text files
+f = open(file_path_store,'r+')
+k = float(f.readline())
+f.close()
+f = open(file_path_storen,'r+')
+l = float(f.readline())
+f.close()
+
+#set up variables for the simulation output and the log files
+scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
+                                       "velocity", "velocity-" + str(k) +"-"+ str(l)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
 #------------------------------------------------------------------------------
 # Setup computational domain
 #------------------------------------------------------------------------------
-def runex(k,l):
+points, vertices, boundary = anuga.rectangular_cross(100,300, len1=1000, len2=500) # Mesh
+domain = anuga.Domain(points, vertices, boundary) # Create domain
+domain.set_name('channel1') # Output name
+domain.set_datadir(scenariodirV) 
 
-   points, vertices, boundary = anuga.rectangular_cross(100,100,
-                                                       len1=l, len2=l) # Mesh
+log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage 
+
+#get the number of triangles
+number = len(domain)
 
 #--------------------------------------------------------------------------
-# Setup Domain only on processor 0
+# Setup initial conditions
 #--------------------------------------------------------------------------
-   domain = anuga.Domain(points, vertices, boundary) # Create domain
-   domain.set_name('channel1') # Output name
-   domain.set_datadir(scenariodir) 
-   
-   number = len(domain)
+def topography(x, y):
+    return  0.0
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.01) # Constant friction
+domain.set_quantity('stage', -1000.0)
 
-   def topography(x, y):
-       return  0.0
-
-   domain.set_quantity('elevation', topography) # Use function for elevation
-   domain.set_quantity('friction', 0.01) # Constant friction
-   domain.set_quantity('stage', -1000.0)
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
-   Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow 
-   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
-   Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
-   domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow 
+Br = anuga.Reflective_boundary(domain) # Solid reflective wall
+Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+log.resource_usage_timing(prefix='afterboundary')#get memory usage
 
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-   for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
-       domain.write_time()
+for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
+    domain.write_time()
 
-   return number
+log.resource_usage_timing(prefix='aftersimulation')  #get memory usage
 
+#write the number of triangles to the file
+c = open(file_path_storea,'r+')
+c.write(str(number))
Index: /trunk/anuga_work/development/mem_time_tests/scenarios/vel2/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/scenarios/vel2/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/scenarios/vel2/main.py	(revision 8326)
@@ -1,47 +1,59 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import random
 import subprocess
-import ex1
 import csv
 import os
 import time
-from anuga.utilities import log
-from anuga.utilities import system_tools
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 
 #------------------------------------------------------------------------------
-# Setup computational domain
+# Set up variables for the correct directories to store the output
 #------------------------------------------------------------------------------
-a = []
-
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
                                      "velocity"])
-
 file = 'ex1.csv'
 file_path = os.path.join(scenariodir, file)
+storea ='storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
+#create and set up the files
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Velocity','Number Of Triangles','Extent','Time','Space'])
-system_tools.MemoryUpdate()
+e = open(file_path_storea,'a')
+e.close()
+e = open(file_path_store,'a')
+e.close()
+e = open(file_path_storen,'a')
+e.close()
 
+# these are the main loops that give the velocity of inflow (m) and the map side length(n)
+for m in range(0,250,10):
+     for n in range(1,2000,300):  
+        #write these values to the temporary file
+        g = open(file_path_store,'r+')
+        g.write(str(m))
+        h = open(file_path_storen,'r+')
+        h.write(str(n))
 
-for m in range(0,250,10):
-     for i in range(1,2000,100):  
-        system_tools.MemoryUpdate()[0]
-        z = time.time()
-        h = ex1.runex(k,i)
-        b = system_tools.MemoryUpdate()[0]
-        y = time.time()
-        spamWriter.writerow([k,h,(i*i),(y-z), b])
+        z = time.time() #time it
+        subprocess.call(['python2.5', 'ex1.py'])#run simulation script
+        y = time.time() #time it
 
+        # read the number of triangles from this text file
+        f = open(file_path_storea,'r+')
+        h = float(f.readline())
+        f.close()
+        
+        spamWriter.writerow([m,h,(n*n),(y-z), 'b'])# record it
 print 'DONE'  
+
+analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
Index: /trunk/anuga_work/development/mem_time_tests/triangles/area/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/area/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/area/main.py	(revision 8326)
@@ -1,9 +1,5 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import subprocess
@@ -12,18 +8,13 @@
 import time
 import liststore
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
-
+from anuga.utilities.log_analyser import analyse_log
 
 #------------------------------------------------------------------------------
-# Setup computational domain
+# Set up variables for the correct directories to store the output
 #------------------------------------------------------------------------------
-a = []
-#SpaceUsed = 0.0
-#number = 0
-
-home1 = os.getenv('INUNDATIONHOME')
+home = os.getenv('INUNDATIONHOME')
 host = os.getenv('HOST')
-scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","area"])
+scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"])
 file1 = 'ex1.csv'
 file_path = os.path.join(scenariodir, file1)
@@ -32,15 +23,10 @@
 storea ='storea.txt'
 file_path_storea = os.path.join(scenariodir, storea)
-store ='store.txt'
-file_path_store = os.path.join(scenariodir, store)
 storen ='storen.txt'
 file_path_storen = os.path.join(scenariodir, storen)
 
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
+#create and set up the files
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s'])
-e = open(file_path_store,'a')
-e.close()
 e = open(file_path_storea,'a')
 e.close()
@@ -50,20 +36,23 @@
 e.close()
 
+# this is the main loops that assigns the maximum triangle area (m) and the map side length(l)
 
+n = 4 #number of processors to use
 for m in range(90,100,10):
-     n = 4 #number of processors to use
      for l in range(100,2000,100):
         
+        #write these values to file
         g = open(file_path_storel,'r+')
         g.write(str(l))
+        h = open(file_path_storea,'r+')
+        h.write(str(m))
+        
+        z = time.time()# time it
 
-        h = open(file_path_storea,'r+')
-        h.write(str(d))
-        
-        z = time.time()
+        #the different ways each host calls MPI properly
         if (host == 'cyclone.agso.gov.au'):
-            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 
+            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
         if (host == 'tornado.agso.gov.au'):
-            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
+            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
         if (host == 'vayu1'):
             subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
@@ -73,18 +62,15 @@
             subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
        
-        y = time.time()
+        y = time.time()# time it
 
-        f = open(file_path_store,'r+')
-        x = float(f.readline())
-        f.close()
-
+        # read the number of triangles from this file
         f = open(file_path_storen,'r+')
         i = float(f.readline())
         f.close()
 
-        spamWriter.writerow([i,d,(l*l),x ,(y-z)])
-        liststore.store = [0,0,0,0]
-
+        spamWriter.writerow([i,d,(l*l),'x' ,(y-z)])# record it
 
 print 'Done'
 
+analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
+
Index: /trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py	(revision 8326)
@@ -1,59 +1,43 @@
-"""Script for running a tsunami inundation scenario for Cairns, QLD Australia.
-
-Source data such as elevation and boundary data is assumed to be available in
-directories specified by project.py
-The output sww file is stored in directory named after the scenario, i.e
-slide or fixed_wave.
-
-The scenario is defined by a triangular mesh created from project.polygon,
-the elevation data and a tsunami wave generated by a submarine mass failure.
-
-Geoscience Australia, 2004-present
-"""
-
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Standard modules
 import os
 import time
 import sys
 import liststore
-
-# Related major packages
 import anuga
 from anuga_parallel import distribute, myid
 from anuga.abstract_2d_finite_volumes.util import add_directories
-from anuga.utilities import system_tools, log
+from anuga.utilities import log
 
+#set up the variables for the temporary data files
+home = os.getenv('INUNDATIONHOME')
+scenariodir = add_directories(home, ["data", "mem_time_test", "triangles", "area"])
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
+storel = 'storel.txt'
+file_path_storel = os.path.join(scenariodir, storel)
+storea = 'storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
 
-home2 = os.getenv('INUNDATIONHOME')
-
-scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
-
-h = 'CAIRNS.msh'
-file_pathh = os.path.join(scenariodir2, h)
-store ='store.txt'
-file_path_store = os.path.join(scenariodir2, store)
-storen ='storen.txt'
-file_path_storen = os.path.join(scenariodir2, storen)
-storel = 'storel.txt'
-file_path_storel = os.path.join(scenariodir2, storel)
-storea = 'storea.txt'
-file_path_storea = os.path.join(scenariodir2, storea)
-
-f = open(file_path_storel,'r+') # SQRT extent this is set
+#read the maximum triangle area and the map side length from the files
+f = open(file_path_storel,'r+')
 length = float(f.readline())
 f.close()
-
-f = open(file_path_storea,'r+') #maxarea this is set
+f = open(file_path_storea,'r+')
 area = float(f.readline())
 f.close()
 
-system_tools.MemoryUpdate()
+#set up the variables for the output data and the log files
+scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
+                                       "area", "triangles-" + str(area) +"-"+ str(length)])
+h = 'CAIRNS.msh'
+file_pathh = os.path.join(scenariodirV, h)
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
+
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
 #------------------------------------------------------------------------------
-# Create the triangular mesh and domain based on 
-# overall clipping polygon with a tagged
-# boundary and interior regions as defined in project.py
+# Create the triangular mesh and domain on one processor
 #------------------------------------------------------------------------------
 if myid == 0:
@@ -65,21 +49,18 @@
                                     maximum_triangle_area=area,
                                     mesh_filename=file_pathh
-                                    #,interior_regions=INTERIORREGIONS#,
-                                    #use_cache=True,
-                                    #verbose=True)
                                     )
+    #get the number of triangles
+    n = len(domain)
 
-    n = len(domain)
 else:
     domain = None
-     
-domain = distribute(domain)
-                               
-#------------------------------------------------------------------------------
-# Setup parameters of computational domain
-#------------------------------------------------------------------------------
+ 
+#parallel   
+domain = distribute(domain)                               
+
 domain.set_name('CAIRNS.sww') # Name of sww file
-domain.set_datadir(scenariodir2)                       # Store sww output here
+domain.set_datadir(scenariodirV)# Store sww output here
 
+log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
 #------------------------------------------------------------------------------
 # Setup initial conditions
@@ -95,5 +76,5 @@
 domain.set_quantity('elevation',topography,alpha=0.1)
 
-
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
 
 #------------------------------------------------------------------------------
@@ -102,29 +83,18 @@
 
 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
-Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
-Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
+Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow
 Br = anuga.Reflective_boundary(domain)
-#Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
-domain.set_boundary({'right': Bo,
-                     'bottom': Br,
-                     'left': Bi,
-                     'top': Br})
+domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
 
-
+log.resource_usage_timing(prefix='afterboundary')#get memory usage
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-
-# Save every two mins leading up to wave approaching land
 for t in domain.evolve(yieldstep=120, finaltime=2000): 
     print domain.timestepping_statistics()
-    
 
-liststore.store[myid] = system_tools.MemoryUpdate()[0]
-a = sum(liststore.store)
+log.resource_usage_timing(prefix='aftersimulation') #get memory usage
 
-v = open(file_path_store, 'r+')
-v.write(str(a))
-
+#write the number of triangles to file
 i = open(file_path_storen, 'r+')
 i.write(str(n))
Index: /trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py	(revision 8326)
@@ -1,49 +1,59 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import subprocess
-import runcairns
 import csv
 import os
 import time
-from anuga.utilities import system_tools, log
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 
 #------------------------------------------------------------------------------
-# Setup computational domain
+# Set up variables for the correct directories to store the output
 #------------------------------------------------------------------------------
-a = []
-
-
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
                                      "fromregions"])
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
+storea ='storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 file = 'ex1.csv'
 file_path = os.path.join(scenariodir, file)
 
+#create and set up the files
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s'])
+e = open(file_path_storea,'a')
+e.close()
+e = open(file_path_store,'a')
+e.close()
+e = open(file_path_storen,'a')
+e.close()
 
+#these are the main loops that determine the maximum triangle area (m) and the map side length(n)
+for m in range(1,100,10):
+    for n in range(1,1000,100):
 
+        #write these values to file
+        g = open(file_path_store,'r+')
+        g.write(str(m))
+        h = open(file_path_storen,'r+')
+        h.write(str(n))
 
-def runlist(r):
-    for n in range(1,2000,100):
-        system_tools.MemoryUpdate()
-        z = time.time()
-        h = runcairns.runex(n,r)
-        y = time.time()
-        x = system_tools.MemoryUpdate()[0]
-        spamWriter.writerow([h,r,(n*n),x ,(y-z)])
+        z = time.time() #time it
+        subprocess.call(['python2.5', 'runcairns.py'])#run simulation
+        y = time.time() #time it
 
-for m in range(1,100,10):
-    runlist(m)
+        #read the number of triangles from this text file
+        f = open(file_path_storea,'r+')
+        h = float(f.readline())
+        f.close()
 
+        spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it
 print 'DONE'
 
+analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files 
Index: /trunk/anuga_work/development/mem_time_tests/triangles/fromregions/runcairns.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/fromregions/runcairns.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/fromregions/runcairns.py	(revision 8326)
@@ -1,51 +1,45 @@
-"""Script for running a tsunami inundation scenario for Cairns, QLD Australia.
-
-Source data such as elevation and boundary data is assumed to be available in
-directories specified by project.py
-The output sww file is stored in directory named after the scenario, i.e
-slide or fixed_wave.
-
-The scenario is defined by a triangular mesh created from project.polygon,
-the elevation data and a tsunami wave generated by a submarine mass failure.
-
-Geoscience Australia, 2004-present
-"""
-
-
-
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Standard modules
 import os
 import time
 import sys
 import random
-
-# Related major packages
-
 import anuga
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
-
+# set up the variables for the temporary files
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
                                      "fromregions"])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
+storea = 'storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
 
+#read the maximum triangle area and map side length from the text files
+f = open(file_path_store,'r+')
+a = float(f.readline())
+f.close()
+f = open(file_path_storen,'r+')
+l = float(f.readline())
+f.close()
 
-file = 'CAIRNS.sww'
-file_path = os.path.join(scenariodir, file)
+#set up the variables for the simulation output and the log files
+scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
+                                       "fromregions", "triangles-" + str(a) +"-"+ str(l)])
+h = 'CAIRNS.msh'
+file_pathh = os.path.join(scenariodirV, h)
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
 
-h = 'CAIRNS.msh'
-file_pathh = os.path.join(scenariodir, h)
-
-def runex(l,a):
-
+log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
 #------------------------------------------------------------------------------
-# Create the triangular mesh and domain based on 
-# overall clipping polygon with a tagged
-# boundary and interior regions as defined in project.py
+# Create the triangular mesh and domain
 #------------------------------------------------------------------------------
-    domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
+domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
                                     boundary_tags={'top': [0],
                                                    'right': [1],
@@ -54,56 +48,45 @@
                                     maximum_triangle_area=a,
                                     mesh_filename=file_pathh
-                                    #,interior_regions=INTERIORREGIONS#,
-                                    #use_cache=True,
-                                    #verbose=True)
-                                    )
-
-    number=len(domain)
-
-                               
-#------------------------------------------------------------------------------
-# Setup parameters of computational domain
-#------------------------------------------------------------------------------
-    domain.set_name('CAIRNS.sww') # Name of sww file
-    domain.set_datadir(scenariodir)                       # Store sww output here
-
+                                    )                            
+domain.set_name('CAIRNS.sww') # Name of sww file
+domain.set_datadir(scenariodirV)# Store sww output here
+log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
 
-    def topography(x,y):
-        return 0.0
+#get the number of triangles
+number=len(domain)
 
-    tide = 100.0
-    friction = 0.0
-    domain.set_quantity('stage', tide)
-    domain.set_quantity('friction', friction) 
-    domain.set_quantity('elevation',topography,alpha=0.1)
+def topography(x,y):
+    return 0.0
 
+tide = 100.0
+friction = 0.0
+domain.set_quantity('stage', tide)
+domain.set_quantity('friction', friction) 
+domain.set_quantity('elevation',topography,alpha=0.1)
 
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
 
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
+Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
+Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
+Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
+Br = anuga.Reflective_boundary(domain)
+domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
 
-    Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
-    Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
-    Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
-    Br = anuga.Reflective_boundary(domain)
-#Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
-    domain.set_boundary({'right': Bo,
-                     'bottom': Br,
-                     'left': Bi,
-                     'top': Br})
-
+log.resource_usage_timing(prefix='afterboundary')#get memory usage
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
-
-# Save every two mins leading up to wave approaching land
-    for t in domain.evolve(yieldstep=120, finaltime=2000): 
-        print domain.timestepping_statistics()
-    
-
-    return number
-
+for t in domain.evolve(yieldstep=120, finaltime=2000): 
+    print domain.timestepping_statistics()
+  
+log.resource_usage_timing(prefix='aftersimulation')#get memory usage
+  
+#write the number of triangles to file
+i = open(file_path_storea, 'r+')
+i.write(str(number))
Index: /trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/main.py	(revision 8326)
@@ -1,49 +1,60 @@
-"""Simple water flow example using ANUGA
-Water flowing down a channel
-"""
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Import standard shallow water domain and standard boundaries.
 import anuga
 import subprocess
-import runcairns
 import csv
 import os
 import time
+from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities.log_analyser import analyse_log
 
-from anuga.utilities import system_tools, log
-from anuga.abstract_2d_finite_volumes.util import add_directories
-
+#------------------------------------------------------------------------------
+# Set up variables for the correct directories to store the output
+#------------------------------------------------------------------------------
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
                                      "rectanglecross"])
-
-log.log_filename = os.path.join(scenariodir, 'log.txt')
-
+storea ='storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
 file = 'ex1.csv'
 file_path = os.path.join(scenariodir, file)
 
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-a = []
+#create and set up the output files
 spamWriter = csv.writer(open(file_path, 'wb'))
 spamWriter.writerow(['Number Of Triangles' ,'MxM Rectangular Mesh', 'Extent', 'Space Used MB' , 'Time Taken s'])
+e = open(file_path_storea,'a')
+e.close()
+e = open(file_path_store,'a')
+e.close()
+e = open(file_path_storen,'a')
+e.close()
 
+#these main loops assign the matrix size[number of triangles] (m) and the map side length(n)
+for m in range(1,500,10):
+    for n in range(1,1000,100):
 
+        #write these values to file
+        g = open(file_path_store,'r+')
+        g.write(str(m))
+        h = open(file_path_storen,'r+')
+        h.write(str(n))
 
-def runlist(r):
-    for n in range(1,2000,100):
-        system_tools.MemoryUpdate()
-        z = time.time()
-        h = runcairns.runex(n,r)
-        y = time.time()
-        x = system_tools.MemoryUpdate()[0]
-        spamWriter.writerow([h,r,(n*n),x ,(y-z)])
+        z = time.time() #time it
+        subprocess.call(['python2.5', 'runcairns.py']) #run the simulation
+        y = time.time() #time it
 
-for m in range(1,100,10):
-    runlist(m)
+        #read the number of triangles from this file
+        f = open(file_path_storea,'r+')
+        h = float(f.readline())
+        f.close()
 
+        spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it
 print 'DONE'
 
+analyse_log(scenariodir, 'metalog.csv')#get the memory statistics from the log files
+
Index: /trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/runcairns.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/runcairns.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/runcairns.py	(revision 8326)
@@ -1,101 +1,81 @@
-"""Script for running a tsunami inundation scenario for Cairns, QLD Australia.
-
-Source data such as elevation and boundary data is assumed to be available in
-directories specified by project.py
-The output sww file is stored in directory named after the scenario, i.e
-slide or fixed_wave.
-
-The scenario is defined by a triangular mesh created from project.polygon,
-the elevation data and a tsunami wave generated by a submarine mass failure.
-
-Geoscience Australia, 2004-present
-"""
-
-
-
 #------------------------------------------------------------------------------
 # Import necessary modules
 #------------------------------------------------------------------------------
-# Standard modules
 import os
 import time
 import sys
-import random
-
-# Related major packages
 import anuga
 from anuga.abstract_2d_finite_volumes.util import add_directories
+from anuga.utilities import log
 
+#set up the variables for the temporary data files
 home = os.getenv('INUNDATIONHOME')
 scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
                                      "rectanglecross"])
+store ='store.txt'
+file_path_store = os.path.join(scenariodir, store)
+storen ='storen.txt'
+file_path_storen = os.path.join(scenariodir, storen)
+storea = 'storea.txt'
+file_path_storea = os.path.join(scenariodir, storea)
 
+#read the matrix size(number of triangles) and the map size from these files
+f = open(file_path_store,'r+')
+a = int(f.readline())
+f.close()
+f = open(file_path_storen,'r+') 
+l = float(f.readline())
+f.close()
 
-file = 'CAIRNS.sww'
-file_path = os.path.join(scenariodir, file)
+#set up the variables for the simulation out put and log files
+scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
+                                       "rectanglecross", "triangles-" + str(a) +"-"+ str(l)])
+log.log_filename = os.path.join(scenariodirV, "anuga.log")
+log._setup = False
 
-h = 'CAIRNS.msh'
-file_pathh = os.path.join(scenariodir, h)
-
-
-def runex(l,a):
-
-
+log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage
 #------------------------------------------------------------------------------
-# Create the triangular mesh and domain based on 
-# overall clipping polygon with a tagged
-# boundary and interior regions as defined in project.py
+# Create the triangular mesh and domain
 #------------------------------------------------------------------------------
-    
-    points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh
-    domain = anuga.Domain(points, vertices, boundary) # Create domain
-
-    number=len(domain)
-
-                               
-#------------------------------------------------------------------------------
-# Setup parameters of computational domain
-#------------------------------------------------------------------------------
-    domain.set_name('CAIRNS.sww') # Name of sww file
-    domain.set_datadir(scenariodir)                       # Store sww output here
-
+points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh
+domain = anuga.Domain(points, vertices, boundary) # Create 
+domain.set_name('CAIRNS.sww') # Name of sww file
+domain.set_datadir(scenariodirV)# Store sww output here
+log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage 
 #------------------------------------------------------------------------------
 # Setup initial conditions
 #------------------------------------------------------------------------------
 
-    def topography(x,y):
-        return 0.0
+#get the number of triangles
+number=len(domain)
 
-    tide = 100.0
-    friction = 0.0
-    domain.set_quantity('stage', tide)
-    domain.set_quantity('friction', friction) 
-    domain.set_quantity('elevation',topography,alpha=0.1)
+def topography(x,y):
+    return 0.0
 
+tide = 100.0
+friction = 0.0
+domain.set_quantity('stage', tide)
+domain.set_quantity('friction', friction) 
+domain.set_quantity('elevation',topography,alpha=0.1)
 
-
+log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
 #------------------------------------------------------------------------------
 # Setup boundary conditions
 #------------------------------------------------------------------------------
+Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
+Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow
+Br = anuga.Reflective_boundary(domain)
+domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
 
-    Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
-    Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
-    Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
-    Br = anuga.Reflective_boundary(domain)
-#Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
-    domain.set_boundary({'right': Bo,
-                     'bottom': Br,
-                     'left': Bi,
-                     'top': Br})
-
+log.resource_usage_timing(prefix='afterboundary')#get memory usage
 #------------------------------------------------------------------------------
 # Evolve system through time
 #------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep=120, finaltime=2000): 
+    print domain.timestepping_statistics()
 
-# Save every two mins leading up to wave approaching land
-    for t in domain.evolve(yieldstep=120, finaltime=2000): 
-        print domain.timestepping_statistics()
-    
-
-    return number
-
+log.resource_usage_timing(prefix='aftersimulation')#get memory usage
+   
+#write the number of triangles to the text file
+v = open(file_path_storea, 'r+')
+v.write(str(number))
Index: /trunk/anuga_work/development/mem_time_tests/triangles/serial/main.py
===================================================================
--- /trunk/anuga_work/development/mem_time_tests/triangles/serial/main.py	(revision 8325)
+++ /trunk/anuga_work/development/mem_time_tests/triangles/serial/main.py	(revision 8326)
@@ -13,7 +13,7 @@
 import os
 import time
-from anuga.utilities import system_tools, log
+from anuga.utilities import system_tools, log, log_analyser
 from anuga.abstract_2d_finite_volumes.util import add_directories
-import logAnalyser
+
 #------------------------------------------------------------------------------
 # Setup computational domain
@@ -28,9 +28,5 @@
                                      "serial"])
 file = 'ex1.csv'
-
-#log.log_filename = os.path.join(scenariodir, 'anuga.log')
-
 file_path = os.path.join(scenariodir, file)
-#print "file_path",file_path
 
 spamWriter = csv.writer(open(file_path, 'wb'))
@@ -40,22 +36,12 @@
 
 
-def runlist(r):
-    n = 1 #20
-    while (n > 0):
-        c = 2 #random.random() * 2000 + 1
+for m in range(40000,50000,10000):
+
+    for n in range(9,10,1):
         z = time.time()
-        h = runcairns.runex(c,r)
+        h = runcairns.runex(n,m)
         y = time.time()
         n = n -1
-        #subprocess.call(['python','timingScript.py',scenariodir,outputresource])
-        logAnalyser.AnalyseLog()
         spamWriter.writerow([h,r,(c*c),'x' ,(y-z)])
-
-while (m > 0):
-    m = m -1
-    d = 101 #random.random() * 100 +1
-    
-    runlist(d)
-
 print 'DONE'
 
