我一直在嘗試兩天以上,看看我做了什麼錯誤,但找不到任何東西。我不斷收到以下錯誤: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