X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/025965074dbe4c1b04466cc260260470f28b7472..6e250f85a054d8939078c3e5573171a39f4aa855:/examples/smpi/second.c diff --git a/examples/smpi/second.c b/examples/smpi/second.c index 5c1d39f15e..e34a2122bc 100644 --- a/examples/smpi/second.c +++ b/examples/smpi/second.c @@ -12,46 +12,46 @@ /* your hostfile, do 'mpirun -machinefile hostfile -np 4 first */ #include +#include #include -main(int argc, char *argv[]) { - const int tag = 42; /* Message tag */ +int main(int argc, char *argv[]) +{ + const int tag = 42; /* Message tag */ int id, ntasks, source_id, dest_id, err, i; MPI_Status status; - int msg[2]; /* Message array */ - + int msg[2]; /* Message array */ + err = MPI_Init(&argc, &argv); /* Initialize MPI */ if (err != MPI_SUCCESS) { printf("MPI initialization failed!\n"); exit(1); } err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); /* Get nr of tasks */ - err = MPI_Comm_rank(MPI_COMM_WORLD, &id); /* Get id of this process */ + err = MPI_Comm_rank(MPI_COMM_WORLD, &id); /* Get id of this process */ if (ntasks < 2) { printf("You have to use at least 2 processors to run this program\n"); - MPI_Finalize(); /* Quit if there is only one processor */ + MPI_Finalize(); /* Quit if there is only one processor */ exit(0); } - - if (id == 0) { /* Process 0 (the receiver) does this */ - for (i=1; i