Your whole program is run on both of the two processors you set with the -np 2. A common way to prevent duplicates of printouts, final results, etc., is have one thread do those things just by checking the thread id first. Like:
int id; MPI_Comm_rank(MPI_COMM_WORLD, &id); if (id == 0) { printf("only process %d does this one\n", id); } printf("everybody"hello doesfrom thisprocess one\n"%d\n", id); // all processes do this one When starting out in MPI I found it helpful to print out those id numbers along with whatever partial results or data each thread was dealing with. Helped me make more sense out of what was happening.