[petsc-dev] PetscSF in Fortran
Adrian Croucher
a.croucher at auckland.ac.nz
Tue Oct 17 22:35:53 CDT 2017
hi
On 16/10/17 15:16, Jed Brown wrote:
> Adrian Croucher <a.croucher at auckland.ac.nz> writes:
>
>> So do you think the SF stuff in petsc/finclude/petscis.h should be taken
>> out, and put into a new petsc/finclude/petscsf.h ?
> I think that's desirable for symmetry with include/petscsf.h, but it
> isn't important for your contribution.
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.
So, now I'm trying to add Fortran bindings for PetscSFBcastBegin() and
PetscSFBcastEnd().
From the C side I have added the following into
src/vec/is/sf/interface/f90-custom/zsff90.c:
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))
{
PetscDataType ptype;
const void* rootdata;
void* leafdata;
*ierr = PetscMPIDataTypeToPetscDataType(*unit, &ptype);if (*ierr) return;
*ierr = F90Array1dAccess(rptr, ptype, (void**) &rootdata
PETSC_F90_2PTR_PARAM(rptrd));if (*ierr) return;
*ierr = F90Array1dAccess(lptr, ptype, (void**) &leafdata
PETSC_F90_2PTR_PARAM(lptrd));if (*ierr) return;
*ierr = PetscSFBcastBegin(*sf, *unit, rootdata, leafdata);
}
and similarly for petscsfbcastend_(). Does this look plausible?
Then some wrappers need to be added to src/vec/f90-mod/petscis.h90. I am
not sure how to do those.
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?
- 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
More information about the petsc-dev
mailing list