flux_get_rank(3)

SYNOPSIS

#include <flux/core.h>

int flux_get_rank (flux_t *h, uint32_t *rank);

int flux_get_size (flux_t *h, uint32_t *size);

DESCRIPTION

flux_get_rank() and flux_get_size() ask the Flux broker for its rank in the Flux instance, and the size of the Flux instance.

Ranks are numbered 0 through size - 1.

RETURN VALUE

These functions return zero on success. On error, -1 is returned, and errno is set appropriately.

ERRORS

EINVAL
Some arguments were invalid.

EXAMPLES

Example:

#include <math.h>
#include <flux/core.h>
#include <inttypes.h>
#include "src/common/libutil/log.h"

int main (int argc, char **argv)
{
    flux_t *h;
    uint32_t rank, n;

    if (!(h = flux_open (NULL, 0)))
        log_err_exit ("flux_open");
    if (flux_get_rank (h, &rank) < 0)
        log_err_exit ("flux_get_rank");
    if (flux_get_size (h, &n) < 0)
        log_err_exit ("flux_get_size");
    flux_close (h);
    return (0);
}