<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 30 April 2016 at 16:04, Ilyas YILMAZ <span dir="ltr"><<a href="mailto:ilyascfd@gmail.com" target="_blank">ilyascfd@gmail.com</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"><div><div><div>Hello,<br><br></div>The code segment I wrote based on "src/dm/da/examples/tutorials/ex2.c" crashes when destroying things / freeing memory as given below. <br>I can't figure out what I'm missing? Any comments are welcome. (Petsc 3.1.p8,</div></div></div></blockquote><div><br></div><div>I'd strongly suggest updating to version 3.7 before proceeding any further.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div> intel fortran compiler). The code and error are below.<br></div><br>        !...Create scatter from global DA parallel vector to local vector that contains all entries<br>        call DAGlobalToNaturalAllCreate(da,tolocalall,ierr)<br>        call DAGlobalToNaturalAllCreate(da,tolocalall2,ierr)<br>        call DAGlobalToNaturalAllCreate(da,tolocalall3,ierr)<br><br>        call VecCreateSeq(PETSC_COMM_SELF,im*jm*km,CSRENOMlocalall,ierr)<br>        call VecScatterBegin(tolocalall,CSRENOM,CSRENOMlocalall,INSERT_VALUES,SCATTER_FORWARD,ierr)
<br>        call VecScatterEnd(  tolocalall,CSRENOM,CSRENOMlocalall,INSERT_VALUES,SCATTER_FORWARD,ierr)<br><br>        call VecCreateSeq(PETSC_COMM_SELF,im*jm*km,CSDENOMlocalall,ierr)<br>        call VecScatterBegin(tolocalall2,CSDENOM,CSDENOMlocalall,INSERT_VALUES,SCATTER_FORWARD,ierr)
<br>        call VecScatterEnd(  tolocalall2,CSDENOM,CSDENOMlocalall,INSERT_VALUES,SCATTER_FORWARD,ierr)<br><br>        call VecCreateSeq(PETSC_COMM_SELF,im*jm*km,CSlocalall,ierr)<br>        call VecScatterBegin(tolocalall3,CS,CSlocalall,INSERT_VALUES,SCATTER_FORWARD,ierr)
<br>        call VecScatterEnd(  tolocalall3,CS,CSlocalall,INSERT_VALUES,SCATTER_FORWARD,ierr)<br><br><br>        call VecGetArray(CSRENOMlocalall,scaCSRENOMlocalall,idCSRENOMlocalall,ierr)<br>        call VecGetArray(CSDENOMlocalall,scaCSDENOMlocalall,idCSDENOMlocalall,ierr)<br>        call VecGetArray(     CSlocalall,scaCSlocalall     ,idCSlocalall     ,ierr)<br><br> <br></div>                          SOME WORK HERE<br><br><br><div>        call VecRestoreArray(CSlocalall     ,scaCSlocalall     ,idCSlocalall,ierr)<br>        call VecRestoreArray(CSRENOMlocalall,scaCSRENOMlocalall,idCSRENOMlocalall,ierr)<br>        call VecRestoreArray(CSDENOMlocalall,scaCSDENOMlocalall,idCSDENOMlocalall,ierr)<br><br><br>        !...scatter back to global vector<br>        call DANaturalAllToGlobalCreate(da,fromlocalall,ierr)<br>        call DANaturalAllToGlobalCreate(da,fromlocalall2,ierr)<br>        call DANaturalAllToGlobalCreate(da,fromlocalall3,ierr)<br><br>        call VecScatterBegin(fromlocalall,CSRENOMlocalall,CSRENOM,INSERT_VALUES,SCATTER_FORWARD,ierr)
<br>        call VecScatterEnd(  fromlocalall,CSRENOMlocalall,CSRENOM,INSERT_VALUES,SCATTER_FORWARD,ierr)<br><br>        call VecScatterBegin(fromlocalall2,CSDENOMlocalall,CSDENOM,INSERT_VALUES,SCATTER_FORWARD,ierr)
<br>        call VecScatterEnd(  fromlocalall2,CSDENOMlocalall,CSDENOM,INSERT_VALUES,SCATTER_FORWARD,ierr)<br><br>        call VecScatterBegin(fromlocalall3,CSlocalall,CS,INSERT_VALUES,SCATTER_FORWARD,ierr)
<br>        call VecScatterEnd(  fromlocalall3,CSlocalall,CS,INSERT_VALUES,SCATTER_FORWARD,ierr)<br><br></div><div>        !..free memory<br>       call VecScatterDestroy(fromlocalall,ierr)<br>       call VecScatterDestroy(fromlocalall2,ierr)<br>       call VecScatterDestroy(fromlocalall3,ierr)<br><br>      call VecScatterDestroy(tolocalall,ierr)<br>      call VecScatterDestroy(tolocalall2,ierr)<br>      call VecScatterDestroy(tolocalall3,ierr)<br><br>      call VecDestroy(CSDENOMlocalall,ierr)<br>      call VecDestroy(CSRENOMlocalall,ierr)<br>      call VecDestroy(CSlocalall,ierr)<br><br><br>.<br>.<br>.<br>.<br>.<br>.<br> ...................... SGS model is called<br> MUT computed<br> MUT computed<br> MUT computed<br> MUT computed<br>[1]PETSC ERROR: ------------------------------------------------------------------------<br>[1]PETSC ERROR: [0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range<br>[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger<br>[0]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC</a> ERROR: or try <a href="http://valgrind.org" target="_blank">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors<br>[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run <br>[0]PETSC ERROR: to get more information on the crash.<br>.<br>.<br>.<br>.<br>.<br><br></div><div>Thank you<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>Ilyas.<br></div></font></span></div>
</blockquote></div><br></div></div>