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