我一直在尝试两天以上,看看我做了什么错误,但找不到任何东西。我不断收到以下错误:MPI分段错误(信号11)
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 139
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
make: *** [run] Error 139
所以,问题显然是MPI_BCAST
和其他功能我有MPI_GATHER
。 你能帮我弄清楚有什么问题吗? 当我编译代码我键入以下内容:
/usr/bin/mpicc -I/usr/include -L/usr/lib z.main.c z.mainMR.c z.mainWR.c -o 1dcode -g -lm
出马:
usr/bin/mpirun -np 2 ./1dcode dat.txt o.out.txt
例如我的代码,包括这样的功能:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include "functions.h"
#include <mpi.h>
/*...................z.mainMR master function............. */
void MASTER(int argc, char *argv[], int nPROC, int nWRs, int mster)
{
/*... Define all the variables we going to use in z.mainMR function..*/
double tend, dtfactor, dtout, D, b, dx, dtexpl, dt, time;
int MM, M, maxsteps, nsteps;
FILE *datp, *outp;
/*.....Reading the data file "dat" then saving the data in o.out.....*/
datp = fopen(argv[1],"r"); // Open the file in read mode
outp = fopen(argv[argc-1],"w"); // Open output file in write mode
if(datp != NULL) // If data file is not empty continue
{
fscanf(datp,"%d %lf %lf %lf %lf %lf",&MM,&tend,&dtfactor,&dtout,&D,&b); // read the data
fprintf(outp,"data>>>\nMM=%d\ntend=%lf\ndtfactor=%lf\ndtout=%lf\nD=%lf\nb=%lf\n",MM,tend,dtfactor,dtout,D,b);
fclose(datp); // Close the data file
fclose(outp); // Close the output file
}
else // If the file is empty then print an error message
{
printf("There is something wrong. Maybe file is empty.\n");
}
/*.... Find dx, M, dtexpl, dt and the maxsteps........*/
dx = 1.0/ (double) MM;
M = b * MM;
dtexpl = (dx * dx)/(2.0 * D);
dt = dtfactor * dtexpl;
maxsteps = (int)(tend/dt) + 1;
/*...Pack integers in iparms array, reals in parms array...*/
int iparms[2] = {MM,M};
double parms[4] = {dx, dt, D, b};
MPI_BCAST(iparms,2, MPI_INT,0,MPI_COMM_WORLD);
MPI_BCAST(parms, 4, MPI_DOUBLE,0, MPI_COMM_WORLD);
}
为什么投我的问题?这是我在这个网站上的第一个问题,我真的需要帮助。我道歉,如果我犯了一些错别字,或使它看起来像一团糟。 – Ruzayqat
你是如何清楚地**推断出问题出现在'MPI_BCAST'中的?除了C函数调用实际上拼写为'MPI_Bcast'这一事实之外,我没有看到MPI调用显示出任何问题。 –
哇!救了我。这是我第一次使用mpi ..问题出在拼写上!哈哈..两天试..我只是从某处复制了函数,它是MPI_BCAST而不是MPI_Bcast。 非常感谢你 – Ruzayqat