#include #include #include int main(int argc, char**argv) { int rank, size; char hostname[1024]; MPI_Init(&argc, &argv); /* Get the rank of the current MPI task */ MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get the total number of MPI tasks */ MPI_Comm_size(MPI_COMM_WORLD, &size); /* Get the hostname */ gethostname(hostname, 1024); if(rank>0) { /* Wait until rank N-1 prints its message */ int n; MPI_Recv(&n, 1, MPI_INTEGER, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); } printf("Hello World from task %d / %d on %s\n", rank, size, hostname); if(rank