1c4762a1bSJed Brown 2c4762a1bSJed Brown static char help[] = "Demonstrates PetscDataTypeFromString().\n\n"; 3c4762a1bSJed Brown 4c4762a1bSJed Brown #include <petscsys.h> 5c4762a1bSJed Brown int main(int argc,char **argv) 6c4762a1bSJed Brown { 7c4762a1bSJed Brown PetscDataType dtype; 8c4762a1bSJed Brown PetscBool found; 9c4762a1bSJed Brown 10c4762a1bSJed Brown /* 11c4762a1bSJed Brown Every PETSc routine should begin with the PetscInitialize() routine. 12c4762a1bSJed Brown argc, argv - These command line arguments are taken to extract the options 13c4762a1bSJed Brown supplied to PETSc and options supplied to MPI. 14c4762a1bSJed Brown help - When PETSc executable is invoked with the option -help, 15c4762a1bSJed Brown it prints the various options that can be applied at 16c4762a1bSJed Brown runtime. The user can use the "help" variable place 17c4762a1bSJed Brown additional help messages in this printout. 18c4762a1bSJed Brown */ 19*327415f7SBarry Smith PetscFunctionBeginUser; 209566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); 21c4762a1bSJed Brown 229566063dSJacob Faibussowitsch PetscCall(PetscDataTypeFromString("Scalar",&dtype,&found)); 2328b400f6SJacob Faibussowitsch PetscCheck(found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Did not find scalar datatype"); 2408401ef6SPierre Jolivet PetscCheck(dtype == PETSC_SCALAR,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found wrong datatype for scalar"); 25c4762a1bSJed Brown 269566063dSJacob Faibussowitsch PetscCall(PetscDataTypeFromString("INT",&dtype,&found)); 2728b400f6SJacob Faibussowitsch PetscCheck(found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Did not find int datatype"); 2808401ef6SPierre Jolivet PetscCheck(dtype == PETSC_INT,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found wrong datatype for int"); 29c4762a1bSJed Brown 309566063dSJacob Faibussowitsch PetscCall(PetscDataTypeFromString("real",&dtype,&found)); 3128b400f6SJacob Faibussowitsch PetscCheck(found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Did not find real datatype"); 3208401ef6SPierre Jolivet PetscCheck(dtype == PETSC_REAL,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found wrong datatype for real"); 33c4762a1bSJed Brown 349566063dSJacob Faibussowitsch PetscCall(PetscDataTypeFromString("abogusdatatype",&dtype,&found)); 3528b400f6SJacob Faibussowitsch PetscCheck(!found,PETSC_COMM_WORLD,PETSC_ERR_ARG_WRONG,"Found a bogus datatype"); 36c4762a1bSJed Brown 379566063dSJacob Faibussowitsch PetscCall(PetscFinalize()); 38b122ec5aSJacob Faibussowitsch return 0; 39c4762a1bSJed Brown } 40c4762a1bSJed Brown 41c4762a1bSJed Brown /*TEST 42c4762a1bSJed Brown 43c4762a1bSJed Brown test: 44c4762a1bSJed Brown 45c4762a1bSJed Brown TEST*/ 46