<div dir="ltr">Thanks Randy, that makes sense.<div>Mark</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 2, 2021 at 3:27 PM Randall Mackie <<a href="mailto:rlmackie862@gmail.com">rlmackie862@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Mark,<br>
<br>
I don’t know what the XGC code is, but the way I do this in my Fortran code is that I initialize all objects I later want to destroy, for example:<br>
<br>
mat11=PETSC_NULL_MAT<br>
vec1=PETSC_NULL_VEC<br>
<br>
etc<br>
<br>
Then I check and destroy like:<br>
<br>
if (mat11 /= PETSC_NULL_MAT) call MatDestroy(mat11, ierr)<br>
<br>
etc.<br>
<br>
Hope this helps,<br>
<br>
Randy<br>
<br>
<br>
> On Feb 2, 2021, at 12:17 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br>
> <br>
> Satish, a few years ago you helped us transition the XGC Fortran code from v3.7.7 and we seemed to have regressed.<br>
> <br>
> As I recall we removed the initialization of Mats (for example) in XGC. PETSc seems to initialize them with -2 in Fortran (Albert, cc'ed, verified this today) and I recall that from our previous conversation. As I look at the code now Fortran MatDestroy just goes straight to C, which would explain our crashes when we MatDestroy an uninitialized (-2) Mat.<br>
> <br>
> What is the correct way to delete with initializing Fortran objects?<br>
> <br>
> Thanks,<br>
> Mark<br>
> <br>
> <br>
<br>
</blockquote></div>