:orphan:
# TSSetPreStep
Sets the general-purpose function called once at the beginning of each time step.
## Synopsis
```
#include "petscts.h"
PetscErrorCode TSSetPreStep(TS ts, PetscErrorCode (*func)(TS))
```
Logically Collective
## Input Parameters
- ***ts -*** The `TS` context obtained from `TSCreate()`
- ***func -*** The function
## Calling sequence of `func`
```none
PetscErrorCode func (TS ts)
```
## See Also
[](ch_ts), `TS`, `TSSetPreStage()`, `TSSetPostStage()`, `TSSetPostStep()`, `TSStep()`, `TSRestartStep()`
## Level
intermediate
## Location
src/ts/interface/ts.c
## Examples
src/ts/tutorials/ex76.c
src/ts/tutorials/ex77.c
src/ts/utils/dmplexlandau/tutorials/ex2.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ts/interface/ts.c)
[Index of all TS routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)