#include #include #include int main(int argc, char* argv[]) { int rank, numP, numO; int rootBcast, order; double test = 0; int solution = 1; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &numP); MPI_Comm intercomm, intracomm; MPI_Comm_get_parent(&intercomm); if(intercomm == MPI_COMM_NULL) { numO = atoi(argv[1]); MPI_Comm_spawn(argv[0], MPI_ARGV_NULL, numO, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE); order = 0; } else { order = 1; } MPI_Intercomm_merge(intercomm, order, &intracomm); printf("TEST 1 P%02d/%d\n", rank, numP); MPI_Bcast(&test, 1, MPI_DOUBLE, 0, intracomm); if(solution) { MPI_Barrier(intercomm); } printf("TEST 2 P%02d/%d\n", rank, numP); MPI_Finalize(); return 0; }