int main(int argc,char **args) { PetscViewer viewer; PetscErrorCode ierr; PetscViewerFormat format; ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr; ierr = PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,NULL,"-myviewer",&viewer,&format,NULL);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PetscViewerView(viewer,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); ierr = PetscFinalize(); return ierr; }
int main(int argc, char **args) { PetscErrorCode ierr; MPI_Comm comm = PETSC_COMM_SELF; H2 h2; ierr = SlepcInitialize(&argc, &args, (char*)0, help); CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) PetscPrintf(comm, "Scalar: complex\n"); #else PetscPrintf(comm, "Scalar: real\n"); #endif PrintTimeStamp(comm, "Create", NULL); ierr = H2Create(&h2); CHKERRQ(ierr); PrintTimeStamp(comm, "Set", NULL); ierr = H2SetFromOptions(h2); CHKERRQ(ierr); PrintTimeStamp(comm, "View", NULL); OCE2View(h2->oce, h2->viewer); if(h2->init_view) PetscViewerView(h2->init_view, h2->viewer); for(int i = 0; i < h2->num_bondlength; i++) { PrintTimeStamp(comm, "Set H", NULL); PetscPrintf(comm, "bond_length = %f\n", h2->bondlength); ierr = H2SetH(h2); CHKERRQ(ierr); PrintTimeStamp(comm, "eps", NULL); ierr = H2Solve(h2); CHKERRQ(ierr); h2->bondlength += h2->d_bondlength; } PrintTimeStamp(comm, "Finalize", NULL); ierr = H2Destroy(&h2); CHKERRQ(ierr); ierr = SlepcFinalize(); CHKERRQ(ierr); return 0; }