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