1c4762a1bSJed Brown 2c4762a1bSJed Brown static char help[] = "Demonstrates PetscDataTypeFromString().\n\n"; 3c4762a1bSJed Brown 4c4762a1bSJed Brown /*T 5c4762a1bSJed Brown Concepts: introduction to PETSc; 6c4762a1bSJed Brown Concepts: printing^in parallel 7c4762a1bSJed Brown Processors: n 8c4762a1bSJed Brown T*/ 9c4762a1bSJed Brown 10c4762a1bSJed Brown #include <petscsys.h> 11c4762a1bSJed Brown int main(int argc,char **argv) 12c4762a1bSJed Brown { 13c4762a1bSJed Brown PetscErrorCode ierr; 14c4762a1bSJed Brown PetscDataType dtype; 15c4762a1bSJed Brown PetscBool found; 16c4762a1bSJed Brown 17c4762a1bSJed Brown /* 18c4762a1bSJed Brown Every PETSc routine should begin with the PetscInitialize() routine. 19c4762a1bSJed Brown argc, argv - These command line arguments are taken to extract the options 20c4762a1bSJed Brown supplied to PETSc and options supplied to MPI. 21c4762a1bSJed Brown help - When PETSc executable is invoked with the option -help, 22c4762a1bSJed Brown it prints the various options that can be applied at 23c4762a1bSJed Brown runtime. The user can use the "help" variable place 24c4762a1bSJed Brown additional help messages in this printout. 25c4762a1bSJed Brown */ 26c4762a1bSJed Brown ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr; 27c4762a1bSJed Brown 28c4762a1bSJed Brown ierr = PetscDataTypeFromString("Scalar",&dtype,&found);CHKERRQ(ierr); 29*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(!found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Did not find scalar datatype"); 30*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(dtype != PETSC_SCALAR,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found wrong datatype for scalar"); 31c4762a1bSJed Brown 32c4762a1bSJed Brown ierr = PetscDataTypeFromString("INT",&dtype,&found);CHKERRQ(ierr); 33*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(!found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Did not find int datatype"); 34*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(dtype != PETSC_INT,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found wrong datatype for int"); 35c4762a1bSJed Brown 36c4762a1bSJed Brown ierr = PetscDataTypeFromString("real",&dtype,&found);CHKERRQ(ierr); 37*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(!found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Did not find real datatype"); 38*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(dtype != PETSC_REAL,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found wrong datatype for real"); 39c4762a1bSJed Brown 40c4762a1bSJed Brown ierr = PetscDataTypeFromString("abogusdatatype",&dtype,&found);CHKERRQ(ierr); 41*2c71b3e2SJacob Faibussowitsch PetscCheckFalse(found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found a bogus datatype"); 42c4762a1bSJed Brown 43c4762a1bSJed Brown ierr = PetscFinalize(); 44c4762a1bSJed Brown return ierr; 45c4762a1bSJed Brown } 46c4762a1bSJed Brown 47c4762a1bSJed Brown /*TEST 48c4762a1bSJed Brown 49c4762a1bSJed Brown test: 50c4762a1bSJed Brown 51c4762a1bSJed Brown TEST*/ 52