# DMGetWorkArray
Gets a work array guaranteed to be at least the input size, restore with `DMRestoreWorkArray()` 
## Synopsis
```
#include "petscdm.h"          
#include "petscdmlabel.h"     
#include "petscds.h"     
PetscErrorCode DMGetWorkArray(DM dm, PetscInt count, MPI_Datatype dtype, void *mem)
```
Not Collective


## Input Parameters

- ***dm -*** the `DM` object
- ***count -*** The minimum size
- ***dtype -*** MPI data type, often MPIU_REAL, MPIU_SCALAR, or MPIU_INT)



## Output Parameter

- ***array -*** the work array





## Note
A `DM` may stash the array between instantations so using this routine may be more efficient than calling `PetscMalloc()`

The array may contain nonzero values


## See Also
 `DMDestroy()`, `DMCreate()`, `DMRestoreWorkArray()`, `PetscMalloc()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/interface/dm.c.html#DMGetWorkArray">src/dm/interface/dm.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dm.c)


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