[petsc-users] Segmentation fault due to TSDestroy
Praveen C
cpraveen at gmail.com
Mon Mar 20 07:46:18 CDT 2017
It turns out the problem was with this
call TSMonitorSet(ts, Monitor, ctx, PETSC_NULL_OBJECT, ierr);
CHKERRQ(ierr)
The correct way is
call TSMonitorSet(ts, Monitor, ctx, PETSC_NULL_FUNCTION, ierr);
CHKERRQ(ierr)
Thanks
praveen
On Sat, Mar 18, 2017 at 9:30 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> Perhaps there is some memory corruption - you can try runnng the code with
> valgrind.
>
> Satish
>
> On Sat, 18 Mar 2017, Praveen C wrote:
>
> > Dear all
> >
> > I get a segmentation fault when I call TSDestroy. Without TSDestroy the
> > code runs fine. I have included portion of my code below.
> >
> > subroutine runts(ctx)
> > use userdata
> > use comdata
> > use mtsdata
> > implicit none
> > #include <petsc/finclude/petsc.h90>
> > type(tsdata) :: ctx
> > ! Local variables
> > integer,parameter :: h = 100 ! File id for history file
> > TS :: ts
> > Vec :: u
> > PetscErrorCode :: ierr
> > external :: RHSFunction, Monitor
> >
> > call VecDuplicate(ctx%p%v_res, u, ierr); CHKERRQ(ierr)
> >
> > ! Copy initial condition into u
> > call VecCopy(ctx%p%v_u, u, ierr); CHKERRQ(ierr)
> >
> > call TSCreate(PETSC_COMM_WORLD, ts, ierr); CHKERRQ(ierr)
> > call TSSetProblemType(ts, TS_NONLINEAR, ierr); CHKERRQ(ierr)
> > call TSSetRHSFunction(ts, PETSC_NULL_OBJECT, RHSFunction, ctx, ierr);
> > CHKERRQ(ierr)
> > call TSSetInitialTimeStep(ts, 0.0, dtg, ierr); CHKERRQ(ierr)
> > call TSSetType(ts, TSRK, ierr); CHKERRQ(ierr);
> > call TSSetDuration(ts, itmax, tfinal, ierr); CHKERRQ(ierr);
> > call TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP, ierr);
> > CHKERRQ(ierr);
> > call TSMonitorSet(ts, Monitor, ctx, PETSC_NULL_OBJECT, ierr);
> > CHKERRQ(ierr)
> > call TSSetSolution(ts, u, ierr); CHKERRQ(ierr)
> > call TSSetFromOptions(ts, ierr); CHKERRQ(ierr)
> > call TSSetUp(ts, ierr); CHKERRQ(ierr)
> >
> > call TSSolve(ts, u, ierr); CHKERRQ(ierr)
> >
> > call VecCopy(u, ctx%p%v_u, ierr); CHKERRQ(ierr)
> > call VecDestroy(u, ierr); CHKERRQ(ierr)
> > call TSDestroy(ts, ierr); CHKERRQ(ierr)
> >
> > end subroutine runts
> >
> > Thanks
> > praveen
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170320/c4eaa252/attachment.html>
More information about the petsc-users
mailing list