我在C中定义了一个大小为8的数组并输入了MPI_INTEGER,使用下面的代码:
/*=================================================================
C example
=================================================================*/
#include <stdio.h>
#include "mpi.h"
int main(int argc, char** argv){
MPI_FLOAT itype[8];
int nproc;
int iproc;
MPI_Comm icomm;
MPI_Request req;
MPI_Status status;
MPI_Init(&argc,&argv);
icomm = MPI_COMM_WORLD;
MPI_Comm_rank(icomm,&iproc);
MPI_Comm_size(icomm,&nproc);
itype[0] = MPI_FLOAT;
itype[1] = MPI_FLOAT;
itype[2] = MPI_FLOAT;
itype[3] = MPI_FLOAT;
itype[4] = MPI_FLOAT;
itype[5] = MPI_FLOAT;
itype[6] = MPI_FLOAT;
itype[7] = MPI_UB;
MPI_Finalize();
}
我收到了以下错误:
type_derived_struct.c(18): error: expected a ";"
MPI_FLOAT itype[8];
^
type_derived_struct.c(93): error: identifier "itype" is undefined
itype[0] = MPI_FLOAT;
我正在使用intel openmpi。谢谢!
答案 0 :(得分:3)
你想要
MPI_Datatype itype[8];
MPI_Datatype
类型为MPI_FLOAT
(和MPI_INT
等。)