<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 17, 2017 at 11:35 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">hi<br><br>
On 16/10/17 15:16, Jed Brown wrote:<span class="gmail-"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Adrian Croucher <<a href="mailto:a.croucher@auckland.ac.nz" target="_blank">a.croucher@auckland.ac.nz</a>> writes:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
So do you think the SF stuff in petsc/finclude/petscis.h should be taken<br>
out, and put into a new petsc/finclude/petscsf.h ?<br>
</blockquote>
I think that's desirable for symmetry with include/petscsf.h, but it<br>
isn't important for your contribution.<br>
</blockquote>
<br></span>
I have got Fortran bindings for PetscSFGetGraph() and PetscSFSetGraph() working. First I tried separating the existing SF stuff out of the IS modules, but ran into dependency problems in other modules. I wasn't too confident about the best way to resolve those without breaking things, so I tried it again just doing minimal changes to the existing SF stuff- essentially just adding Fortran wrappers for PetscSFGetGraph() and PetscSFSetGraph() into src/vec/f90-mod/petscis.h90- and that seemed to work fine. Maybe someone more familiar with the setup could separate out the SF stuff from IS sometime.<br>
<br>
<br>
So, now I'm trying to add Fortran bindings for PetscSFBcastBegin() and PetscSFBcastEnd().<br>
<br>
>From the C side I have added the following into src/vec/is/sf/interface/f90-cu<wbr>stom/zsff90.c:<br>
<br>
PETSC_EXTERN void PETSC_STDCALL petscsfbcastbegin_(PetscSF *sf, MPI_Datatype *unit, F90Array1d *rptr, F90Array1d *lptr , int *ierr PETSC_F90_2PTR_PROTO(rptrd) PETSC_F90_2PTR_PROTO(lptrd))<br>
{<br>
  PetscDataType ptype;<br>
  const void* rootdata;<br>
  void* leafdata;<br>
<br>
  *ierr = PetscMPIDataTypeToPetscDataTyp<wbr>e(*unit, &ptype);if (*ierr) return;<br>
  *ierr = F90Array1dAccess(rptr, ptype, (void**) &rootdata PETSC_F90_2PTR_PARAM(rptrd));i<wbr>f (*ierr) return;<br>
  *ierr = F90Array1dAccess(lptr, ptype, (void**) &leafdata PETSC_F90_2PTR_PARAM(lptrd));i<wbr>f (*ierr) return;<br>
<br>
  *ierr = PetscSFBcastBegin(*sf, *unit, rootdata, leafdata);<br>
<br>
}<br>
<br>
and similarly for petscsfbcastend_(). Does this look plausible?<br>
<br>
Then some wrappers need to be added to src/vec/f90-mod/petscis.h90. I am not sure how to do those.<br>
<br>
The difficulty is in declaring the arrays that are passed in, which can be of various types. In C they are declared as void*, but I'm not sure what to do with that in Fortran. I can't seem to find any other example wrappers in PETSc to model it on either. Any suggestions?</blockquote><div><br></div><div>I do not understand Fortran. However, it looks like you can choose an arbitrary type for the array, such as character,</div><div>and then use the 'transfer' intrinsic from F95 in your code to get an array like that</div><div><br></div><div>  <a href="https://jblevins.org/log/transfer">https://jblevins.org/log/transfer</a></div><div><br></div><div>so you only need an interface with that generic array type in PETSc.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">
- Adrian<br>
<br>
-- <br>
Dr Adrian Croucher<br>
Senior Research Fellow<br>
Department of Engineering Science<br>
University of Auckland, New Zealand<br>
email: <a href="mailto:a.croucher@auckland.ac.nz" target="_blank">a.croucher@auckland.ac.nz</a><br>
tel: <a href="tel:%2B64%20%280%299%20923%204611" value="+6499234611" target="_blank">+64 (0)9 923 4611</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>