<div>As usual, anything that is duplicated and not checked by the compiler is broken.<br><br><font face="courier new, monospace">$ grep PetscObjectAllocateFortranPointers src/**/*.c                                                                                                                  </font></div>
<div><font face="courier new, monospace">src/dm/impls/da/ftn-custom/zda2f.c:  PetscObjectAllocateFortranPointers(*da,6);</font></div><div><font face="courier new, monospace">src/dm/impls/da/ftn-custom/zda2f.c:  PetscObjectAllocateFortranPointers(*da,6);</font></div>
<div><font face="courier new, monospace">src/dm/impls/shell/ftn-custom/zdmshellf.c:  PetscObjectAllocateFortranPointers(*dm,2);</font></div><div><font face="courier new, monospace">src/dm/impls/shell/ftn-custom/zdmshellf.c:  PetscObjectAllocateFortranPointers(*dm,2);</font></div>
<div><br></div><div>Note that changing the type does not reset the function pointers, thus having a DMSHELL, calling DMSetType(dm,DMDA), and then setting a DMDA local function will cause memory corruption.</div><div><br></div>
<div>I cannot express how much I hate this system. The full-blown solution is that for each type, we register a (global) token which is the index of that function pointer. That doesn't have any false dependencies, but is more "initialize" code.</div>
<div><br></div><div>An alternative, used in the TS and KSP code below, is to have a common enum that lists all the Fortran functions. It's a false header dependency, but not a binary dependency.</div><div><br></div><div>
What should we do? The current state is a disaster.</div><div><br></div><div><font face="courier new, monospace">src/ksp/ksp/impls/gmres/fgmres/ftn-custom/zmodpcff.c:  PetscObjectAllocateFortranPointers(*ksp,3);</font></div>
<div><font face="courier new, monospace">src/ksp/ksp/interface/ftn-custom/zitfuncf.c:  PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);</font></div><div><font face="courier new, monospace">src/ksp/ksp/interface/ftn-custom/zitfuncf.c:  PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);</font></div>
<div><font face="courier new, monospace">src/ksp/pc/impls/mg/ftn-custom/zmgfuncf.c:    PetscObjectAllocateFortranPointers(*mat,1);</font></div><div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:  PetscObjectAllocateFortranPointers(*pc,5);</font></div>
<div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:  PetscObjectAllocateFortranPointers(*pc,5);</font></div><div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:  PetscObjectAllocateFortranPointers(*pc,5);</font></div>
<div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:  PetscObjectAllocateFortranPointers(*pc,5);</font></div><div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:  PetscObjectAllocateFortranPointers(*pc,5);</font></div>
<div><font face="courier new, monospace">src/mat/impls/mffd/ftn-custom/zmffdf.c:  PetscObjectAllocateFortranPointers(*mat,2);</font></div><div><font face="courier new, monospace">src/mat/impls/shell/ftn-custom/zshellf.c:  PetscObjectAllocateFortranPointers(*mat,11);</font></div>
<div><font face="courier new, monospace">src/mat/interface/ftn-custom/zmatrixf.c:  PetscObjectAllocateFortranPointers(*sp,1);</font></div><div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:  PetscObjectAllocateFortranPointers(*snes,14);</font></div>
<div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:  PetscObjectAllocateFortranPointers(*snes,14);</font></div><div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:  PetscObjectAllocateFortranPointers(*snes,14);</font></div>
<div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:  PetscObjectAllocateFortranPointers(*snes,14);</font></div><div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:  PetscObjectAllocateFortranPointers(*snes,14);</font></div>
<div><font face="courier new, monospace">src/snes/linesearch/impls/shell/ftn-custom/zlinesearchshellf.c:  PetscObjectAllocateFortranPointers(*linesearch,3);</font></div><div><font face="courier new, monospace">src/snes/linesearch/interface/ftn-custom/zlinesearchf.c:  PetscObjectAllocateFortranPointers(*linesearch,3);</font></div>
<div><font face="courier new, monospace">src/snes/linesearch/interface/ftn-custom/zlinesearchf.c:  PetscObjectAllocateFortranPointers(*linesearch,3);</font></div><div><font face="courier new, monospace">src/sys/draw/utils/ftn-custom/zzoomf.c:  PetscObjectAllocateFortranPointers(*draw,1);</font></div>
<div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:  PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div><div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:  PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
<div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:    PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div><div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:    PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
<div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:  PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div><div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:  PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
<div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:  PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>