[petsc-dev] PetscSF in Fortran

Matthew Knepley knepley at gmail.com
Sun Oct 15 19:12:37 CDT 2017


On Sun, Oct 15, 2017 at 6:54 PM, Adrian Croucher <a.croucher at auckland.ac.nz>
wrote:

> hi
>
> On 14/10/17 00:47, Matthew Knepley wrote:
>
>
> If you want the wrapper to take in F90 pointer arguments, then you have to
> declare it or you get an SEGV. These
> get autogenerated in include/petsc/finclude/ftn-auto/*.h90 when you run
> 'make allfortranstubs'. Did this happen
> for your function?
>
>
> I just tried running make allfortranstubs, but I don't see anything new in
> include/petsc/finclude/ftn-auto/*.h90, and my test program still crashes.
>
> I also tried doing a make clean and make allfortranstubs all, but that
> didn't help.
>
> I even tried deleting my $PETSC_ARCH directory and rebuilding everything
> (including make allfortranstubs) but again it didn't help.
>
> I'm a bit surprised that custom Fortran bindings should produce anything
> in include/petsc/finclude/ftn-auto/, I thought that would only be for the
> auto-generated stuff that comes out of bfort?
>

Okay, I was wrong about what gets produced. Barry rewrote the Fortran
bindings last, and I did not understand how everything
was put together. You will need to make some modifications. Here is the
idea: we build an F90 module for each class, and your
stuff will go in the Vec module here:


https://bitbucket.org/petsc/petsc/src/c99b676fdc4d0978b5621d138ceee2e1b7869aa6/src/vec/f90-mod/petscvecmod.F?at=master&fileviewer=file-view-default

You will need to make a module in this file petscsf. It should look about
like the petscao module. That means making
a petscsf.h90 with your new interfaces, like this one


https://bitbucket.org/petsc/petsc/src/c99b676fdc4d0978b5621d138ceee2e1b7869aa6/src/vec/f90-mod/petscis.h90?at=master&fileviewer=file-view-default

and also a generic petscsf.h, like this one


https://bitbucket.org/petsc/petsc/src/c99b676fdc4d0978b5621d138ceee2e1b7869aa6/src/vec/f90-mod/petscao.h?at=master&fileviewer=file-view-default

Then in your example you need a

  use petscsf

which will bring in the interface for your function, causing Fortran to
pass the array descriptor instead of some bogus pointer.

  Thanks,

    Matt


>
> - Adrian
>
> --
> Dr Adrian Croucher
> Senior Research Fellow
> Department of Engineering Science
> University of Auckland, New Zealand
> email: a.croucher at auckland.ac.nz
> tel: +64 (0)9 923 4611 <+64%209-923%204611>
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20171015/66a50edb/attachment.html>


More information about the petsc-dev mailing list