标准通信模式--阻塞方式
//mpitest.c
#include "mpi.h"
#include <stdio.h>
#include <math.h>
#define buf_size 10
int main(int argc, char *argv[])
{
int myid, numprocs, other, sb[buf_size], rb[buf_size];
MPI_Status status;
/*这三句为初使化MPI环境*/
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myid); //myid保存进程号
MPI_Comm_size(MPI_COMM_WORLD, &numprocs); //numprocs保存一共运行的进程数量
int i;
for(i = 0; i < buf_size; i++)
{
sb[i] = myid + i;
}
if(myid == 0) other = 1;
if(myid == 1) other = 0;
if(myid == 0)
/*进程0*/
{
fprintf(stdout, "process : %d of %d trying sending...\n", myid, numprocs);
MPI_Send(sb, buf_size, MPI_INT, other, 1, MPI_COMM_WORLD);
/*其中sb为发送缓冲区首地址,