Changeset 8291


Ignore:
Timestamp:
Dec 20, 2011, 5:50:32 PM (8 years ago)
Author:
steve
Message:

Added delete_old flag to sww_merge

Location:
trunk/anuga_core/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/utilities/sww_merge.py

    r8290 r8291  
    1919
    2020
    21 def sww_merge_parallel(domain_global_name, np, verbose=False):
     21def sww_merge_parallel(domain_global_name, np, verbose=False, delete_old=False):
    2222
    2323    output = domain_global_name+".sww"
    2424    swwfiles = [ domain_global_name+"_P"+str(np)+"_"+str(v)+".sww" for v in range(np)]
    2525
    26     _sww_merge_parallel(swwfiles, output, verbose)
     26    _sww_merge_parallel(swwfiles, output, verbose, delete_old)
    2727
    2828
     
    176176
    177177
    178 def _sww_merge_parallel(swwfiles, output, verbose):
     178def _sww_merge_parallel(swwfiles, output,  verbose, delete_old):
    179179    """
    180180        Merge a list of sww files into a single file.
     
    377377   
    378378    fido.close()
    379 
     379   
     380    if delete_old:
     381        import os
     382        for filename in swwfiles:
     383
     384            if verbose:
     385                print 'Deleting file ', filename, ':'
     386            os.remove(filename)
    380387
    381388if __name__ == "__main__":
     
    392399    parser.add_argument('-v', nargs='?', type=bool, const=True, default=False,
    393400                   help='verbosity')
    394 
     401    parser.add_argument('-delete_old', nargs='?', type=bool, const=True, default=False,
     402                   help='Flag to delete the input files')
    395403    args = parser.parse_args()
    396404
     
    398406    domain_global_name = args.f
    399407    verbose = args.v
     408    delete_old = args.delete_old
    400409
    401410
    402411    try:
    403         sww_merge_parallel(domain_global_name, np, verbose)
     412        sww_merge_parallel(domain_global_name, np, verbose, delete_old)
    404413    except:
    405414        msg = 'ERROR: When merging sww files %s '% domain_global_name
  • trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r8283 r8291  
    129129
    130130
    131     def sww_merge(self, verbose=False):
     131    def sww_merge(self, verbose=False, delete_old=False):
    132132
    133133        if self.processor == 0 and self.numproc > 1:
    134134            import anuga.utilities.sww_merge as merge
    135135           
    136             merge.sww_merge_parallel(self.get_global_name(),self.numproc,verbose)
     136            merge.sww_merge_parallel(self.get_global_name(),self.numproc,verbose,delete_old)
    137137
    138138
Note: See TracChangeset for help on using the changeset viewer.