[petsc-users] Segmentation fault in PetscInitialize()

Longxiang Chen suifengls at gmail.com
Tue Jun 25 21:30:53 CDT 2013


Yes. I move MPI_Init() outsidet the LOOP.
Now it works.
Thanks you.

Best regards,
Longxiang Chen




On Tue, Jun 25, 2013 at 4:58 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Jun 25, 2013, at 6:50 PM, "Zou (Non-US), Ling" <ling.zou at inl.gov>
> wrote:
>
> > Hmmm... I guess you cannot do PetscInitialize multiple times.
>
>    You must call PetscFinalize() each time before calling
> PetscInitialize() again. In addition you must call MPI_Init() your self
> ONCE at the beginning of the application code.
>
>    Barry
>
> >
> > Ling
> >
> >
> > On Tue, Jun 25, 2013 at 5:47 PM, Zou (Non-US), Ling <ling.zou at inl.gov>
> wrote:
> > I have petsc 3.3p5 on my Mac.
> >
> >   PetscInitialize(NULL, NULL, NULL, NULL);
> >
> > It seems working fine here.
> >
> > Ling
> >
> >
> > On Tue, Jun 25, 2013 at 4:54 PM, Longxiang Chen <suifengls at gmail.com>
> wrote:
> > Dear all,
> >
> > I try to use ksp to solve Ax=b.
> >
> > ALL programs are in fortran, except petscsolve() in c.
> >
> > Because petscsolve() is a sub-function that I don't have argc and argv.
> > So I use following statement to set the options.
> >
> >         PetscInitialize(NULL, NULL, NULL, help);
> >       PetscOptionsSetValue("-ksp_type", "bcgs");
> >       PetscOptionsSetValue("-pc_type", "jacobi");
> >       PetscOptionsSetValue("-ksp_max_it", "100");
> >       PetscOptionsInsert(NULL, NULL, NULL);
> >
> > The program works like this:
> >
> > main()
> > Init()
> > LOOP:
> > call MULTI (calculate Jacob A)
> > -> call petscsolve( solve Ax=b)
> > -> check solution
> > Goto LOOP
> >
> > The first iteration works well that I can calculate the solution x from
> petscsolve().
> > But when it enters the second iteration of LOOP, it has Segmentation
> fault:
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x000000000d8e11f0 in ?? ()
> > (gdb) bt
> > #0  0x000000000d8e11f0 in ?? ()
> > #1  0x0000000001a32625 in PMPI_Barrier ()
> > #2  0x0000000000bdd2b7 in PetscLogBegin_Private () at
> /home/lchen/ft-petsc/src/sys/logging/plog.c:234
> > #3  0x0000000000bdd876 in PetscLogBegin () at
> /home/lchen/ft-petsc/src/sys/logging/plog.c:278
> > #4  0x00000000004c1f6c in PetscOptionsCheckInitial_Private ()
> >     at /home/lchen/ft-petsc/src/sys/objects/init.c:494
> > #5  0x00000000004cbe6d in PetscInitialize (argc=0x0, args=0x0, file=0x0,
> >     help=0x20a9f00 "Replace with PETSC_solve") at
> /home/lchen/ft-petsc/src/sys/objects/pinit.c:779
> > #6  0x00000000004991e3 in petscsolve_ (N=0x20c7d28, RHS=0x9813500,
> WKAREA=0x4902c80, NZ=0xc0629e0,
> >     IA=0xb8b9ac0, JA=0x754e520, CO=0x9871ac0, TOL=0x22c0528,
> ITMAX=0x71ef048, ITER=0x7fffffffd3a8,
> >     ERR=0x7fffffffd3b0, IERR=0x7fffffffd3b8, IUNIT=0x1bcb310,
> RWORK=0x57d2000, LENW=0x49f4cc0,
> >     IWORK=0x3e32860, LENIW=0x49f4cc8) at petscsolve.c:184
> > #7  0x000000000044ed15 in lineq () at t2cg22.f:1698
> > #8  0x000000000046a24c in cycit () at t2f.f:2055
> > #9  0x00000000004483d3 in tough2 () at t2cg22.f:625
> > #10 0x000000000040bfcc in main ()
> >
> > Are there any problems with PetscInitialize(NULL, NULL, NULL, help)?
> > Thank you.
> >
> > Best regards,
> > Longxiang Chen
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130625/060c3c09/attachment.html>


More information about the petsc-users mailing list