<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 3, 2014 at 11:41 PM, Adrian Croucher <span dir="ltr"><<a href="mailto:a.croucher@auckland.ac.nz" target="_blank">a.croucher@auckland.ac.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">hi,<br>
<br>
What is the right way to call DMPlexPointLocalRef() from fortran?<br></blockquote><div><br></div><div>Right now, there is none. Jed did not write a Fortran interface, and did not turn off the automatic one which is non-functional.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a test subroutine that I'm basically translating from the CreatePartitionVec() function in the TS ex 33 example problem.<br>
<br>
Near the end there's a loop which in C goes:<br>
<br>
ierr = VecGetArray(*partition, &part);CHKERRQ(ierr);<br>
for (c = cStart; c < cEnd; ++c) {<br>
PetscScalar *p;<br>
ierr = DMPlexPointLocalRef(*dmCell, c, part, &p);CHKERRQ(ierr);<br>
p[0] = rank;<br>
}<br>
ierr = VecRestoreArray(*partition, &part);CHKERRQ(ierr);<br>
<br>
<br>
So in fortran I've done this:<br>
<br>
call VecGetArrayF90(partition, part, ierr); CHKERRQ(ierr)<br>
do c = cStart, cEnd-1<br>
call DMPlexPointLocalRef(cell_dm, c, part, p, ierr); CHKERRQ(ierr)<br></blockquote><div><br></div><div>Instead of this, use</div><div><br></div><div> call DMPlexGetDefaultSection(cell_dm, section, ierr); (Move outside of loop)</div>
<div> call PetscSectionGetOffset(section, c, off, ierr);</div><div> part(off) =rank</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
p(1) = rank<br>
end do<br>
call VecRestoreArrayF90(partition, part, ierr); CHKERRQ(ierr)<br>
<br>
where I've previously declared<br>
<br>
PetscScalar, pointer :: part(:)<br>
PetscScalar, pointer:: p(:)<br>
<br>
However the compiler complains:<br>
<br>
Error: Rank mismatch in argument 'array' at (1) (scalar and rank-1)<br>
<br>
It's not liking the 'part' argument, but I'm not sure how it's supposed to be passed in. Any clues?<br>
<br>
Cheers, Adrian<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Dr Adrian Croucher<br>
Department of Engineering Science<br>
University of Auckland<br>
New Zealand<br>
tel 64-9-373-7599 ext 84611<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>