Changes between Initial Version and Version 1 of AnugaCheckpoints


Ignore:
Timestamp:
Jun 15, 2010, 9:38:32 AM (12 years ago)
Author:
hudson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AnugaCheckpoints

    v1 v1  
     1= ANUGA Checkpoints =
     2
     3Since ANUGA may take a long time to run a simulation, it can be prudent to save off the partial results at different stages of execution in case of hardware failure or power loss.
     4
     5== cPickle Method ==
     6
     7Many people have requested restore point functionality in ANUGA to deal with interruptions to a running script. Python already has the ability to save state to a file using the cPickle module.
     8
     9You can use code like this in your application to implement restore points:
     10
     11{{{
     12import cPickle
     13
     14start_time = 0.0
     15if use_restore_point is True:
     16    print 'resuming from restore point...'
     17    domain = cPickle.load(open('domain_pickle.txt'))
     18    start_time = domain.time
     19else:
     20    # do your normal domain initialisation here
     21
     22
     23for restorepoint in range(start_time, 10):
     24    # evolve domain in small chunks, regularly pickling a restore point
     25    for t in domain.evolve(yieldstep=0.1, finaltime=restorepoint):
     26        pass
     27    print 'saving restore point...'
     28    cPickle.dump(domain, open('domain_pickle.txt', 'w'))
     29}}}
     30
     31== use_cache Method ==
     32ANUGA also has inbuilt caching functionality. You can set the use_cache = True parameter on many functions, and the results of the operation will be stored on disk for the next time the same operation is executed.