<div class="gmail_quote">On Wed, Nov 24, 2010 at 23:18, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">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;">
<div id=":pz">Presumably. Or we could pull the reference counting up into the base method and only call the VecGet/RestoreArray[Read]() method the first/last time so that each implementation does not need to manage it. For "standard" PETSc vectors the counting is not needed except for checking that the user has done things correctly.<br>

<div class="im"><br>
>  This violates the present API implied by VecGetArray_Seq:<br>
><br>
> if (vin->array_gotten) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Array has already been gotten for this vector,you may\nhave forgotten a call to VecRestoreArray()");<br>
<br>
</div>    This particular piece of code should not normally (ever) be triggered. Do you have code where this error is generated? Please let me know where. Eventually this check will be tossed.<br></div></blockquote><div>
<br></div><div>When is VecGetArray_Seq actually executed?  I thought it always fell under the x->petscnative clause.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":pz"><div class="im">
> Do you want to relax this restriction on the API (placing extra burden on the implementation), or revert the patch?<br>
<br>
</div>    The current model (which does not have code to check if it is violated, except for the code fragment above you found) is that multiple VecGetArrayRead() reads can be done on the same Vec but only a single VecGetArray[Write]().  A write can be called on a Vec that has an open VecGetArrayRead().</div>
</blockquote><div><br></div><div>I think this is correct behavior, though not strictly conforming from Fortran.  C users can restrict-qualify when they know that they have distinct memory.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":pz"> After the VecRestoreArray[Write]() is called the values are copied back to their original location, when all reads and writes are closed the array can be freed. Restoring the Write array results in an increase in the Vec state.<br>
</div></blockquote><div><br></div><div>Could VecGetArray[Write] also set a flag so that the usual Vec operations error when write access is checked out.</div><div><br></div><div>Jed</div></div>