<div dir="ltr">It turns out the problem was with this<div><br></div><div><div style="font-size:12.8px">   call TSMonitorSet(ts, Monitor, ctx, PETSC_NULL_OBJECT, ierr); CHKERRQ(ierr)</div></div><div><br></div><div>The correct way is</div><div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">   call TSMonitorSet(ts, Monitor, ctx, PETSC_NULL_FUNCTION, ierr); CHKERRQ(ierr)</div></div><div><br></div><div>Thanks</div><div>praveen</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 18, 2017 at 9:30 PM, Satish Balay <span dir="ltr"><<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Perhaps there is some memory corruption - you can try runnng the code with valgrind.<br>
<span class="HOEnZb"><font color="#888888"><br>
Satish<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Sat, 18 Mar 2017, Praveen C wrote:<br>
<br>
> Dear all<br>
><br>
> I get a segmentation fault when I call TSDestroy. Without TSDestroy the<br>
> code runs fine. I have included portion of my code below.<br>
><br>
> subroutine runts(ctx)<br>
>    use userdata<br>
>    use comdata<br>
>    use mtsdata<br>
>    implicit none<br>
> #include <petsc/finclude/petsc.h90><br>
>    type(tsdata) :: ctx<br>
>    ! Local variables<br>
>    integer,parameter :: h = 100 ! File id for history file<br>
>    TS                :: ts<br>
>    Vec               :: u<br>
>    PetscErrorCode    :: ierr<br>
>    external          :: RHSFunction, Monitor<br>
><br>
>    call VecDuplicate(ctx%p%v_res, u, ierr); CHKERRQ(ierr)<br>
><br>
>    ! Copy initial condition into u<br>
>    call VecCopy(ctx%p%v_u, u, ierr); CHKERRQ(ierr)<br>
><br>
>    call TSCreate(PETSC_COMM_WORLD, ts, ierr); CHKERRQ(ierr)<br>
>    call TSSetProblemType(ts, TS_NONLINEAR, ierr); CHKERRQ(ierr)<br>
>    call TSSetRHSFunction(ts, PETSC_NULL_OBJECT, RHSFunction, ctx, ierr);<br>
> CHKERRQ(ierr)<br>
>    call TSSetInitialTimeStep(ts, 0.0, dtg, ierr); CHKERRQ(ierr)<br>
>    call TSSetType(ts, TSRK, ierr); CHKERRQ(ierr);<br>
>    call TSSetDuration(ts, itmax, tfinal, ierr); CHKERRQ(ierr);<br>
>    call TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP, ierr);<br>
> CHKERRQ(ierr);<br>
>    call TSMonitorSet(ts, Monitor, ctx, PETSC_NULL_OBJECT, ierr);<br>
> CHKERRQ(ierr)<br>
>    call TSSetSolution(ts, u, ierr); CHKERRQ(ierr)<br>
>    call TSSetFromOptions(ts, ierr); CHKERRQ(ierr)<br>
>    call TSSetUp(ts, ierr); CHKERRQ(ierr)<br>
><br>
>    call TSSolve(ts, u, ierr); CHKERRQ(ierr)<br>
><br>
>    call VecCopy(u, ctx%p%v_u, ierr); CHKERRQ(ierr)<br>
>    call VecDestroy(u, ierr); CHKERRQ(ierr)<br>
>    call TSDestroy(ts, ierr); CHKERRQ(ierr)<br>
><br>
> end subroutine runts<br>
><br>
> Thanks<br>
> praveen<br>
><br>
<br>
</div></div></blockquote></div><br></div>