以下函数在使用任意数量的进程运行时会产生错误。有人可以告诉我为什么。我正在使用 MPICH 3.1 。 (这不是一种理想的方法,但我试图理解 MPI I / O 的基础知识 - 只是说该示例应该有用)。
#include<stdio.h>
#include<mpi.h>
#define BUF 100
void main(int argc, char *argv[])
{
int buf[BUF], rank, loop_i ;
FILE *fp ;
char filename[BUF];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
for(loop_i = 0 ; loop_i <= BUF - 1 ; loop_i++)
buf[loop_i] = rank * BUF + loop_i ;
sprintf(filename, "testfile.%d", rank);
fp = fopen(filename, "w");
fwrite(buf, sizeof(int), BUF, fp);
fclose(fp);
MPI_Finalize();
}
编译时我得:
mpiio_2.c: In function ‘main’:
mpiio_2.c:11: warning: return type of ‘main’ is not ‘int’
ld: warning: duplicate dylib /usr/lib/libgcc_s.1.dylib
使用4个触发器运行:
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 4584 RUNNING AT sepultrite7432.local
= EXIT CODE: 224
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES