2006-09-15 01:29:51 +04:00
|
|
|
/* -*- C -*-
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
* The most basic of MPI applications
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2013-10-08 22:37:59 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2006-09-15 01:29:51 +04:00
|
|
|
#include "mpi.h"
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
int rank, size;
|
2013-10-08 22:37:59 +04:00
|
|
|
int errcode;
|
|
|
|
|
|
|
|
if (1 < argc) {
|
|
|
|
errcode = strtol(argv[1], NULL, 10);
|
|
|
|
} else {
|
|
|
|
errcode = 2;
|
|
|
|
}
|
2006-09-15 01:29:51 +04:00
|
|
|
|
|
|
|
MPI_Init(&argc, &argv);
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
|
|
|
|
|
|
printf("Hello, World, I am %d of %d\n", rank, size);
|
|
|
|
|
2014-02-09 02:00:12 +04:00
|
|
|
if (1 == size) {
|
|
|
|
MPI_Abort(MPI_COMM_WORLD, errcode);
|
2013-10-08 22:37:59 +04:00
|
|
|
} else {
|
2014-02-09 02:00:12 +04:00
|
|
|
if (1 == rank) {
|
|
|
|
MPI_Abort(MPI_COMM_WORLD, errcode);
|
|
|
|
} else {
|
|
|
|
errcode = 0;
|
2016-02-19 00:48:41 +03:00
|
|
|
sleep(99999999);
|
2014-02-09 02:00:12 +04:00
|
|
|
}
|
2013-10-08 22:37:59 +04:00
|
|
|
}
|
2006-09-15 01:29:51 +04:00
|
|
|
|
|
|
|
MPI_Finalize();
|
2013-10-08 22:37:59 +04:00
|
|
|
return errcode;
|
2006-09-15 01:29:51 +04:00
|
|
|
}
|