Openmpi mpmd get communication size
I have two openmpi programs which I start like this mpirun -n 4 ./prog1 : -n 2 ./prog2 Now how do I use MPI_Comm_size(MPI_COMM_WORLD, &size) such that i get size values as prog1 size=4 prog2 size=2. As of now I get "6" in both programs. This is doable albeit a bit cumbersome to get that. The principle is to split MPI_COMM_WORLD into communicators based on the value of argv[0] , which contains the executable's name. That could be something like that: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <mpi.h> int main( int argc, char *argv[] ) { MPI_Init( &argc, &argv ); int