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:
1.0 KB
|
| Line | |
|---|
| 1 | /* Shows how to use probe & get_count to find the size of an */
|
|---|
| 2 | /* incomming message */
|
|---|
| 3 | #include <stdio.h>
|
|---|
| 4 | #include <stdlib.h>
|
|---|
| 5 | #include <mpi.h>
|
|---|
| 6 | #include <math.h>
|
|---|
| 7 | int main(int argc,char **argv)
|
|---|
| 8 | {
|
|---|
| 9 | int myid, numprocs;
|
|---|
| 10 | MPI_Status status;
|
|---|
| 11 | int mytag,ierr,icount,j,*i;
|
|---|
| 12 |
|
|---|
| 13 | MPI_Init(&argc,&argv);
|
|---|
| 14 | MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
|
|---|
| 15 | MPI_Comm_rank(MPI_COMM_WORLD,&myid);
|
|---|
| 16 | printf(" Hello from c process: %d Numprocs is %d\n",myid,numprocs);
|
|---|
| 17 |
|
|---|
| 18 | mytag=123;
|
|---|
| 19 | if(myid == 0) {
|
|---|
| 20 | j=200;
|
|---|
| 21 | icount=1;
|
|---|
| 22 | ierr=MPI_Send(&j,icount,MPI_INT,1,mytag,MPI_COMM_WORLD);
|
|---|
| 23 | }
|
|---|
| 24 | if(myid == 1){
|
|---|
| 25 | ierr=MPI_Probe(0,mytag,MPI_COMM_WORLD,&status);
|
|---|
| 26 | ierr=MPI_Get_count(&status,MPI_INT,&icount);
|
|---|
| 27 | i=(int*)malloc(icount*sizeof(int));
|
|---|
| 28 | printf("getting %d\n",icount);
|
|---|
| 29 | ierr = MPI_Recv(i,icount,MPI_INT,0,mytag,MPI_COMM_WORLD,&status);
|
|---|
| 30 | printf("i= ");
|
|---|
| 31 | for(j=0;j<icount;j++)
|
|---|
| 32 | printf("%d ",i[j]);
|
|---|
| 33 | printf("\n");
|
|---|
| 34 | }
|
|---|
| 35 | MPI_Finalize();
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.