def save_state(kset, X, Y, f, y, tau_min, sigma_min, prefix='fail'): """ dump current state to HDF5 """ from mpi4py import MPI rank = MPI.COMM_WORLD.rank with h5py.File(prefix + '%d.h5' % rank, 'w') as fh5: grpX = ot.save(fh5, 'X', X, kset) grpf = ot.save(fh5, 'fn', f, kset) grpY = ot.save(fh5, 'Y', Y, kset) grpy = ot.save(fh5, 'y', y, kset) grpY.attrs['tau_min'] = tau_min grpy.attrs['sigma_min'] = sigma_min
def save_state(objs_dict, kset, prefix='fail'): """ Arguments: objs_dict = dictionary(string: CoefficientArray), example: {'Z': Z, 'G': G} dump current state to HDF5 """ logger('save state') rank = MPI.COMM_WORLD.rank import sirius.ot as ot with h5py.File(prefix+'%d.h5' % rank, 'w') as fh5: for key in objs_dict: # assume it is a string name = key ot.save(fh5, name, objs_dict[key], kset)