source: CIVL/examples/mpi/c_ex01.c@ bd7a43e

main test-branch
Last change on this file since bd7a43e 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: 926 bytes
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <mpi.h>
4#include <math.h>
5
6/************************************************************
7This is a simple send/receive program in MPI
8************************************************************/
9
10int main(argc,argv)
11int argc;
12char *argv[];
13{
14 int myid, numprocs;
15 int tag,source,destination,count;
16 int buffer;
17 MPI_Status status;
18
19 MPI_Init(&argc,&argv);
20 MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
21 MPI_Comm_rank(MPI_COMM_WORLD,&myid);
22 tag=1234;
23 source=0;
24 destination=1;
25 count=1;
26 if(myid == source){
27 buffer=5678;
28 MPI_Send(&buffer,count,MPI_INT,destination,tag,MPI_COMM_WORLD);
29 printf("processor %d sent %d\n",myid,buffer);
30 }
31 if(myid == destination){
32 MPI_Recv(&buffer,count,MPI_INT,source,tag,MPI_COMM_WORLD,&status);
33 printf("processor %d got %d\n",myid,buffer);
34 }
35 MPI_Finalize();
36}
Note: See TracBrowser for help on using the repository browser.