Actual source code: zlinesearchf.c

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

      4: #if defined(PETSC_HAVE_FORTRAN_CAPS)
      5:   #define sneslinesearchsetprecheck_  SNESLINESEARCHSETPRECHECK
      6:   #define sneslinesearchgetprecheck_  SNESLINESEARCHGETPRECHECK
      7:   #define sneslinesearchsetpostcheck_ SNESLINESEARCHSETPOSTCHECK
      8:   #define sneslinesearchgetpostcheck_ SNESLINESEARCHGETPOSTCHECK
      9: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     10:   #define sneslinesearchsetprecheck_  sneslinesearchsetprecheck
     11:   #define sneslinesearchgetprecheck_  sneslinesearchgetprecheck
     12:   #define sneslinesearchsetpostcheck_ sneslinesearchsetpostcheck
     13:   #define sneslinesearchgetpostcheck_ sneslinesearchgetpostcheck
     14: #endif

     16: /* fortranpointers go: shell, precheck, postcheck */

     18: static PetscErrorCode oursneslinesearchprecheck(SNESLineSearch linesearch, Vec X, Vec Y, PetscBool *changed, void *ctx)
     19: {
     20:   PetscFunctionBegin;
     21:   PetscCallFortranVoidFunction((*(void (*)(SNESLineSearch *, Vec *, Vec *, PetscBool *, void *, PetscErrorCode *))(((PetscObject)linesearch)->fortran_func_pointers[1]))(&linesearch, &X, &Y, changed, ctx, &ierr));
     22:   PetscFunctionReturn(PETSC_SUCCESS);
     23: }

     25: static PetscErrorCode oursneslinesearchpostcheck(SNESLineSearch linesearch, Vec X, Vec Y, Vec W, PetscBool *changed_Y, PetscBool *changed_W, void *ctx)
     26: {
     27:   PetscFunctionBegin;
     28:   PetscCallFortranVoidFunction((*(void (*)(SNESLineSearch *, Vec *, Vec *, Vec *, PetscBool *, PetscBool *, void *, PetscErrorCode *))(((PetscObject)linesearch)->fortran_func_pointers[2]))(&linesearch, &X, &Y, &W, changed_Y, changed_W, ctx, &ierr));
     29:   PetscFunctionReturn(PETSC_SUCCESS);
     30: }

     32: PETSC_EXTERN void sneslinesearchsetprecheck_(SNESLineSearch *linesearch, void (*func)(SNESLineSearch *, Vec *, Vec *, PetscBool *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)
     33: {
     34:   PetscObjectAllocateFortranPointers(*linesearch, 3);
     35:   ((PetscObject)*linesearch)->fortran_func_pointers[1] = (PetscFortranCallbackFn *)func;

     37:   *ierr = SNESLineSearchSetPreCheck(*linesearch, oursneslinesearchprecheck, ctx);
     38: }

     40: PETSC_EXTERN void sneslinesearchsetpostcheck_(SNESLineSearch *linesearch, void (*func)(SNESLineSearch *, Vec *, Vec *, Vec *, PetscBool *, PetscBool *, PetscErrorCode *, void *), void *ctx, PetscErrorCode *ierr)
     41: {
     42:   PetscObjectAllocateFortranPointers(*linesearch, 3);
     43:   ((PetscObject)*linesearch)->fortran_func_pointers[2] = (PetscFortranCallbackFn *)func;

     45:   *ierr = SNESLineSearchSetPostCheck(*linesearch, oursneslinesearchpostcheck, ctx);
     46: }