It does not compromise the checkpointing ability since TSAdjoint does not rely 
on TSHistory.

diff --git a/src/ts/trajectory/interface/traj.c 
b/src/ts/trajectory/interface/traj.c
index 465a52f5cf..8267fd73a3 100644
--- a/src/ts/trajectory/interface/traj.c
+++ b/src/ts/trajectory/interface/traj.c
@@ -450,7 +450,7 @@ PetscErrorCode  TSTrajectoryCreate(MPI_Comm 
comm,TSTrajectory *tj)
   t->adjoint_solve_mode   = PETSC_TRUE;
   t->solution_only        = PETSC_FALSE;
   t->keepfiles            = PETSC_FALSE;
-  t->usehistory           = PETSC_TRUE;
+  t->usehistory           = PETSC_FALSE;
   *tj  = t;
   ierr = TSTrajectorySetFiletemplate(t,"TS-%06D.bin");CHKERRQ(ierr);
   PetscFunctionReturn(0)

Hong (Mr.)

On Aug 18, 2020, at 6:07 PM, Salazar De Troya, Miguel 
<[email protected]<mailto:[email protected]>> wrote:

Thank you,

Does this compromise the ability of TSAdjoint to use checkpointing schemes to 
save memory?

Miguel



From: "Zhang, Hong" <[email protected]<mailto:[email protected]>>
Date: Tuesday, August 18, 2020 at 3:46 PM
To: "Salazar De Troya, Miguel" 
<[email protected]<mailto:[email protected]>>
Cc: "Zhang, Hong via petsc-users" 
<[email protected]<mailto:[email protected]>>
Subject: Re: [petsc-users] Error calling TSSolve more than once with 
TSSetSaveTrajectory

To get rid of this error, you can disable TSHistory with the command line 
option -ts_trajectory_use_history 0

or set up your TS with

TSGetTrajectory(ts, &tj);
TSTrajectorySetUseHistory(tj, PETSC_FALSE);

It is a known issue, but not the intended behavior for TSSetSaveTrajectory. I 
think TSHistory should be disabled by default in TS. It is actually disabled in 
the setup for TSAdjoint. So if you call TSAdjointSolve once, this error should 
not occur in the following calls to TSSolve.

Hong(Mr.)


On Aug 18, 2020, at 1:11 PM, Salazar De Troya, Miguel via petsc-users 
<[email protected]<mailto:[email protected]>> wrote:

Hello,

If I set up my TS with TSSetSaveTrajectory() and then call TSSolve() more than 
once, the second time I get this error:

[0] TSSolve() line 4102 in 
/Users/salazardetro1/scicomp_libraries/firedrake-debug/firedrake/src/petsc/src/ts/interface/ts.c
[0] TSTrajectorySet() line 73 in 
/Users/salazardetro1/scicomp_libraries/firedrake-debug/firedrake/src/petsc/src/ts/trajectory/interface/traj.c
[0] TSHistoryUpdate() line 82 in 
/Users/salazardetro1/scicomp_libraries/firedrake-debug/firedrake/src/petsc/src/ts/interface/tshistory.c
[0] Petsc has generated inconsistent data
[0] History id should be unique

If I call TSAdjointSolve() in between calls to TSSolve(), there is no problem. 
Is this the intended behavior for TSSetSaveTrajectory? Meaning that 
TSAdjointSolve() always has to be called right after TSSolve() if 
TSSetSaveTrajectory() is called. I need to call TSSolve() independently of 
TSAdjointSolve() whenever I want to perform a line search during the 
optimization.

Is there a workaround like creating a new trajectory whenever TSSolve() is 
called?

Thanks
Miguel



Miguel A. Salazar de Troya
Postdoctoral Researcher, Lawrence Livermore National Laboratory
B141
Rm: 1085-5
Ph: 1(925) 422-6411

Reply via email to