# Source callbacks (1D FDTD) A **source callback** is a function called once per simulation step to apply an excitation. FDTD OpenMP separates the waveform calculation from the field-update kernel, allowing new sources without changing the FDTD loops. A callback has this signature: ```c void Source(Fdtd_EzSim *sim, Fdtd_EzSourceData *data); ``` Register it with `Fdtd_EzSimAddSource(sim, Source, parameters)`. The parameter structure provides six numeric fields and a `void *` pointer for custom data. Registration copies the structure by value; data referenced by its pointer must remain valid while the callback uses it. A newly created simulation has room for sixteen sources. Inside the callback, `Fdtd_EzSimGetTime()` returns the current step counter. `Fdtd_EzSimInjectEz()` adds the calculated value to $E_z$ at the selected cell. The caller must choose a valid cell index. Callbacks execute after the electric update and before the counter advances. In the [[fdtd-openmp-openmp-kernel|OpenMP kernel]], one thread executes the entire source list. Other threads wait before starting the next step, preserving the ordering between injection and field updates.