<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">PetscErrorCode AOApplicationToPetsc_Mapping(</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">AO ao, PetscInt n, PetscInt *ia)</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">

<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">has</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">

<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">    if (low > high) SETERRQ1(PETSC_COMM_SELF,</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">PETSC_ERR_ARG_OUTOFRANGE, "Invalid input index %D", idex);</span><div>

<font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">Well.... is it a good idea to rewrite this part as </font></div><div><font color="#222222" face="arial, sans-serif"><br>

</font></div><div><span style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)"> if (low > high) ia[i] = -1;</span></div><div><font color="#222222" face="arial, sans-serif"><br>

</font></div><div><font color="#222222" face="arial, sans-serif">And wait for comments from PETSc developers?</font></div><div><font color="#222222" face="arial, sans-serif"><br></font></div><div>Need I recompile petsc4py after compiling PETSc?</div>

<div><br></div><div><font color="#222222" face="arial, sans-serif">Best,</font></div><div><font color="#222222" face="arial, sans-serif">Xin<br></font><br><div class="gmail_quote">On Wed, Aug 8, 2012 at 9:26 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
  Hmm,<br>
<br>
PetscErrorCode AOApplicationToPetsc_Basic(AO ao,PetscInt n,PetscInt *ia)<br>
<br>
   has<br>
<br>
    if (ia[i] >= 0 && ia[i] < N) {<br>
      ia[i] = aobasic->petsc[ia[i]];<br>
    } else {<br>
      ia[i] = -1;<br>
    }<br>
<br>
PetscErrorCode AOApplicationToPetsc_Mapping(AO ao, PetscInt n, PetscInt *ia)<br>
<br>
has<br>
<br>
    if (low > high) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE, "Invalid input index %D", idex);<br>
<br>
PetscErrorCode AOApplicationToPetsc_MemoryScalable(AO ao,PetscInt n,PetscInt *ia)<br>
<br>
has<br>
<br>
      if (ia[i] >= owners[rank] && ia[i] < owners[rank+1] ) {<br>
        ia[i] = maploc[ia[i]-owners[rank]];<br>
      } else {<br>
        ia[i] = -1 ; /* ia[i] is not in the range of 0 and N-1, maps it to -1 */<br>
      }<br>
<br>
So it seems the intention is to return -1 for out of range not an error.<br>
<br>
Can the PETSc developer who wrote all this stuff comment?   Likely our bug! Also we should fix the manual page for AOApplicationToPetsc() to clearly indicate what happens for out of range values<br>
<span class="HOEnZb"><font color="#888888"><br>
   Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Aug 8, 2012, at 3:10 PM, Xin Zhao <<a href="mailto:sean.null@gmail.com">sean.null@gmail.com</a>> wrote:<br>
<br>
> Dear all,<br>
><br>
> Assume that I want to convert an indices in application order into petsc order.<br>
> But I don't know the indices in application is in range.<br>
><br>
> Say<br>
> I call<br>
> ao = PETSc.AO().createMapping([4,2,3])<br>
><br>
> then<br>
> ao.app2petsc([2,5,3])<br>
> will raise an error.<br>
><br>
> is there any way to make return value to [1,-1,2] instead of raising an error?<br>
><br>
><br>
> Or there is any way I can handle this error to make it work?<br>
><br>
> Best,<br>
> Xin<br>
<br>
</div></div></blockquote></div><br></div>