1 2 static char help[] = "Tests loading DM vector from file.\n\n"; 3 4 /* 5 ex14.c writes out the DMDA and vector read by this program. 6 */ 7 8 #include <petscdmda.h> 9 10 int main(int argc,char **argv) 11 { 12 PetscErrorCode ierr; 13 PetscInt M = PETSC_DECIDE,N = PETSC_DECIDE; 14 DM da; 15 Vec global; 16 PetscViewer bviewer; 17 18 ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr; 19 ierr = PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL);CHKERRQ(ierr); 20 ierr = PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL);CHKERRQ(ierr); 21 22 ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,"daoutput",FILE_MODE_READ,&bviewer);CHKERRQ(ierr); 23 ierr = DMCreate(PETSC_COMM_WORLD,&da);CHKERRQ(ierr); 24 25 ierr = DMLoad(da,bviewer);CHKERRQ(ierr); 26 ierr = DMCreateGlobalVector(da,&global);CHKERRQ(ierr); 27 ierr = VecLoad(global,bviewer);CHKERRQ(ierr); 28 ierr = PetscViewerDestroy(&bviewer);CHKERRQ(ierr); 29 30 ierr = VecView(global,PETSC_VIEWER_DRAW_WORLD);CHKERRQ(ierr); 31 32 /* Free memory */ 33 ierr = VecDestroy(&global);CHKERRQ(ierr); 34 ierr = DMDestroy(&da);CHKERRQ(ierr); 35 ierr = PetscFinalize(); 36 return ierr; 37 } 38 39