MPI_Type_create_subarray function

Defines a new data type that consists of an n-dimensional subarray of an n-dimensional array. The subarray can be located anywhere within the full array. It can be any nonzero size as long as it is fully contained within the array.

Syntax

int MPIAPI MPI_Type_create_subarray(
        int                   ndims,
        _In_count_(ndims) int array_of_sizes[],
        _In_count_(ndims) int array_of_subsizes[],
        _In_count_(ndims) int array_of_starts[],
        int                   order,
        MPI_Datatype          oldtype,
  _Out_ MPI_Datatype          *newtype
);

Parameters

ndims

The number of array dimensions and the number of elements in the array_of_sizes, array_of_subsizes and array_of_starts parameters.

array_of_sizes

The number of elements in each dimension of the full array.

array_of_subsizes

The number of elements in each dimension of the subarray.

array_of_starts

The starting index of the subarray in each dimension.

order

The order of the dimensions.

MPI_ORDER_C

The row-major order in which all the elements for a given row are stored contiguously.

MPI_ORDER_FORTRAN

The column-major order in which all the elements for a given column are stored contiguously.

Note

Both C and Fortran programs can use either order. The defined values reflect typical usage.

 

oldtype

Specifies the data type of each element.

newtype [out]

On return, contains an MPI_Datatype handle that represents the new data type.

Return value

Returns MPI_SUCCESS on success. Otherwise, the return value is an error code.

In Fortran, the return value is stored in the IERROR parameter.

Fortran

    MPI_TYPE_CREATE_SUBARRAY(NDIMS, ARRAY_OF_SIZES, ARRAY_OF_SUBSIZES, ARRAY_OF_STARTS, ORDER, OLDTYPE, NEWTYPE, IERROR)
        NDIMS, ARRAY_OF_SIZES, ARRAY_OF_SUBSIZES, ARRAY_OF_STARTS, ORDER, OLDTYPE, NEWTYPE, IERROR

Remarks

The function returns an error if the size of the subarray exceeds the size of the array. For each dimension i, the value of array_of_subsizes[i] parameter must be greater than or equal to one and less than or equal to the array_of_sizes[i] parameter.

The function returns an error if the subarray starts or ends outside the bounds of the array. For any dimension i, the value of parameter must be zero and the sum of the array_of_starts[i] and array_of_subsizes[i] parameters must be less than or equal to the value of the array_of_sizes[i] parameter. For example, if the subarray is the same size as the array, then the subarray must start at index zero. Arrays are assumed to be indexed starting from zero.

Requirements

Product

HPC Pack 2012 MS-MPI Redistributable Package, HPC Pack 2008 R2 MS-MPI Redistributable Package, HPC Pack 2008 MS-MPI Redistributable Package or HPC Pack 2008 Client Utilities

Header

Mpi.h; Mpif.h

Library

Msmpi.lib

DLL

Msmpi.dll

See also

MPI Datatype Functions