[petsc-users] Segmentation fault due to TSDestroy

Satish Balay balay at mcs.anl.gov
Sat Mar 18 11:00:19 CDT 2017


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
> 



More information about the petsc-users mailing list