[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, outValues[p] will be equal to the value parameter of the process with rank p when this routine returns. Use this variant of the routine when you want to pre-allocate storage for the outValues array.

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

Syntax

C#
public void Gather<T>(
	T inValue,
	int root,
	ref T[] outValues
)
Visual Basic (Declaration)
Public Sub Gather(Of T) ( _
	inValue As T, _
	root As Integer, _
	ByRef outValues As T() _
)
Visual C++
public:
generic<typename T>
void Gather(
	T inValue, 
	int root, 
	array<T>^% outValues
)

Parameters

inValue
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.
outValues
Type: array< T >[]()[] %
An array that will store the values contributed by each process. This value is only significant at the root, and can be omitted by non-root processes. Supply this argument when you have pre-allocated space for the resulting array.

Type Parameters

T
Any serializable type.

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 = new int[world.Size];
                world.Gather(world.Rank, 0, ref ranks);
                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