Commits

Jed Brown committed 93cf248 Merge with conflicts

Merge branch 'barry/dmvecmattypes'

The MatType argument is removed from DMCreateMatrix(), you can use
DMSetMatType() to indicate the type you want used with a DM, defaults to
MATAIJ.

* barry/dmvecmattypes:
DMPlex ExodusII: fix dm->vectype pointer syntax
removed use of VecSetFromOptions() all over the placed, instead use MatGetVecs() or use dm->vectype to determine type added DMGetVecType() and DMGetMatTYpe()
removed MatType argument from DMCreateMatrix() and DMCreateColoring() since information is obtained from DM

Conflicts:
src/dm/impls/da/fdda.c
src/dm/impls/plex/plex.c

Comments (0)

Files changed (110)

bin/matlab/classes/matlabheader.h

 int DMDASetStencilWidth(DM, int);
 int DMDASetStencilType(DM, DMDAStencilType);
 int DMCreateGlobalVector(DM,Vec*);
-int DMCreateMatrix(DM,const char*,Mat*);
+int DMCreateMatrix(DM,Mat*);
 int DMDAGetInfo(DM,int*,int*,int*,int*,int*,int*,int*,int*,int*,DMDABoundaryType*,DMDAStencilType*);
 
 typedef PetscPointer PC;

include/petsc-private/dmimpl.h

   PetscErrorCode (*createfieldis)(DM,PetscInt*,char***,IS**);
   PetscErrorCode (*createcoordinatedm)(DM,DM*);
 
-  PetscErrorCode (*getcoloring)(DM,ISColoringType,MatType,ISColoring*);
-  PetscErrorCode (*creatematrix)(DM, MatType,Mat*);
+  PetscErrorCode (*getcoloring)(DM,ISColoringType,ISColoring*);
+  PetscErrorCode (*creatematrix)(DM, Mat*);
   PetscErrorCode (*createinterpolation)(DM,DM,Mat*,Vec*);
   PetscErrorCode (*getaggregates)(DM,DM,Mat*);
   PetscErrorCode (*getinjection)(DM,DM,VecScatter*);

include/petscdm.h

 PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*);
 PETSC_EXTERN PetscErrorCode DMCreateFieldIS(DM,PetscInt*,char***,IS**);
 PETSC_EXTERN PetscErrorCode DMGetBlockSize(DM,PetscInt*);
-PETSC_EXTERN PetscErrorCode DMCreateColoring(DM,ISColoringType,MatType,ISColoring*);
-PETSC_EXTERN PetscErrorCode DMCreateMatrix(DM,MatType,Mat*);
+PETSC_EXTERN PetscErrorCode DMCreateColoring(DM,ISColoringType,ISColoring*);
+PETSC_EXTERN PetscErrorCode DMCreateMatrix(DM,Mat*);
 PETSC_EXTERN PetscErrorCode DMSetMatrixPreallocateOnly(DM,PetscBool);
 PETSC_EXTERN PetscErrorCode DMCreateInterpolation(DM,DM,Mat*,Vec*);
 PETSC_EXTERN PetscErrorCode DMCreateInjection(DM,DM,VecScatter*);
 
 PETSC_EXTERN PetscErrorCode DMSetOptionsPrefix(DM,const char []);
 PETSC_EXTERN PetscErrorCode DMSetVecType(DM,VecType);
+PETSC_EXTERN PetscErrorCode DMGetVecType(DM,VecType*);
 PETSC_EXTERN PetscErrorCode DMSetMatType(DM,MatType);
+PETSC_EXTERN PetscErrorCode DMGetMatType(DM,MatType*);
 PETSC_EXTERN PetscErrorCode DMSetApplicationContext(DM,void*);
 PETSC_EXTERN PetscErrorCode DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**));
 PETSC_EXTERN PetscErrorCode DMGetApplicationContext(DM,void*);

include/petscdmda.h

 PETSC_EXTERN PetscErrorCode MatCreateDAAD(DM,Mat*);
 PETSC_EXTERN PetscErrorCode MatCreateSeqUSFFT(Vec,DM,Mat*);
 
-PETSC_EXTERN PetscErrorCode DMDASetGetMatrix(DM,PetscErrorCode (*)(DM, MatType,Mat *));
+PETSC_EXTERN PetscErrorCode DMDASetGetMatrix(DM,PetscErrorCode (*)(DM, Mat *));
 PETSC_EXTERN PetscErrorCode DMDASetBlockFills(DM,const PetscInt*,const PetscInt*);
 PETSC_EXTERN PetscErrorCode DMDASetRefinementFactor(DM,PetscInt,PetscInt,PetscInt);
 PETSC_EXTERN PetscErrorCode DMDAGetRefinementFactor(DM,PetscInt*,PetscInt*,PetscInt*);

include/petscdmshell.h

 PETSC_EXTERN PetscErrorCode DMShellSetLocalToGlobalVecScatter(DM,VecScatter);
 PETSC_EXTERN PetscErrorCode DMShellSetLocalToLocal(DM,PetscErrorCode (*)(DM,Vec,InsertMode,Vec),PetscErrorCode (*)(DM,Vec,InsertMode,Vec));
 PETSC_EXTERN PetscErrorCode DMShellSetLocalToLocalVecScatter(DM,VecScatter);
-PETSC_EXTERN PetscErrorCode DMShellSetCreateMatrix(DM,PetscErrorCode (*)(DM,MatType,Mat*));
+PETSC_EXTERN PetscErrorCode DMShellSetCreateMatrix(DM,PetscErrorCode (*)(DM,Mat*));
 PETSC_EXTERN PetscErrorCode DMGlobalToLocalBeginDefaultShell(DM,Vec,InsertMode,Vec);
 PETSC_EXTERN PetscErrorCode DMGlobalToLocalEndDefaultShell(DM,Vec,InsertMode,Vec);
 PETSC_EXTERN PetscErrorCode DMLocalToGlobalBeginDefaultShell(DM,Vec,InsertMode,Vec);

src/dm/examples/tests/ex22.c

   ierr = DMDACreate3d(PETSC_COMM_WORLD,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,stencil_type,M,N,P,m,n,p,w,s,
                       0,0,0,&da);CHKERRQ(ierr);
 
-  ierr = DMCreateMatrix(da,MATMPIBAIJ,&mat);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATMPIBAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&mat);CHKERRQ(ierr);
 
   idx[0].i = 1;   idx[0].j = 1; idx[0].k = 0;
   idx[1].i = 2;   idx[1].j = 1; idx[1].k = 0;

src/dm/examples/tests/ex26.c

   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
   ierr = DMDACreate2d(PETSC_COMM_WORLD,DMDA_BOUNDARY_PERIODIC, DMDA_BOUNDARY_NONE,DMDA_STENCIL_BOX,-5,-5,
                       PETSC_DECIDE,PETSC_DECIDE,1,2,0,0,&da);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATAIJ,&J);CHKERRQ(ierr);
-  ierr = DMCreateColoring(da,IS_COLORING_GHOSTED,MATAIJ,&iscoloring);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&J);CHKERRQ(ierr);
+  ierr = DMCreateColoring(da,IS_COLORING_GHOSTED,&iscoloring);CHKERRQ(ierr);
   ierr = MatFDColoringCreate(J,iscoloring,&matfdcoloring);CHKERRQ(ierr);
   ierr = ISColoringDestroy(&iscoloring);CHKERRQ(ierr);
 

src/dm/examples/tests/ex30.c

   ierr = DMSlicedCreate(comm,bs,n,2,ghosts,d_nnz,o_nnz,&slice);CHKERRQ(ierr); /* Currently does not copy X_nnz so we can't free them until after DMSlicedGetMatrix */
 
   if (!useblock) {ierr = DMSlicedSetBlockFills(slice,dfill,ofill);CHKERRQ(ierr);} /* Irrelevant for baij formats */
-  ierr = DMCreateMatrix(slice,mat_type,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(slice,mat_type);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(slice,&A);CHKERRQ(ierr);
   ierr = PetscFree2(d_nnz,o_nnz);CHKERRQ(ierr);
   ierr = MatSetOption(A,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_TRUE);CHKERRQ(ierr);
 

src/dm/examples/tests/ex35.c

   /* Create distributed array and get vectors */
   ierr = DMDACreate3d(PETSC_COMM_WORLD,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,
                       X,Y,Z,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,NULL,&da);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATMPIAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATMPIAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr);
   ierr = MatShift(A,X);CHKERRQ(ierr);
   ierr = MatView(A,viewer);CHKERRQ(ierr);
   ierr = MatDestroy(&A);CHKERRQ(ierr);
   ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
 
   ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,"temp.dat",FILE_MODE_READ,&viewer);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATMPIAIJ,&A);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr);
   ierr = MatLoad(A,viewer);CHKERRQ(ierr);
 
   /* Free memory */

src/dm/examples/tests/ex9.c

   ierr = PetscFree(ly);CHKERRQ(ierr);
   ierr = PetscFree(lz);CHKERRQ(ierr);
 
-  ierr = DMCreateColoring(da,IS_COLORING_GLOBAL,MATMPIAIJ,&coloring);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATMPIAIJ,&mat);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATMPIAIJ);CHKERRQ(ierr);
+  ierr = DMCreateColoring(da,IS_COLORING_GLOBAL,&coloring);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATMPIAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&mat);CHKERRQ(ierr);
   ierr = MatFDColoringCreate(mat,coloring,&fdcoloring);CHKERRQ(ierr);
 
   ierr = DMCreateGlobalVector(da,&dvec);CHKERRQ(ierr);

src/dm/examples/tutorials/ex14.c

       if (i == rank) {
         Mat m;
         ierr = PetscPrintf(PETSC_COMM_SELF,"Processor %d: \n",i);CHKERRQ(ierr);
-        ierr = DMCreateMatrix(subda[0],"mpiaij",&m);CHKERRQ(ierr);
+        ierr = DMSetMatType(subda[0],MATAIJ);CHKERRQ(ierr);
+        ierr = DMCreateMatrix(subda[0],&m);CHKERRQ(ierr);
         ierr = MatView(m,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
         ierr = MatDestroy(&m);CHKERRQ(ierr);
       }

src/dm/impls/adda/adda.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateColoring_ADDA"
-PetscErrorCode  DMCreateColoring_ADDA(DM dm, ISColoringType ctype,MatType mtype,ISColoring *coloring)
+PetscErrorCode  DMCreateColoring_ADDA(DM dm, ISColoringType ctype,ISColoring *coloring)
 {
   PetscFunctionBegin;
   SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP, "Not implemented yet");
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_ADDA"
-PetscErrorCode  DMCreateMatrix_ADDA(DM dm, MatType mtype, Mat *mat)
+PetscErrorCode  DMCreateMatrix_ADDA(DM dm, Mat *mat)
 {
   PetscErrorCode ierr;
   DM_ADDA        *dd = (DM_ADDA*)dm->data;
   PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
   ierr = MatCreate(PetscObjectComm((PetscObject)dm), mat);CHKERRQ(ierr);
   ierr = MatSetSizes(*mat, dd->lsize, dd->lsize, PETSC_DECIDE, PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = MatSetType(*mat, mtype);CHKERRQ(ierr);
+  ierr = MatSetType(*mat, dm->mattype);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 

src/dm/impls/composite/pack.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateColoring_Composite"
-PetscErrorCode  DMCreateColoring_Composite(DM dm,ISColoringType ctype,MatType mtype,ISColoring *coloring)
+PetscErrorCode  DMCreateColoring_Composite(DM dm,ISColoringType ctype,ISColoring *coloring)
 {
   PetscErrorCode  ierr;
   PetscInt        n,i,cnt;
     while (next) {
       ISColoring lcoloring;
 
-      ierr = DMCreateColoring(next->dm,IS_COLORING_GLOBAL,mtype,&lcoloring);CHKERRQ(ierr);
+      ierr = DMCreateColoring(next->dm,IS_COLORING_GLOBAL,&lcoloring);CHKERRQ(ierr);
       for (i=0; i<lcoloring->N; i++) {
         colors[cnt++] = maxcol + lcoloring->colors[i];
       }

src/dm/impls/composite/packimpl.h

   PetscErrorCode (*FormCoupleLocations)(DM,Mat,PetscInt*,PetscInt*,PetscInt,PetscInt,PetscInt,PetscInt);
 } DM_Composite;
 
-PETSC_INTERN PetscErrorCode DMCreateMatrix_Composite(DM,MatType,Mat*);
+PETSC_INTERN PetscErrorCode DMCreateMatrix_Composite(DM,Mat*);
 
 #endif

src/dm/impls/composite/packm.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Composite_Nest"
-static PetscErrorCode DMCreateMatrix_Composite_Nest(DM dm,MatType mtype,Mat *J)
+static PetscErrorCode DMCreateMatrix_Composite_Nest(DM dm,Mat *J)
 {
   const DM_Composite           *com = (DM_Composite*)dm->data;
   const struct DMCompositeLink *rlink,*clink;
     for (j=0,clink=com->next; clink; j++,clink=clink->next) {
       Mat sub = NULL;
       if (i == j) {
-        ierr = DMCreateMatrix(rlink->dm,NULL,&sub);CHKERRQ(ierr);
+        ierr = DMCreateMatrix(rlink->dm,&sub);CHKERRQ(ierr);
       } else if (com->FormCoupleLocations) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Cannot manage off-diagonal parts yet");
       submats[i*n+j] = sub;
     }
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Composite_AIJ"
-static PetscErrorCode DMCreateMatrix_Composite_AIJ(DM dm,MatType mtype,Mat *J)
+static PetscErrorCode DMCreateMatrix_Composite_AIJ(DM dm,Mat *J)
 {
   PetscErrorCode         ierr;
   DM_Composite           *com = (DM_Composite*)dm->data;
 
   ierr = MatCreate(PetscObjectComm((PetscObject)dm),J);CHKERRQ(ierr);
   ierr = MatSetSizes(*J,m,m,PETSC_DETERMINE,PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = MatSetType(*J,mtype);CHKERRQ(ierr);
+  ierr = MatSetType(*J,dm->mattype);CHKERRQ(ierr);
 
   /*
      Extremely inefficient but will compute entire Jacobian for testing
     const PetscInt *cols,*rstarts;
     PetscMPIInt    proc;
 
-    ierr = DMCreateMatrix(next->dm,mtype,&Atmp);CHKERRQ(ierr);
+    ierr = DMCreateMatrix(next->dm,&Atmp);CHKERRQ(ierr);
     ierr = MatGetOwnershipRange(Atmp,&rstart,NULL);CHKERRQ(ierr);
     ierr = MatGetOwnershipRanges(Atmp,&rstarts);CHKERRQ(ierr);
     ierr = MatGetLocalSize(Atmp,&mA,NULL);CHKERRQ(ierr);
     const PetscScalar *values;
     PetscMPIInt       proc;
 
-    ierr  = DMCreateMatrix(next->dm,mtype,&Atmp);CHKERRQ(ierr);
+    ierr  = DMCreateMatrix(next->dm,&Atmp);CHKERRQ(ierr);
     ierr  = MatGetOwnershipRange(Atmp,&rstart,NULL);CHKERRQ(ierr);
     ierr  = MatGetOwnershipRanges(Atmp,&rstarts);CHKERRQ(ierr);
     ierr  = MatGetLocalSize(Atmp,&mA,NULL);CHKERRQ(ierr);
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Composite"
-PetscErrorCode DMCreateMatrix_Composite(DM dm,MatType mtype,Mat *J)
+PetscErrorCode DMCreateMatrix_Composite(DM dm,Mat *J)
 {
   PetscErrorCode         ierr;
   PetscBool              usenest;
 
   PetscFunctionBegin;
   ierr = DMSetUp(dm);CHKERRQ(ierr);
-  ierr = PetscStrcmp(mtype,MATNEST,&usenest);CHKERRQ(ierr);
+  ierr = PetscStrcmp(dm->mattype,MATNEST,&usenest);CHKERRQ(ierr);
   if (usenest) {
-    ierr = DMCreateMatrix_Composite_Nest(dm,mtype,J);CHKERRQ(ierr);
+    ierr = DMCreateMatrix_Composite_Nest(dm,J);CHKERRQ(ierr);
   } else {
-    ierr = DMCreateMatrix_Composite_AIJ(dm,mtype ? mtype : MATAIJ,J);CHKERRQ(ierr);
+    ierr = DMCreateMatrix_Composite_AIJ(dm,J);CHKERRQ(ierr);
   }
 
   ierr = DMGetLocalToGlobalMapping(dm,&ltogmap);CHKERRQ(ierr);

src/dm/impls/da/da.c

 
 .seealso: DMCreateMatrix(), DMDASetBlockFills()
 @*/
-PetscErrorCode  DMDASetGetMatrix(DM da,PetscErrorCode (*f)(DM, MatType,Mat*))
+PetscErrorCode  DMDASetGetMatrix(DM da,PetscErrorCode (*f)(DM, Mat*))
 {
   PetscFunctionBegin;
   PetscValidHeaderSpecific(da,DM_CLASSID,1);
   dd2->coarsen_z = dd2->refine_z = dd->refine_z;
 
   /* copy vector type information */
-  ierr = PetscFree(da2->vectype);CHKERRQ(ierr);
-  ierr = PetscStrallocpy(da->vectype,(char**)&da2->vectype);CHKERRQ(ierr);
+  ierr = DMSetVecType(da2,da->vectype);CHKERRQ(ierr);
 
   dd2->lf = dd->lf;
   dd2->lj = dd->lj;
   dd2->coarsen_z = dd2->refine_z = dd->coarsen_z;
 
   /* copy vector type information */
-  ierr = PetscFree(da2->vectype);CHKERRQ(ierr);
-  ierr = PetscStrallocpy(da->vectype,(char**)&da2->vectype);CHKERRQ(ierr);
+  ierr = DMSetVecType(da2,da->vectype);CHKERRQ(ierr);
 
   dd2->lf = dd->lf;
   dd2->lj = dd->lj;

src/dm/impls/da/dacreate.c

 extern PetscErrorCode  DMLocalToLocalBegin_DA(DM,Vec,InsertMode,Vec);
 extern PetscErrorCode  DMLocalToLocalEnd_DA(DM,Vec,InsertMode,Vec);
 extern PetscErrorCode  DMCreateInterpolation_DA(DM,DM,Mat*,Vec*);
-extern PetscErrorCode  DMCreateColoring_DA(DM,ISColoringType,MatType,ISColoring*);
-extern PetscErrorCode  DMCreateMatrix_DA(DM,MatType,Mat*);
+extern PetscErrorCode  DMCreateColoring_DA(DM,ISColoringType,ISColoring*);
+extern PetscErrorCode  DMCreateMatrix_DA(DM,Mat*);
 extern PetscErrorCode  DMCreateCoordinateDM_DA(DM,DM*);
 extern PetscErrorCode  DMRefine_DA(DM,MPI_Comm,DM*);
 extern PetscErrorCode  DMCoarsen_DA(DM,MPI_Comm,DM*);
 
   dd->elementtype = DMDA_ELEMENT_Q1;
 
-  ierr = PetscStrallocpy(VECSTANDARD,(char**)&da->vectype);CHKERRQ(ierr);
-
   da->ops->globaltolocalbegin          = DMGlobalToLocalBegin_DA;
   da->ops->globaltolocalend            = DMGlobalToLocalEnd_DA;
   da->ops->localtoglobalbegin          = DMLocalToGlobalBegin_DA;

src/dm/impls/da/dadist.c

     ierr = VecSetSizes(*g,dd->Nlocal,PETSC_DETERMINE);CHKERRQ(ierr);
     ierr = VecSetBlockSize(*g,dd->w);CHKERRQ(ierr);
     ierr = VecSetType(*g,da->vectype);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(*g);CHKERRQ(ierr);
     ierr = VecSetDM(*g, da);CHKERRQ(ierr);
     ierr = VecSetLocalToGlobalMapping(*g,da->ltogmap);CHKERRQ(ierr);
     ierr = VecSetLocalToGlobalMappingBlock(*g,da->ltogmapb);CHKERRQ(ierr);

src/dm/impls/da/fdda.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateColoring_DA"
-PetscErrorCode  DMCreateColoring_DA(DM da,ISColoringType ctype,MatType mtype,ISColoring *coloring)
+PetscErrorCode  DMCreateColoring_DA(DM da,ISColoringType ctype,ISColoring *coloring)
 {
   PetscErrorCode   ierr;
   PetscInt         dim,m,n,p,nc;
 
   /* Tell the DMDA it has 1 degree of freedom per grid point so that the coloring for BAIJ
      matrices is for the blocks, not the individual matrix elements  */
-  ierr = PetscStrcmp(mtype,MATBAIJ,&isBAIJ);CHKERRQ(ierr);
-  if (!isBAIJ) {ierr = PetscStrcmp(mtype,MATMPIBAIJ,&isBAIJ);CHKERRQ(ierr);}
-  if (!isBAIJ) {ierr = PetscStrcmp(mtype,MATSEQBAIJ,&isBAIJ);CHKERRQ(ierr);}
+  ierr = PetscStrcmp(da->mattype,MATBAIJ,&isBAIJ);CHKERRQ(ierr);
+  if (!isBAIJ) {ierr = PetscStrcmp(da->mattype,MATMPIBAIJ,&isBAIJ);CHKERRQ(ierr);}
+  if (!isBAIJ) {ierr = PetscStrcmp(da->mattype,MATSEQBAIJ,&isBAIJ);CHKERRQ(ierr);}
   if (isBAIJ) {
     dd->w  = 1;
     dd->xs = dd->xs/nc;
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_DA"
-PetscErrorCode DMCreateMatrix_DA(DM da, MatType mtype,Mat *J)
+PetscErrorCode DMCreateMatrix_DA(DM da, Mat *J)
 {
   PetscErrorCode ierr;
   PetscInt       dim,dof,nx,ny,nz,dims[3],starts[3],M,N,P;
   MatType        Atype;
   PetscSection   section, sectionGlobal;
   void           (*aij)(void)=NULL,(*baij)(void)=NULL,(*sbaij)(void)=NULL;
-  MatType        ttype[256];
-  PetscBool      flg;
+  MatType        mtype;
   PetscMPIInt    size;
   DM_DA          *dd = (DM_DA*)da->data;
 
   PetscFunctionBegin;
   ierr = MatInitializePackage();CHKERRQ(ierr);
-  if (!mtype) mtype = MATAIJ;
-  ierr = PetscStrcpy((char*)ttype,mtype);CHKERRQ(ierr);
-  ierr = PetscOptionsBegin(PetscObjectComm((PetscObject)da),((PetscObject)da)->prefix,"DMDA options","Mat");CHKERRQ(ierr);
-  ierr = PetscOptionsList("-dm_mat_type","Matrix type","MatSetType",MatList,mtype,(char*)ttype,256,&flg);CHKERRQ(ierr);
-  ierr = PetscOptionsEnd();
+  mtype = da->mattype;
 
   ierr = DMGetDefaultSection(da, &section);CHKERRQ(ierr);
   if (section) {
   ierr = PetscObjectGetComm((PetscObject)da,&comm);CHKERRQ(ierr);
   ierr = MatCreate(comm,&A);CHKERRQ(ierr);
   ierr = MatSetSizes(A,dof*nx*ny*nz,dof*nx*ny*nz,dof*M*N*P,dof*M*N*P);CHKERRQ(ierr);
-  ierr = MatSetType(A,(MatType)ttype);CHKERRQ(ierr);
+  ierr = MatSetType(A,mtype);CHKERRQ(ierr);
   ierr = MatSetDM(A,da);CHKERRQ(ierr);
   ierr = MatSetFromOptions(A);CHKERRQ(ierr);
   ierr = MatGetType(A,&Atype);CHKERRQ(ierr);

src/dm/impls/patch/patchcreate.c

 #define __FUNCT__ "DMInitialize_Patch"
 PetscErrorCode DMInitialize_Patch(DM dm)
 {
-  PetscErrorCode ierr;
-
   PetscFunctionBegin;
-  ierr = PetscStrallocpy(VECSTANDARD,(char**) &dm->vectype);CHKERRQ(ierr);
-
   dm->ops->view                            = DMView_Patch;
   dm->ops->setfromoptions                  = DMSetFromOptions_Patch;
   dm->ops->setup                           = DMSetUp_Patch;

src/dm/impls/plex/plex.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Plex"
-PetscErrorCode DMCreateMatrix_Plex(DM dm, MatType mtype, Mat *J)
+PetscErrorCode DMCreateMatrix_Plex(DM dm, Mat *J)
 {
   PetscSection   section, sectionGlobal;
   PetscInt       bs = -1;
   PetscInt       localSize;
   PetscBool      isShell, isBlock, isSeqBlock, isMPIBlock, isSymBlock, isSymSeqBlock, isSymMPIBlock;
   PetscErrorCode ierr;
+  MatType        mtype;
 
   PetscFunctionBegin;
   ierr = MatInitializePackage();CHKERRQ(ierr);
-  if (!mtype) mtype = MATAIJ;
+  mtype = dm->mattype;
   ierr = DMGetDefaultSection(dm, &section);CHKERRQ(ierr);
   ierr = DMGetDefaultGlobalSection(dm, &sectionGlobal);CHKERRQ(ierr);
   /* ierr = PetscSectionGetStorageSize(sectionGlobal, &localSize);CHKERRQ(ierr); */
 
   ierr = PetscSectionGetStorageSize(newSection, &fieldSize);CHKERRQ(ierr);
   ierr = VecSetSizes(newVec, fieldSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(newVec);CHKERRQ(ierr);
+  ierr = VecSetType(newVec,dm->vectype);CHKERRQ(ierr);
 
   ierr = VecGetArray(originalVec, &originalValues);CHKERRQ(ierr);
   ierr = VecGetArray(newVec, &newValues);CHKERRQ(ierr);
     ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinatesNew);CHKERRQ(ierr);
     ierr = PetscObjectSetName((PetscObject) coordinatesNew, "coordinates");CHKERRQ(ierr);
     ierr = VecSetSizes(coordinatesNew, coordSizeNew, PETSC_DETERMINE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(coordinatesNew);CHKERRQ(ierr);
+    ierr = VecSetType(coordinatesNew,dm->vectype);CHKERRQ(ierr);
     ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
     ierr = VecGetArray(coordinatesNew, &coordsNew);CHKERRQ(ierr);
     /* Old vertices have the same coordinates */

src/dm/impls/plex/plexcgns.c

   ierr = VecCreate(comm, &coordinates);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+  ierr = VecSetType(coordinates,(*dm)->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   if (!rank) {
     PetscInt off = 0;

src/dm/impls/plex/plexcreate.c

   ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr);
   ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr);
   ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+  ierr = VecSetType(coordinates,dm->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   for (vy = 0; vy <= edges[1]; ++vy) {
     for (vx = 0; vx <= edges[0]; ++vx) {
   ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+  ierr = VecSetType(coordinates,dm->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   for (vz = 0; vz <= faces[2]; ++vz) {
     for (vy = 0; vy <= faces[1]; ++vy) {
     ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr);
     ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr);
     ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+    ierr = VecSetType(coordinates,dm->vectype);CHKERRQ(ierr);
     ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
     for (vy = 0; vy < numYVertices; ++vy) {
       for (vx = 0; vx < numXVertices; ++vx) {
 
 /* External function declarations here */
 extern PetscErrorCode DMCreateInterpolation_Plex(DM dmCoarse, DM dmFine, Mat *interpolation, Vec *scaling);
-extern PetscErrorCode DMCreateMatrix_Plex(DM dm, MatType mtype, Mat *J);
+extern PetscErrorCode DMCreateMatrix_Plex(DM dm,  Mat *J);
 extern PetscErrorCode DMCreateCoordinateDM_Plex(DM dm, DM *cdm);
 extern PetscErrorCode DMRefine_Plex(DM dm, MPI_Comm comm, DM *dmRefined);
 extern PetscErrorCode DMClone_Plex(DM dm, DM *newdm);
 #define __FUNCT__ "DMInitialize_Plex"
 PetscErrorCode DMInitialize_Plex(DM dm)
 {
-  PetscErrorCode ierr;
-
   PetscFunctionBegin;
-  ierr = PetscStrallocpy(VECSTANDARD, (char**)&dm->vectype);CHKERRQ(ierr);
-
   dm->ops->view                            = DMView_Plex;
   dm->ops->setfromoptions                  = DMSetFromOptions_Plex;
   dm->ops->clone                           = DMClone_Plex;
   ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+  ierr = VecSetType(coordinates,dm->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   for (v = 0; v < numVertices; ++v) {
     for (d = 0; d < spaceDim; ++d) {
   ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+  ierr = VecSetType(coordinates,dm->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   for (v = 0; v < numPoints[0]; ++v) {
     PetscInt off;

src/dm/impls/plex/plexexodusii.c

   ierr = VecCreate(comm, &coordinates);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);
+  ierr = VecSetType(coordinates,(*dm)->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   if (!rank) {
     float *x, *y, *z;

src/dm/impls/plex/plexinterpolate.c

   ierr = VecCreate(PetscObjectComm((PetscObject) dmB), &coordinatesB);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinatesB, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinatesB, coordSizeB, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(coordinatesB);CHKERRQ(ierr);
+  ierr = VecSetType(coordinatesB,dmB->vectype);CHKERRQ(ierr);
   ierr = VecGetArray(coordinatesA, &coordsA);CHKERRQ(ierr);
   ierr = VecGetArray(coordinatesB, &coordsB);CHKERRQ(ierr);
   for (v = 0; v < vEndB-vStartB; ++v) {

src/dm/impls/plex/plexsubmesh.c

   ierr = VecCreate(PetscObjectComm((PetscObject)dm), &newCoordinates);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) newCoordinates, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(newCoordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(newCoordinates);CHKERRQ(ierr);
+  ierr = VecSetType(newCoordinates,dm->vectype);CHKERRQ(ierr);
   ierr = DMSetCoordinatesLocal(dmNew, newCoordinates);CHKERRQ(ierr);
   ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
     ierr = PetscSectionGetStorageSize(subCoordSection, &coordSize);CHKERRQ(ierr);
     ierr = VecCreate(comm, &subCoordinates);CHKERRQ(ierr);
     ierr = VecSetSizes(subCoordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(subCoordinates);CHKERRQ(ierr);
+    ierr = VecSetType(subCoordinates,dm->vectype);CHKERRQ(ierr);
     if (coordSize) {
       ierr = VecGetArray(coordinates,    &coords);CHKERRQ(ierr);
       ierr = VecGetArray(subCoordinates, &subCoords);CHKERRQ(ierr);
     ierr = PetscSectionGetStorageSize(subCoordSection, &coordSize);CHKERRQ(ierr);
     ierr = VecCreate(comm, &subCoordinates);CHKERRQ(ierr);
     ierr = VecSetSizes(subCoordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(subCoordinates);CHKERRQ(ierr);
+    ierr = VecSetType(subCoordinates,dm->vectype);CHKERRQ(ierr);
     ierr = VecGetArray(coordinates,    &coords);CHKERRQ(ierr);
     ierr = VecGetArray(subCoordinates, &subCoords);CHKERRQ(ierr);
     for (v = 0; v < numSubPoints[0]; ++v) {
     ierr = PetscSectionGetStorageSize(subCoordSection, &coordSize);CHKERRQ(ierr);
     ierr = VecCreate(comm, &subCoordinates);CHKERRQ(ierr);
     ierr = VecSetSizes(subCoordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(subCoordinates);CHKERRQ(ierr);
+    ierr = VecSetType(subCoordinates,dm->vectype);CHKERRQ(ierr);
     ierr = VecGetArray(coordinates,    &coords);CHKERRQ(ierr);
     ierr = VecGetArray(subCoordinates, &subCoords);CHKERRQ(ierr);
     for (v = 0; v < numSubVertices; ++v) {
     ierr = PetscSectionGetStorageSize(subCoordSection, &coordSize);CHKERRQ(ierr);
     ierr = VecCreate(comm, &subCoordinates);CHKERRQ(ierr);
     ierr = VecSetSizes(subCoordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(subCoordinates);CHKERRQ(ierr);
+    ierr = VecSetType(subCoordinates,dm->vectype);CHKERRQ(ierr);
     ierr = VecGetArray(coordinates,    &coords);CHKERRQ(ierr);
     ierr = VecGetArray(subCoordinates, &subCoords);CHKERRQ(ierr);
     for (v = 0; v < numSubPoints[0]; ++v) {

src/dm/impls/redundant/dmredundant.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Redundant"
-static PetscErrorCode DMCreateMatrix_Redundant(DM dm,MatType mtype,Mat *J)
+static PetscErrorCode DMCreateMatrix_Redundant(DM dm,Mat *J)
 {
   DM_Redundant           *red = (DM_Redundant*)dm->data;
   PetscErrorCode         ierr;
   PetscFunctionBegin;
   ierr = MatCreate(PetscObjectComm((PetscObject)dm),J);CHKERRQ(ierr);
   ierr = MatSetSizes(*J,red->n,red->n,red->N,red->N);CHKERRQ(ierr);
-  ierr = MatSetType(*J,mtype);CHKERRQ(ierr);
+  ierr = MatSetType(*J,dm->mattype);CHKERRQ(ierr);
   ierr = MatSeqAIJSetPreallocation(*J,red->n,NULL);CHKERRQ(ierr);
   ierr = MatSeqBAIJSetPreallocation(*J,1,red->n,NULL);CHKERRQ(ierr);
   ierr = MatMPIAIJSetPreallocation(*J,red->n,NULL,red->N-red->n,NULL);CHKERRQ(ierr);
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateColoring_Redundant"
-static PetscErrorCode DMCreateColoring_Redundant(DM dm,ISColoringType ctype,MatType mtype,ISColoring *coloring)
+static PetscErrorCode DMCreateColoring_Redundant(DM dm,ISColoringType ctype,ISColoring *coloring)
 {
   DM_Redundant    *red = (DM_Redundant*)dm->data;
   PetscErrorCode  ierr;
   dm->ops->createinterpolation= DMCreateInterpolation_Redundant;
   dm->ops->getcoloring        = DMCreateColoring_Redundant;
 
-  ierr = PetscStrallocpy(VECSTANDARD,(char**)&dm->vectype);CHKERRQ(ierr);
   ierr = PetscObjectComposeFunction((PetscObject)dm,"DMRedundantSetSize_C",DMRedundantSetSize_Redundant);CHKERRQ(ierr);
   ierr = PetscObjectComposeFunction((PetscObject)dm,"DMRedundantGetSize_C",DMRedundantGetSize_Redundant);CHKERRQ(ierr);
   PetscFunctionReturn(0);

src/dm/impls/shell/dmshell.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Shell"
-static PetscErrorCode DMCreateMatrix_Shell(DM dm,MatType mtype,Mat *J)
+static PetscErrorCode DMCreateMatrix_Shell(DM dm,Mat *J)
 {
   PetscErrorCode ierr;
   DM_Shell       *shell = (DM_Shell*)dm->data;
       ierr = VecGetLocalSize(shell->Xglobal,&m);CHKERRQ(ierr);
       ierr = MatCreate(PetscObjectComm((PetscObject)dm),&shell->A);CHKERRQ(ierr);
       ierr = MatSetSizes(shell->A,m,m,M,M);CHKERRQ(ierr);
-      if (mtype) {ierr = MatSetType(shell->A,mtype);CHKERRQ(ierr);}
+      ierr = MatSetType(shell->A,dm->mattype);CHKERRQ(ierr);
       ierr = MatSetUp(shell->A);CHKERRQ(ierr);
     } else SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_USER,"Must call DMShellSetMatrix(), DMShellSetCreateMatrix(), or provide a vector");
   }
   A = shell->A;
   /* the check below is tacky and incomplete */
-  if (mtype) {
+  if (dm->mattype) {
     PetscBool flg,aij,seqaij,mpiaij;
-    ierr = PetscObjectTypeCompare((PetscObject)A,mtype,&flg);CHKERRQ(ierr);
+    ierr = PetscObjectTypeCompare((PetscObject)A,dm->mattype,&flg);CHKERRQ(ierr);
     ierr = PetscObjectTypeCompare((PetscObject)A,MATSEQAIJ,&seqaij);CHKERRQ(ierr);
     ierr = PetscObjectTypeCompare((PetscObject)A,MATMPIAIJ,&mpiaij);CHKERRQ(ierr);
-    ierr = PetscStrcmp(mtype,MATAIJ,&aij);CHKERRQ(ierr);
+    ierr = PetscStrcmp(dm->mattype,MATAIJ,&aij);CHKERRQ(ierr);
     if (!flg) {
-      if (!(aij && (seqaij || mpiaij))) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_NOTSAMETYPE,"Requested matrix of type %s, but only %s available",mtype,((PetscObject)A)->type_name);
+      if (!(aij && (seqaij || mpiaij))) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_NOTSAMETYPE,"Requested matrix of type %s, but only %s available",dm->mattype,((PetscObject)A)->type_name);
     }
   }
   if (((PetscObject)A)->refct < 2) { /* We have an exclusive reference so we can give it out */
 
 .seealso: DMCreateMatrix(), DMShellSetMatrix()
 @*/
-PetscErrorCode DMShellSetCreateMatrix(DM dm,PetscErrorCode (*func)(DM,MatType,Mat*))
+PetscErrorCode DMShellSetCreateMatrix(DM dm,PetscErrorCode (*func)(DM,Mat*))
 {
 
   PetscFunctionBegin;

src/dm/impls/shell/ftn-custom/zdmshellf.c

 
 #undef __FUNCT__
 #define __FUNCT__ "ourcreatematrix"
-static PetscErrorCode ourcreatematrix(DM dm,MatType type,Mat *A)
+static PetscErrorCode ourcreatematrix(DM dm,Mat *A)
 {
-  int  len;
-  char *ftype = (char*)type;
-  if (type) {
-    size_t slen;
-    PetscStrlen(type,&slen);
-    len = (int)slen;
-  } else {
-    type = PETSC_NULL_CHARACTER_Fortran;
-    len  = 0;
-  }
-  PetscObjectUseFortranCallbackSubType(dm,_cb.creatematrix,(DM*,CHAR PETSC_MIXED_LEN_PROTO,Mat*,PetscErrorCode* PETSC_END_LEN_PROTO),
-                                       (&dm,ftype PETSC_MIXED_LEN_CALL(len),A,&ierr PETSC_END_LEN_CALL(len)));
+  PetscObjectUseFortranCallbackSubType(dm,_cb.creatematrix,(DM*,Mat*,PetscErrorCode*),
+                                       (&dm,A,&ierr));
   return 0;
 }
 
 }
 
 
-PETSC_EXTERN void PETSC_STDCALL dmshellsetcreatematrix_(DM *dm,void (PETSC_STDCALL *func)(DM*,CHAR type PETSC_MIXED_LEN(len),Mat*,PetscErrorCode* PETSC_END_LEN(len)),PetscErrorCode *ierr)
+PETSC_EXTERN void PETSC_STDCALL dmshellsetcreatematrix_(DM *dm,void (PETSC_STDCALL *func)(DM*,Mat*,PetscErrorCode* PETSC_END_LEN(len)),PetscErrorCode *ierr)
 {
   *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.creatematrix,(PetscVoidFunction)func,NULL);
   if (*ierr) return;

src/dm/impls/sliced/sliced.c

 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix_Sliced"
-PetscErrorCode  DMCreateMatrix_Sliced(DM dm, MatType mtype,Mat *J)
+PetscErrorCode  DMCreateMatrix_Sliced(DM dm, Mat *J)
 {
   PetscErrorCode         ierr;
   PetscInt               *globals,*sd_nnz,*so_nnz,rstart,bs,i;
   ierr = MatCreate(PetscObjectComm((PetscObject)dm),J);CHKERRQ(ierr);
   ierr = MatSetSizes(*J,slice->n*bs,slice->n*bs,PETSC_DETERMINE,PETSC_DETERMINE);CHKERRQ(ierr);
   ierr = MatSetBlockSize(*J,bs);CHKERRQ(ierr);
-  ierr = MatSetType(*J,mtype);CHKERRQ(ierr);
+  ierr = MatSetType(*J,dm->mattype);CHKERRQ(ierr);
   ierr = MatSeqBAIJSetPreallocation(*J,bs,slice->d_nz,slice->d_nnz);CHKERRQ(ierr);
   ierr = MatMPIBAIJSetPreallocation(*J,bs,slice->d_nz,slice->d_nnz,slice->o_nz,slice->o_nnz);CHKERRQ(ierr);
   /* In general, we have to do extra work to preallocate for scalar (AIJ) matrices so we check whether it will do any

src/dm/interface/dm.c

   }
   v->numFields = 0;
   v->fields    = NULL;
-
+  ierr = DMSetVecType(v,VECSTANDARD);CHKERRQ(ierr);
+  ierr = DMSetMatType(v,MATAIJ);CHKERRQ(ierr);
   *dm = v;
   PetscFunctionReturn(0);
 }
 
    Level: intermediate
 
-.seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DMDA, DMDAInterpolationType, VecType
+.seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DMDA, DMDAInterpolationType, VecType, DMGetVecType()
 @*/
 PetscErrorCode  DMSetVecType(DM da,VecType ctype)
 {
 }
 
 #undef __FUNCT__
+#define __FUNCT__ "DMGetVecType"
+/*@C
+       DMGetVecType - Gets the type of vector created with DMCreateLocalVector() and DMCreateGlobalVector()
+
+   Logically Collective on DMDA
+
+   Input Parameter:
+.  da - initial distributed array
+
+   Output Parameter:
+.  ctype - the vector type
+
+   Level: intermediate
+
+.seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DMDA, DMDAInterpolationType, VecType
+@*/
+PetscErrorCode  DMGetVecType(DM da,VecType *ctype)
+{
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(da,DM_CLASSID,1);
+  *ctype = da->vectype;
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "VecGetDM"
 /*@
   VecGetDM - Gets the DM defining the data layout of the vector
 
    Level: intermediate
 
-.seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMCreateMatrix(), DMSetMatrixPreallocateOnly(), MatType
+.seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMCreateMatrix(), DMSetMatrixPreallocateOnly(), MatType, DMGetMatType()
 @*/
 PetscErrorCode  DMSetMatType(DM dm,MatType ctype)
 {
 }
 
 #undef __FUNCT__
+#define __FUNCT__ "DMGetMatType"
+/*@C
+       DMGetMatType - Gets the type of matrix created with DMCreateMatrix()
+
+   Logically Collective on DM
+
+   Input Parameter:
+.  dm - the DM context
+
+   Output Parameter:
+.  ctype - the matrix type
+
+   Options Database:
+.   -dm_mat_type ctype
+
+   Level: intermediate
+
+.seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMCreateMatrix(), DMSetMatrixPreallocateOnly(), MatType, DMSetMatType()
+@*/
+PetscErrorCode  DMGetMatType(DM dm,MatType *ctype)
+{
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
+  *ctype = dm->mattype;
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "MatGetDM"
 /*@
   MatGetDM - Gets the DM defining the data layout of the matrix
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateColoring"
-/*@C
-    DMCreateColoring - Gets coloring for a DMDA or DMComposite
+/*@
+    DMCreateColoring - Gets coloring for a DM
 
     Collective on DM
 
     Input Parameter:
 +   dm - the DM object
-.   ctype - IS_COLORING_GHOSTED or IS_COLORING_GLOBAL
--   matype - either MATAIJ or MATBAIJ
+-   ctype - IS_COLORING_GHOSTED or IS_COLORING_GLOBAL
 
     Output Parameter:
 .   coloring - the coloring
 
     Level: developer
 
-.seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateInterpolation(), DMCreateMatrix()
+.seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateInterpolation(), DMCreateMatrix(), DMSetMatType()
 
 @*/
-PetscErrorCode  DMCreateColoring(DM dm,ISColoringType ctype,MatType mtype,ISColoring *coloring)
+PetscErrorCode  DMCreateColoring(DM dm,ISColoringType ctype,ISColoring *coloring)
 {
   PetscErrorCode ierr;
 
   PetscFunctionBegin;
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
   if (!dm->ops->getcoloring) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"No coloring for this type of DM yet");
-  ierr = (*dm->ops->getcoloring)(dm,ctype,mtype,coloring);CHKERRQ(ierr);
+  ierr = (*dm->ops->getcoloring)(dm,ctype,coloring);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
 #undef __FUNCT__
 #define __FUNCT__ "DMCreateMatrix"
-/*@C
+/*@
     DMCreateMatrix - Gets empty Jacobian for a DMDA or DMComposite
 
     Collective on DM
 
     Input Parameter:
-+   dm - the DM object
--   mtype - Supported types are MATSEQAIJ, MATMPIAIJ, MATSEQBAIJ, MATMPIBAIJ, or
-            any type which inherits from one of these (such as MATAIJ)
+.   dm - the DM object
 
     Output Parameter:
 .   mat - the empty Jacobian
        For structured grid problems, in general it is easiest to use MatSetValuesStencil() or MatSetValuesLocal() to put values into the matrix because MatSetValues() requires
        the indices for the global numbering for DMDAs which is complicated.
 
-.seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateInterpolation()
+.seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateInterpolation(), DMSetMatType()
 
 @*/
-PetscErrorCode  DMCreateMatrix(DM dm,MatType mtype,Mat *mat)
+PetscErrorCode  DMCreateMatrix(DM dm,Mat *mat)
 {
   PetscErrorCode ierr;
 
   ierr = MatInitializePackage();CHKERRQ(ierr);
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
   PetscValidPointer(mat,3);
-  if (dm->mattype) {
-    ierr = (*dm->ops->creatematrix)(dm,dm->mattype,mat);CHKERRQ(ierr);
-  } else {
-    ierr = (*dm->ops->creatematrix)(dm,mtype,mat);CHKERRQ(ierr);
-  }
+  ierr = (*dm->ops->creatematrix)(dm,mat);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 

src/dm/interface/dmi.c

   ierr = VecCreate(PetscObjectComm((PetscObject)dm), vec);CHKERRQ(ierr);
   ierr = VecSetSizes(*vec, localSize, PETSC_DETERMINE);CHKERRQ(ierr);
   ierr = VecSetBlockSize(*vec, bs);CHKERRQ(ierr);
-  /* ierr = VecSetType(*vec, dm->vectype);CHKERRQ(ierr); */
-  ierr = VecSetFromOptions(*vec);CHKERRQ(ierr);
+  ierr = VecSetType(*vec,dm->vectype);CHKERRQ(ierr);
   ierr = VecSetDM(*vec, dm);CHKERRQ(ierr);
   /* ierr = VecSetLocalToGlobalMapping(*vec, dm->ltogmap);CHKERRQ(ierr); */
   /* ierr = VecSetLocalToGlobalMappingBlock(*vec, dm->ltogmapb);CHKERRQ(ierr); */
   ierr = VecCreate(PETSC_COMM_SELF, vec);CHKERRQ(ierr);
   ierr = VecSetSizes(*vec, localSize, localSize);CHKERRQ(ierr);
   ierr = VecSetBlockSize(*vec, blockSize);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(*vec);CHKERRQ(ierr);
+  ierr = VecSetType(*vec,dm->vectype);CHKERRQ(ierr);
   ierr = VecSetDM(*vec, dm);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }

src/dm/interface/ftn-custom/zdmf.c

 
 #if defined(PETSC_HAVE_FORTRAN_CAPS)
 #define dmview_                      DMVIEW
-#define dmcreatecoloring_            DMCREATECOLORING
-#define dmcreatematrix_              DMCREATEMATRIX
 #define dmsetoptionsprefix_          DMSETOPTIONSPREFIX
+#define dmsetmattype_                DMSETMATTYPE
+#define dmsetvectype_                DMSETVECTYPE
+#define dmgetmattype_                DMGETMATTYPE
+#define dmgetvectype_                DMGETVECTYPE
 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
 #define dmview_                      dmview
-#define dmcreatecoloring_            dmcreatecoloring
-#define dmcreatematrix_              dmcreatematrix
 #define dmsetoptionsprefix_          dmsetoptionsprefix
+#define dmsetmattype_                dmsetmattype
+#define dmsetvectype_                dmsetvectype
+#define dmgetmattype_                dmgetmattype
+#define dmgetvectype_                dmgetvectype
 #endif
 
-PETSC_EXTERN void PETSC_STDCALL dmcreatecoloring_(DM *dm,ISColoringType *ctype, CHAR mtype PETSC_MIXED_LEN(len),ISColoring *coloring, int *ierr PETSC_END_LEN(len))
+PETSC_EXTERN void PETSC_STDCALL dmgetmattype_(DM *mm,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
 {
-  char *t;
+  const char *tname;
+
+  *ierr = DMGetMatType(*mm,&tname);if (*ierr) return;
+  if (name != PETSC_NULL_CHARACTER_Fortran) {
+    *ierr = PetscStrncpy(name,tname,len);if (*ierr) return;
+  }
+  FIXRETURNCHAR(PETSC_TRUE,name,len);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmgetvectype_(DM *mm,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
+{
+  const char *tname;
 
-  FIXCHAR(mtype,len,t);
-  *ierr = DMCreateColoring(*dm,*ctype,t,coloring);
-  FREECHAR(mtype,t);
+  *ierr = DMGetVecType(*mm,&tname);if (*ierr) return;
+  if (name != PETSC_NULL_CHARACTER_Fortran) {
+    *ierr = PetscStrncpy(name,tname,len);if (*ierr) return;
+  }
+  FIXRETURNCHAR(PETSC_TRUE,name,len);
 }
 
 PETSC_EXTERN void PETSC_STDCALL dmview_(DM *da,PetscViewer *vin,PetscErrorCode *ierr)
   *ierr = DMView(*da,v);
 }
 
-PETSC_EXTERN void PETSC_STDCALL dmcreatematrix_(DM *dm,CHAR mat_type PETSC_MIXED_LEN(len),Mat *J,PetscErrorCode *ierr PETSC_END_LEN(len))
+PETSC_EXTERN void PETSC_STDCALL dmsetoptionsprefix_(DM *dm,CHAR prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
+{
+  char *t;
+
+  FIXCHAR(prefix,len,t);
+  *ierr = DMSetOptionsPrefix(*dm,t);
+  FREECHAR(prefix,t);
+}
+
+PETSC_EXTERN void PETSC_STDCALL dmsetmattype_(DM *dm,CHAR prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
 {
   char *t;
-  FIXCHAR(mat_type,len,t);
-  *ierr = DMCreateMatrix(*dm,t,J);
-  FREECHAR(mat_type,t);
+
+  FIXCHAR(prefix,len,t);
+  *ierr = DMSetMatType(*dm,t);
+  FREECHAR(prefix,t);
 }
 
-PETSC_EXTERN void PETSC_STDCALL dmsetoptionsprefix_(DM *dm,CHAR prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
+
+PETSC_EXTERN void PETSC_STDCALL dmsetvectype_(DM *dm,CHAR prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
 {
   char *t;
 
   FIXCHAR(prefix,len,t);
-  *ierr = DMSetOptionsPrefix(*dm,t);
+  *ierr = DMSetVecType(*dm,t);
   FREECHAR(prefix,t);
 }

src/docs/website/documentation/changes/dev.html

       <h4>SNESLineSearch:</h4>
       <h4>TS:</h4>
       <h4>DM/DA:</h4>
+      <ul>
+        <li>The MatType argument is removed from DMCreateMatrix(), you can use DMSetMatType() to indicate the type you want used with a DM, defaults to MATAIJ</li>
+      </ul>
       <h4>DMComplex/DMPlex:</h4>
       <h4>DMMesh:</h4>
       <h4>DMMG:</h4>

src/ksp/ksp/examples/tests/ex32.c

   ierr = DMCreateGlobalVector(da,&x);CHKERRQ(ierr);
   ierr = DMCreateGlobalVector(da,&b);CHKERRQ(ierr);
   ierr = ComputeRHS(da,b);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATBAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATBAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr);
   ierr = ComputeMatrix(da,A);CHKERRQ(ierr);
 
 

src/ksp/ksp/examples/tests/ex35.c

 
   ierr = DMCreateGlobalVector(da,&x);CHKERRQ(ierr);
   ierr = DMCreateGlobalVector(da,&b);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr);
   ierr = VecSet(b,zero);CHKERRQ(ierr);
 
   /* Test sbaij matrix */

src/ksp/ksp/examples/tests/ex41.c

   }
 
   /* Create and set A at fine grids */
-  ierr = DMCreateMatrix(user.fine.da,MATAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(user.fine.da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(user.fine.da,&A);CHKERRQ(ierr);
   ierr = MatGetLocalSize(A,&m,&n);CHKERRQ(ierr);
   ierr = MatGetSize(A,&M,&N);CHKERRQ(ierr);
 

src/ksp/ksp/examples/tutorials/ex31.c

 
   PetscFunctionBeginUser;
   ierr = PetscObjectGetComm((PetscObject) da, &comm);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da, MATAIJ, &mat);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da, &mat);CHKERRQ(ierr);
   ierr = MatSetOption(mat,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr);
   ierr = DMGetGlobalVector(da, &rhs_u);CHKERRQ(ierr);
   ierr = DMGetGlobalVector(da, &rhs_v);CHKERRQ(ierr);
 
   PetscFunctionBeginUser;
   ierr = PetscObjectGetComm((PetscObject) da, &comm);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da, MATAIJ, &mat);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da, &mat);CHKERRQ(ierr);
   ierr = MatSetOption(mat,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr);
   ierr = DMGetGlobalVector(da, &rhs_m);CHKERRQ(ierr);
   ierr = DMGetGlobalVector(da, &rhs_e);CHKERRQ(ierr);

src/ksp/ksp/examples/tutorials/ex39.c

   ierr = MPI_Comm_size(PETSC_COMM_WORLD,&comm_size);CHKERRQ(ierr);
 
   /* construct matrix */
-  if (comm_size == 1) {
-    ierr = DMCreateMatrix(da, MATSEQAIJ, &H);CHKERRQ(ierr);
-  } else {
-    ierr = DMCreateMatrix(da, MATMPIAIJ, &H);CHKERRQ(ierr);
-  }
+  ierr = DMSetMatType(da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da, &H);CHKERRQ(ierr);
 
   /* get local corners for this processor */
   ierr = DMDAGetCorners(da,&xs,&ys,0,&xm,&ym,0);CHKERRQ(ierr);
 
   /* permutation matrix to check whether H and HtH are identical to the ones in the paper */
 /*   Mat perm; */
-/*   ierr = DMCreateMatrix(da, MATSEQAIJ, &perm);CHKERRQ(ierr); */
+/*   ierr = DMCreateMatrix(da, &perm);CHKERRQ(ierr); */
 /*   PetscInt row, col; */
 /*   PetscScalar one = 1.0; */
 /*   for (PetscInt i=0; i<n; i++) { */

src/ksp/ksp/examples/tutorials/ex4.c

   if (doGPU) {
     ierr = PetscLogStageRegister("GPU Stage", &gpuStage);CHKERRQ(ierr);
     ierr = PetscLogStagePush(gpuStage);CHKERRQ(ierr);
-    ierr = DMCreateMatrix(dm, MATAIJ, &A);CHKERRQ(ierr);
+    ierr = DMSetMatType(dm,MATAIJ);CHKERRQ(ierr);
+    ierr = DMCreateMatrix(dm, &A);CHKERRQ(ierr);
     ierr = MatSetType(A, MATAIJCUSP);CHKERRQ(ierr);
     ierr = MatSeqAIJSetPreallocation(A, 0, NULL);CHKERRQ(ierr);
     ierr = MatMPIAIJSetPreallocation(A, 0, NULL, 0, NULL);CHKERRQ(ierr);
   if (doCPU) {
     ierr = PetscLogStageRegister("CPU Stage", &cpuStage);CHKERRQ(ierr);
     ierr = PetscLogStagePush(cpuStage);CHKERRQ(ierr);
-    ierr = DMCreateMatrix(dm, MATAIJ, &A);CHKERRQ(ierr);
+    ierr = DMSetMatType(dm,MATAIJ);CHKERRQ(ierr);
+    ierr = DMCreateMatrix(dm, &A);CHKERRQ(ierr);
     ierr = MatZeroEntries(A);CHKERRQ(ierr);
     ierr = MatSetValuesBatch(A, Ne, Nl, elemRows, elemMats);CHKERRQ(ierr);
     ierr = MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);

src/ksp/ksp/examples/tutorials/ex40.c

   ierr = MPI_Comm_size(PETSC_COMM_WORLD,&comm_size);CHKERRQ(ierr);
 
   /* construct matrix */
-  if (comm_size == 1) {
-    ierr = DMCreateMatrix(adda, MATSEQAIJ, &H);CHKERRQ(ierr);
-  } else {
-    ierr = DMCreateMatrix(adda, MATMPIAIJ, &H);CHKERRQ(ierr);
-  }
+  ierr = DMSetMatType(adda,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(adda, &H);CHKERRQ(ierr);
 
   /* get local corners for this processor, user is responsible for freeing lcs,lce */
   ierr = DMADDAGetCorners(adda, &lcs, &lce);CHKERRQ(ierr);

src/ksp/ksp/examples/tutorials/ex42.c

   ierr = DMDAVecRestoreArray(vel_cda,vel_coords,&_vel_coords);CHKERRQ(ierr);
 
   /* Generate a matrix with the correct non-zero pattern of type AIJ. This will work in parallel and serial */
-  ierr = DMCreateMatrix(da_Stokes,MATAIJ,&A);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da_Stokes,MATAIJ,&B);CHKERRQ(ierr);
+  ierr = DMSetMatType(da_Stokes,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da_Stokes,&A);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da_Stokes,&B);CHKERRQ(ierr);
   ierr = DMCreateGlobalVector(da_Stokes,&X);CHKERRQ(ierr);
   ierr = DMCreateGlobalVector(da_Stokes,&f);CHKERRQ(ierr);
 

src/ksp/ksp/examples/tutorials/ex43.c

 
 
   /* Generate a matrix with the correct non-zero pattern of type AIJ. This will work in parallel and serial */
-  ierr = DMCreateMatrix(da_Stokes,MATAIJ,&A);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da_Stokes,MATAIJ,&B);CHKERRQ(ierr);
+  ierr = DMSetMatType(da_Stokes,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da_Stokes,&A);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da_Stokes,&B);CHKERRQ(ierr);
   ierr = DMCreateGlobalVector(da_Stokes,&f);CHKERRQ(ierr);
   ierr = DMCreateGlobalVector(da_Stokes,&X);CHKERRQ(ierr);
 

src/ksp/ksp/examples/tutorials/ex44f.F90

      &  PETSC_NULL_INTEGER,da,ierr)
       call DMCreateGlobalVector(da,x,ierr)
       call VecDuplicate(x,f,ierr)
-      call DMCreateMatrix(da,MATAIJ,J,ierr)
+      call DMSetMatType(da,MATAIJ,ierr)
+      call DMCreateMatrix(da,J,ierr)
 
       call ComputeRHS(da,f,ierr)
       call ComputeMatrix(da,J,ierr)

src/ksp/ksp/examples/tutorials/ex46.c

      Create parallel matrix preallocated according to the DMDA, format AIJ by default.
      To use symmetric storage, run with -dm_mat_type sbaij -mat_ignore_lower_triangular
   */
-  ierr = DMCreateMatrix(da,MATAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr);
 
   /*
      Set matrix elements for the 2-D, five-point stencil in parallel.

src/ksp/ksp/examples/tutorials/ex49.c

   }
 
   /* Generate a matrix with the correct non-zero pattern of type AIJ. This will work in parallel and serial */
-  ierr = DMCreateMatrix(elas_da,MATAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(elas_da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(elas_da,&A);CHKERRQ(ierr);
   ierr = DMGetCoordinates(elas_da,&vel_coords);CHKERRQ(ierr);
   ierr = MatNullSpaceCreateRigidBody(vel_coords,&matnull);CHKERRQ(ierr);
   ierr = MatSetNearNullSpace(A,matnull);CHKERRQ(ierr);

src/ksp/ksp/interface/itfunc.c

     /* first time in so build matrix and vector data structures using DM */
     if (!ksp->vec_rhs) {ierr = DMCreateGlobalVector(ksp->dm,&ksp->vec_rhs);CHKERRQ(ierr);}
     if (!ksp->vec_sol) {ierr = DMCreateGlobalVector(ksp->dm,&ksp->vec_sol);CHKERRQ(ierr);}
-    ierr = DMCreateMatrix(ksp->dm,MATAIJ,&A);CHKERRQ(ierr);
+    ierr = DMCreateMatrix(ksp->dm,&A);CHKERRQ(ierr);
     ierr = KSPSetOperators(ksp,A,A,stflg);CHKERRQ(ierr);
     ierr = PetscObjectDereference((PetscObject)A);CHKERRQ(ierr);
   }

src/ksp/pc/impls/gamg/gamg.c

     /* Create a vector to contain the newly ordered element information */
     ierr = VecCreate(comm, &dest_crd);CHKERRQ(ierr);
     ierr = VecSetSizes(dest_crd, node_data_sz*ncrs_prim_new, PETSC_DECIDE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(dest_crd);CHKERRQ(ierr); /* this is needed! */
+    ierr = VecSetType(dest_crd,VECSTANDARD);CHKERRQ(ierr); /* this is needed! */
     /*
      There are 'ndata_rows*ndata_cols' data items per node, (one can think of the vectors of having
      a block size of ...).  Note, ISs are expanded into equation space by 'cr_bs'.

src/ksp/pc/impls/ml/ml.c

 
   ierr = VecCreate(MLcomm->USR_comm,&shellctx->y);CHKERRQ(ierr);
   ierr = VecSetSizes(shellctx->y,m,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(shellctx->y);CHKERRQ(ierr);
+  ierr = VecSetType(shellctx->y,VECSTANDARD);CHKERRQ(ierr);
 
   (*newmat)->ops->destroy = MatDestroy_ML;
   PetscFunctionReturn(0);

src/mat/examples/tests/ex129.c

   ierr = VecDuplicate(b,&y);CHKERRQ(ierr);
   ierr = ComputeRHS(da,b);CHKERRQ(ierr);
   ierr = VecSet(y,one);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(da,MATBAIJ,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(da,MATBAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr);
   ierr = ComputeMatrix(da,A);CHKERRQ(ierr);
   ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr);
   nrhs = 2;

src/mat/examples/tests/ex96.c

 
   /* Test DMCreateMatrix()                                         */
   /*------------------------------------------------------------*/
-  ierr = DMCreateMatrix(user.fine.da,MATAIJ,&A);CHKERRQ(ierr);
-  ierr = DMCreateMatrix(user.fine.da,MATBAIJ,&C);CHKERRQ(ierr);
+  ierr = DMSetMatType(user.fine.da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(user.fine.da,&A);CHKERRQ(ierr);
+  ierr = DMSetMatType(user.fine.da,MATBAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(user.fine.da,&C);CHKERRQ(ierr);
 
   ierr = MatConvert(C,MATAIJ,MAT_INITIAL_MATRIX,&A_tmp);CHKERRQ(ierr); /* not work for mpisbaij matrix! */
   ierr = MatEqual(A,A_tmp,&flg);CHKERRQ(ierr);

src/mat/impls/aij/mpi/mpimattransposematmult.c

   /* create vectors bt and ct to hold locally transposed arrays of B and C */
   ierr = VecCreate(PetscObjectComm((PetscObject)A),&bt);CHKERRQ(ierr);
   ierr = VecSetSizes(bt,m*BN,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(bt);CHKERRQ(ierr);
+  ierr = VecSetType(bt,VECSTANDARD);CHKERRQ(ierr);
   ierr = VecCreate(PetscObjectComm((PetscObject)A),&ct);CHKERRQ(ierr);
   ierr = VecSetSizes(ct,n*BN,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(ct);CHKERRQ(ierr);
+  ierr = VecSetType(ct,VECSTANDARD);CHKERRQ(ierr);
   atb->bt = bt;
   atb->ct = ct;
 

src/mat/impls/aij/mpi/mumps/mumps.c

       ierr = VecCreateSeq(PETSC_COMM_SELF,0,&mumps->b_seq);CHKERRQ(ierr);
       ierr = ISCreateStride(PETSC_COMM_SELF,0,0,1,&is_iden);CHKERRQ(ierr);
     }
-    ierr = VecCreate(PetscObjectComm((PetscObject)A),&b);CHKERRQ(ierr);
-    ierr = VecSetSizes(b,A->rmap->n,PETSC_DECIDE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(b);CHKERRQ(ierr);
-
+    ierr = MatGetVecs(A,NULL,&b);CHKERRQ(ierr);
     ierr = VecScatterCreate(b,is_iden,mumps->b_seq,is_iden,&mumps->scat_rhs);CHKERRQ(ierr);
     ierr = ISDestroy(&is_iden);CHKERRQ(ierr);
     ierr = VecDestroy(&b);CHKERRQ(ierr);
       ierr = VecCreateSeq(PETSC_COMM_SELF,0,&mumps->b_seq);CHKERRQ(ierr);
       ierr = ISCreateStride(PETSC_COMM_SELF,0,0,1,&is_iden);CHKERRQ(ierr);
     }
-    ierr = VecCreate(PetscObjectComm((PetscObject)A),&b);CHKERRQ(ierr);
-    ierr = VecSetSizes(b,A->rmap->n,PETSC_DECIDE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(b);CHKERRQ(ierr);
-
+    ierr = MatGetVecs(A,NULL,&b);CHKERRQ(ierr);
     ierr = VecScatterCreate(b,is_iden,mumps->b_seq,is_iden,&mumps->scat_rhs);CHKERRQ(ierr);
     ierr = ISDestroy(&is_iden);CHKERRQ(ierr);
     ierr = VecDestroy(&b);CHKERRQ(ierr);
       ierr = VecCreateSeq(PETSC_COMM_SELF,0,&mumps->b_seq);CHKERRQ(ierr);
       ierr = ISCreateStride(PETSC_COMM_SELF,0,0,1,&is_iden);CHKERRQ(ierr);
     }
-    ierr = VecCreate(PetscObjectComm((PetscObject)A),&b);CHKERRQ(ierr);
-    ierr = VecSetSizes(b,A->rmap->n,PETSC_DECIDE);CHKERRQ(ierr);
-    ierr = VecSetFromOptions(b);CHKERRQ(ierr);
-
+    ierr = MatGetVecs(A,NULL,&b);CHKERRQ(ierr);
     ierr = VecScatterCreate(b,is_iden,mumps->b_seq,is_iden,&mumps->scat_rhs);CHKERRQ(ierr);
     ierr = ISDestroy(&is_iden);CHKERRQ(ierr);
     ierr = VecDestroy(&b);CHKERRQ(ierr);

src/mat/impls/aij/mpi/pastix/pastix.c

       /* PaStiX only supports centralized rhs. Create scatter scat_rhs for repeated use in MatSolve() */
       ierr = VecCreateSeq(PETSC_COMM_SELF,A->cmap->N,&lu->b_seq);CHKERRQ(ierr);
       ierr = ISCreateStride(PETSC_COMM_SELF,A->cmap->N,0,1,&is_iden);CHKERRQ(ierr);
-      ierr = VecCreate(PetscObjectComm((PetscObject)A),&b);CHKERRQ(ierr);
-      ierr = VecSetSizes(b,A->rmap->n,PETSC_DECIDE);CHKERRQ(ierr);
-      ierr = VecSetFromOptions(b);CHKERRQ(ierr);
-
+      ierr = MatGetVecs(A,NULL,&b);CHKERRQ(ierr);
       ierr = VecScatterCreate(b,is_iden,lu->b_seq,is_iden,&lu->scat_rhs);CHKERRQ(ierr);
       ierr = VecScatterCreate(lu->b_seq,is_iden,b,is_iden,&lu->scat_sol);CHKERRQ(ierr);
       ierr = ISDestroy(&is_iden);CHKERRQ(ierr);

src/mat/impls/aij/seq/mattransposematmult.c

   /* create vectors bt and ct to hold locally transposed arrays of B and C */
   ierr = VecCreate(PETSC_COMM_SELF,&bt);CHKERRQ(ierr);
   ierr = VecSetSizes(bt,m*BN,m*BN);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(bt);CHKERRQ(ierr);
+  ierr = VecSetType(bt,VECSTANDARD);CHKERRQ(ierr);
   ierr = VecCreate(PETSC_COMM_SELF,&ct);CHKERRQ(ierr);
   ierr = VecSetSizes(ct,n*BN,n*BN);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(ct);CHKERRQ(ierr);
+  ierr = VecSetType(ct,VECSTANDARD);CHKERRQ(ierr);
   atb->bt = bt;
   atb->ct = ct;
 

src/mat/utils/multequal.c

 #endif
   ierr = PetscRandomCreate(PetscObjectComm((PetscObject)A),&rctx);CHKERRQ(ierr);
   ierr = PetscRandomSetFromOptions(rctx);CHKERRQ(ierr);
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&x);CHKERRQ(ierr);
-  ierr = VecSetSizes(x,an,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(x);CHKERRQ(ierr);
-
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&s1);CHKERRQ(ierr);
-  ierr = VecSetSizes(s1,am,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(s1);CHKERRQ(ierr);
+  ierr = MatGetVecs(A,&x,&s1);CHKERRQ(ierr);
   ierr = VecDuplicate(s1,&s2);CHKERRQ(ierr);
 
   *flg = PETSC_TRUE;
   PetscCheckSameComm(A,1,B,2);
   ierr = PetscRandomCreate(PetscObjectComm((PetscObject)A),&rctx);CHKERRQ(ierr);
   ierr = PetscRandomSetFromOptions(rctx);CHKERRQ(ierr);
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&x);CHKERRQ(ierr);
-  ierr = VecSetSizes(x,an,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(x);CHKERRQ(ierr);
-
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&s1);CHKERRQ(ierr);
-  ierr = VecSetSizes(s1,am,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(s1);CHKERRQ(ierr);
+  ierr = MatGetVecs(A,&x,&s1);CHKERRQ(ierr);
   ierr = VecDuplicate(s1,&s2);CHKERRQ(ierr);
   ierr = VecDuplicate(s1,&y);CHKERRQ(ierr);
 
   PetscCheckSameComm(A,1,B,2);
   ierr = PetscRandomCreate(PetscObjectComm((PetscObject)A),&rctx);CHKERRQ(ierr);
   ierr = PetscRandomSetFromOptions(rctx);CHKERRQ(ierr);
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&x);CHKERRQ(ierr);
-  ierr = VecSetSizes(x,am,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(x);CHKERRQ(ierr);
-
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&s1);CHKERRQ(ierr);
-  ierr = VecSetSizes(s1,an,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(s1);CHKERRQ(ierr);
+  ierr = MatGetVecs(A,&s1,&x);CHKERRQ(ierr);
   ierr = VecDuplicate(s1,&s2);CHKERRQ(ierr);
 
   *flg = PETSC_TRUE;
   PetscCheckSameComm(A,1,B,2);
   ierr = PetscRandomCreate(PetscObjectComm((PetscObject)A),&rctx);CHKERRQ(ierr);
   ierr = PetscRandomSetFromOptions(rctx);CHKERRQ(ierr);
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&x);CHKERRQ(ierr);
-  ierr = VecSetSizes(x,am,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(x);CHKERRQ(ierr);
-
-  ierr = VecCreate(PetscObjectComm((PetscObject)A),&s1);CHKERRQ(ierr);
-  ierr = VecSetSizes(s1,an,PETSC_DECIDE);CHKERRQ(ierr);
-  ierr = VecSetFromOptions(s1);CHKERRQ(ierr);
+  ierr = MatGetVecs(A,&s1,&x);CHKERRQ(ierr);
   ierr = VecDuplicate(s1,&s2);CHKERRQ(ierr);
   ierr = VecDuplicate(s1,&y);CHKERRQ(ierr);
 

src/snes/examples/tests/ex15.c

 #define __FUNCT__ "main"
 int main(int argc, char **argv)
 {
-  PetscErrorCode      info;               /* used to check for functions returning nonzeros */
+  PetscErrorCode      ierr;               /* used to check for functions returning nonzeros */
   Vec                 x;                  /* variables vector */
   Vec                 xl,xu;              /* lower and upper bound on variables */
   PetscBool           flg;              /* A return variable when checking for user options */
   user.nx = 50; user.ny = 50; user.ecc = 0.1; user.b = 10.0;
 
   /* Check for any command line arguments that override defaults */
-  info = PetscOptionsGetReal(NULL,"-ecc",&user.ecc,&flg);CHKERRQ(info);
-  info = PetscOptionsGetReal(NULL,"-b",&user.b,&flg);CHKERRQ(info);
+  ierr = PetscOptionsGetReal(NULL,"-ecc",&user.ecc,&flg);CHKERRQ(ierr);
+  ierr = PetscOptionsGetReal(NULL,"-b",&user.b,&flg);CHKERRQ(ierr);
 
   /*
      A two dimensional distributed array will help define this problem,
      which derives from an elliptic PDE on two dimensional domain.  From
      the distributed array, Create the vectors.
   */
-  info = DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,-50,-50,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&user.da);CHKERRQ(info);
-  info = DMDAGetInfo(user.da,PETSC_IGNORE,&user.nx,&user.ny,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE);CHKERRQ(info);
+  ierr = DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,-50,-50,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&user.da);CHKERRQ(ierr);
+  ierr = DMDAGetIerr(user.da,PETSC_IGNORE,&user.nx,&user.ny,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE);CHKERRQ(ierr);
 
   PetscPrintf(PETSC_COMM_WORLD,"\n---- Journal Bearing Problem -----\n");
   PetscPrintf(PETSC_COMM_WORLD,"mx: %d,  my: %d,  ecc: %4.3f, b:%3.1f \n",
      gradient, and Hessian.  Duplicate for remaining vectors that are
      the same types.
   */
-  info = DMCreateGlobalVector(user.da,&x);CHKERRQ(info); /* Solution */
-  info = VecDuplicate(x,&user.B);CHKERRQ(info); /* Linear objective */
-  info = VecDuplicate(x,&r);CHKERRQ(info);
+  ierr = DMCreateGlobalVector(user.da,&x);CHKERRQ(ierr); /* Solution */
+  ierr = VecDuplicate(x,&user.B);CHKERRQ(ierr); /* Linear objective */
+  ierr = VecDuplicate(x,&r);CHKERRQ(ierr);
 
   /*  Create matrix user.A to store quadratic, Create a local ordering scheme. */
-  info = DMCreateMatrix(user.da,MATAIJ,&user.A);CHKERRQ(info);
+  ierr = DMSetMatType(user.da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(user.da,&user.A);CHKERRQ(ierr);
 
   /* User defined function -- compute linear term of quadratic */
-  info = ComputeB(&user);CHKERRQ(info);
+  ierr = ComputeB(&user);CHKERRQ(ierr);
 
   /* Create nonlinear solver context */
-  info = SNESCreate(PETSC_COMM_WORLD,&snes);CHKERRQ(info);
+  ierr = SNESCreate(PETSC_COMM_WORLD,&snes);CHKERRQ(ierr);
 
   /*  Set function evaluation and Jacobian evaluation  routines */
-  info = SNESSetFunction(snes,r,FormGradient,&user);CHKERRQ(info);
-  info = SNESSetJacobian(snes,user.A,user.A,FormHessian,&user);CHKERRQ(info);
+  ierr = SNESSetFunction(snes,r,FormGradient,&user);CHKERRQ(ierr);
+  ierr = SNESSetJacobian(snes,user.A,user.A,FormHessian,&user);CHKERRQ(ierr);
 
   /* Set the initial solution guess */
-  info = VecSet(x, zero);CHKERRQ(info);
+  ierr = VecSet(x, zero);CHKERRQ(ierr);
 
-  info = SNESSetFromOptions(snes);CHKERRQ(info);
+  ierr = SNESSetFromOptions(snes);CHKERRQ(ierr);
 
   /* Set variable bounds */
-  info = VecDuplicate(x,&xl);CHKERRQ(info);
-  info = VecDuplicate(x,&xu);CHKERRQ(info);
-  info = VecSet(xl,zero);CHKERRQ(info);
-  info = VecSet(xu,thnd);CHKERRQ(info);
-  info = SNESVISetVariableBounds(snes,xl,xu);CHKERRQ(info);
+  ierr = VecDuplicate(x,&xl);CHKERRQ(ierr);
+  ierr = VecDuplicate(x,&xu);CHKERRQ(ierr);
+  ierr = VecSet(xl,zero);CHKERRQ(ierr);
+  ierr = VecSet(xu,thnd);CHKERRQ(ierr);
+  ierr = SNESVISetVariableBounds(snes,xl,xu);CHKERRQ(ierr);
 
   /* Solve the application */
-  info = SNESSolve(snes,NULL,x);CHKERRQ(info);
+  ierr = SNESSolve(snes,NULL,x);CHKERRQ(ierr);
 
-  info = SNESGetConvergedReason(snes,&reason);CHKERRQ(info);
+  ierr = SNESGetConvergedReason(snes,&reason);CHKERRQ(ierr);
   if (reason <= 0) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"The SNESVI solver did not converge, adjust some parameters, or check the function evaluation routines\n");
 
   /* Free memory */
-  info = VecDestroy(&x);CHKERRQ(info);
-  info = VecDestroy(&xl);CHKERRQ(info);
-  info = VecDestroy(&xu);CHKERRQ(info);
-  info = VecDestroy(&r);CHKERRQ(info);
-  info = MatDestroy(&user.A);CHKERRQ(info);
-  info = VecDestroy(&user.B);CHKERRQ(info);
-  info = DMDestroy(&user.da);CHKERRQ(info);
-  info = SNESDestroy(&snes);CHKERRQ(info);
+  ierr = VecDestroy(&x);CHKERRQ(ierr);
+  ierr = VecDestroy(&xl);CHKERRQ(ierr);
+  ierr = VecDestroy(&xu);CHKERRQ(ierr);
+  ierr = VecDestroy(&r);CHKERRQ(ierr);
+  ierr = MatDestroy(&user.A);CHKERRQ(ierr);
+  ierr = VecDestroy(&user.B);CHKERRQ(ierr);
+  ierr = DMDestroy(&user.da);CHKERRQ(ierr);
+  ierr = SNESDestroy(&snes);CHKERRQ(ierr);
 
-  info = PetscFinalize();
+  ierr = PetscFinalize();
 
   return 0;
 }
 #define __FUNCT__ "ComputeB"
 PetscErrorCode ComputeB(AppCtx *user)
 {
-  PetscErrorCode info;
+  PetscErrorCode ierr;
   PetscInt       i,j;
   PetscInt       nx,ny,xs,xm,ys,ym;
   PetscReal      two=2.0, pi=4.0*atan(1.0);
   ehxhy = ecc*hx*hy;
 
   /* Get pointer to local vector data */
-  info = DMDAVecGetArray(user->da,user->B, &b);CHKERRQ(info);
+  ierr = DMDAVecGetArray(user->da,user->B, &b);CHKERRQ(ierr);
 
-  info = DMDAGetCorners(user->da,&xs,&ys,NULL,&xm,&ym,NULL);CHKERRQ(info);
+  ierr = DMDAGetCorners(user->da,&xs,&ys,NULL,&xm,&ym,NULL);CHKERRQ(ierr);
 
   /* Compute the linear term in the objective function */
   for (i=xs; i<xs+xm; i++) {
     for (j=ys; j<ys+ym; j++) b[j][i] = -ehxhy*temp;
   }
   /* Restore vectors */
-  info = DMDAVecRestoreArray(user->da,user->B,&b);CHKERRQ(info);
-  info = PetscLogFlops(5*xm*ym+3*xm);CHKERRQ(info);
+  ierr = DMDAVecRestoreArray(user->da,user->B,&b);CHKERRQ(ierr);
+  ierr = PetscLogFlops(5*xm*ym+3*xm);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
 PetscErrorCode FormGradient(SNES snes, Vec X, Vec G,void *ctx)
 {
   AppCtx         *user=(AppCtx*)ctx;
-  PetscErrorCode info;
+  PetscErrorCode ierr;
   PetscInt       i,j,k,kk;
   PetscInt       row[5],col[5];
   PetscInt       nx,ny,xs,xm,ys,ym;
   hxhx = one/(hx*hx);
   hyhy = one/(hy*hy);
 
-  info = VecSet(G, zero);CHKERRQ(info);
+  ierr = VecSet(G, zero);CHKERRQ(ierr);
 
   /* Get local vector */
-  info = DMGetLocalVector(user->da,&localX);CHKERRQ(info);
+  ierr = DMGetLocalVector(user->da,&localX);CHKERRQ(ierr);
   /* Get ghoist points */
-  info = DMGlobalToLocalBegin(user->da,X,INSERT_VALUES,localX);CHKERRQ(info);
-  info = DMGlobalToLocalEnd(user->da,X,INSERT_VALUES,localX);CHKERRQ(info);
+  ierr = DMGlobalToLocalBegin(user->da,X,INSERT_VALUES,localX);CHKERRQ(ierr);
+  ierr = DMGlobalToLocalEnd(user->da,X,INSERT_VALUES,localX);CHKERRQ(ierr);
   /* Get pointer to vector data */
-  info = DMDAVecGetArray(user->da,localX,&x);CHKERRQ(info);
-  info = DMDAVecGetArray(user->da,G,&g);CHKERRQ(info);
+  ierr = DMDAVecGetArray(user->da,localX,&x);CHKERRQ(ierr);
+  ierr = DMDAVecGetArray(user->da,G,&g);CHKERRQ(ierr);
 
-  info = DMDAGetCorners(user->da,&xs,&ys,NULL,&xm,&ym,NULL);CHKERRQ(info);
+  ierr = DMDAGetCorners(user->da,&xs,&ys,NULL,&xm,&ym,NULL);CHKERRQ(ierr);
 
   for (i=xs; i< xs+xm; i++) {
     xi     = (i+1)*hx;
   }
 
   /* Restore vectors */
-  info = DMDAVecRestoreArray(user->da,localX, &x);CHKERRQ(info);
-  info = DMDAVecRestoreArray(user->da,G, &g);CHKERRQ(info);
-  info = DMRestoreLocalVector(user->da,&localX);CHKERRQ(info);
+  ierr = DMDAVecRestoreArray(user->da,localX, &x);CHKERRQ(ierr);
+  ierr = DMDAVecRestoreArray(user->da,G, &g);CHKERRQ(ierr);
+  ierr = DMRestoreLocalVector(user->da,&localX);CHKERRQ(ierr);
 
-  info = VecAXPY(G, one, user->B);CHKERRQ(info);
+  ierr = VecAXPY(G, one, user->B);CHKERRQ(ierr);
 
-  info = PetscLogFlops((91 + 10*ym) * xm);CHKERRQ(info);
+  ierr = PetscLogFlops((91 + 10*ym) * xm);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
 PetscErrorCode FormHessian(SNES snes,Vec X,Mat *H, Mat *Hpre, MatStructure *flg, void *ptr)
 {
   AppCtx         *user=(AppCtx*)ptr;
-  PetscErrorCode info;
+  PetscErrorCode ierr;
   PetscInt       i,j,k;
   MatStencil     row,col[5];
   PetscInt       nx,ny,xs,xm,ys,ym;
   hxhx = one/(hx*hx);
   hyhy = one/(hy*hy);
 
-  info = MatAssembled(hes,&assembled);CHKERRQ(info);
-  if (assembled) {info = MatZeroEntries(hes);CHKERRQ(info);}
+  ierr = MatAssembled(hes,&assembled);CHKERRQ(ierr);
+  if (assembled) {ierr = MatZeroEntries(hes);CHKERRQ(ierr);}
   *flg=SAME_NONZERO_PATTERN;
 
   /* Get local vector */
-  info = DMGetLocalVector(user->da,&localX);CHKERRQ(info);
+  ierr = DMGetLocalVector(user->da,&localX);CHKERRQ(ierr);
   /* Get ghost points */
-  info = DMGlobalToLocalBegin(user->da,X,INSERT_VALUES,localX);CHKERRQ(info);
-  info = DMGlobalToLocalEnd(user->da,X,INSERT_VALUES,localX);CHKERRQ(info);
+  ierr = DMGlobalToLocalBegin(user->da,X,INSERT_VALUES,localX);CHKERRQ(ierr);
+  ierr = DMGlobalToLocalEnd(user->da,X,INSERT_VALUES,localX);CHKERRQ(ierr);
 
   /* Get pointers to vector data */
-  info = DMDAVecGetArray(user->da,localX, &x);CHKERRQ(info);
+  ierr = DMDAVecGetArray(user->da,localX, &x);CHKERRQ(ierr);
 
-  info = DMDAGetCorners(user->da,&xs,&ys,NULL,&xm,&ym,NULL);CHKERRQ(info);
+  ierr = DMDAGetCorners(user->da,&xs,&ys,NULL,&xm,&ym,NULL);CHKERRQ(ierr);
 
   for (i=xs; i< xs+xm; i++) {
     xi     = (i+1)*hx;
       if (j+1 < ny) {
         v[k]= vup; col[k].i = i; col[k].j = j+1; k++;
       }
-      info = MatSetValuesStencil(hes,1,&row,k,col,v,INSERT_VALUES);CHKERRQ(info);
+      ierr = MatSetValuesStencil(hes,1,&row,k,col,v,INSERT_VALUES);CHKERRQ(ierr);
     }
   }
 
-  info = MatAssemblyBegin(hes,MAT_FINAL_ASSEMBLY);CHKERRQ(info);
-  info = DMDAVecRestoreArray(user->da,localX,&x);CHKERRQ(info);
-  info = MatAssemblyEnd(hes,MAT_FINAL_ASSEMBLY);CHKERRQ(info);
-  info = DMRestoreLocalVector(user->da,&localX);CHKERRQ(info);
+  ierr = MatAssemblyBegin(hes,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = DMDAVecRestoreArray(user->da,localX,&x);CHKERRQ(ierr);
+  ierr = MatAssemblyEnd(hes,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = DMRestoreLocalVector(user->da,&localX);CHKERRQ(ierr);
 
   /*
     Tell the matrix we will never add a new nonzero location to the
     matrix. If we do it will generate an error.
   */
-  info = MatSetOption(hes,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE);CHKERRQ(info);
-  info = MatSetOption(hes,MAT_SYMMETRIC,PETSC_TRUE);CHKERRQ(info);
+  ierr = MatSetOption(hes,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE);CHKERRQ(ierr);
+  ierr = MatSetOption(hes,MAT_SYMMETRIC,PETSC_TRUE);CHKERRQ(ierr);
 
-  info = PetscLogFlops(9*xm*ym+49*xm);CHKERRQ(info);
+  ierr = PetscLogFlops(9*xm*ym+49*xm);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }

src/snes/examples/tests/ex16.c

 #define __FUNCT__ "main"
 int main(int argc, char **argv)
 {
-  PetscErrorCode info;              /* used to check for functions returning nonzeros */
+  PetscErrorCode ierr;              /* used to check for functions returning nonzeros */
   Vec            x,r;               /* solution and residual vectors */
   Vec            xl,xu;             /* Bounds on the variables */
   SNES           snes;              /* nonlinear solver context */
 #endif
 
   /* Create distributed array to manage the 2d grid */
-  info = DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE,DMDA_STENCIL_BOX,-10,-10,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&user.da);CHKERRQ(info);
-  info = DMDAGetInfo(user.da,PETSC_IGNORE,&user.mx,&user.my,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE);CHKERRQ(info);
+  ierr = DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE,DMDA_STENCIL_BOX,-10,-10,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&user.da);CHKERRQ(ierr);
+  ierr = DMDAGetIerr(user.da,PETSC_IGNORE,&user.mx,&user.my,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE,PETSC_IGNORE);CHKERRQ(ierr);
 
   user.bheight = 0.1;
-  info         = PetscOptionsGetScalar(NULL,"-bheight",&user.bheight,&flg);CHKERRQ(info);
+  ierr         = PetscOptionsGetScalar(NULL,"-bheight",&user.bheight,&flg);CHKERRQ(ierr);
 
   user.bmx = user.mx/2; user.bmy = user.my/2;
-  info     = PetscOptionsGetInt(NULL,"-bmx",&user.bmx,&flg);CHKERRQ(info);
-  info     = PetscOptionsGetInt(NULL,"-bmy",&user.bmy,&flg);CHKERRQ(info);
+  ierr     = PetscOptionsGetInt(NULL,"-bmx",&user.bmx,&flg);CHKERRQ(ierr);
+  ierr     = PetscOptionsGetInt(NULL,"-bmy",&user.bmy,&flg);CHKERRQ(ierr);
 
   PetscPrintf(PETSC_COMM_WORLD,"\n---- Minimum Surface Area With Plate Problem -----\n");
   PetscPrintf(PETSC_COMM_WORLD,"mx:%d, my:%d, bmx:%d, bmy:%d, height:%4.2f\n",
               user.mx,user.my,user.bmx,user.bmy,user.bheight);
 
   /* Extract global vectors from DMDA; */
-  info = DMCreateGlobalVector(user.da,&x);CHKERRQ(info);
-  info = VecDuplicate(x, &r);CHKERRQ(info);
+  ierr = DMCreateGlobalVector(user.da,&x);CHKERRQ(ierr);
+  ierr = VecDuplicate(x, &r);CHKERRQ(ierr);
 
-  info = DMCreateMatrix(user.da,MATAIJ,&J);CHKERRQ(info);
+  ierr = DMSetMatType(user.da,MATAIJ);CHKERRQ(ierr);
+  ierr = DMCreateMatrix(user.da,&J);CHKERRQ(ierr);
 
   /* Create nonlinear solver context */
-  info = SNESCreate(PETSC_COMM_WORLD,&snes);CHKERRQ(info);
+  ierr = SNESCreate(PETSC_COMM_WORLD,&snes);CHKERRQ(ierr);
 
   /*  Set function evaluation and Jacobian evaluation  routines */
-  info = SNESSetDM(snes,user.da);CHKERRQ(info);
-  info = SNESSetFunction(snes,r,FormGradient,&user);CHKERRQ(info);
-  info = SNESSetJacobian(snes,J,J,FormJacobian,&user);CHKERRQ(info);
+  ierr = SNESSetDM(snes,user.da);CHKERRQ(ierr);
+  ierr = SNESSetFunction(snes,r,FormGradient,&user);CHKERRQ(ierr);
+  ierr = SNESSetJacobian(snes,J,J,FormJacobian,&user);CHKERRQ(ierr);
 
   /* Set the boundary conditions */
-  info = MSA_BoundaryConditions(&user);CHKERRQ(info);
+  ierr = MSA_BoundaryConditions(&user);CHKERRQ(ierr);
 
   /* Set initial solution guess */
-  info = MSA_InitialPoint(&user, x);CHKERRQ(info);
+  ierr = MSA_InitialPoint(&user, x);CHKERRQ(ierr);
 
-  info = SNESSetFromOptions(snes);CHKERRQ(info);
+  ierr = SNESSetFromOptions(snes);CHKERRQ(ierr);
 
   /* Set Bounds on variables */
-  info = VecDuplicate(x, &xl);CHKERRQ(info);
-  info = VecDuplicate(x, &xu);CHKERRQ(info);
-  info = MSA_Plate(xl,xu,&user);CHKERRQ(info);
+  ierr = VecDuplicate(x, &xl);CHKERRQ(ierr);
+  ierr = VecDuplicate(x, &xu);CHKERRQ(ierr);
+  ierr = MSA_Plate(xl,xu,&user);CHKERRQ(ierr);
 
-  info = SNESVISetVariableBounds(snes,xl,xu);CHKERRQ(info);
+  ierr = SNESVISetVariableBounds(snes,xl,xu);CHKERRQ(ierr);
 
   /* Solve the application */
-  info = SNESSolve(snes,NULL,x);CHKERRQ(info);
+  ierr = SNESSolve(snes,NULL,x);CHKERRQ(ierr);
 
-  info = PetscOptionsHasName(NULL,"-view_sol",&flg);CHKERRQ(info);
-  if (flg) { info = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(info); }
+  ierr = PetscOptionsHasName(NULL,"-view_sol",&flg);CHKERRQ(ierr);
+  if (flg) { ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); }
 
   /* Free memory */
-  info = VecDestroy(&x);CHKERRQ(info);
-  info = VecDestroy(&xl);CHKERRQ(info);
-  info = VecDestroy(&xu);CHKERRQ(info);
-  info = VecDestroy(&r);CHKERRQ(info);
-  info = MatDestroy(&J);CHKERRQ(info);
-  info = SNESDestroy(&snes);CHKERRQ(info);
+  ierr = VecDestroy(&x);CHKERRQ(ierr);
+  ierr = VecDestroy(&xl);CHKERRQ(ierr);
+  ierr = VecDestroy(&xu);CHKERRQ(ierr);
+  ierr = VecDestroy(&r);CHKERRQ(ierr);
+  ierr = MatDestroy(&J);CHKERRQ(ierr);