# PetscViewerHDF5SetCollective
Use collective MPI-IO transfer mode for HDF5 reads and writes. 
## Synopsis
```
#include "petscviewerhdf5.h" 
PetscErrorCode PetscViewerHDF5SetCollective(PetscViewer viewer, PetscBool flg)
```
Logically Collective; flg must contain common value


## Input Parameters

- ***viewer -*** the `PetscViewer`; if it is not `PETSCVIEWERHDF5` then this command is ignored
- ***flg -*** `PETSC_TRUE` for collective mode; `PETSC_FALSE` for independent mode (default)



## Options Database Key

- ***-viewer_hdf5_collective -*** turns on (true) or off (false) collective transfers



## Note
Collective mode gives the MPI-IO layer underneath HDF5 a chance to do some additional collective optimizations and hence can perform better.
However, this works correctly only since HDF5 1.10.3 and if HDF5 is installed for MPI; hence, we ignore this setting for older versions.


## Developer Note
In the HDF5 layer, `PETSC_TRUE` / `PETSC_FALSE` means `H5Pset_dxpl_mpio()` is called with `H5FD_MPIO_COLLECTIVE` / `H5FD_MPIO_INDEPENDENT`, respectively.
This in turn means use of MPI_File_{read,write}_all /  MPI_File_{read,write} in the MPI-IO layer, respectively.
See HDF5 documentation and MPI-IO documentation for details.




## See Also
 [](sec_viewers), `PETSCVIEWERHDF5`, `PetscViewerHDF5GetCollective()`, `PetscViewerCreate()`, `PetscViewerSetType()`, `PetscViewerHDF5Open()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/viewer/impls/hdf5/hdf5v.c.html#PetscViewerHDF5SetCollective">src/sys/classes/viewer/impls/hdf5/hdf5v.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/viewer/impls/hdf5/hdf5v.c.html#PetscViewerHDF5SetCollective_HDF5">PetscViewerHDF5SetCollective_HDF5 in src/sys/classes/viewer/impls/hdf5/hdf5v.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/classes/viewer/impls/hdf5/hdf5v.c)


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