<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I believe this should be automated in TSSolve when step == 0 as for other TS internal stuff.<div class="">Hong? Are you ok with this?</div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 14, 2020, at 7:31 PM, Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" class="">stefano.zampini@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Take a look at<div class=""><span style="font-family: Menlo; font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-family: Menlo; font-size: 14px;" class="">src/tao/unconstrained/examples/tutorials/spectraladjointassimilation.c</span><span style="font-family: Menlo; font-size: 14px;" class=""> </span><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><br class=""></div></div><div class="">You need to call TSResetTrajectory before calling TSSolve when reusing the same TS</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Mar 14, 2020, at 6:54 PM, Zane Charles Jakobs <<a href="mailto:Zane.Jakobs@colorado.edu" class="">Zane.Jakobs@colorado.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi PETSc devs,</div><div class=""><br class=""></div><div class="">I have some code that implements (essentially) 4D-VAR with PETSc, and the results of both my forward and adjoint integrations look correct to me (i.e. calling TSSolve() and then TSAdjointSolve() works correctly as far as I can tell). However, when I try to use a TaoSolve() to optimize my initial condition, I get this error message:</div><div class=""><br class=""></div><div class="">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br class="">[0]PETSC ERROR: Petsc has generated inconsistent data<br class="">[0]PETSC ERROR: History id should be unique<br class="">[0]PETSC ERROR: See <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html" class="">https://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br class="">[0]PETSC ERROR: Petsc Development GIT revision: v3.12.4-783-g88ddbcab12 GIT Date: 2020-02-21 16:53:25 -0600<br class="">[0]PETSC ERROR: ./var_ic_test on a arch-linux2-c-debug named DiffeoInvariant by diffeoinvariant Sat Mar 14 09:39:05 2020<br class="">[0]PETSC ERROR: Configure options CFLAGS="-O3 -march=native -mtune=native -fPIE" --with-shared-libraries=1 --with-openmp=1 --with-threads=1 --with-fortran=0 --with-avx2=1 CXXOPTFLAGS="-O3 -march=native -mtune=native -fPIE" --with-cc=clang --with-cxx=clang++ --download-mpich<br class="">[0]PETSC ERROR: #1 TSHistoryUpdate() line 82 in /usr/local/petsc/src/ts/interface/tshistory.c<br class="">[0]PETSC ERROR: #2 TSTrajectorySet() line 73 in /usr/local/petsc/src/ts/trajectory/interface/traj.c<br class="">[0]PETSC ERROR: #3 TSSolve() line 4005 in /usr/local/petsc/src/ts/interface/ts.c<br class="">[0]PETSC ERROR: #4 MixedModelFormVARICFunctionGradient() line 301 in mixed.c<br class="">[0]PETSC ERROR: #5 TaoComputeObjectiveAndGradient() line 261 in /usr/local/petsc/src/tao/interface/taosolver_fg.c<br class="">[0]PETSC ERROR: #6 TaoSolve_LMVM() line 23 in /usr/local/petsc/src/tao/unconstrained/impls/lmvm/lmvm.c<br class="">[0]PETSC ERROR: #7 TaoSolve() line 219 in /usr/local/petsc/src/tao/interface/taosolver.c<br class="">[0]PETSC ERROR: #8 MixedModelOptimize() line 639 in mixed.c<br class="">[0]PETSC ERROR: #9 MixedModelOptimizeInitialCondition() line 648 in mixed.c<br class="">[0]PETSC ERROR: #10 main() line 76 in var_ic_test.c<br class="">[0]PETSC ERROR: No PETSc Option Table entries<br class="">[0]PETSC ERROR: ----------------End of Error Message -------send entire error message to <a href="mailto:petsc-maint@mcs.anl.gov" class="">petsc-maint@mcs.anl.gov</a>----------</div><div class=""><br class=""></div><div class="">In the function MixedModelFormVARICFunctionGradient(), I do</div><div class=""><br class=""></div><div class="">ierr = TSSetTime(model->ts, 0.0);CHKERRQ(ierr);<br class="">ierr = TSSetStepNumber(model->ts, 0);CHKERRQ(ierr);<br class="">ierr = TSSetFromOptions(model->ts);CHKERRQ(ierr);</div><div class="">ierr = TSSetMaxTime(model->ts, model->obs->t);CHKERRQ(ierr);<br class="">ierr = TSSolve(model->ts, model->X);CHKERRQ(ierr);</div><div class="">... [allocating and setting cost gradient vec]</div><div class="">ierr = TSSetCostGradients(model->ts, 1, model->lambda, NULL);CHKERRQ(ierr);<br class="">ierr = TSAdjointSolve(model->ts);CHKERRQ(ierr);<br class="">ierr = VecCopy(model->lambda[0], G);CHKERRQ(ierr);</div><div class=""><br class=""></div><div class="">What might be causing the above error? Am I using a deprecated version of the Tao interface? (I'm using TaoSetObjectiveAndGradientRoutine, as done in ex20_opt_ic.c)</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">-Zane Jakobs<br class=""></div><div class=""><br class=""> </div></div>
</div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>