# PetscObjectName
Gives an object a name if it does not have one 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscObjectName(PetscObject obj)
```
Collective


## Input Parameters

- ***obj -*** the Petsc variable
Thus must be cast with a (`PetscObject`), for example,
`PetscObjectName`((`PetscObject`)mat,name);





## Notes
This is used in a small number of places when an object NEEDS a name, for example when it is saved to MATLAB with that variable name.

Use `PetscObjectSetName()` to set the name of an object to what you want. The SAWs viewer requires that no two published objects
share the same name.


## Developer Note
This needs to generate the exact same string on all ranks that share the object. The current algorithm may not always work.


## See Also
 `PetscObjectGetName()`, `PetscObjectSetName()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/pname.c.html#PetscObjectName">src/sys/objects/pname.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/pname.c)


[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)  
