private void DistributeSegments(ScalarPlan plan, ParallelManager <Transceiver> pm, GreenScalars gs, ScalarSegments local, ScalarSegments all, ScalarSegments result)
        {
            var starts     = pm.GetAllStartIndecies();
            var lengths    = pm.GetAllLength();
            var fullStarts = new int[lengths.Length];
            var fullLength = new int[lengths.Length];

            var localLength = gs.SingleScalars.Length;

            int nComp = gs.GetNumberOfAvailableIs(plan);
            int nRho  = local.Radii.Length - 1;

            var localSize = localLength * nComp * 2 * nRho;

            for (int i = 0; i < starts.Length; i++)
            {
                fullStarts[i] = starts[i] * nComp * 2 * nRho;
                fullLength[i] = lengths[i] * nComp * 2 * nRho;
            }

            Mpi.AllGatherV(local.Ptr, localSize, all.Ptr, fullLength, fullStarts);

            using (Profiler?.StartAuto(ProfilerEvent.GreenScalarAtoATrans))
            {
                for (int i = 0; i < starts.Length; i++)
                {
                    int start  = starts[i];
                    int length = lengths[i];

                    var tmp = ScalarSegments.ReUseScalarSegments(all.Ptr + fullStarts[i], plan, gs, length);

                    for (int j = 0; j < result.SingleSegment.Length; j++)
                    {
                        var src = tmp.SingleSegment[j];
                        var dst = result.SingleSegment[j];

                        if (src.I1A != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I1A[k + start] = src.I1A[k];
                            }
                        }
                        if (src.I2A != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I2A[k + start] = src.I2A[k];
                            }
                        }
                        if (src.I3A != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I3A[k + start] = src.I3A[k];
                            }
                        }
                        if (src.I4A != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I4A[k + start] = src.I4A[k];
                            }
                        }
                        if (src.I5A != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I5A[k + start] = src.I5A[k];
                            }
                        }

                        if (src.I1B != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I1B[k + start] = src.I1B[k];
                            }
                        }
                        if (src.I2B != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I2B[k + start] = src.I2B[k];
                            }
                        }
                        if (src.I3B != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I3B[k + start] = src.I3B[k];
                            }
                        }
                        if (src.I4B != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I4B[k + start] = src.I4B[k];
                            }
                        }
                        if (src.I5B != null)
                        {
                            for (int k = 0; k < length; k++)
                            {
                                dst.I5B[k + start] = src.I5B[k];
                            }
                        }
                    }
                }
            }
        }