[This is preliminary documentation and is subject to change.]

Gather the values from each process into an array of values at the root process. On the root process, the pth element of the result will be equal to the value parameter of the process with rank p when this routine returns.

Namespace:  MPI
Assembly:  MPI (in MPI.dll)
Version: 0.6.0.0 (0.6.0.0)

Syntax

C#
public T[] Gather<T>(
	T value,
	int root
)
Visual Basic (Declaration)
Public Function Gather(Of T) ( _
	value As T, _
	root As Integer _
) As T()
Visual C++
public:
generic<typename T>
array<T>^ Gather(
	T value, 
	int root
)

Parameters

value
Type: T
The value contributed by this process.
root
Type: System..::.Int32
The rank of the process that will receive values for all of the processes in the communicator.

Type Parameters

T
Any serializable type.

Return Value

At the root, an array containing the values supplied by each of the processes in the communicator. All other processes receive null.

Examples

This example demonstrates the use of Gather to gather the ranks of all processes together at root 0.
CopyC#
using System;
using MPI;

class Gather
{
    static void Main(string[] args)
    {
        using (MPI.Environment env = new MPI.Environment(ref args))
        {
            Communicator world = Communicator.world;
            if (world.Rank == 0)
            {
                int[] ranks = world.Gather(world.Rank, 0);
                System.Console.Write("Ranks of all of the processes:");
                for (int i = 0; i < ranks.Length; ++i)
                    System.Console.Write(" " + i);
                System.Console.WriteLine();
            }
            else
            {
                world.Gather(world.Rank, 0);
            }
        }
    }
}

See Also