[petsc-dev] DMPlexCreateSection from fortran

Adrian Croucher a.croucher at auckland.ac.nz
Thu Aug 7 19:01:20 CDT 2014


I'm getting a compile-time error when calling DMPlexCreateSection() from 
fortran. The error is:

        num_bc, pbc_field, pbc_pointIS, section, ierr); if (ierr .ne. 0) 
call MP
Error: Type mismatch in argument 'section' at (1); passed INTEGER(4) to 

The code is below. (I'm not sure if there is a simpler way to do this 
that doesn't require all those extra pointer variables.) I based it on 
the C code in SNES ex12.

Is my code wrong or could it be a bug? I'm using the 'next' branch of PETSc.

Cheers, Adrian


subroutine setup_dm_section(dm)

   ! Sets up section on dm.

   implicit none

#include <finclude/petsc.h90>

   DM, intent(in out) :: dm
   ! Locals:
   PetscInt, parameter :: dim = 3, num_fields = 1
   PetscInt, target :: num_comp(1) = [1], num_dof(3) = [0,0,1]
   PetscInt, pointer :: pnum_comp(:), pnum_dof(:)
   PetscInt, parameter :: num_bc = 0
   PetscInt, target :: bc_field(1) = [0]
   PetscInt, pointer :: pbc_field(:)
   IS, target :: bc_pointIS(1)
   IS, pointer :: pbc_pointIS(:)
   PetscSection :: section
   PetscErrorCode :: ierr

   pnum_comp => num_comp; pnum_dof => num_dof
   pbc_field => bc_field; pbc_pointIS => bc_pointIS

   call DMPlexCreateSection(dm, dim, num_fields, pnum_comp, pnum_dof, &
        num_bc, pbc_field, pbc_pointIS, section, ierr); CHKERRQ(ierr)
   call PetscSectionSetFieldName(section, 0, "y", ierr); CHKERRQ(ierr)
   call PetscSectionSetUp(section, ierr); CHKERRQ(ierr)
   call DMSetDefaultSection(dm, section); CHKERRQ(ierr)
   call PetscSectionDestroy(section, ierr); CHKERRQ(ierr)

end subroutine setup_dm_section

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