#include "stdio.h" #include "stdlib.h" #include "mpi.h" #define a(x,y) a[x*M+y] /*A为M*M矩阵*/ #define A(x,y) A[x*M+y] #define l(x,y) l[x*M+y] #define u(x,y) u[x*M+y] #define floatsize sizeof(float) #define intsize sizeof(int) int M,N; int m; float *A; int my_rank; int p; MPI_Status status; void fatal(char *message) { printf("%s\n",message); exit(1); } void Environment_Finalize(float *a,float *f) { free(a); free(f); } int main(int argc, char **argv) { int i,j,k,my_rank,group_size; int i1,i2; int v,w; float *a,*f,*l,*u; FILE *fdA; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&group_size); MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); p=group_size; if (my_rank==0) { fdA=fopen("dataIn.txt","r"); fscanf(fdA,"%d %d", &M, &N); if(M != N) { puts("The input is error!"); exit(0); } A=(float *)malloc(floatsize*M*M); for(i = 0; i < M; i ++) for(j = 0; j < M; j ++) fscanf(fdA, "%f", A+i*M+j); fclose(fdA); printf("Input of file \"dataIn.txt\"\n"); printf("%d\t %d\n",M, N); for(i=0;ij) for(k=0;kj) l(i,j)=A(i,j); else u(i,j)=A(i,j); //printf("Input of file \"dataIn.txt\"\n"); //printf("%d\t %d\n",M, N); //for(i=0;i