program TestMatNullSpace
#include <finclude/petscdef.h>
      use petsc
      implicit none
!
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!                   Variable declarations
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!
!  Variables:
!     x, y, w - vectors
!     z       - array of vectors
!
#if defined(PETSC_USE_FORTRAN_DATATYPES)
      type(DM)             da
      type(Vec)            X
      type(Mat)            M
      type(MatNullSpace)   nsp
#else
      DM                   da
      Vec                  X
      Mat                  M
      MatNullSpace         nsp
#endif
      PetscErrorCode       ierr
      PetscInt             n
      PetscInt             dof

      call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
      n = 10
      dof = 1
      call DMDACreate1d(PETSC_COMM_WORLD,DMDA_BOUNDARY_NONE,n,dof,1,PETSC_NULL_INTEGER,da,ierr)
      call DMCreateMatrix(da,MATAIJ,M,ierr)
      call MatNullSpaceCreate(PETSC_COMM_WORLD,PETSC_TRUE,0,PETSC_NULL_OBJECT,nsp,ierr)
      call MatNullSpaceView(nsp,PETSC_VIEWER_STDOUT_WORLD,ierr)
      
      call PetscFinalize(ierr)
      end program TestMatNullSpace
