#if !defined(PETSC_USE_FORTRAN_MODULES)
#include "petsc/finclude/ftn-custom/petscmatdef.h90"
#endif
#include "petsc/finclude/ftn-custom/petscishide.h90"
#include "petsc/finclude/ftn-custom/petscmathide.h90"

! rename MAT_INFO_SIZE and MAT_FACTORINFO_SIZE to enable reuse here
#define MAT_INFO_SIZE MAT_INFO_SIZE_MOD
#define MAT_FACTORINFO_SIZE MAT_FACTORINFO_SIZE_MOD

      Interface
        Subroutine MatGetRowIJF90(v,sh,sym,bl,n,ia,ja,d,ierr)
          USE_MAT_HIDE
          PetscInt, pointer :: ia(:), ja(:)
          PetscInt  n,sh
          PetscBool  sym,bl,d
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface

      Interface
        Subroutine MatRestoreRowIJF90(v,s,sy,b,n,ia,ja,d,ierr)
          USE_MAT_HIDE
          PetscInt, pointer :: ia(:), ja(:)
          PetscInt  n,s
          PetscBool  sy,b,d
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface

      Interface
        Subroutine MatDenseGetArrayF90(v,array,ierr)
          USE_MAT_HIDE
          PetscScalar, pointer :: array(:,:)
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface


      Interface
        Subroutine MatDenseRestoreArrayF90(v,array,ierr)
          USE_MAT_HIDE
          PetscScalar, pointer :: array(:,:)
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface

      Interface
        Subroutine MatSeqAIJGetArrayF90(v,array,ierr)
          USE_MAT_HIDE
          PetscScalar, pointer :: array(:)
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface


      Interface
        Subroutine MatSeqAIJRestoreArrayF90(v,array,ierr)
          USE_MAT_HIDE
          PetscScalar, pointer :: array(:)
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface

      Interface
        Subroutine MatGetGhostsF90(v,array,ierr)
          USE_MAT_HIDE
          PetscInt, pointer :: array(:)
          PetscErrorCode ierr
          MAT_HIDE     v
        End Subroutine
      End Interface

      Interface
         Subroutine MatGetInfo(v, flag, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  v
         MatInfoType flag
#include "petsc/finclude/petscmatinfosize.h"
         MatInfo info(MAT_INFO_SIZE)
         PetscErrorCode ierr
       End Subroutine
      End Interface

      Interface
         subroutine MatLUFactor(v, row, col, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  v
         IS_HIDE row
         IS_HIDE col
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatILUFactor(v, row, col, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  v
         IS_HIDE row
         IS_HIDE col
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatLUFactorSymbolic(fact, v, row, col, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  fact
         MAT_HIDE  v
         IS_HIDE row
         IS_HIDE col
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatLUFactorNumeric(fact, v, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  fact
         MAT_HIDE  v
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatCholeskyFactor(v, perm, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  v
         IS_HIDE perm
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatCholeskyFactorSymbolic(fact,v,perm,info,ierr)
         USE_MAT_HIDE
         MAT_HIDE  fact
         MAT_HIDE  v
         IS_HIDE perm
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatCholeskyFactorNumeric(fact, v, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  fact
         MAT_HIDE  v
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatILUFactorSymbolic(fact,v,row,col,info,ierr)
         USE_MAT_HIDE
         MAT_HIDE  fact
         MAT_HIDE  v
         IS_HIDE row
         IS_HIDE col
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatICCFactorSymbolic(fact, v, perm, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  fact
         MAT_HIDE  v
         IS_HIDE perm
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatICCFactor(v, row, info ,ierr)
         USE_MAT_HIDE
         MAT_HIDE  v
         IS_HIDE row
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

      Interface
         subroutine MatFactorInfoInitialize(info ,ierr)
#include "petsc/finclude/petscmatfactorinfosize.h"
         MatFactorInfo info(MAT_FACTORINFO_SIZE)
         PetscErrorCode ierr
         end subroutine
      End Interface

! revert MAT_INFO_SIZE and MAT_FACTORINFO_SIZE defines
#undef MAT_INFO_SIZE
#undef MAT_FACTORINFO_SIZE

