Actual source code: zmffdf.c

      1: #include <petsc/private/ftnimpl.h>
      2: #include <petscmat.h>

      4: #if defined(PETSC_HAVE_FORTRAN_CAPS)
      5:   #define matmffdsetfunction_ MATMFFDSETFUNCTION
      6:   #define matmffdsetbase_     MATMFFDSETBASE
      7: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
      8:   #define matmffdsetfunction_ matmffdsetfunction
      9:   #define matmffdsetbase_     matmffdsetbase
     10: #endif

     12: static PetscErrorCode ourmatmffdfunction(PetscCtx ctx, Vec x, Vec f)
     13: {
     14:   Mat mat = (Mat)ctx;
     15:   PetscCallFortranVoidFunction((*(void (*)(void *, Vec *, Vec *, PetscErrorCode *))(((PetscObject)mat)->fortran_func_pointers[0]))((void *)(PETSC_UINTPTR_T)((PetscObject)mat)->fortran_func_pointers[1], &x, &f, &ierr));
     16:   return PETSC_SUCCESS;
     17: }

     19: PETSC_EXTERN void matmffdsetfunction_(Mat *mat, void (*func)(void *, Vec *, Vec *, PetscErrorCode *), PetscCtx ctx, PetscErrorCode *ierr)
     20: {
     21:   PetscObjectAllocateFortranPointers(*mat, 2);
     22:   ((PetscObject)*mat)->fortran_func_pointers[0] = (PetscFortranCallbackFn *)func;
     23:   ((PetscObject)*mat)->fortran_func_pointers[1] = (PetscFortranCallbackFn *)(PETSC_UINTPTR_T)ctx;

     25:   *ierr = MatMFFDSetFunction(*mat, ourmatmffdfunction, *mat);
     26: }