<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Tim:</div><div class="gmail_quote">It is in the release branch</div><div class="gmail_quote"><a href="https://bitbucket.org/petsc/petsc/commits/f79229c73db120b69d05e6d49c19f429e09e633f">https://bitbucket.org/petsc/petsc/commits/f79229c73db120b69d05e6d49c19f429e09e633f</a></div><div class="gmail_quote">Thanks for reporting it.</div><div class="gmail_quote">Hong</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hong,<br>
we are fine with that. Thanks!<br>
Volker<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
2018-04-18 17:32 GMT+02:00 Hong <<a href="mailto:hzhang@mcs.anl.gov">hzhang@mcs.anl.gov</a>>:<br>
> Tim :<br>
>><br>
>> Hi all,<br>
>><br>
>> with PETSc v3.9 there seems to be a out of bounds write in the fortran<br>
>> interface of MatCreateSubmatrices.<br>
>><br>
>> <a href="https://bitbucket.org/petsc/petsc/src/59479656cffe26dd9a9d446f6d00dfe5e3168168/src/mat/interface/ftn-custom/zmatrixf.c?at=maint&fileviewer=file-view-default#zmatrixf.c-609" rel="noreferrer" target="_blank">https://bitbucket.org/petsc/<wbr>petsc/src/<wbr>59479656cffe26dd9a9d446f6d00df<wbr>e5e3168168/src/mat/interface/<wbr>ftn-custom/zmatrixf.c?at=<wbr>maint&fileviewer=file-view-<wbr>default#zmatrixf.c-609</a><br>
>><br>
>> The reference mentions that in fortran one should pass a preallocated<br>
>> array for submat with at least the size of m (actually it's probably a<br>
>> typo and should be n)<br>
>><br>
>> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateSubMatrices.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>petsc-current/docs/<wbr>manualpages/Mat/<wbr>MatCreateSubMatrices.html</a><br>
>><br>
>> Then n+1 entries are copied into that array, where the last entry<br>
>> seems to be some unneeded dummy (as mentioned).<br>
>> for (i=0; i<=*n; i++) { /* lsmat[*n] might be a dummy matrix for<br>
>> saving data struc */<br>
>>   smat[i] = lsmat[i];<br>
>> }<br>
>> This leads to some bad errors afterwards, when that array is only of<br>
>> the size of n as recommended.<br>
><br>
><br>
> We need this extra space for reuse -- I agree it makes Fortran API odd.<br>
><br>
> I made following fix to the help manual:<br>
> diff --git a/src/mat/interface/matrix.c b/src/mat/interface/matrix.c<br>
><br>
>     When finished using the submatrices, the user should destroy<br>
> -   them with MatDestroyMatrices().<br>
> +   them with MatDestroySubMatrices().<br>
><br>
>     Fortran Note:<br>
>     The Fortran interface is slightly different from that given below; it<br>
> -   requires one to pass in  as submat a Mat (integer) array of size at<br>
> least m.<br>
> +   requires one to pass in  as submat a Mat (integer) array of size at<br>
> least n+1.<br>
><br>
> If you agree, I'll push it to the petsc released version.<br>
><br>
> Hong<br>
><br>
</div></div></blockquote></div><br></div></div>