source: CIVL/examples/mpi/simple/anysource.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 513 bytes
Line 
1#include<mpi.h>
2#include<assert.h>
3
4int nprocs;
5int myrank;
6
7void main() {
8 int argc;
9 char **argv;
10 double x;
11 MPI_Status status;
12
13 MPI_Init(&argc, &argv);
14 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
15 if (myrank == 0) {
16 MPI_Recv(&x, 1, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
17 assert(x == (double)(status.MPI_SOURCE));
18 assert(status.MPI_TAG == 10+status.MPI_SOURCE);
19 } else {
20 x = (double)myrank;
21 MPI_Send(&x, 1, MPI_DOUBLE, 0, myrank+10, MPI_COMM_WORLD);
22 }
23 MPI_Finalize();
24}
Note: See TracBrowser for help on using the repository browser.