def write_into_shared_storage(traj):
    traj.f_add_result('ggg', 42)
    traj.f_add_derived_parameter('huuu', 46)

    root = get_root_logger()
    daarrays = traj.res.daarrays
    idx = traj.v_idx
    ncores = traj[traj.v_environment_name].f_get_default('ncores', 1)
    root.info('1. This')
    a = daarrays.a
    a[idx] = idx
    root.info('2. is')
    ca = daarrays.ca
    ca[idx] = idx
    root.info('3. a')
    ea = daarrays.ea
    ea.append(np.ones((1,10))*idx)
    root.info('4. sequential')
    vla = daarrays.vla
    vla.append(np.ones(idx+2)*idx)
    root.info('5. Block')
    the_range = list(range(max(0, idx-2*ncores), max(0, idx)))
    for irun in the_range:
        x, y = a[irun], irun
        if x != y and x != 0:
            raise RuntimeError('ERROR in write_into_shared_storage %s != %s' % (str(x), str(y)))
        x, y = ca[irun], irun
        if x != y and x != 0:
            raise RuntimeError('ERROR in write_into_shared_storage %s != %s' % (str(x), str(y)))
        try:
            x, y = ea[irun, 9], ea[irun, 8]
            if x != y and x != 0:
                raise RuntimeError('ERROR in write_into_shared_storage %s != %s' % (str(x), str(y)))
        except IndexError:
            pass  # Array is not at this size yet
        try:
            x, y = vla[irun][0], vla[irun][1]
            if x != y and x != 0:
                raise RuntimeError('ERROR in write_into_shared_storage %s != %s' % (str(x), str(y)))
        except __HOLE__:
            pass  # Array is not at this size yet
    root.info('6. !!!!!!!!!')

    tabs = traj.tabs

    with StorageContextManager(traj) as cm:
        t1 = tabs.t1
        row = t1.row
        row['run_name'] = compat.tobytes(traj.v_crun)
        row['idx'] = idx
        row.append()
        t1.flush()

    t2 = tabs.t2
    row = t2[idx]
    if row['run_name'] != compat.tobytes(traj.v_crun):
        raise RuntimeError('Names in run table do not match, Run: %s != %s' % (row['run_name'],
                                                                                   traj.v_crun) )

    df = traj.df
    df.append(pd.DataFrame({'idx':[traj.v_idx], 'run_name':traj.v_crun}))
dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/tests/integration/shared_data_test.py/write_into_shared_storage