IBM Books

MPI Subroutine Reference

MPI_COMM_RANK, MPI_Comm_rank

Purpose

Returns the rank of the local task in the group associated with a communicator.

C synopsis

#include <mpi.h>
int MPI_Comm_rank(MPI_Comm comm,int *rank);

C++ synopsis

#include mpi.h
int MPI::Comm::Get_rank() const;

FORTRAN synopsis

include 'mpif.h' or use mpi
MPI_COMM_RANK(INTEGER COMM,INTEGER RANK,INTEGER IERROR)

Parameters

comm
is the communicator (handle) (IN)

rank
is an integer specifying the rank of the calling task in group of comm (OUT)

IERROR
is the FORTRAN return code. It is always the last argument.

Description

This subroutine returns the rank of the local task in the group associated with a communicator.

You can use this subroutine with MPI_COMM_SIZE to determine the amount of concurrency available for a specific job. MPI_COMM_RANK indicates the rank of the task that calls it in the range from 0...size - 1, where size is the return value of MPI_COMM_SIZE.

This subroutine is a shortcut to accessing the communicator's group with MPI_COMM_GROUP, computing the rank using MPI_GROUP_RANK and freeing the temporary group by using MPI_GROUP_FREE.

If comm is an intercommunicator, rank is the rank of the local task in the local group.

Errors

Invalid communicator

MPI not initialized

MPI already finalized

Related information

MPI_GROUP_RANK


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]