a problem with error of "An error occurred in MPI_Comm_rank after MPI was finalized"

Yin Feng yfeng1 at tigers.lsu.edu
Sun Oct 11 21:38:44 CDT 2009


I put PETSc solver in one function and use another function to call that.This
problem only appears when I put the function with PETSc solver in a loop,
it works well at first step, and reports error "An error occurred in
MPI_Comm_rank after MPI was finalized"
at second time. The program is designed to support only one processor like:

Vec            x,b;

Mat            A;

KSP            ksp;

PC             pc;

PetscInt       i,j,col[N];

PetscScalar    value[N];

PetscScalar    val;


 PetscInitialize(PETSC_NULL,PETSC_NULL,PETSC_NULL,PETSC_NULL);

VecCreate(PETSC_COMM_WORLD,&x);

VecSetSizes(x,PETSC_DECIDE,N);

VecSetFromOptions(x);

VecDuplicate(x,&b);

MatCreate(PETSC_COMM_WORLD,&A);

MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);

MatSetFromOptions(A);

        ........

        ........

KSPCreate(PETSC_COMM_WORLD,&ksp);

KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);

KSPGetPC(ksp,&pc);

        ................
        ...............

        KSPSetTolerances(ksp,tol,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);

        KSPSetFromOptions(ksp);

        KSPSolve(ksp,b,x);


        VecDestroy(x);

        VecDestroy(b);

        MatDestroy(A);

        KSPDestroy(ksp);

        PetscFinalize();


Any one has ideal about this?

The detailed error description is:

An error occurred in MPI_Comm_rank

*** after MPI was finalized

*** MPI_ERRORS_ARE_FATAL (goodbye)

Abort before MPI_INIT completed successfully; not able to guarantee that all
other processes were killed!

Thank you so much in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20091011/798351b4/attachment.htm>


More information about the petsc-users mailing list