HP-MPI User's Guide (11th Edition)

Understanding HP-MPI
MPI options
Chapter 3162
MPI_LOCALNRANKS This is set to the number of ranks on the local host.
MPI_LOCALRANKID This is set to the rank number of the current process
relative to the local host (0.. MPI_LOCALNRANKS-1).
Note that these settings are not available when
running under srun or prun. However, similar
information can be gathered from the variables set by
those systems; such as SLURM_NPROCS and
SLURM_PROCID.