# PetscDataType
Used for handling different basic data types. 
## Synopsis
```
typedef enum {
  PETSC_DATATYPE_UNKNOWN = 0,
  PETSC_DOUBLE           = 1,
  PETSC_COMPLEX          = 2,
  PETSC_LONG             = 3,
  PETSC_SHORT            = 4,
  PETSC_FLOAT            = 5,
  PETSC_CHAR             = 6,
  PETSC_BIT_LOGICAL      = 7,
  PETSC_ENUM             = 8,
  PETSC_BOOL             = 9,
  PETSC___FLOAT128       = 10,
  PETSC_OBJECT           = 11,
  PETSC_FUNCTION         = 12,
  PETSC_STRING           = 13,
  PETSC___FP16           = 14,
  PETSC_STRUCT           = 15,
  PETSC_INT              = 16,
  PETSC_INT64            = 17,
  PETSC_COUNT            = 18
} PetscDataType;
```



## Notes
Use of this should be avoided if one can directly use `MPI_Datatype` instead.

`PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes.
`PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes.


## Developer Notes
It would be nice if we could always just use MPI Datatypes, why can we not?

If you change any values in `PetscDatatype` make sure you update their usage in
share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m

TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM


## See Also
 `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`,
`PetscDataTypeGetSize()`


## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscsystypes.h.html#PetscDataType">include/petscsystypes.h</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/tutorials/ex5.c.html">src/sys/tutorials/ex5.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex6.c.html">src/vec/vec/tutorials/ex6.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex6f.F90.html">src/vec/vec/tutorials/ex6f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex20.c.html">src/dm/tutorials/ex20.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/swarm_ex3.c.html">src/dm/tutorials/swarm_ex3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex63.c.html">src/snes/tutorials/ex63.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsystypes.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
