HDFql Reference Manual v2.6.0

5.2.63hdfql_mpi_get_rank

Syntax

int hdfql_mpi_get_rank(void)

Description

Get the rank of the calling process associated with the default MPI communicator (MPI_COMM_WORLD) or with a user-defined MPI communicator (that may have been set through the function hdfql_mpi_use_communicator). Of note, the function is essentially a wrapper for the MPI function “MPI_Comm_rank” (please refer to https://www.mpich.org/static/docs/v3.4/www3/MPI_Comm_rank.html or https://www.open-mpi.org/doc/v3.1/man3/MPI_Comm_rank.3.php for additional information in case the MPI library used is MPICH or Open MPI, respectively).

Parameter(s)

None

Return

int – depending on the success in getting the rank of the calling process associated with the default MPI communicator (MPI_COMM_WORLD) or with a user-defined MPI communicator, it can be equal to or greater than zero (i.e. the rank of the calling process), HDFQL_ERROR_NOT_SUPPORTED (in case MPI itself was not initialized properly or when using an HDFql non MPI-based distribution), or HDFQL_ERROR_UNKNOWN.

Example(s)

// display rank of the MPI process (if the program (that employs HDFql) is launched as, e.g., "mpiexec -n 3 ./my_program", the message "Rank of the MPI process is X" will be displayed three times where X is 0, 1, or 2 (not necessarily in this order))
printf("Rank of the MPI process is %d\n", hdfql_mpi_get_rank());