def __init__(self, name, comm): self.comm = comm # used for broadcasting replicated data if self.comm.size > 1: comm = self.comm.get_c_object() else: comm = None self.file = File(name, 'r', comm) self.dims_grp = self.file['Dimensions'] self.params_grp = self.file['Parameters'] self.hdf5 = True
def __init__(self, name, comm=None): self.comm = comm # for possible future use self.dims = {} try: if self.comm.rank == 0: if os.path.isfile(name): os.rename(name, name[:-5] + '.old'+name[-5:]) self.comm.barrier() except AttributeError: if os.path.isfile(name): os.rename(name, name[:-5] + '.old'+name[-5:]) if self.comm.size > 1: comm = self.comm.get_c_object() else: comm = None self.file = File(name, 'w', comm) self.dims_grp = self.file.create_group("Dimensions") self.params_grp = self.file.create_group("Parameters") self.file.attrs['title'] = 'gpaw_io version="0.1"' self.hdf5 = True