PMPI_COMM_RANK Invalid Communicator

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

So I am a complete novice at MPI but I've inherited code that uses it. The script contains a section that processes a data file and uses the MPI_COMM_RANK routine:

/* Load Data */ std::cout << "Loading data..." << std::endl; ThisTask=0; All.ICFormat=1; RestartFlag=1; /* This is actually an MPI routine, so we will need to set up MPI */ NTask=1; /* Gadget2 global */ All.PartAllocFactor=1.0; /* The factor for allocating memory for particle   data. */ All.BufferSize = 1024.0; /* The size (in MByte per processor) of a communication buffer. */ if(!(CommBuffer = malloc(All.BufferSize * 1024 * 1024))) { printf("failed to allocate memory for `CommBuffer' (%i MB).\n", All.BufferSize); return EXIT_FAILURE; } MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask); MPI_Comm_size(MPI_COMM_WORLD, &NTask); read_file(fname, readTask, lastTask); free(CommBuffer); MPI_Finalize();     /* clean up & finalize MPI */ std::cout << "...done" << std::endl; 

However, Comm rank returns the error:

Fatal error in PMPI_Comm_rank: Invalid communicator, error stack: PMPI_Comm_rank(122): MPI_Comm_rank(comm=0x629300, rank=0x631eec) failed PMPI_Comm_rank(75).: Invalid communicator 

Again, as I'm totally new to this I have no idea why COMM_WORLD would be an invalid communicator here. Any ideas?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!