<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jun 12, 2016 at 7:49 AM, Santiago Ospina De Los Rios <span dir="ltr"><<a href="mailto:sospinar@unal.edu.co" target="_blank">sospinar@unal.edu.co</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello there,<div><br></div><div>I'm using your Application Ordering (AO) objects to switch between vectors with my application ordering to petsc ordering. I built a little routine which helps me to gather the information in the proper order:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>SUBROUTINE VecApplicationToPetsc(DataMngr,AppVec,ierr)</div></div><div><div><br></div></div><div><div> IMPLICIT NONE</div></div><div><div><br></div></div><div><div>#include <petsc/finclude/petscsys.h></div></div><div><div>#include <petsc/finclude/petscvec.h></div></div><div><div>#include <petsc/finclude/petscis.h></div></div><div><div>#include <petsc/finclude/petscdm.h></div></div><div><div>#include <petsc/finclude/petscdmda.h></div></div><div><div>#include <petsc/finclude/petscao.h></div></div><div><div><br></div></div><div><div> PetscErrorCode,INTENT(INOUT) :: ierr</div></div><div><div> DM,INTENT(IN) :: DataMngr</div></div><div><div> Vec,INTENT(INOUT) :: AppVec ! it outs as PetscVec</div></div><div><div><br></div></div><div><div> AO :: AppOrd</div></div><div><div> PetscInt :: RangeLow,RangeHigh,i</div></div><div><div> IS :: PetscIS,AppIS</div></div><div><div> VecScatter :: Scatter</div></div><div><div> Vec :: PetscVec</div></div><div><div><br></div></div><div><div> ! It obtains a temporal vector to store in PETSc ordering</div></div><div><div> CALL DMCreateGlobalVector(DataMngr,PetscVec,ierr)</div></div><div><div> CALL AOCreate(PETSC_COMM_WORLD,AppOrd,ierr)</div></div></blockquote></div></blockquote><div><br></div><div>Here you create a new AO object</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> CALL DMDAGetAO(DataMngr,AppOrd,ierr)</div></div></blockquote></div></blockquote><div><br></div><div>Here you overwrite that initial AO with the AO from the DMDA, thus leaking memory.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> CALL VecGetOwnershipRange(PetscVec,RangeLow,RangeHigh,ierr)</div></div><div><div> CALL ISCreateGeneral(PETSC_COMM_WORLD,RangeHigh-RangeLow,(/(i,i=RangeLow,RangeHigh)/),PETSC_COPY_VALUES,PetscIS,ierr)</div></div><div><div> CALL ISDuplicate(PetscIS,AppIS,ierr)</div></div><div><div> CALL ISCopy(PetscIS,AppIS,ierr)</div></div><div><div> CALL AOPetscToApplicationIS(AppOrd,AppIS,ierr)</div></div><div><div> CALL VecScatterCreate(AppVec,AppIS,PetscVec,PetscIS,Scatter,ierr)</div></div><div><div> CALL VecScatterBegin(Scatter,AppVec,PetscVec,INSERT_VALUES,SCATTER_FORWARD,ierr)</div></div><div><div> CALL VecScatterEnd(Scatter,AppVec,PetscVec,INSERT_VALUES,SCATTER_FORWARD,ierr)</div></div><div><div><br></div></div><div><div> CALL VecScatterDestroy(Scatter,ierr)</div></div><div><div> CALL ISDestroy(AppIS,ierr)</div></div><div><div> CALL ISDestroy(PetscIS,ierr)</div></div><div><div> CALL AODestroy(AppOrd,ierr)</div></div></blockquote></div></blockquote><div><br></div><div>Here you destroy the DMDA AO, which causes the error, but not the original AO, which causes a leak.</div><div><br></div><div>Remove the Create/Destroy.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> CALL VecCopy(PetscVec,AppVec,ierr)</div></div><div><div> CALL VecDestroy(PetscVec,ierr)</div></div><div><div><br></div></div><div><div>END SUBROUTINE VecApplicationToPetsc</div></div></blockquote><div><br></div><div><div>It is working well for my purpose, but just the first time I call it; the second time I call it, the AO object give me back an error. The most obviously way to avoid it is creating AO, IS and VecScatter objects just one time, but I don't want to handle those variables through my whole program.</div><div><br></div><div>Am I doing something wrong with the AO object?</div><div><br></div><div>Thank you.</div></div><span class="HOEnZb"><font color="#888888"><div><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br><div><span style="color:rgb(136,136,136)">-- <br><span style="font-family:Tahoma">Att:<br style="text-indent:0px!important"><br style="text-indent:0px!important">Santiago Ospina De Los Ríos<br style="text-indent:0px!important">National University of Colombia<br></span></span></div></div></div></div></div></div>
</div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>