1

我使用下面的代码定义了一个大小为 8 的数组并在 C 中键入 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;

我正在使用英特尔 openmpi。谢谢!

4

1 回答 1

3

你要

MPI_Datatype itype[8];     

MPI_DatatypeMPI_FLOAT(andMPI_INT等)的类型

于 2013-01-16T17:22:33.803 回答