There is no standard MPI way to tell the difference between an MPI application that runs directly, or as one rank with mpirun. See " Singleton MPI_Init " for more information on this MPI job.
The answer of checking the environment variable from Douglas is a reasonable hack ... but it does not carry over to any other MPI implementation.
source share