我正在尝试用MPI并行我的程序。
MPI_File fh; MPI_File_open(MPI_COMM_WORLD,"input.txt",MPI_MODE_CREATE|MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); if(rank == 0){ nwords = -1; do { err = fscanf(fh, "%[^\n]\n", word[++nwords]); } while( err != EOF && nwords < maxwords); printf("Read in %d words\n", nwords); }
然后我犯了这个错误。
warning #167: argument of type "MPI_File" is incompatible with parameter of type "FILE *__restrict__" err = fscanf(fh, "%[^\n]\n", word[++nwords]);
如何使用MPI\u file\u open读取文件?
MPI_File_open 使用 MPI_File ,和 fscanf() 使用 FILE * 而且没有互操作性。
MPI_File_open
MPI_File
fscanf()
FILE *
你要么 - MPI_File_open() MPI_File_read() -或者坚持 fopen() fscanf()
MPI_File_open()
MPI_File_read()
fopen()
MPI-IO真正的潜力是在执行集体IO时释放的(例如。 MPI_File_read_all() )没有什么 MPI_File_scanf() 所以除非你愿意 MPI文件读取全部() 和 sscanf() ,您可能希望继续使用非MPI子例程。
MPI_File_read_all()
MPI_File_scanf()
MPI文件读取全部()
sscanf()